]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: Fix Dumper::undump (missing lock)
authorJohn Spray <john.spray@inktank.com>
Tue, 25 Mar 2014 13:31:24 +0000 (13:31 +0000)
committerJohn Spray <john.spray@inktank.com>
Sun, 18 May 2014 10:21:29 +0000 (11:21 +0100)
Two problems were causing undump to fail:
* Objecter lock was not being taken around call to
  .write() and .write_full() calls, causing assertion.
* Once that is fixed, it is necessary to use a separate,
  local lock to protect the completion condition for
  write operations

Signed-off-by: John Spray <john.spray@inktank.com>
src/mds/Dumper.cc

index 6535f7d6b0811aea911bf727dcbefeaa6cb6d5e7..1db68bc136094f8b3104f87b4c527964874a06e0 100644 (file)
@@ -132,6 +132,7 @@ void Dumper::dump(const char *dump_file)
 
 void Dumper::undump(const char *dump_file)
 {
+  Mutex localLock("undump:lock");
   cout << "undump " << dump_file << std::endl;
   
   int fd = ::open(dump_file, O_RDONLY);
@@ -179,14 +180,16 @@ void Dumper::undump(const char *dump_file)
   Cond cond;
   
   cout << "writing header " << oid << std::endl;
+  lock.Lock();
   objecter->write_full(oid, oloc, snapc, hbl, ceph_clock_now(g_ceph_context), 0, 
                       NULL, 
-                      new C_SafeCond(&lock, &cond, &done));
+                      new C_SafeCond(&localLock, &cond, &done));
+  lock.Unlock();
 
-  lock.Lock();
+  localLock.Lock();
   while (!done)
-    cond.Wait(lock);
-  lock.Unlock();
+    cond.Wait(localLock);
+  localLock.Unlock();
   
   // read
   Filer filer(objecter);
@@ -198,13 +201,16 @@ void Dumper::undump(const char *dump_file)
     uint64_t l = MIN(left, 1024*1024);
     j.read_fd(fd, l);
     cout << " writing " << pos << "~" << l << std::endl;
-    filer.write(ino, &h.layout, snapc, pos, l, j, ceph_clock_now(g_ceph_context), 0, NULL, new C_SafeCond(&lock, &cond, &done));
-
     lock.Lock();
-    while (!done)
-      cond.Wait(lock);
+    filer.write(ino, &h.layout, snapc, pos, l, j, ceph_clock_now(g_ceph_context), 0, NULL,
+        new C_SafeCond(&localLock, &cond, &done));
     lock.Unlock();
-    
+
+    localLock.Lock();
+    while (!done)
+      cond.Wait(localLock);
+    localLock.Unlock();
+      
     pos += l;
     left -= l;
   }