]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: require callers to ObjectMap::aio_update to acquire lock
authorJason Dillaman <dillaman@redhat.com>
Thu, 19 Mar 2015 19:35:59 +0000 (15:35 -0400)
committerJason Dillaman <dillaman@redhat.com>
Fri, 10 Apr 2015 18:10:04 +0000 (14:10 -0400)
This is needed to allow an atomic compare and update operation
from the rebuild object map utility.

Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/librbd/AioRequest.cc
src/librbd/AsyncTrimRequest.cc
src/librbd/CopyupRequest.cc
src/librbd/ObjectMap.cc

index ea1df532d1ec27862f8562d8fdc47d051a1d1bb1..454f1ea3412e574f4a1e8a95b82d0f06a372f573 100644 (file)
@@ -453,6 +453,7 @@ namespace librbd {
         m_state = LIBRBD_AIO_WRITE_PRE;
         FunctionContext *ctx = new FunctionContext(
           boost::bind(&AioRequest::complete, this, _1));
+        RWLock::WLocker object_map_locker(m_ictx->object_map_lock);
         if (!m_ictx->object_map.aio_update(m_object_no, new_state,
                                            current_state, ctx)) {
          // no object map update required
@@ -487,6 +488,7 @@ namespace librbd {
     m_state = LIBRBD_AIO_WRITE_POST;
     FunctionContext *ctx = new FunctionContext(
       boost::bind(&AioRequest::complete, this, _1));
+    RWLock::WLocker object_map_locker(m_ictx->object_map_lock);
     if (!m_ictx->object_map.aio_update(m_object_no, OBJECT_NONEXISTENT,
                                        OBJECT_PENDING, ctx)) {
       // no object map update required
index b474124c85c2ac74805d2322153fb41414d17f24..f6864f9e0dd5ac6875955c241b0295764fbe6e4e 100644 (file)
@@ -173,6 +173,7 @@ void AsyncTrimRequest::send_pre_remove() {
       } else {
         // flag the objects as pending deletion
         Context *ctx = create_callback_context();
+        RWLock::WLocker object_map_locker(m_image_ctx.object_map_lock);
         if (!m_image_ctx.object_map.aio_update(m_delete_start, m_num_objects,
                                               OBJECT_PENDING, OBJECT_EXISTS,
                                                ctx)) {
@@ -210,6 +211,7 @@ bool AsyncTrimRequest::send_post_remove() {
       } else {
         // flag the pending objects as removed
         Context *ctx = create_callback_context();
+        RWLock::WLocker object_map_locker(m_image_ctx.object_map_lock);
         if (!m_image_ctx.object_map.aio_update(m_delete_start, m_num_objects,
                                               OBJECT_NONEXISTENT,
                                               OBJECT_PENDING, ctx)) {
index a58ec84f6ccdaa43cc6c60d3051c7bd09ea101c2..7abb475fa4dec804584dfd2c17edb3e2368aeaf5 100644 (file)
@@ -187,6 +187,7 @@ namespace librbd {
       } else {
        m_state = STATE_OBJECT_MAP;
         Context *ctx = create_callback_context();
+        RWLock::WLocker object_map_locker(m_ictx->object_map_lock);
         if (!m_ictx->object_map.aio_update(m_object_no, OBJECT_EXISTS,
                                           boost::optional<uint8_t>(), ctx)) {
           delete ctx;
index f32ad7cf48beb12dd4109485821fbcd49bcbf3c9..aa30fac5884440e5c0d1658f18b650d86a851b7b 100644 (file)
@@ -323,8 +323,7 @@ bool ObjectMap::aio_update(uint64_t start_object_no, uint64_t end_object_no,
   assert(m_image_ctx.test_features(RBD_FEATURE_OBJECT_MAP));
   assert(m_image_ctx.owner_lock.is_locked());
   assert(m_image_ctx.image_watcher->is_lock_owner());
-
-  RWLock::WLocker l(m_image_ctx.object_map_lock);
+  assert(m_image_ctx.object_map_lock.is_wlocked());
   assert(start_object_no < end_object_no);
 
   CephContext *cct = m_image_ctx.cct;