From 9e44fca13bf1ba39dbcad29111b29f46c49d59f7 Mon Sep 17 00:00:00 2001 From: Samuel Just Date: Fri, 11 Jan 2013 16:43:14 -0800 Subject: [PATCH] ReplicatedPG: correctly handle new snap collections on replica Backport: bobtail Signed-off-by: Samuel Just Reviewed-by: Sage Weil --- src/osd/PG.cc | 16 +++++++++++----- src/osd/ReplicatedPG.cc | 2 +- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/osd/PG.cc b/src/osd/PG.cc index 0d17211a5e1ba..7b2a0ec5a1004 100644 --- a/src/osd/PG.cc +++ b/src/osd/PG.cc @@ -2921,13 +2921,19 @@ void PG::update_snap_collections(vector &log_entries, // If past backfill line, snap_collections will be updated during push if (i->soid > info.last_backfill) continue; - if (i->is_clone()) { + if (i->snaps.length() > 0) { vector snaps; bufferlist::iterator p = i->snaps.begin(); - ::decode(snaps, p); - make_snap_collection(t, snaps[0]); - if (snaps.size() > 1) - make_snap_collection(t, *(snaps.rbegin())); + try { + ::decode(snaps, p); + } catch (...) { + snaps.clear(); + } + if (snaps.size()) { + make_snap_collection(t, snaps[0]); + if (snaps.size() > 1) + make_snap_collection(t, *(snaps.rbegin())); + } } } } diff --git a/src/osd/ReplicatedPG.cc b/src/osd/ReplicatedPG.cc index 43361e503c1a0..d267a3c2c2754 100644 --- a/src/osd/ReplicatedPG.cc +++ b/src/osd/ReplicatedPG.cc @@ -1437,7 +1437,7 @@ ReplicatedPG::RepGather *ReplicatedPG::trim_object(const hobject_t &coid, ctx->log.push_back(pg_log_entry_t(pg_log_entry_t::MODIFY, coid, coi.version, coi.prior_version, osd_reqid_t(), ctx->mtime)); - ::encode(coi, ctx->log.back().snaps); + ::encode(coi.snaps, ctx->log.back().snaps); ctx->at_version.version++; } -- 2.39.5