Re: [PATCH] fix: release unused ceph cap reservation on readdir error
Viacheslav Dubeyko <[email protected]> Thu, 16 Jul 2026 10:24:38 -0700
| Newsgroups | org.kernel.vger.ceph-devel,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <[email protected]> |
On Wed, 2026-07-15 at 23:46 +0530, deepakroag wrote: > Return unused reserved caps to the MDS client pool when > ceph_readdir_prepopulate() exits with an error. > > Corrected standalone submission: this patch was mistakenly > sent earlier as [PATCH 4/4] in an unrelated multi-subsystem > series. It is ceph-only and resubmitted here as [PATCH 1/1]. Frankly speaking, it will be better to explain the issue detection and analysis here. > > Link: > https://lore.kernel.org/ceph-devel/[email protected]/ > > Signed-off-by: deepakroag <[email protected]> > --- > fs/ceph/inode.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c > index 61d7c0b81..2d6a80054 100644 > --- a/fs/ceph/inode.c > +++ b/fs/ceph/inode.c > @@ -2188,6 +2188,8 @@ int ceph_readdir_prepopulate(struct > ceph_mds_request *req, > dput(dn); > } > out: > + if (err) > + ceph_unreserve_caps(req->r_mdsc, &req- > >r_caps_reservation); > if (err == 0 && skipped == 0) { > set_bit(CEPH_MDS_R_DID_PREPOPULATE, &req- > >r_req_flags); > req->r_readdir_cache_idx = cache_ctl.index; OK. So, we need to do this because handle_reply() [1] execute this after ceph_readdir_prepopulate(): if (err == 0) { ... ceph_unreserve_caps(mdsc, &req->r_caps_reservation); } However, we are missing another execution branch [2]: if (test_bit(CEPH_MDS_R_ABORTED, &req->r_req_flags)) return readdir_prepopulate_inodes_only(req, session); I believe that we need to improve the patch. Thanks, Slava. [1] https://elixir.bootlin.com/linux/v7.2-rc3/source/fs/ceph/mds_client.c#L4186 [2] https://elixir.bootlin.com/linux/v7.2-rc3/source/fs/ceph/inode.c#L2017