osd: unconditionally encode snaps buffer

Previously we would only encode the updated snaps vector for CLONE ops.
This doesn't work for MODIFY ops generated by the snap trimmer, which
may also adjust the clone collections.  It is also possible that other
operations may need to populate this field in the future (e.g.,
LOST_REVERT may, although it currently does not).

Fixes: #4071, and possibly #4051.

Signed-off-by: Sage Weil <sage@inktank.com>
Reviewed-by: Samuel Just <sam.just@inktank.com>
This commit is contained in:
Sage Weil 2013-02-10 16:59:48 -08:00
parent 8b05492ca5
commit 54b6dd924f

View File

@ -1696,7 +1696,7 @@ void pg_query_t::generate_test_instances(list<pg_query_t*>& o)
void pg_log_entry_t::encode(bufferlist &bl) const
{
ENCODE_START(6, 4, bl);
ENCODE_START(7, 4, bl);
::encode(op, bl);
::encode(soid, bl);
::encode(version, bl);
@ -1715,17 +1715,15 @@ void pg_log_entry_t::encode(bufferlist &bl) const
::encode(reqid, bl);
::encode(mtime, bl);
if (op == CLONE)
::encode(snaps, bl);
if (op == LOST_REVERT)
::encode(prior_version, bl);
::encode(snaps, bl);
ENCODE_FINISH(bl);
}
void pg_log_entry_t::decode(bufferlist::iterator &bl)
{
DECODE_START_LEGACY_COMPAT_LEN(5, 4, 4, bl);
DECODE_START_LEGACY_COMPAT_LEN(7, 4, 4, bl);
::decode(op, bl);
if (struct_v < 2) {
sobject_t old_soid;
@ -1747,8 +1745,6 @@ void pg_log_entry_t::decode(bufferlist::iterator &bl)
::decode(reqid, bl);
::decode(mtime, bl);
if (op == CLONE)
::decode(snaps, bl);
if (struct_v < 5)
invalid_pool = true;
@ -1759,6 +1755,10 @@ void pg_log_entry_t::decode(bufferlist::iterator &bl)
reverting_to = prior_version;
}
}
if (struct_v >= 7 || // for v >= 7, this is for all ops.
op == CLONE) { // for v < 7, it's only present for CLONE.
::decode(snaps, bl);
}
DECODE_FINISH(bl);
}