From e7f4b9e22f215d7abed5888b90bd15020b2320bd Mon Sep 17 00:00:00 2001 From: John Spray Date: Tue, 25 Mar 2014 13:31:24 +0000 Subject: [PATCH] mds: Fix Dumper::undump (missing lock) 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 --- src/mds/Dumper.cc | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/mds/Dumper.cc b/src/mds/Dumper.cc index 6535f7d6b08..1db68bc1360 100644 --- a/src/mds/Dumper.cc +++ b/src/mds/Dumper.cc @@ -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; } -- 2.47.3