]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd/PG: wait for scan_snaps() mapper repair 24832/head
authorSage Weil <sage@redhat.com>
Mon, 22 Jan 2018 14:29:22 +0000 (08:29 -0600)
committerMykola Golub <mgolub@suse.com>
Tue, 30 Oct 2018 14:57:07 +0000 (16:57 +0200)
Wait for our repair to apply before continuing to avoid reading the
broken state again.

Signed-off-by: Sage Weil <sage@redhat.com>
(cherry picked from commit ea531df216c65a3773a55b5f6c42af20e5004263)

Conflicts:
src/osd/PG.cc: trivial (oi_snaps vs obj_snaps)

src/osd/PG.cc

index 12dd75d7281494681dca67a2ca7f97c407d0ce2f..a855c5549944787fcaefcc498901b5ffc9be21b9 100644 (file)
@@ -3915,10 +3915,25 @@ void PG::_scan_snaps(ScrubMap &smap)
                            << "...repaired";
        }
        snap_mapper.add_oid(hoid, oi_snaps, &_t);
-       r = osd->store->queue_transaction(osr.get(), std::move(t), nullptr);
-       if (r != 0) {
-         derr << __func__ << ": queue_transaction got " << cpp_strerror(r)
-              << dendl;
+
+       // wait for repair to apply to avoid confusing other bits of the system.
+       {
+         Cond my_cond;
+         Mutex my_lock("PG::_scan_snaps my_lock");
+         int r = 0;
+         bool done;
+         t.register_on_applied_sync(
+           new C_SafeCond(&my_lock, &my_cond, &done, &r));
+         r = osd->store->queue_transaction(osr.get(), std::move(t), nullptr);
+         if (r != 0) {
+           derr << __func__ << ": queue_transaction got " << cpp_strerror(r)
+                << dendl;
+         } else {
+           my_lock.Lock();
+           while (!done)
+             my_cond.Wait(my_lock);
+           my_lock.Unlock();
+         }
        }
       }
     } else {