]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: check inode type when deciding if filelock should be in EXCL state 32816/head
authorYan, Zheng <zyan@redhat.com>
Mon, 13 Jan 2020 07:21:44 +0000 (15:21 +0800)
committerYan, Zheng <zyan@redhat.com>
Tue, 4 Feb 2020 02:17:35 +0000 (10:17 +0800)
Conditions for regular file and directory are different.

Signed-off-by: "Yan, Zheng" <zyan@redhat.com>
src/mds/CInode.cc
src/mds/Locker.cc

index 3f0ea1f4357ffe63e00362443a0acfcaa9e4f0f9..57908d996518dcee3f4075ab82c85565f44ed06a 100644 (file)
@@ -3096,8 +3096,9 @@ client_t CInode::calc_ideal_loner()
   client_t loner = -1;
   for (const auto &p : client_caps) {
     if (!p.second.is_stale() &&
-       ((p.second.wanted() & (CEPH_CAP_ANY_WR|CEPH_CAP_FILE_WR|CEPH_CAP_FILE_RD)) ||
-        (inode.is_dir() && !has_subtree_root_dirfrag()))) {
+       (is_dir() ?
+        !has_subtree_or_exporting_dirfrag() :
+        (p.second.wanted() & (CEPH_CAP_ANY_WR|CEPH_CAP_FILE_RD)))) {
       if (n)
        return -1;
       n++;
index 79ec9dc4711f99ad5f36549813278cdbd0d9ca38..2b14c22e9bd65b9ac926a251ff6e55cfb157f07e 100644 (file)
@@ -5297,8 +5297,8 @@ void Locker::file_eval(ScatterLock *lock, bool *need_issue)
            << " xlocker_issued=" << gcap_string(xlocker_issued)
            << dendl;
     if (!((loner_wanted|loner_issued) & (CEPH_CAP_GEXCL|CEPH_CAP_GWR|CEPH_CAP_GBUFFER)) ||
-        (other_wanted & (CEPH_CAP_GEXCL|CEPH_CAP_GWR|CEPH_CAP_GRD)) ||
-       (in->inode.is_dir() && in->multiple_nonstale_caps())) {  // FIXME.. :/
+       (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;
       // we should lose it.
       //  loner  other   want
@@ -5326,9 +5326,10 @@ void Locker::file_eval(ScatterLock *lock, bool *need_issue)
   else if (lock->get_state() != LOCK_EXCL &&
           !lock->is_rdlocked() &&
           //!lock->is_waiter_for(SimpleLock::WAIT_WR) &&
-          ((wanted & (CEPH_CAP_GWR|CEPH_CAP_GBUFFER)) ||
-           (in->inode.is_dir() && !in->has_subtree_or_exporting_dirfrag())) &&
-          in->get_target_loner() >= 0) {
+          in->get_target_loner() >= 0 &&
+          (in->is_dir() ?
+           !in->has_subtree_or_exporting_dirfrag() :
+           (wanted & (CEPH_CAP_GEXCL|CEPH_CAP_GWR|CEPH_CAP_GBUFFER)))) {
     dout(7) << "file_eval stable, bump to loner " << *lock
            << " on " << *lock->get_parent() << dendl;
     file_excl(lock, need_issue);