]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
client: get quota root based off of provided inode in statfs
authorChristopher Hoffman <choffman@redhat.com>
Tue, 5 Aug 2025 19:39:29 +0000 (19:39 +0000)
committerChristopher Hoffman <choffman@redhat.com>
Wed, 13 Aug 2025 13:06:30 +0000 (13:06 +0000)
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 <choffman@redhat.com>
src/client/Client.cc

index 33f1945a4c3197ca436543f4d1daa06555a788c3..7d21c3298143535230c09c9e819ff5f07c924c03 100644 (file)
@@ -12552,8 +12552,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: "
@@ -12581,12 +12586,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<bool>("client_quota") == false || quota_root != nullptr);