From: Jason Dillaman Date: Thu, 19 Mar 2015 20:26:40 +0000 (-0400) Subject: librbd: connect async rebuild object map to state machine X-Git-Tag: v9.0.1~149^2~14 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=7ae1b1496664dab999903a06defb4d1e2f4a1805;p=ceph.git librbd: connect async rebuild object map to state machine Signed-off-by: Jason Dillaman --- diff --git a/src/librbd/internal.cc b/src/librbd/internal.cc index 9a84db5a082..4d7f54086a2 100644 --- a/src/librbd/internal.cc +++ b/src/librbd/internal.cc @@ -24,10 +24,10 @@ #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; }