Re: [PATCH v2 2/5] ceph: replace the request_tree rbtree with an xarray keyed by r_tid.

From: Xiubo Li

Date: Thu Jul 16 2026 - 00:21:09 EST


On Thu, 16 Jul 2026 at 02:25, Viacheslav Dubeyko <slava@xxxxxxxxxxx> wrote:
>
> On Wed, 2026-07-15 at 11:58 +0800, Xiubo Li via B4 Relay wrote:
> > From: Xiubo Li <xiubo.li@xxxxxxxxx>
> >
> > The xarray gives O(1) lookups by tid (vs O(log N) rbtree) and
> > uses internal RCU-based locking, eliminating mdsc->mutex as a
> > precondition for tree access and paving the way for lockless
> > xa_load() in the future. In practise this yields a 13x reduction
> > of handle_reply mutex hold time, from 51-416us down to 10-32us,
> > due to parse_reply_info() no longer being protected by the global
> > mutex.
> >
> > Check xa_store() for allocation failure, which would otherwise be
> > silent, and skip __do_request() in the submit path if registration
> > failed.
> >
> > On 32-bit architectures xarray silently truncates u64 keys because
> > its index type is unsigned long. Guard the entire conversion by
> > BITS_PER_LONG==64 and fall back to the original rbtree on 32-bit
> > so there is no regression from the current code.
[......]
> > @@ -1195,7 +1197,11 @@ lookup_get_request(struct ceph_mds_client
> > *mdsc, u64 tid)
> > {
> > struct ceph_mds_request *req;
> >
> > +#if BITS_PER_LONG == 64
> > + req = xa_load(&mdsc->request_tree, tid);
> > +#else
> > req = lookup_request(&mdsc->request_tree, tid);
> > +#endif
> > if (req)
> > ceph_mdsc_get_request(req);
> >
> > @@ -1229,7 +1235,17 @@ static void __register_request(struct
> > ceph_mds_client *mdsc,
> > }
> > doutc(cl, "%p tid %lld\n", req, req->r_tid);
> > ceph_mdsc_get_request(req);
>
> It looks like we get request before failure check. And the failure path
> returns without undoing it. I believe we have issue here.
>
Good catch. Let me fix it.

Thanks
Xiubo

> Thanks,
> Slava.
[......]