Skip to content

Commit dd7bdd3

Browse files
committed
client: bring client_lock out of statfs helper method
Signed-off-by: Christopher Hoffman <[email protected]>
1 parent 9ab1209 commit dd7bdd3

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

src/client/Client.cc

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12529,24 +12529,25 @@ int Client::getcwd(string& dir, const UserPerm& perms)
1252912529
int Client::_statfs(Inode *in, struct statvfs *stbuf,
1253012530
const UserPerm& perms)
1253112531
{
12532+
ceph_assert(ceph_mutex_is_locked_by_me(client_lock));
12533+
1253212534
ldout(cct, 10) << __func__ << dendl;
1253312535
tout(cct) << __func__ << std::endl;
1253412536
unsigned long int total_files_on_fs;
1253512537

1253612538
ceph_statfs stats;
1253712539
C_SaferCond cond;
1253812540

12539-
std::unique_lock lock(client_lock);
1254012541
const vector<int64_t> &data_pools = mdsmap->get_data_pools();
1254112542
if (data_pools.size() == 1) {
1254212543
objecter->get_fs_stats(stats, data_pools[0], &cond);
1254312544
} else {
1254412545
objecter->get_fs_stats(stats, std::optional<int64_t>(), &cond);
1254512546
}
1254612547

12547-
lock.unlock();
12548+
client_lock.unlock();
1254812549
int rval = cond.wait();
12549-
lock.lock();
12550+
client_lock.lock();
1255012551

1255112552
ceph_assert(in);
1255212553
// Usually quota_root will == root_ancestor, but if the mount root has no
@@ -12970,9 +12971,7 @@ int Client::ll_statfs(Inode *in, struct statvfs *stbuf, const UserPerm& perms)
1297012971
if (!mref_reader.is_state_satisfied())
1297112972
return -ENOTCONN;
1297212973

12973-
/* Since the only thing this does is wrap a call to statfs, and
12974-
statfs takes a lock, it doesn't seem we have a need to split it
12975-
out. */
12974+
std::unique_lock cl(client_lock);
1297612975
return _statfs(in, stbuf, perms);
1297712976
}
1297812977

@@ -12982,12 +12981,11 @@ int Client::statfs(const char *path, struct statvfs *stbuf, const UserPerm& perm
1298212981
if (!mref_reader.is_state_satisfied())
1298312982
return -ENOTCONN;
1298412983

12984+
std::unique_lock cl(client_lock);
12985+
1298512986
walk_dentry_result wdr;
12986-
{
12987-
std::scoped_lock l(client_lock);
12988-
if (int rc = path_walk(cwd, filepath(path), &wdr, perms, {}); rc < 0) {
12989-
return rc;
12990-
}
12987+
if (int rc = path_walk(cwd, filepath(path), &wdr, perms, {}); rc < 0) {
12988+
return rc;
1299112989
}
1299212990

1299312991
auto in = wdr.target.get();

0 commit comments

Comments
 (0)