From: Josh Durgin Date: Thu, 28 Mar 2013 00:30:42 +0000 (-0700) Subject: librbd: flush cache when set_snap() is called X-Git-Tag: v0.60~6^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F163%2Fhead;p=ceph.git librbd: flush cache when set_snap() is called 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 --- diff --git a/src/librbd/internal.cc b/src/librbd/internal.cc index 24a3444a859..9c4f3c24d45 100644 --- a/src/librbd/internal.cc +++ b/src/librbd/internal.cc @@ -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); }