librados: fix calc_snap_set_diff interval calculation

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: 
Signed-off-by: Sage Weil <sage@inktank.com>
Reviewed-by: Samuel Just <sam.just@inktank.com>
This commit is contained in:
Sage Weil 2013-04-24 13:48:40 -07:00
parent 5668e5b5a4
commit 3604c98232

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