]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librados: fix calc_snap_set_diff interval calculation
authorSage Weil <sage@inktank.com>
Wed, 24 Apr 2013 20:48:40 +0000 (13:48 -0700)
committerSage Weil <sage@inktank.com>
Wed, 24 Apr 2013 21:34:40 +0000 (14:34 -0700)
When calculating the [a,b] interval over which a given clone is valid, do
not assume that b == the clone id; that is *not* true when the original
end snap has been deleted/trimmed.

While we are here, make the code a bit cleaner to read.

Fixes: #4785
Signed-off-by: Sage Weil <sage@inktank.com>
Reviewed-by: Samuel Just <sam.just@inktank.com>
src/librados/snap_set_diff.cc

index 60cfec6f8103cc4cf311ae51f85dee9fe24d4e4e..2cf7c9387456966ce7657a779598f65987817eda 100644 (file)
@@ -32,13 +32,14 @@ void calc_snap_set_diff(CephContext *cct, const librados::snap_set_t& snap_set,
     // make an interval, and hide the fact that the HEAD doesn't
     // include itself in the snaps list
     librados::snap_t a, b;
-    b = r->cloneid;
-    if (b == librados::SNAP_HEAD) {
+    if (r->cloneid == librados::SNAP_HEAD) {
       // head is valid starting from right after the last seen seq
       a = snap_set.seq + 1;
+      b = librados::SNAP_HEAD;
     } else {
-      assert(b == r->snaps[r->snaps.size()-1]);
       a = r->snaps[0];
+      // note: b might be < r->cloneid if a snap has been trimmed.
+      b = r->snaps[r->snaps.size()-1];
     }
     ldout(cct, 20) << " clone " << r->cloneid << " snaps " << r->snaps
                   << " -> [" << a << "," << b << "]"