Skip to content

Commit b6a0e49

Browse files
committed
Merge PR ceph#61250 into main
* refs/pull/61250/head: mds: avoid acquiring the wrlock twice for a single request mds: add 'mds_allow_async_dirops' opt to allow/disable async dirop Reviewed-by: Venky Shankar <[email protected]>
2 parents cc96a38 + 276b81a commit b6a0e49

File tree

5 files changed

+24
-5
lines changed

5 files changed

+24
-5
lines changed

src/common/options/mds.yaml.in

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -990,6 +990,14 @@ options:
990990
- mds
991991
fmt_desc: Ceph will randomly fragment or merge directories.
992992
with_legacy: true
993+
- name: mds_allow_async_dirops
994+
type: bool
995+
level: advanced
996+
default: true
997+
services:
998+
- mds
999+
fmt_desc: MDS will enable/disable the async dirop feature.
1000+
with_legacy: true
9931001
- name: mds_dump_cache_on_map
9941002
type: bool
9951003
level: dev

src/mds/MDCache.cc

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8515,8 +8515,11 @@ int MDCache::path_traverse(const MDRequestRef& mdr, MDSContextFactory& cf,
85158515
lov.add_xlock(&dn->lock);
85168516
} else {
85178517
// force client to flush async dir operation if necessary
8518-
if (cur->filelock.is_cached())
8518+
if (cur->filelock.is_cached() &&
8519+
!(mdr->lock_cache &&
8520+
static_cast<const MutationImpl*>(mdr->lock_cache)->is_wrlocked(&cur->filelock))) {
85198521
lov.add_wrlock(&cur->filelock);
8522+
}
85208523
lov.add_rdlock(&dn->lock);
85218524
}
85228525
if (!mds->locker->acquire_locks(mdr, lov)) {
@@ -8635,8 +8638,11 @@ int MDCache::path_traverse(const MDRequestRef& mdr, MDSContextFactory& cf,
86358638
lov.add_xlock(&dn->lock);
86368639
} else {
86378640
// force client to flush async dir operation if necessary
8638-
if (cur->filelock.is_cached())
8641+
if (cur->filelock.is_cached() &&
8642+
!(mdr->lock_cache &&
8643+
static_cast<const MutationImpl*>(mdr->lock_cache)->is_wrlocked(&cur->filelock))) {
86398644
lov.add_wrlock(&cur->filelock);
8645+
}
86408646
lov.add_rdlock(&dn->lock);
86418647
}
86428648
if (!mds->locker->acquire_locks(mdr, lov)) {

src/mds/MDSRank.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4041,6 +4041,7 @@ const char** MDSRankDispatcher::get_tracked_conf_keys() const
40414041
"clog_to_syslog_level", \
40424042
"fsid", \
40434043
"host", \
4044+
"mds_allow_async_dirops", \
40444045
"mds_alternate_name_max", \
40454046
"mds_bal_export_pin", \
40464047
"mds_bal_fragment_dirs", \

src/mds/Server.cc

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1350,6 +1350,9 @@ void Server::evict_cap_revoke_non_responders() {
13501350
}
13511351

13521352
void Server::handle_conf_change(const std::set<std::string>& changed) {
1353+
if (changed.count("mds_allow_async_dirops")){
1354+
mds_allow_async_dirops = g_conf().get_val<bool>("mds_allow_async_dirops");
1355+
}
13531356
if (changed.count("mds_forward_all_requests_to_auth")){
13541357
forward_all_requests_to_auth = g_conf().get_val<bool>("mds_forward_all_requests_to_auth");
13551358
}
@@ -2522,7 +2525,7 @@ void Server::set_reply_extra_bl(const cref_t<MClientRequest> &req, inodeno_t ino
25222525
{
25232526
Session *session = mds->get_session(req);
25242527

2525-
if (session->info.has_feature(CEPHFS_FEATURE_DELEG_INO)) {
2528+
if (mds_allow_async_dirops && session->info.has_feature(CEPHFS_FEATURE_DELEG_INO)) {
25262529
openc_response_t ocresp;
25272530

25282531
dout(10) << "adding created_ino and delegated_inos" << dendl;
@@ -4815,7 +4818,7 @@ void Server::handle_client_openc(const MDRequestRef& mdr)
48154818
if (!check_dir_max_entries(mdr, dir))
48164819
return;
48174820

4818-
if (mdr->dn[0].size() == 1)
4821+
if (mds_allow_async_dirops && mdr->dn[0].size() == 1)
48194822
mds->locker->create_lock_cache(mdr, diri, &mdr->dir_layout);
48204823

48214824
// create inode.
@@ -8196,7 +8199,7 @@ void Server::handle_client_unlink(const MDRequestRef& mdr)
81968199
return; // we're waiting for a witness.
81978200
}
81988201

8199-
if (!rmdir && dnl->is_primary() && mdr->dn[0].size() == 1)
8202+
if (mds_allow_async_dirops && !rmdir && dnl->is_primary() && mdr->dn[0].size() == 1)
82008203
mds->locker->create_lock_cache(mdr, diri);
82018204

82028205
// ok!

src/mds/Server.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,7 @@ class Server {
544544
feature_bitset_t supported_metric_spec;
545545
feature_bitset_t required_client_features;
546546

547+
bool mds_allow_async_dirops = true;
547548
bool forward_all_requests_to_auth = false;
548549
bool replay_unsafe_with_closed_session = false;
549550
double cap_revoke_eviction_timeout = 0;

0 commit comments

Comments
 (0)