From: Patrick Donnelly Date: Tue, 27 Feb 2024 20:24:26 +0000 (-0500) Subject: mds: avoid issuing exclusive caps to clients lacking w caps X-Git-Tag: testing/wip-root-testing-20240411.174241~89^2~13 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=924fcf5dad2a8c6d011d3263ba14ec171a991fa9;p=ceph-ci.git mds: avoid issuing exclusive caps to clients lacking w caps Signed-off-by: Leonid Usov (cherry picked from commit 772f04afdf87d25de8102b7f6aa7e0a242cd566e) --- diff --git a/src/mds/Locker.cc b/src/mds/Locker.cc index 91547a82152..5b296dffa57 100644 --- a/src/mds/Locker.cc +++ b/src/mds/Locker.cc @@ -2965,10 +2965,13 @@ bool Locker::check_inode_max_size(CInode *in, bool force_wrlock, } else if (!force_wrlock && !in->filelock.can_wrlock(in->get_loner())) { // lock? if (in->filelock.is_stable()) { - if (in->get_target_loner() >= 0) - file_excl(&in->filelock); - else - simple_lock(&in->filelock); + auto wanted = in->get_caps_wanted(); + if (in->get_target_loner() >= 0 && (wanted & CEPH_CAP_ANY_FILE_WR)) { + dout(10) << "check_inode_max_size requesting file_excl for wanted caps " << ccap_string(wanted) << " " << *in << dendl; + file_excl(&in->filelock); + } else { + simple_lock(&in->filelock); + } } if (!in->filelock.can_wrlock(in->get_loner())) { dout(10) << "check_inode_max_size can't wrlock, waiting on " << *in << dendl; @@ -5586,7 +5589,7 @@ void Locker::file_eval(ScatterLock *lock, bool *need_issue) << " other_issued=" << gcap_string(other_issued) << " xlocker_issued=" << gcap_string(xlocker_issued) << dendl; - if (!((loner_wanted|loner_issued) & (CEPH_CAP_GEXCL|CEPH_CAP_GWR|CEPH_CAP_GBUFFER)) || + if (!((loner_wanted|loner_issued) & (CEPH_CAP_ANY_FILE_WR >> CEPH_CAP_SFILE)) || (other_wanted & (CEPH_CAP_GEXCL|CEPH_CAP_GWR|CEPH_CAP_GRD)) || (in->is_dir() && in->multiple_nonstale_caps())) { // FIXME.. :/ dout(20) << " should lose it" << dendl; @@ -5619,7 +5622,7 @@ void Locker::file_eval(ScatterLock *lock, bool *need_issue) in->get_target_loner() >= 0 && (in->is_dir() ? !in->has_subtree_or_exporting_dirfrag() : - (wanted & (CEPH_CAP_GEXCL|CEPH_CAP_GWR|CEPH_CAP_GBUFFER)))) { + (wanted & (CEPH_CAP_ANY_FILE_WR >> CEPH_CAP_SFILE)))) { dout(7) << "file_eval stable, bump to loner " << *lock << " on " << *lock->get_parent() << dendl; file_excl(lock, need_issue);