From 84af2873bab0d658b8b56b0e78c9a4b64df4a603 Mon Sep 17 00:00:00 2001 From: Christopher Hoffman Date: Tue, 5 Aug 2025 19:39:29 +0000 Subject: [PATCH] client: get quota root based off of provided inode in statfs In statfs, get quota_root for inode provided. Check if a quota is directly applied to inode. If not, reverse tree walk up and maybe find a quota set higher up the tree. Fixes: https://tracker.ceph.com/issues/72355 Signed-off-by: Christopher Hoffman (cherry picked from commit 85f9fc29d202e1b050e50ad8bae13d7751ef28db) --- src/client/Client.cc | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/client/Client.cc b/src/client/Client.cc index 6a60ca28c4e..bb799a7cde8 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -12480,8 +12480,13 @@ int Client::_statfs(Inode *in, struct statvfs *stbuf, int rval = cond.wait(); lock.lock(); - ceph_assert(root); - total_files_on_fs = root->rstat.rfiles + root->rstat.rsubdirs; + ceph_assert(in); + // Usually quota_root will == root_ancestor, but if the mount root has no + // quota but we can see a parent of it that does have a quota, we'll + // respect that one instead. + InodeRef quota_root = in->quota.is_enabled() ? in : get_quota_root(in, perms); + + total_files_on_fs = quota_root->rstat.rfiles + quota_root->rstat.rsubdirs; if (rval < 0) { ldout(cct, 1) << "underlying call to statfs returned error: " @@ -12509,12 +12514,6 @@ int Client::_statfs(Inode *in, struct statvfs *stbuf, stbuf->f_flag = 0; // ?? stbuf->f_namemax = NAME_MAX; - // Usually quota_root will == root_ancestor, but if the mount root has no - // quota but we can see a parent of it that does have a quota, we'll - // respect that one instead. - ceph_assert(root != nullptr); - InodeRef quota_root = root->quota.is_enabled(QUOTA_MAX_BYTES) ? root : get_quota_root(root.get(), perms, QUOTA_MAX_BYTES); - // get_quota_root should always give us something if client quotas are // enabled ceph_assert(cct->_conf.get_val("client_quota") == false || quota_root != nullptr); -- 2.39.5