]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
dumper: fix Objecter locking
authorGreg Farnum <greg@inktank.com>
Wed, 1 May 2013 21:10:31 +0000 (14:10 -0700)
committerGreg Farnum <greg@inktank.com>
Wed, 1 May 2013 21:10:31 +0000 (14:10 -0700)
Locking expectations changed at some point, and the Dumper wasn't
updated to comply:
1) We need to take the lock for Objecter, as it
doesn't do so on its own any more.
2) We need to drop the lock in several places so that Objecter
can take delivery of messages

Signed-off-by: Greg Farnum <greg@inktank.com>
Reviewed-by: Sage Weil <sage@inktank.com>
src/mds/Dumper.cc
src/mds/Dumper.h

index 917403ee2088502644b6e9e5dd5e6f408080dd08..9b83b4d9b002195582a1ce3c9a6b80180598e0e5 100644 (file)
@@ -25,6 +25,8 @@
 #include "mon/MonClient.h"
 #include "osdc/Journaler.h"
 
+#define dout_subsys ceph_subsys_mds
+
 Dumper::~Dumper()
 {
 }
@@ -69,9 +71,9 @@ void Dumper::init(int rank)
   objecter->init_unlocked();
   lock.Lock();
   objecter->init_locked();
+  lock.Unlock();
   objecter->wait_for_osd_map();
   timer.init();
-  lock.Unlock();
 }
 
 void Dumper::shutdown()
@@ -91,11 +93,14 @@ void Dumper::dump(const char *dump_file)
   int rank = strtol(g_conf->name.get_id().c_str(), 0, 0);
   inodeno_t ino = MDS_INO_LOG_OFFSET + rank;
 
+  Mutex localLock("dump:lock");
   lock.Lock();
-  journaler->recover(new C_SafeCond(&lock, &cond, &done, &r));
-  while (!done)
-    cond.Wait(lock);
+  journaler->recover(new C_SafeCond(&localLock, &cond, &done, &r));
   lock.Unlock();
+  localLock.Lock();
+  while (!done)
+    cond.Wait(localLock);
+  localLock.Unlock();
 
   if (r < 0) { // Error
     derr << "error on recovery: " << cpp_strerror(r) << dendl;
@@ -103,6 +108,8 @@ void Dumper::dump(const char *dump_file)
     // wait for messenger to finish
     messenger->wait();
     shutdown();
+  } else {
+    dout(10) << "completed journal recovery" << dendl;
   }
 
   uint64_t start = journaler->get_read_pos();
@@ -112,12 +119,14 @@ void Dumper::dump(const char *dump_file)
 
   Filer filer(objecter);
   bufferlist bl;
-  filer.read(ino, &journaler->get_layout(), CEPH_NOSNAP,
-             start, len, &bl, 0, new C_SafeCond(&lock, &cond, &done));
   lock.Lock();
-  while (!done)
-    cond.Wait(lock);
+  filer.read(ino, &journaler->get_layout(), CEPH_NOSNAP,
+             start, len, &bl, 0, new C_SafeCond(&localLock, &cond, &done));
   lock.Unlock();
+  localLock.Lock();
+  while (!done)
+    cond.Wait(localLock);
+  localLock.Unlock();
 
   cout << "read " << bl.length() << " bytes at offset " << start << std::endl;
 
index 066ba5ccb1df136798b87ec529940c10436a6298..794ae0c8aa732c1776c0fb086ee5972b04408fd7 100644 (file)
@@ -62,6 +62,7 @@ public:
   virtual ~Dumper();
 
   bool ms_dispatch(Message *m) {
+    Mutex::Locker locker(lock);
     switch (m->get_type()) {
     case CEPH_MSG_OSD_OPREPLY:
       objecter->handle_osd_op_reply((MOSDOpReply *)m);