[PATCH v2 1/4] libceph: resend replica reads on a new interval
From: Xiubo Li via B4 Relay
Date: Thu Dec 03 2026 - 08:24:56 EST
From: Xiubo Li <xiubo.li@xxxxxxxxx>
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@xxxxxxxxxx>
Link: https://lore.kernel.org/all/20261202131101.582425-1-amarkuze@xxxxxxxxxx/
Signed-off-by: Xiubo Li <xiubo.li@xxxxxxxxx>
---
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