]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: flush cache when set_snap() is called 163/head
authorJosh Durgin <josh.durgin@inktank.com>
Thu, 28 Mar 2013 00:30:42 +0000 (17:30 -0700)
committerJosh Durgin <josh.durgin@inktank.com>
Thu, 28 Mar 2013 07:10:05 +0000 (00:10 -0700)
If there are writes pending, they should be sent while the image
is still writeable. If the image becomes read-only, flushing the
cache will just mark everything dirty again due to -EROFS.

Fixes: #4525
Backport: bobtail
Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
src/librbd/internal.cc

index 24a3444a859468e793d260d50652eb81ebb4a96e..9c4f3c24d45797ed46b204ef91a0fb2c4712ecd5 100644 (file)
@@ -1898,6 +1898,12 @@ reprotect_and_return_err:
     // ignore return value, since we may be set to a non-existent
     // snapshot and the user is trying to fix that
     ictx_check(ictx);
+    if (ictx->object_cacher) {
+      // complete pending writes before we're set to a snapshot and
+      // get -EROFS for writes
+      RWLock::WLocker l(ictx->md_lock);
+      ictx->flush_cache();
+    }
     return _snap_set(ictx, snap_name);
   }