]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: allow snapshots to be created when snapshot is active
authorJason Dillaman <dillaman@redhat.com>
Mon, 27 Apr 2015 05:00:38 +0000 (01:00 -0400)
committerJason Dillaman <dillaman@redhat.com>
Wed, 6 May 2015 15:52:06 +0000 (11:52 -0400)
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 <dillaman@redhat.com>
(cherry picked from commit 594a6610802f2cadb62200815bd8b9860809e759)

Conflicts:
src/librbd/internal.cc

src/librbd/internal.cc

index 2c06a3ec29614660f04569d5d143a2e002bbdd9f..ba494f96fbcb7942364fe185627e1685669b96fb 100644 (file)
@@ -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<int(Context*)>& local_request,
                          const boost::function<int()>& 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,