* [PATCH v2 1/4] libceph: resend replica reads on a new interval
2026-12-03 13:24 [PATCH v2 0/4] libceph: support pg_upmap_primary (the read balancer) Xiubo Li via B4 Relay
@ 2026-12-03 13:24 ` Xiubo Li via B4 Relay
2026-12-03 13:24 ` [PATCH v2 2/4] libceph: get a full osdmap after failing to apply an incremental Xiubo Li via B4 Relay
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Xiubo Li via B4 Relay @ 2026-12-03 13:24 UTC (permalink / raw)
To: Ilya Dryomov, Alex Markuze, Viacheslav Dubeyko
Cc: ceph-devel, linux-kernel, Xiubo Li
From: Xiubo Li <xiubo.li@clyso.com>
A replica drops a balanced or localized read that was sent before its
current interval started (PG::can_discard_op()), on the assumption
that the client resends such a read on every interval change.
calc_target() resends a read that went to a replica only when the
acting set or the primary changes, though, and an interval also ends
when only the up set changes, e.g. when pg_upmap_items,
pg_upmap_primary or a CRUSH change moves the up set while a pg_temp
keeps the acting set for a backfill, or when the pool's size or
min_size changes. The dropped read is never answered and waits until
the acting set changes for some other reason.
Check for a new interval for requests that went to a replica too, as
is done for linger requests.
Tested with read_from_replica=balance on a 5-OSD cluster: with
nobackfill set and a pg_upmap_items entry, a PG had up [4,2,0] and
acting [4,2,1] (pg_temp). Its up set was then moved to [4,2,3], the
acting set staying the same, and 40 4K O_DIRECT reads, one per object
of the PG, were issued from a krbd device before the client had the
new map:
+----------------------------------+--------+-------+
| | before | after |
+----------------------------------+--------+-------+
| reads not completed after 14 s | 28/40 | 0/40 |
| reads resent on the new interval | 0 | 16 |
+----------------------------------+--------+-------+
Before, all of the stuck reads were on the two replicas, and they
completed only once nobackfill was unset and the acting set changed.
Fixes: 117d96a04f00 ("libceph: support for balanced and localized reads")
Reported-by: Alex Markuze <amarkuze@redhat.com>
Link: https://lore.kernel.org/all/20261202131101.582425-1-amarkuze@redhat.com/
Signed-off-by: Xiubo Li <xiubo.li@clyso.com>
---
net/ceph/osd_client.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c
index 22a793a4bdc8..81da34869d5a 100644
--- a/net/ceph/osd_client.c
+++ b/net/ceph/osd_client.c
@@ -1640,7 +1640,16 @@ static enum calc_target_result calc_target(struct ceph_osd_client *osdc,
last_pgid.seed = ceph_stable_mod(pgid.seed, t->pg_num, t->pg_num_mask);
ceph_pg_to_up_acting_osds(osdc->osdmap, pi, &pgid, &up, &acting);
- if (any_change &&
+ /*
+ * A replica drops a balanced or localized read that was sent
+ * before the current interval started (PG::can_discard_op()),
+ * and the interval also changes with the up set or the pool's
+ * size alone, while the acting set stays the same. Resend such
+ * a read on any new interval, not only when the acting set
+ * changes. The primary does not drop requests that way, so
+ * this is only needed for the ones sent to a replica.
+ */
+ if ((any_change || t->used_replica) &&
ceph_is_new_interval(&t->acting,
&acting,
&t->up,
--
2.53.0
^ permalink raw reply [flat|nested] 5+ messages in thread* [PATCH v2 2/4] libceph: get a full osdmap after failing to apply an incremental
2026-12-03 13:24 [PATCH v2 0/4] libceph: support pg_upmap_primary (the read balancer) Xiubo Li via B4 Relay
2026-12-03 13:24 ` [PATCH v2 1/4] libceph: resend replica reads on a new interval Xiubo Li via B4 Relay
@ 2026-12-03 13:24 ` Xiubo Li via B4 Relay
2026-12-03 13:24 ` [PATCH v2 3/4] libceph: decode and apply pg_upmap_primary mappings Xiubo Li via B4 Relay
2026-12-03 13:24 ` [PATCH v2 4/4] libceph: advertise SERVER_REEF Xiubo Li via B4 Relay
3 siblings, 0 replies; 5+ messages in thread
From: Xiubo Li via B4 Relay @ 2026-12-03 13:24 UTC (permalink / raw)
To: Ilya Dryomov, Alex Markuze, Viacheslav Dubeyko
Cc: ceph-devel, linux-kernel, Xiubo Li
From: Xiubo Li <xiubo.li@clyso.com>
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 <amarkuze@redhat.com>
Link: https://lore.kernel.org/all/20261202131101.582425-1-amarkuze@redhat.com/
Signed-off-by: Xiubo Li <xiubo.li@clyso.com>
---
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
^ permalink raw reply [flat|nested] 5+ messages in thread* [PATCH v2 3/4] libceph: decode and apply pg_upmap_primary mappings
2026-12-03 13:24 [PATCH v2 0/4] libceph: support pg_upmap_primary (the read balancer) Xiubo Li via B4 Relay
2026-12-03 13:24 ` [PATCH v2 1/4] libceph: resend replica reads on a new interval Xiubo Li via B4 Relay
2026-12-03 13:24 ` [PATCH v2 2/4] libceph: get a full osdmap after failing to apply an incremental Xiubo Li via B4 Relay
@ 2026-12-03 13:24 ` Xiubo Li via B4 Relay
2026-12-03 13:24 ` [PATCH v2 4/4] libceph: advertise SERVER_REEF Xiubo Li via B4 Relay
3 siblings, 0 replies; 5+ messages in thread
From: Xiubo Li via B4 Relay @ 2026-12-03 13:24 UTC (permalink / raw)
To: Ilya Dryomov, Alex Markuze, Viacheslav Dubeyko
Cc: ceph-devel, linux-kernel, Xiubo Li
From: Xiubo Li <xiubo.li@clyso.com>
Since reef, the mgr read balancer and "ceph osd pg-upmap-primary" can
choose the primary of a PG explicitly. The mapping is kept in the
OSDMap as pg_upmap_primaries (client data v10 of a full map) and as
new_pg_upmap_primary/old_pg_upmap_primary (client data v9 of an
incremental), and the OSDs apply it after pg_upmap and pg_upmap_items:
if the chosen OSD is in the raw set and not marked out, it is swapped
into the first position.
libceph stops decoding after pg_upmap_items, so for every such PG it
computes a different primary than the OSDs do. Decode the mapping,
skipping the crush_version, removed/purged snaps and last up/in change
fields in front of it, apply it in apply_upmap() the same way
OSDMap::_apply_upmap() does, and list it in the osdmap debugfs file.
The monitors and OSDs send these encodings only to clients that have
the SERVER_REEF feature, which the next patch advertises.
Signed-off-by: Xiubo Li <xiubo.li@clyso.com>
---
include/linux/ceph/osdmap.h | 4 ++
net/ceph/debugfs.c | 7 ++++
net/ceph/osdmap.c | 99 ++++++++++++++++++++++++++++++++++++++++++++-
3 files changed, 109 insertions(+), 1 deletion(-)
diff --git a/include/linux/ceph/osdmap.h b/include/linux/ceph/osdmap.h
index 5553019c3f07..0b36658cba56 100644
--- a/include/linux/ceph/osdmap.h
+++ b/include/linux/ceph/osdmap.h
@@ -164,6 +164,9 @@ struct ceph_pg_mapping {
int len;
int from_to[][2];
} pg_upmap_items;
+ struct {
+ int osd;
+ } pg_upmap_primary;
};
};
@@ -185,6 +188,7 @@ struct ceph_osdmap {
/* remap (post-CRUSH, pre-up) */
struct rb_root pg_upmap; /* PG := raw set */
struct rb_root pg_upmap_items; /* from -> to within raw set */
+ struct rb_root pg_upmap_primaries; /* new primary within raw set */
u32 *osd_primary_affinity;
diff --git a/net/ceph/debugfs.c b/net/ceph/debugfs.c
index 79c9714cfda9..4039f8a5d001 100644
--- a/net/ceph/debugfs.c
+++ b/net/ceph/debugfs.c
@@ -139,6 +139,13 @@ static int osdmap_show(struct seq_file *s, void *p)
pg->pg_upmap_items.from_to[i][1]);
seq_printf(s, "]\n");
}
+ for (n = rb_first(&map->pg_upmap_primaries); n; n = rb_next(n)) {
+ struct ceph_pg_mapping *pg =
+ rb_entry(n, struct ceph_pg_mapping, node);
+
+ seq_printf(s, "pg_upmap_primary %llu.%x %d\n", pg->pgid.pool,
+ pg->pgid.seed, pg->pg_upmap_primary.osd);
+ }
out_unlock:
up_read(&osdc->lock);
diff --git a/net/ceph/osdmap.c b/net/ceph/osdmap.c
index a946724d4ef7..aedb8b15c972 100644
--- a/net/ceph/osdmap.c
+++ b/net/ceph/osdmap.c
@@ -1152,6 +1152,7 @@ struct ceph_osdmap *ceph_osdmap_alloc(void)
map->primary_temp = RB_ROOT;
map->pg_upmap = RB_ROOT;
map->pg_upmap_items = RB_ROOT;
+ map->pg_upmap_primaries = RB_ROOT;
init_workspace_manager(&map->crush_wsm);
@@ -1194,6 +1195,13 @@ void ceph_osdmap_destroy(struct ceph_osdmap *map)
rb_erase(&pg->node, &map->pg_upmap_items);
kfree(pg);
}
+ while (!RB_EMPTY_ROOT(&map->pg_upmap_primaries)) {
+ struct ceph_pg_mapping *pg =
+ rb_entry(rb_first(&map->pg_upmap_primaries),
+ struct ceph_pg_mapping, node);
+ rb_erase(&pg->node, &map->pg_upmap_primaries);
+ kfree(pg);
+ }
while (!RB_EMPTY_ROOT(&map->pg_pools)) {
struct ceph_pg_pool_info *pi =
rb_entry(rb_first(&map->pg_pools),
@@ -1678,6 +1686,44 @@ static int decode_old_pg_upmap_items(void **p, void *end,
return decode_pg_mapping(p, end, &map->pg_upmap_items, NULL, true);
}
+static struct ceph_pg_mapping *__decode_pg_upmap_primary(void **p, void *end,
+ bool incremental)
+{
+ struct ceph_pg_mapping *pg;
+ u32 osd;
+
+ ceph_decode_32_safe(p, end, osd, e_inval);
+ pg = alloc_pg_mapping(0);
+ if (!pg)
+ return ERR_PTR(-ENOMEM);
+
+ pg->pg_upmap_primary.osd = osd;
+ return pg;
+
+e_inval:
+ return ERR_PTR(-EINVAL);
+}
+
+static int decode_pg_upmap_primaries(void **p, void *end,
+ struct ceph_osdmap *map)
+{
+ return decode_pg_mapping(p, end, &map->pg_upmap_primaries,
+ __decode_pg_upmap_primary, false);
+}
+
+static int decode_new_pg_upmap_primaries(void **p, void *end,
+ struct ceph_osdmap *map)
+{
+ return decode_pg_mapping(p, end, &map->pg_upmap_primaries,
+ __decode_pg_upmap_primary, true);
+}
+
+static int decode_old_pg_upmap_primaries(void **p, void *end,
+ struct ceph_osdmap *map)
+{
+ return decode_pg_mapping(p, end, &map->pg_upmap_primaries, NULL, true);
+}
+
/*
* decode a full map.
*/
@@ -1812,6 +1858,23 @@ static int osdmap_decode(void **p, void *end, bool msgr2,
WARN_ON(!RB_EMPTY_ROOT(&map->pg_upmap_items));
}
+ if (struct_v >= 10) {
+ /* crush_version */
+ ceph_decode_skip_32(p, end, e_inval);
+ /* new_removed_snaps, new_purged_snaps */
+ ceph_decode_skip_map_of_map(p, end, 64, 64, 64, e_inval);
+ ceph_decode_skip_map_of_map(p, end, 64, 64, 64, e_inval);
+ /* last_up_change, last_in_change */
+ ceph_decode_skip_n(p, end, 2 * sizeof(struct ceph_timespec),
+ e_inval);
+
+ err = decode_pg_upmap_primaries(p, end, map);
+ if (err)
+ goto bad;
+ } else {
+ WARN_ON(!RB_EMPTY_ROOT(&map->pg_upmap_primaries));
+ }
+
/* ignore the rest */
*p = end;
@@ -2127,6 +2190,23 @@ struct ceph_osdmap *osdmap_apply_incremental(void **p, void *end, bool msgr2,
goto bad;
}
+ if (struct_v >= 9) {
+ /* new_removed_snaps, new_purged_snaps */
+ ceph_decode_skip_map_of_map(p, end, 64, 64, 64, e_inval);
+ ceph_decode_skip_map_of_map(p, end, 64, 64, 64, e_inval);
+ /* new_last_up_change, new_last_in_change */
+ ceph_decode_skip_n(p, end, 2 * sizeof(struct ceph_timespec),
+ e_inval);
+
+ err = decode_new_pg_upmap_primaries(p, end, map);
+ if (err)
+ goto bad;
+
+ err = decode_old_pg_upmap_primaries(p, end, map);
+ if (err)
+ goto bad;
+ }
+
/* ignore the rest */
*p = end;
@@ -2631,7 +2711,7 @@ static void pg_to_raw_osds(struct ceph_osdmap *osdmap,
remove_nonexistent_osds(osdmap, pi, raw);
}
-/* apply pg_upmap[_items] mappings */
+/* apply pg_upmap[_items] and pg_upmap_primary mappings */
static void apply_upmap(struct ceph_osdmap *osdmap,
const struct ceph_pg *pgid,
struct ceph_osds *raw)
@@ -2690,6 +2770,23 @@ static void apply_upmap(struct ceph_osdmap *osdmap,
raw->osds[pos] = to;
}
}
+
+ pg = lookup_pg_mapping(&osdmap->pg_upmap_primaries, pgid);
+ if (pg) {
+ int osd = pg->pg_upmap_primary.osd;
+
+ /* ignore mapping if new primary is invalid or marked out */
+ if (osd != CRUSH_ITEM_NONE && osd >= 0 &&
+ osd < osdmap->max_osd && osdmap->osd_weight[osd] != 0) {
+ for (i = 1; i < raw->size; i++) {
+ if (raw->osds[i] == osd) {
+ raw->osds[i] = raw->osds[0];
+ raw->osds[0] = osd;
+ break;
+ }
+ }
+ }
+ }
}
/*
--
2.53.0
^ permalink raw reply [flat|nested] 5+ messages in thread* [PATCH v2 4/4] libceph: advertise SERVER_REEF
2026-12-03 13:24 [PATCH v2 0/4] libceph: support pg_upmap_primary (the read balancer) Xiubo Li via B4 Relay
` (2 preceding siblings ...)
2026-12-03 13:24 ` [PATCH v2 3/4] libceph: decode and apply pg_upmap_primary mappings Xiubo Li via B4 Relay
@ 2026-12-03 13:24 ` Xiubo Li via B4 Relay
3 siblings, 0 replies; 5+ messages in thread
From: Xiubo Li via B4 Relay @ 2026-12-03 13:24 UTC (permalink / raw)
To: Ilya Dryomov, Alex Markuze, Viacheslav Dubeyko
Cc: ceph-devel, linux-kernel, Xiubo Li
From: Xiubo Li <xiubo.li@clyso.com>
Once the OSDMap holds a pg_upmap_primary entry, the monitors require
the SERVER_REEF feature from every client, and "ceph osd
set-require-min-compat-client reef", which pg-upmap-primary needs
first, is refused while clients without it are connected. So a
cluster with kernel clients cannot use the read balancer, and a kernel
client cannot connect to a cluster that already uses it.
SERVER_REEF reuses bit 31, whose first incarnation MON_SINGLE_PAXOS is
retired. Towards clients it only selects the OSDMap encodings that
carry pg_upmap_primary, which libceph decodes now, so advertise it.
Tested on a 3-OSD tentacle cluster with the read balancer
(osdmaptool --read) applied to its pools. Without this series the
monitors drop the session ("missing required protocol features",
0x80000000), so neither a CephFS mount nor an rbd map succeeds. With
it, both work; after the full map at mount time and after a burst of
22 incrementals the kernel's pg_upmap_primary list matches the
cluster's, all reads and writes of a PG go to the chosen primary, and
no OSD logs a misdirected op.
krbd fio on a 128-PG pool whose primaries were split 40/48/40, and
43/43/42 after the read balancer added 5 entries (O_DIRECT, 30 s,
median of 3 runs, MiB/s with p99 latency):
+-----------------------------+------------------+------------------+
| | primary reads | read balancer |
+-----------------------------+------------------+------------------+
| 4M seq read, 4 x qd16 | 4713 (163 ms) | 4995 (128 ms) |
| 4K random read, 4 x qd32 | 586 (1.93 ms) | 594 (1.73 ms) |
+-----------------------------+------------------+------------------+
4K random writes do not change beyond the run-to-run spread. The gain
follows how uneven the primaries were: the busiest OSD went from 37.5%
to 33.6% of the primaries here.
Signed-off-by: Xiubo Li <xiubo.li@clyso.com>
---
include/linux/ceph/ceph_features.h | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/include/linux/ceph/ceph_features.h b/include/linux/ceph/ceph_features.h
index 1e4dce93a8a1..9202749a820d 100644
--- a/include/linux/ceph/ceph_features.h
+++ b/include/linux/ceph/ceph_features.h
@@ -118,7 +118,8 @@ DEFINE_CEPH_FEATURE_RETIRED(28, 1, OSD_HBMSGS, HAMMER, JEWEL)
DEFINE_CEPH_FEATURE(28, 2, SERVER_MIMIC)
DEFINE_CEPH_FEATURE(29, 1, MDSENC)
DEFINE_CEPH_FEATURE(30, 1, OSDHASHPSPOOL)
-DEFINE_CEPH_FEATURE(31, 1, MON_SINGLE_PAXOS) // deprecate me
+DEFINE_CEPH_FEATURE_RETIRED(31, 1, MON_SINGLE_PAXOS, NAUTILUS, PACIFIC)
+DEFINE_CEPH_FEATURE(31, 3, SERVER_REEF)
DEFINE_CEPH_FEATURE_RETIRED(32, 1, OSD_SNAPMAPPER, JEWEL, LUMINOUS)
DEFINE_CEPH_FEATURE_RETIRED(33, 1, MON_SCRUB, JEWEL, LUMINOUS)
@@ -210,6 +211,7 @@ DEFINE_CEPH_FEATURE_DEPRECATED(63, 1, RESERVED_BROKEN, LUMINOUS) // client-facin
CEPH_FEATURE_CRUSH_TUNABLES2 | \
CEPH_FEATURE_REPLY_CREATE_INODE | \
CEPH_FEATURE_SERVER_MIMIC | \
+ CEPH_FEATURE_SERVER_REEF | \
CEPH_FEATURE_MDSENC | \
CEPH_FEATURE_OSDHASHPSPOOL | \
CEPH_FEATURE_OSD_CACHEPOOL | \
--
2.53.0
^ permalink raw reply [flat|nested] 5+ messages in thread