]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: flush cache when set_snap() is called
authorJosh Durgin <josh.durgin@inktank.com>
Thu, 28 Mar 2013 00:30:42 +0000 (17:30 -0700)
committerJosh Durgin <josh.durgin@inktank.com>
Tue, 23 Apr 2013 18:33:17 +0000 (11:33 -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>
(cherry picked from commit 613b7085bb48cde1e464b7a97c00b8751e0e917f)

src/librbd/internal.cc

index 87bc7a3ee163e60013e76028cee688aef0259145..0307762d0f59db8ba17dea28bb36af8d300278dc 100644 (file)
@@ -1899,6 +1899,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);
   }