]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
client: use path supplied in statfs
authorChristopher Hoffman <choffman@redhat.com>
Tue, 5 Aug 2025 19:34:45 +0000 (19:34 +0000)
committerChristopher Hoffman <choffman@redhat.com>
Tue, 19 Aug 2025 14:48:15 +0000 (14:48 +0000)
If path provided, use in statfs. Replumb internal statfs
for internal only to allow for use in ll_statfs and statfs

Fixes: https://tracker.ceph.com/issues/72355
Signed-off-by: Christopher Hoffman <choffman@redhat.com>
(cherry picked from commit 0c6a8add81c61960b733ce3ec38f7bbb3b5e93e9)

src/client/Client.cc
src/client/Client.h

index 9674f1e88b3b37bafec61098cf1268f0dc3763aa..795931019c77156602b97a13d494becc5029b3a7 100644 (file)
@@ -12521,13 +12521,14 @@ int Client::getcwd(string& dir, const UserPerm& perms)
   return _getcwd(dir, perms);
 }
 
-int Client::statfs(const char *path, struct statvfs *stbuf,
+int Client::_statfs(Inode *in, struct statvfs *stbuf,
                   const UserPerm& perms)
 {
   RWRef_t mref_reader(mount_state, CLIENT_MOUNTING);
   if (!mref_reader.is_state_satisfied())
     return -ENOTCONN;
 
+  ldout(cct, 10) << __func__ << dendl;
   tout(cct) << __func__ << std::endl;
   unsigned long int total_files_on_fs;
 
@@ -12968,7 +12969,21 @@ int Client::ll_statfs(Inode *in, struct statvfs *stbuf, const UserPerm& perms)
   /* Since the only thing this does is wrap a call to statfs, and
      statfs takes a lock, it doesn't seem we have a need to split it
      out. */
-  return statfs(0, stbuf, perms);
+  return _statfs(in, stbuf, perms);
+}
+
+int Client::statfs(const char *path, struct statvfs *stbuf, const UserPerm& perms)
+{
+  walk_dentry_result wdr;
+  {
+    std::scoped_lock l(client_lock);
+    if (int rc = path_walk(cwd, filepath(path), &wdr, perms, {}); rc < 0) {
+      return rc;
+    }
+  }
+
+  auto in = wdr.target.get();
+  return _statfs(in, stbuf, perms);
 }
 
 void Client::_ll_register_callbacks(struct ceph_client_callback_args *args)
index 97f035c3bc61cfa100b59dbbcf2275e40c4297aa..f5457eb27b8d7f3a2d829fb88799b6ca09ada71f 100644 (file)
@@ -1862,6 +1862,8 @@ private:
   int _lookup_vino(vinodeno_t ino, const UserPerm& perms, Inode **inode=NULL);
   bool _ll_forget(Inode *in, uint64_t count);
 
+  int _statfs(Inode *in, struct statvfs *stbuf, const UserPerm& perms);
+
   void collect_and_send_metrics();
   void collect_and_send_global_metrics();