]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: race when disabling object map with overlapping in-flight writes 41787/head
authorJason Dillaman <dillaman@redhat.com>
Thu, 18 Jun 2020 19:20:40 +0000 (15:20 -0400)
committerMykola Golub <mgolub@suse.com>
Wed, 9 Jun 2021 11:54:25 +0000 (14:54 +0300)
The block guard that protects against overlapping updates to the object
map needs to be flushed prior to closing the object map instance.

Fixes: https://tracker.ceph.com/issues/46083
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
(cherry picked from commit ee69323cd27263cb7f9dd97dcbfb1c36f1cc0837)

Conflicts:
src/librbd/ObjectMap.cc (FunctionContext vs LambdaContext, on_finish vs ctx)

src/librbd/ObjectMap.cc
src/librbd/ObjectMap.h

index 50cbfda89220edc23747aa1a8763401754ecd6f7..7e73d7f3ce521c4a722d59a5fa201917e96c1b2b 100644 (file)
@@ -165,8 +165,14 @@ void ObjectMap<I>::close(Context *on_finish) {
     return;
   }
 
-  auto req = object_map::UnlockRequest<I>::create(m_image_ctx, on_finish);
-  req->send();
+  auto ctx = new FunctionContext([this, on_finish](int r) {
+      auto req = object_map::UnlockRequest<I>::create(m_image_ctx, on_finish);
+      req->send();
+    });
+
+  // ensure the block guard for aio updates is empty before unlocking
+  // the object map
+  m_async_op_tracker.wait_for_ops(ctx);
 }
 
 template <typename I>
@@ -268,6 +274,7 @@ void ObjectMap<I>::detained_aio_update(UpdateOperation &&op) {
     lderr(cct) << "failed to detain object map update: " << cpp_strerror(r)
                << dendl;
     m_image_ctx.op_work_queue->queue(op.on_finish, r);
+    m_async_op_tracker.finish_op();
     return;
   } else if (r > 0) {
     ldout(cct, 20) << "detaining object map update due to in-flight update: "
@@ -307,6 +314,7 @@ void ObjectMap<I>::handle_detained_aio_update(BlockGuardCell *cell, int r,
   }
 
   on_finish->complete(r);
+  m_async_op_tracker.finish_op();
 }
 
 template <typename I>
index c930a5b554a353dcf224c99f66999a177da5ae37..0991416dc5300d5c34ca7b3b74438080854cac33 100644 (file)
@@ -8,6 +8,7 @@
 #include "include/fs_types.h"
 #include "include/rados/librados_fwd.hpp"
 #include "include/rbd/object_map_types.h"
+#include "common/AsyncOpTracker.h"
 #include "common/bit_vector.hpp"
 #include "librbd/Utils.h"
 #include <boost/optional.hpp>
@@ -89,6 +90,7 @@ public:
         return false;
       }
 
+      m_async_op_tracker.start_op();
       UpdateOperation update_operation(start_object_no, end_object_no,
                                        new_state, current_state, parent_trace,
                                        ignore_enoent,
@@ -135,6 +137,7 @@ private:
   ceph::BitVector<2> m_object_map;
   uint64_t m_snap_id;
 
+  AsyncOpTracker m_async_op_tracker;
   UpdateGuard *m_update_guard = nullptr;
 
   void detained_aio_update(UpdateOperation &&update_operation);