]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: add MDS::damaged_unlocked helper
authorJohn Spray <john.spray@redhat.com>
Mon, 1 Jun 2015 14:18:52 +0000 (15:18 +0100)
committerJohn Spray <john.spray@redhat.com>
Thu, 18 Jun 2015 10:19:44 +0000 (11:19 +0100)
...to avoid doing a lock/damaged/unlock in lots
of places in MDLog.

Signed-off-by: John Spray <john.spray@redhat.com>
src/mds/MDLog.cc
src/mds/MDS.cc
src/mds/MDS.h

index 4ee502ee1a80f9b52000a8bcc0688fdf4964d7d1..b62ec748aa3059ce5dfceaf5d1fa86664f0cf079 100644 (file)
@@ -847,9 +847,7 @@ void MDLog::_recovery_thread(MDSInternalContextBase *completion)
   } else if (read_result != 0) {
     mds->clog->error() << "failed to read JournalPointer: " << read_result
                        << " (" << cpp_strerror(read_result) << ")";
-    mds->mds_lock.Lock();
-    mds->damaged();
-    mds->mds_lock.Unlock();
+    mds->damaged_unlocked();
     assert(0);  // Should be unreachable because damaged() calls respawn()
   }
 
@@ -877,9 +875,7 @@ void MDLog::_recovery_thread(MDSInternalContextBase *completion)
       // means something worse like a corrupt header, which we can't handle here.
       mds->clog->error() << "Error recovering journal " << jp.front << ": "
         << cpp_strerror(recovery_result);
-      mds->mds_lock.Lock();
-      mds->damaged();
-      mds->mds_lock.Unlock();
+      mds->damaged_unlocked();
       assert(recovery_result == 0); // Unreachable because damaged() calls respawn()
     }
 
@@ -912,9 +908,7 @@ void MDLog::_recovery_thread(MDSInternalContextBase *completion)
   if (recovery_result != 0) {
     mds->clog->error() << "Error recovering journal " << jp.front << ": "
       << cpp_strerror(recovery_result);
-    mds->mds_lock.Lock();
-    mds->damaged();
-    mds->mds_lock.Unlock();
+    mds->damaged_unlocked();
     assert(recovery_result == 0); // Unreachable because damaged() calls respawn()
   }
 
@@ -1150,9 +1144,7 @@ void MDLog::_replay_thread()
           r = -EAGAIN;
         } else {
           mds->clog->error() << "missing journal object";
-          mds->mds_lock.Lock();
-          mds->damaged();
-          mds->mds_lock.Unlock();
+          mds->damaged_unlocked();
           assert(0);  // Should be unreachable because damaged() calls respawn()
         }
       } else if (r == -EINVAL) {
@@ -1163,9 +1155,7 @@ void MDLog::_replay_thread()
             r = -EAGAIN;
           } else {
             mds->clog->error() << "invalid journaler offsets";
-            mds->mds_lock.Lock();
-            mds->damaged();
-            mds->mds_lock.Unlock();
+            mds->damaged_unlocked();
             assert(0);  // Should be unreachable because damaged() calls respawn()
           }
         } else {
@@ -1188,9 +1178,7 @@ void MDLog::_replay_thread()
                         << dendl;
 
                 mds->clog->error() << "error reading journal header";
-                mds->mds_lock.Lock();
-                mds->damaged();
-                mds->mds_lock.Unlock();
+                mds->damaged_unlocked();
                 assert(0);  // Should be unreachable because damaged() calls
                             // respawn()
             }
@@ -1234,9 +1222,7 @@ void MDLog::_replay_thread()
       if (g_conf->mds_log_skip_corrupt_events) {
         continue;
       } else {
-        mds->mds_lock.Lock();
-        mds->damaged();
-        mds->mds_lock.Unlock();
+        mds->damaged_unlocked();
         assert(0);  // Should be unreachable because damaged() calls
                     // respawn()
       }
index 4f78af193dc2479bfa6af7970478aae93e0b28c8..f3679c43b5dc3ec8567c8c8f7a5e8aaceaa3f87e 100644 (file)
@@ -2423,6 +2423,7 @@ void MDS::handle_signal(int signum)
 void MDS::damaged()
 {
   assert(whoami != MDS_RANK_NONE);
+  assert(mds_lock.is_locked_by_me());
 
   set_want_state(MDSMap::STATE_DAMAGED);
   monc->flush_log();  // Flush any clog error from before we were called
index f7335e46bca13cc851c9db52ffc4a3a0442b3646..807bbbfa43a8a8bdd30d8e2ac5228080678c24df 100644 (file)
@@ -449,9 +449,23 @@ private:
    * to load an MDS rank's data structures.  This is *not* for use with
    * errors affecting normal dirfrag/inode objects -- they should be handled
    * through cleaner scrub/repair mechanisms.
+   *
+   * Callers must already hold mds_lock.
    */
   void damaged();
 
+  /**
+   * Wrapper around `damaged` for users who are not
+   * already holding mds_lock.
+   *
+   * Callers must not already hold mds_lock.
+   */
+  void damaged_unlocked()
+  {
+    Mutex::Locker l(mds_lock);
+    damaged();
+  }
+
   /**
    * Terminate this daemon process.
    *