]> 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>
Tue, 19 Aug 2025 14:49:48 +0000 (14:49 +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>
(cherry picked from commit 85f9fc29d202e1b050e50ad8bae13d7751ef28db)

src/client/Client.cc

index 6a60ca28c4e56346945328e42e036d17505a1ed0..bb799a7cde8b3f55df03bd969e77ad4a405aef65 100644 (file)
@@ -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<bool>("client_quota") == false || quota_root != nullptr);