]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: make _need_flush_mdlog() check in both stable and unstable cases
authorXiubo Li <xiubli@redhat.com>
Mon, 7 Mar 2022 05:53:19 +0000 (13:53 +0800)
committerXiubo Li <xiubli@redhat.com>
Thu, 18 Aug 2022 00:52:57 +0000 (08:52 +0800)
lock_state_any is true will ignore the lock state.

Signed-off-by: Xiubo Li <xiubli@redhat.com>
(cherry picked from commit 9ceaa3ae9621b7034c02fd57a28885b2b4652af9)

src/mds/Locker.cc
src/mds/Locker.h
src/mds/SimpleLock.h

index 503f65718da374460a4c19c5f6625a56cc361a5c..6329e1a42d4f2b01ce14daadb4549214eca1e1d6 100644 (file)
@@ -2230,7 +2230,7 @@ Capability* Locker::issue_new_caps(CInode *in,
     // [auth] twiddle mode?
     eval(in, CEPH_CAP_LOCKS);
 
-    if (_need_flush_mdlog(in, my_want))
+    if (_need_flush_mdlog(in, my_want, true))
       mds->mdlog->flush();
 
   } else {
@@ -2934,18 +2934,18 @@ void Locker::share_inode_max_size(CInode *in, Capability *only_cap)
   }
 }
 
-bool Locker::_need_flush_mdlog(CInode *in, int wanted)
+bool Locker::_need_flush_mdlog(CInode *in, int wanted, bool lock_state_any)
 {
   /* flush log if caps are wanted by client but corresponding lock is unstable and locked by
    * pending mutations. */
   if (((wanted & (CEPH_CAP_FILE_RD|CEPH_CAP_FILE_WR|CEPH_CAP_FILE_SHARED|CEPH_CAP_FILE_EXCL)) &&
-       in->filelock.is_unstable_and_locked()) ||
+       (lock_state_any ? in->filelock.is_locked() : in->filelock.is_unstable_and_locked())) ||
       ((wanted & (CEPH_CAP_AUTH_SHARED|CEPH_CAP_AUTH_EXCL)) &&
-       in->authlock.is_unstable_and_locked()) ||
+       (lock_state_any ? in->authlock.is_locked() : in->authlock.is_unstable_and_locked())) ||
       ((wanted & (CEPH_CAP_LINK_SHARED|CEPH_CAP_LINK_EXCL)) &&
-       in->linklock.is_unstable_and_locked()) ||
+       (lock_state_any ? in->linklock.is_locked() : in->linklock.is_unstable_and_locked())) ||
       ((wanted & (CEPH_CAP_XATTR_SHARED|CEPH_CAP_XATTR_EXCL)) &&
-       in->xattrlock.is_unstable_and_locked()))
+       (lock_state_any ? in->xattrlock.is_locked() : in->xattrlock.is_unstable_and_locked())))
     return true;
   return false;
 }
index c8ddaccd6a6a8fe5804b5e8408ce693cbeb24502..2dedde8e62563d7a5c13d5f09ce9e6d075a3686c 100644 (file)
@@ -212,7 +212,7 @@ protected:
 
   void scatter_writebehind_finish(ScatterLock *lock, MutationRef& mut);
 
-  bool _need_flush_mdlog(CInode *in, int wanted_caps);
+  bool _need_flush_mdlog(CInode *in, int wanted_caps, bool lock_state_any=false);
   void adjust_cap_wanted(Capability *cap, int wanted, int issue_seq);
   void handle_client_caps(const cref_t<MClientCaps> &m);
   void _update_cap_fields(CInode *in, int dirty, const cref_t<MClientCaps> &m, CInode::mempool_inode *pi);
index 5c625b6af06f2819b80bbd2df7984f038f1c3d34..725c4488c17f0a8fb7eafb965decc36da7bf999c 100644 (file)
@@ -256,8 +256,9 @@ public:
     return get_sm()->states[state].next == 0;
   }
   bool is_unstable_and_locked() const {
-    if (is_stable())
-      return false;
+    return (!is_stable() && is_locked());
+  }
+  bool is_locked() const {
     return is_rdlocked() || is_wrlocked() || is_xlocked();
   }
   int get_next_state() {