]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: keep locks in sync state when MDS is readonly
authorYan, Zheng <zyan@redhat.com>
Fri, 28 Nov 2014 08:02:32 +0000 (16:02 +0800)
committerYan, Zheng <zyan@redhat.com>
Tue, 2 Dec 2014 02:47:23 +0000 (10:47 +0800)
when transit locks to sync state, we may submit new entries to the log.
This should be safe as long as we don't trim old log segments.

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

index d84ef5f9e2f4ce7049d6642840909df11de0504d..3147ead0ca9f627ea0d98fbf171672e0cfd5884f 100644 (file)
@@ -2500,6 +2500,8 @@ void CInode::decode_snap(bufferlist::iterator& p)
 
 client_t CInode::calc_ideal_loner()
 {
+  if (mdcache->is_readonly())
+    return -1;
   if (!mds_caps_wanted.empty())
     return -1;
   
index 57350c60a6dcdcc43c7a7eb622cbeb1a97664c2f..c1903519aaa0a86e680490cb30e154dc8a1efc64 100644 (file)
@@ -3692,6 +3692,14 @@ void Locker::simple_eval(SimpleLock *lock, bool *need_issue)
       return;
   }
 
+  if (mdcache->is_readonly()) {
+    if (lock->get_state() != LOCK_SYNC) {
+      dout(10) << "simple_eval read-only FS, syncing " << *lock << " on " << *lock->get_parent() << dendl;
+      simple_sync(lock, need_issue);
+    }
+    return;
+  }
+
   CInode *in = 0;
   int wanted = 0;
   if (lock->get_type() != CEPH_LOCK_DN) {
@@ -4119,6 +4127,14 @@ void Locker::scatter_eval(ScatterLock *lock, bool *need_issue)
     dout(20) << "  freezing|frozen" << dendl;
     return;
   }
+
+  if (mdcache->is_readonly()) {
+    if (lock->get_state() != LOCK_SYNC) {
+      dout(10) << "scatter_eval read-only FS, syncing " << *lock << " on " << *lock->get_parent() << dendl;
+      simple_sync(lock, need_issue);
+    }
+    return;
+  }
   
   if (!lock->is_rdlocked() &&
       lock->get_state() != LOCK_MIX &&
@@ -4226,6 +4242,14 @@ void Locker::scatter_nudge(ScatterLock *lock, MDSInternalContextBase *c, bool fo
        }
        */
 
+       if (mdcache->is_readonly()) {
+         if (lock->get_state() != LOCK_SYNC) {
+           dout(10) << "scatter_nudge auth, read-only FS, syncing " << *lock << " on " << *p << dendl;
+           simple_sync(static_cast<ScatterLock*>(lock));
+         }
+         break;
+       }
+
        // adjust lock state
        dout(10) << "scatter_nudge auth, scatter/unscattering " << *lock << " on " << *p << dendl;
        switch (lock->get_type()) {
@@ -4468,6 +4492,14 @@ void Locker::file_eval(ScatterLock *lock, bool *need_issue)
   if (lock->get_parent()->is_freezing_or_frozen())
     return;
 
+  if (mdcache->is_readonly()) {
+    if (lock->get_state() != LOCK_SYNC) {
+      dout(10) << "file_eval read-only FS, syncing " << *lock << " on " << *lock->get_parent() << dendl;
+      simple_sync(lock, need_issue);
+    }
+    return;
+  }
+
   // excl -> *?
   if (lock->get_state() == LOCK_EXCL) {
     dout(20) << " is excl" << dendl;