From: Jason Dillaman Date: Mon, 27 Apr 2015 05:00:38 +0000 (-0400) Subject: librbd: allow snapshots to be created when snapshot is active X-Git-Tag: v0.94.2~18^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=af8939be80310e234745fe81e67244ab52c6add5;p=ceph.git librbd: allow snapshots to be created when snapshot is active The librbd API previously permitted the creation of snapshots while the image context was associated to another snapshot. A recent code cleanup broke that ability, so this re-introduces it. The code change also allows minor cleanup with rebuild_object_map. Fixes: #11475 Signed-off-by: Jason Dillaman (cherry picked from commit 594a6610802f2cadb62200815bd8b9860809e759) Conflicts: src/librbd/internal.cc --- diff --git a/src/librbd/internal.cc b/src/librbd/internal.cc index 2c06a3ec296..ba494f96fbc 100644 --- a/src/librbd/internal.cc +++ b/src/librbd/internal.cc @@ -87,6 +87,7 @@ int prepare_image_update(ImageCtx *ictx) { } int invoke_async_request(ImageCtx *ictx, const std::string& request_type, + bool permit_snapshot, const boost::function& local_request, const boost::function& remote_request) { int r; @@ -96,7 +97,8 @@ int invoke_async_request(ImageCtx *ictx, const std::string& request_type, RWLock::RLocker l(ictx->owner_lock); { RWLock::RLocker snap_locker(ictx->snap_lock); - if (ictx->read_only || ictx->snap_id != CEPH_NOSNAP) { + if (ictx->read_only || + (!permit_snapshot && ictx->snap_id != CEPH_NOSNAP)) { return -EROFS; } } @@ -541,7 +543,7 @@ int invoke_async_request(ImageCtx *ictx, const std::string& request_type, } } - r = invoke_async_request(ictx, "snap_create", + r = invoke_async_request(ictx, "snap_create", true, boost::bind(&snap_create_helper, ictx, _1, snap_name), boost::bind(&ImageWatcher::notify_snap_create, @@ -1705,7 +1707,7 @@ reprotect_and_return_err: } uint64_t request_id = ictx->async_request_seq.inc(); - r = invoke_async_request(ictx, "resize", + r = invoke_async_request(ictx, "resize", false, boost::bind(&async_resize, ictx, _1, size, boost::ref(prog_ctx)), boost::bind(&ImageWatcher::notify_resize, @@ -2525,7 +2527,7 @@ reprotect_and_return_err: } uint64_t request_id = ictx->async_request_seq.inc(); - r = invoke_async_request(ictx, "flatten", + r = invoke_async_request(ictx, "flatten", false, boost::bind(&async_flatten, ictx, _1, boost::ref(prog_ctx)), boost::bind(&ImageWatcher::notify_flatten,