]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: check that the current snapid for a snap name matches
authorJosh Durgin <josh.durgin@inktank.com>
Fri, 8 Jun 2012 15:04:12 +0000 (08:04 -0700)
committerJosh Durgin <josh.durgin@inktank.com>
Fri, 8 Jun 2012 23:38:22 +0000 (16:38 -0700)
Checking that it exists doesn't prevent you from having the snapshot
change out from under you in the following situation:

You have the image open at snapshot "foo".
Someone removes snapshot "foo", writes some data to the image, and
creates a new snapshot called "foo".

This second snapshot will have a different id, but nothing prevents it
from having the name of a previously deleted snapshot.

Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
src/librbd.cc

index d3a78fb569a600c29d2547a50ff7dfa8bb5e9e91..737d0161ff001fdbfd29fa92c21e1d17fc3748df 100644 (file)
@@ -1388,7 +1388,7 @@ int ictx_refresh(ImageCtx *ictx)
   ictx->snapc = new_snapc;
 
   if (ictx->snapid != CEPH_NOSNAP &&
-      ictx->get_snapid(ictx->snapname) == CEPH_NOSNAP) {
+      ictx->get_snapid(ictx->snapname) != ictx->snapid) {
     lderr(cct) << "tried to read from a snapshot that no longer exists: "
               << ictx->snapname << dendl;
     ictx->snap_exists = false;