]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
client: bring client_lock out of statfs helper method
authorChristopher Hoffman <choffman@redhat.com>
Mon, 11 Aug 2025 14:33:24 +0000 (14:33 +0000)
committerChristopher Hoffman <choffman@redhat.com>
Tue, 19 Aug 2025 14:49:48 +0000 (14:49 +0000)
Signed-off-by: Christopher Hoffman <choffman@redhat.com>
(cherry picked from commit dd7bdd32381ec81104f8399904c770f1ba0485b7)

src/client/Client.cc

index 56c2db337045d9310b11c76565a860776363a894..4fa7245ca31b849a88063b14d4cfcff810da2e79 100644 (file)
@@ -12457,6 +12457,8 @@ int Client::getcwd(string& dir, const UserPerm& perms)
 int Client::_statfs(Inode *in, struct statvfs *stbuf,
                   const UserPerm& perms)
 {
+  ceph_assert(ceph_mutex_is_locked_by_me(client_lock));
+
   ldout(cct, 10) << __func__ << dendl;
   tout(cct) << __func__ << std::endl;
   unsigned long int total_files_on_fs;
@@ -12464,7 +12466,6 @@ int Client::_statfs(Inode *in, struct statvfs *stbuf,
   ceph_statfs stats;
   C_SaferCond cond;
 
-  std::unique_lock lock(client_lock);
   const vector<int64_t> &data_pools = mdsmap->get_data_pools();
   if (data_pools.size() == 1) {
     objecter->get_fs_stats(stats, data_pools[0], &cond);
@@ -12472,9 +12473,9 @@ int Client::_statfs(Inode *in, struct statvfs *stbuf,
     objecter->get_fs_stats(stats, std::optional<int64_t>(), &cond);
   }
 
-  lock.unlock();
+  client_lock.unlock();
   int rval = cond.wait();
-  lock.lock();
+  client_lock.lock();
 
   ceph_assert(in);
   // Usually quota_root will == root_ancestor, but if the mount root has no
@@ -12898,9 +12899,7 @@ int Client::ll_statfs(Inode *in, struct statvfs *stbuf, const UserPerm& perms)
   if (!mref_reader.is_state_satisfied())
     return -ENOTCONN;
 
-  /* 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. */
+  std::unique_lock cl(client_lock);
   return _statfs(in, stbuf, perms);
 }
 
@@ -12910,12 +12909,11 @@ int Client::statfs(const char *path, struct statvfs *stbuf, const UserPerm& perm
   if (!mref_reader.is_state_satisfied())
     return -ENOTCONN;
 
+  std::unique_lock cl(client_lock);
+
   walk_dentry_result wdr;
-  {
-    std::scoped_lock l(client_lock);
-    if (int rc = path_walk(cwd, filepath(path), &wdr, perms, {}); rc < 0) {
-      return rc;
-    }
+  if (int rc = path_walk(cwd, filepath(path), &wdr, perms, {}); rc < 0) {
+    return rc;
   }
 
   auto in = wdr.target.get();