]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: connect async rebuild object map to state machine
authorJason Dillaman <dillaman@redhat.com>
Thu, 19 Mar 2015 20:26:40 +0000 (16:26 -0400)
committerJason Dillaman <dillaman@redhat.com>
Fri, 10 Apr 2015 18:10:04 +0000 (14:10 -0400)
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/librbd/internal.cc

index 9a84db5a082e74ce19d025de47093896c80d3802..4d7f54086a2da59128c34d64fcd93507e4475f9d 100644 (file)
 #include "librbd/CopyupRequest.h"
 #include "librbd/ImageCtx.h"
 #include "librbd/ImageWatcher.h"
-
 #include "librbd/internal.h"
 #include "librbd/ObjectMap.h"
 #include "librbd/parent_types.h"
+#include "librbd/RebuildObjectMapRequest.h"
 #include "include/util.h"
 
 #include "librados/snap_set_diff.h"
@@ -2666,7 +2666,7 @@ reprotect_and_return_err:
       RWLock::RLocker l(ictx->snap_lock);
       RWLock::RLocker l2(ictx->parent_lock);
 
-      if (ictx->read_only || ictx->snap_id != CEPH_NOSNAP) {
+      if (ictx->read_only) {
         return -EROFS;
       }
 
@@ -2737,7 +2737,31 @@ reprotect_and_return_err:
 
   int async_rebuild_object_map(ImageCtx *ictx, Context *ctx,
                                ProgressContext &prog_ctx) {
-    // TODO rebuild image HEAD
+    assert(ictx->owner_lock.is_locked());
+    assert(!ictx->image_watcher->is_lock_supported() ||
+          ictx->image_watcher->is_lock_owner());
+
+    CephContext *cct = ictx->cct;
+    ldout(cct, 20) << "async_rebuild_object_map " << ictx << dendl;
+
+    int r = ictx_check(ictx);
+    if (r < 0) {
+      return r;
+    }
+
+    {
+      RWLock::RLocker snap_locker(ictx->snap_lock);
+      if (ictx->read_only) {
+        return -EROFS;
+      }
+      if (!ictx->test_features(RBD_FEATURE_OBJECT_MAP)) {
+        return -EINVAL;
+      }
+    }
+
+    RebuildObjectMapRequest *req = new RebuildObjectMapRequest(*ictx, ctx,
+                                                               prog_ctx);
+    req->send();
     return 0;
   }