From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=100.103.45.18 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796304285; b=0ebG/UUkOOmjKMpxJ0i2WRzxAVk6tmz8eOYbu8hEYEX7EoQffF0HnldJWywVrz/0pbEf J0kbjZE5FNS3SGUr6a9FHEgFj5Uij897hcvkweUqtjW+1aD1nU3GO5MIXaf54Y3cKw7FV kfYT8A68//XnVAftJcUbO3M0TiTjn2ONpnMZBbUdqNd63gltf5zmyYTQXn7y4z9PMgUu2 h1AnGvUZO4fNEoLNaUSvWTp8sbze1BPRqNKA6plIIci+OH0HkAQXAuB3ie4YLyp8ti0tg zrGecTa0rlTn7RBNzADzhe1GjZSnFBZjR0D/wjLiNNeXZ8yhA780C7VVFEJmFfpeyKQ== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796304285; h=Received:DKIM-Signature:Received:From:Date:Subject:MIME-Version: Content-Type:Message-Id:References:In-Reply-To:To:Cc:X-Mailer: X-Developer-Signature:X-Developer-Key:X-Endpoint-Received: X-Original-From:Reply-To:Content-Transfer-Encoding; bh=xdIGsJXCjTonINriuLy/4F61Ss1pFb7USjB6dAsmPlU=; b=n6UDtFMVVk16wFzMsTLrj/Fzr1yX7dxB8xgh413k62yTsx6sA3DM+N05wXIx1RjR7rRV WsQpIyIAjupNO1eZIbF1bvNJIjOGVjJ3qpUTevyeshOAFO7LeEuMeeoLoaZ3yACurMy1o Ldqt+SYzJyksPNSnwl79lOgC2FQTKyx4/FF/42NfCXK+1zccyQMmdclbxbc2SwkHVRjmf UhVMFviC+2iFR1Jg5iR2gMelIoPG5JSZK/yrUW+DLTKIOvFQ60UlMSY7b/iJKa8v9H3DU 9CVf3J4l8ZoztxZGUFiEOeBVHJI0MGk2GmePHb31866Vo/3rHPeBmlaF+XnuFZayy6w== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Wtye0FtT; arc=pass header.oldest-pass=0 smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7E12D606A68D; Thu, 3 Dec 2026 13:24:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Wtye0FtT Authentication-Results: smtp.kernel.org; arc=none smtp.remote-ip=100.80.115.77 ARC-Seal: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; cv=none; t=1796304285; b=dsuIGFy776QY4x5KlVyzKS3CwHfOqOl2omj2knjX0XfCBrCNRT54oF4qFvpRVqkU69oN vuzaZg5eKiV+elQUekIYkt2uPbtSqVeTrndbe+OYOfQ2BLigb8+fElEhhfZldFxnQdr5t A85EuZklMpsqxsqxrlKA+r6TdnHBYSEAAttkIsxxCEXQ3Sdkc52z+OgzjqbZXDlsnVJL2 WkC4RHjwB2xr3koL9jEib/45dpLI0V5Yyy2iQ+umr2ZPf2Q9lllwvjZ6ZgiBC3v3Jf/VP ZKSkZJhovDkENyIzAT62R9esrXSIkM2mqq6JX5KaKZZRfldQvK4eFFTitZzVEGHkLPQ== ARC-Message-Signature: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; c=relaxed/relaxed; t=1796304285; h=DKIM-Signature:Received:From:Date:Subject:MIME-Version:Content-Type: Message-Id:References:In-Reply-To:To:Cc:X-Mailer: X-Developer-Signature:X-Developer-Key:X-Endpoint-Received: X-Original-From:Reply-To:Content-Transfer-Encoding; bh=xdIGsJXCjTonINriuLy/4F61Ss1pFb7USjB6dAsmPlU=; b=oPf/GOrVZ8PLCxGBkOC4HjHVc4Pgddq57eDMBO/sj2rZJrX2YFZs8WcpmkmMPdFHkUAl pAFKJj5GFxolUUQ7OWNLi97oDSDn8iMYLE5Lv2kbJN8342RCiC6lOjoi6O2vXdJQGxAC3 Eit0slispTMIIQn8B48ajdolM/LBtTQxiyqwNAcRAaGZ30Q9DJV5IHcwCiwBppw9urhIE 9nc5VAkwpfohGi2vHo8dAVdG1MMOk1WYlnWIFJelh7+A1qopsWzrQH+mQqKQUfE6pZnjY Mx2ZwWH5snYHu94ZpArxpU+2OT6UcTFJ1cVxTFpdbNCD5Qwg2nAL8QnNDLnVjedbQkA== ARC-Authentication-Results: i=1; smtp.kernel.org; arc=none smtp.remote-ip=100.80.115.77 Received: from lkml.kernel.org (nexus.subspace.kernel.org [100.80.115.77]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.kernel.org (Postfix) with ESMTPS id 9255A1F00893; Thu, 3 Dec 2026 13:24:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796304285; bh=xdIGsJXCjTonINriuLy/4F61Ss1pFb7USjB6dAsmPlU=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To; b=Wtye0FtT6g8vONW0kWQC0ID4lNbDfQm6AP+4Zg+sPBttqgOA9AWAi79KiyUgOmW2E 9HKC3+2iEUve2FI8IbAKCJmbmj/fj86WmYDTPgQGDlsytG08EqszG5RreXsNTpvwq6 gXMeFW17VZjp+rSnLoPu3OvW6pDdSBLKKY3qNKfItN3IfQ8Nm7IymnhXAHI2XlvClZ D8DJJC4cGK9GSY9Kgn5VhBUSc7f4Til/2oibMtrik7PpDtFL48MYSykcWmGJ1ArKso KV4Dsy9Hnm+c9hh7YjfX6yTxYTdp8nh+1bCiZO7jO6gHUEh6iXvvHfXfJo/CIbyDlJ hNWBBD80v1ztQ== Received: from nexus.subspace.kernel.org (localhost [IPv6:::1]) by lkml.kernel.org (Postfix) with ESMTP id 1BBF84F9AB; Thu, 3 Dec 2026 13:24:43 +0000 (UTC) From: Xiubo Li via B4 Relay Date: Thu, 03 Dec 2026 14:24:21 +0100 Subject: [PATCH v2 2/4] libceph: get a full osdmap after failing to apply an incremental X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Message-Id: <20261203-b4-libceph-upmap-primary-v2-2-8a15d2fc7318@clyso.com> References: <20261203-b4-libceph-upmap-primary-v2-0-8a15d2fc7318@clyso.com> In-Reply-To: <20261203-b4-libceph-upmap-primary-v2-0-8a15d2fc7318@clyso.com> To: Ilya Dryomov , Alex Markuze , Viacheslav Dubeyko Cc: ceph-devel@vger.kernel.org, linux-kernel@vger.kernel.org, Xiubo Li X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1796304272; l=9191; i=xiubo.li@clyso.com; s=20260625; h=from:subject:message-id; bh=4xTTMfPQcvHoHIi8OkTWlPq88KpESiqDFeNuMCAHgWA=; b=CLqi3BITfgI4Y6+O3AVNPDwsa3a7QaJ9U4RU4USiSBAnPeAZv/QGkio1p9IARczq1uOcAexAi 5YCqj21KXzHCahbKI1r8fO1LKOp4Ii0gHu884Lz4iqpa9TwsiiwQR4C X-Developer-Key: i=xiubo.li@clyso.com; a=ed25519; pk=V3NGr0AgAopiUhaLY51ipBkLN5LlcLhjOEfLEq1RoZ8= X-Endpoint-Received: by B4 Relay for xiubo.li@clyso.com/20260625 with auth_id=840 X-Original-From: Xiubo Li Reply-To: xiubo.li@clyso.com Content-Transfer-Encoding: 7bit From: Xiubo Li osdmap_apply_incremental() updates the map in place and advances its epoch before it decodes new_pools, new_pg_temp, new_pg_upmap_items and the like, each of which can fail, with -ENOMEM in particular. On failure the map is left half updated at the new epoch. Any repeat of that epoch is then ignored, the next incrementals are applied on top of it, and whatever was missed stays missed until a full map happens to replace it, while requests are routed with it. This has been so since incremental maps were first applied in place. Instead, mark the map invalid when an incremental fails to apply, for any error, also one hit before the map was changed. While it is invalid, pause new requests as for an epoch barrier, ignore incrementals, and ask the monitor for its latest full map (subscribing from epoch 0), taking it even if it is not newer than the invalid one. Once it arrives, recalculate all requests as after a gap in the maps. If the full map cannot be decoded either, ask again from the periodic timeout work, once per osd_keepalive_timeout, so that a map that keeps failing does not turn into a request loop. Tested by injecting -ENOMEM into the decoding of a new pg_upmap_primary entry (the next patch adds that decoder), then reading the 31 objects of the PG from a krbd device: +-------------------------------------+--------------+---------+ | | before | after | +-------------------------------------+--------------+---------+ | pg_upmap_primary in the kernel map | missing | present | | ... after a later incremental | missing | present | | reads completed | 0/31 | 31/31 | | OSD log | misdirected | clean | +-------------------------------------+--------------+---------+ Before, the reads went to the old primary, which dropped them as misdirected, and they completed only after that OSD was marked down. With every full map failing to decode as well, the client asked for one every 5 seconds (3 failed full maps in 10 seconds), and took the next one once the injection stopped. Reported-by: Alex Markuze Link: https://lore.kernel.org/all/20261202131101.582425-1-amarkuze@redhat.com/ Signed-off-by: Xiubo Li --- include/linux/ceph/osd_client.h | 1 + net/ceph/debugfs.c | 5 ++-- net/ceph/osd_client.c | 60 ++++++++++++++++++++++++++++++++--------- 3 files changed, 51 insertions(+), 15 deletions(-) diff --git a/include/linux/ceph/osd_client.h b/include/linux/ceph/osd_client.h index ba4618ac38b0..4e4091f6e68f 100644 --- a/include/linux/ceph/osd_client.h +++ b/include/linux/ceph/osd_client.h @@ -411,6 +411,7 @@ struct ceph_osd_client { struct list_head osd_lru; /* idle osds */ spinlock_t osd_lru_lock; u32 epoch_barrier; + bool osdmap_invalid; /* need a full map */ struct ceph_osd homeless_osd; atomic64_t last_tid; /* tid of last request */ u64 last_linger_id; diff --git a/net/ceph/debugfs.c b/net/ceph/debugfs.c index 20674e5d2711..79c9714cfda9 100644 --- a/net/ceph/debugfs.c +++ b/net/ceph/debugfs.c @@ -71,8 +71,9 @@ static int osdmap_show(struct seq_file *s, void *p) if (map == NULL) goto out_unlock; - seq_printf(s, "epoch %u barrier %u flags 0x%x\n", map->epoch, - osdc->epoch_barrier, map->flags); + seq_printf(s, "epoch %u barrier %u flags 0x%x%s\n", map->epoch, + osdc->epoch_barrier, map->flags, + osdc->osdmap_invalid ? " invalid" : ""); for (n = rb_first(&map->pg_pools); n; n = rb_next(n)) { struct ceph_pg_pool_info *pi = diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c index 81da34869d5a..1827d1f2719e 100644 --- a/net/ceph/osd_client.c +++ b/net/ceph/osd_client.c @@ -1534,7 +1534,8 @@ static bool target_should_be_paused(struct ceph_osd_client *osdc, WARN_ON(pi->id != t->target_oloc.pool); return ((t->flags & CEPH_OSD_FLAG_READ) && pauserd) || ((t->flags & CEPH_OSD_FLAG_WRITE) && pausewr) || - (osdc->osdmap->epoch < osdc->epoch_barrier); + (osdc->osdmap->epoch < osdc->epoch_barrier) || + osdc->osdmap_invalid; } static int pick_random_replica(const struct ceph_osds *acting) @@ -2370,6 +2371,7 @@ static void send_request(struct ceph_osd_request *req) static void maybe_request_map(struct ceph_osd_client *osdc) { bool continuous = false; + u32 epoch; verify_osdc_locked(osdc); WARN_ON(!osdc->osdmap->epoch); @@ -2383,8 +2385,10 @@ static void maybe_request_map(struct ceph_osd_client *osdc) dout("%s osdc %p onetime\n", __func__, osdc); } - if (ceph_monc_want_map(&osdc->client->monc, CEPH_SUB_OSDMAP, - osdc->osdmap->epoch + 1, continuous)) + /* epoch 0 asks for the latest full map */ + epoch = osdc->osdmap_invalid ? 0 : osdc->osdmap->epoch + 1; + if (ceph_monc_want_map(&osdc->client->monc, CEPH_SUB_OSDMAP, epoch, + continuous)) ceph_monc_renew_subs(&osdc->client->monc); } @@ -2417,9 +2421,11 @@ static void __submit_request(struct ceph_osd_request *req, bool wrlocked) if (osdc->abort_err) { dout("req %p abort_err %d\n", req, osdc->abort_err); err = osdc->abort_err; - } else if (osdc->osdmap->epoch < osdc->epoch_barrier) { - dout("req %p epoch %u barrier %u\n", req, osdc->osdmap->epoch, - osdc->epoch_barrier); + } else if (osdc->osdmap->epoch < osdc->epoch_barrier || + osdc->osdmap_invalid) { + dout("req %p epoch %u barrier %u invalid %d\n", req, + osdc->osdmap->epoch, osdc->epoch_barrier, + osdc->osdmap_invalid); req->r_t.paused = true; maybe_request_map(osdc); } else if ((req->r_flags & CEPH_OSD_FLAG_WRITE) && @@ -3534,6 +3540,16 @@ static void handle_timeout(struct work_struct *work) if (atomic_read(&osdc->num_homeless) || !list_empty(&slow_osds)) maybe_request_map(osdc); + /* + * Ask for the full map again if the last one could not be + * decoded either, once per tick rather than right away, so a + * map that keeps failing does not turn into a request loop. + */ + if (osdc->osdmap_invalid) { + maybe_request_map(osdc); + ceph_monc_renew_subs(&osdc->client->monc); + } + while (!list_empty(&slow_osds)) { struct ceph_osd *osd = list_first_entry(&slow_osds, struct ceph_osd, @@ -4092,14 +4108,16 @@ static int handle_one_map(struct ceph_osd_client *osdc, WARN_ON(pi->was_full); } - if (osdc->osdmap->epoch && - osdc->osdmap->epoch + 1 < newmap->epoch) { + if ((osdc->osdmap->epoch && + osdc->osdmap->epoch + 1 < newmap->epoch) || + osdc->osdmap_invalid) { WARN_ON(incremental); skipped_map = true; } ceph_osdmap_destroy(osdc->osdmap); osdc->osdmap = newmap; + osdc->osdmap_invalid = false; } was_full &= !ceph_osdmap_flag(osdc, CEPH_OSDMAP_FULL); @@ -4216,14 +4234,27 @@ void ceph_osdc_handle_map(struct ceph_osd_client *osdc, struct ceph_msg *msg) epoch = ceph_decode_32(&p); maplen = ceph_decode_32(&p); ceph_decode_need(&p, end, maplen, bad); - if (osdc->osdmap->epoch && + if (osdc->osdmap->epoch && !osdc->osdmap_invalid && osdc->osdmap->epoch + 1 == epoch) { dout("applying incremental map %u len %d\n", epoch, maplen); err = handle_one_map(osdc, p, p + maplen, true, &need_resend, &need_resend_linger); - if (err) + if (err) { + /* + * The map may have been changed in part, + * and a repeat of this epoch would not be + * applied: stop routing requests with it + * until a full map replaces it. This is + * done for any error, also for one hit + * before the map was changed. + */ + pr_err("osdc failed to apply incremental map %u, requesting a full map\n", + epoch); + osdc->osdmap_invalid = true; + maybe_request_map(osdc); goto bad; + } handled_incremental = true; } else { dout("ignoring incremental map %u len %d\n", @@ -4246,7 +4277,8 @@ void ceph_osdc_handle_map(struct ceph_osd_client *osdc, struct ceph_msg *msg) if (nr_maps > 1) { dout("skipping non-latest full map %u len %d\n", epoch, maplen); - } else if (osdc->osdmap->epoch >= epoch) { + } else if (osdc->osdmap->epoch >= epoch && + !osdc->osdmap_invalid) { dout("skipping full map %u len %d, " "older than our %u\n", epoch, maplen, osdc->osdmap->epoch); @@ -4278,8 +4310,10 @@ void ceph_osdc_handle_map(struct ceph_osd_client *osdc, struct ceph_msg *msg) kick_requests(osdc, &need_resend, &need_resend_linger); ceph_osdc_abort_on_full(osdc); - ceph_monc_got_map(&osdc->client->monc, CEPH_SUB_OSDMAP, - osdc->osdmap->epoch); + /* keep asking for the full map while the current one is invalid */ + if (!osdc->osdmap_invalid) + ceph_monc_got_map(&osdc->client->monc, CEPH_SUB_OSDMAP, + osdc->osdmap->epoch); up_write(&osdc->lock); wake_up_all(&osdc->client->auth_wq); return; -- 2.53.0