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>
// 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 << "]"