fs/ceph/inode.c | 2 ++ 1 file changed, 2 insertions(+)
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].
Link: https://lore.kernel.org/ceph-devel/20260715143646.15828-4-gaikwad.dcg@gmail.com/
Signed-off-by: deepakroag <gaikwad.dcg@gmail.com>
---
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;
--
Deepak Rao Gaikwad
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/20260715143646.15828-4-gaikwad.dcg@gmail.com/
>
> Signed-off-by: deepakroag <gaikwad.dcg@gmail.com>
> ---
> 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
© 2016 - 2026 Red Hat, Inc.