From ebcc9395b084f3c8f65914fe0d03256499495e76 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Mon, 6 Dec 2010 14:01:28 -0800 Subject: [PATCH] osd: drop not-quite-copy constructor for object_info_t Making a copy-like constructor that doesn't actaully copy is confusing and error prone. In this case, we initialized a clone's object_info with the head's snapid, causing problems with what info was encoded and crashing later in the snap_trimmer. Here the one caller already called copy_user_bits(); let's move the lost copy there. This backs out one of the changes in 0cc8d34e. Signed-off-by: Sage Weil --- src/osd/ReplicatedPG.cc | 4 ++-- src/osd/osd_types.h | 6 +----- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/osd/ReplicatedPG.cc b/src/osd/ReplicatedPG.cc index 3878f64cf6701..7723dbe39cca8 100644 --- a/src/osd/ReplicatedPG.cc +++ b/src/osd/ReplicatedPG.cc @@ -558,12 +558,12 @@ bool ReplicatedPG::snap_trimmer() bufferlist bl; osd->store->getattr(coll_t(info.pgid), coid, OI_ATTR, bl); object_info_t coi(bl); + vector& snaps = coi.snaps; // get snap set context SnapSetContext *ssc = get_snapset_context(coid.oid, false); assert(ssc); SnapSet& snapset = ssc->snapset; - vector& snaps = coi.snaps; dout(10) << coid << " snaps " << snaps << " old snapset " << snapset << dendl; assert(snapset.seq); @@ -1703,7 +1703,7 @@ void ReplicatedPG::make_writeable(OpContext *ctx) snaps[i] = snapc.snaps[i]; // prepare clone - object_info_t static_snap_oi(oi); + object_info_t static_snap_oi(coid, oi.oloc); object_info_t *snap_oi; if (is_primary()) { ctx->clone_obc = new ObjectContext(static_snap_oi, true, NULL); diff --git a/src/osd/osd_types.h b/src/osd/osd_types.h index f8302e2d2cace..05dd887fadfd4 100644 --- a/src/osd/osd_types.h +++ b/src/osd/osd_types.h @@ -1308,6 +1308,7 @@ struct object_info_t { last_reqid = other.last_reqid; truncate_seq = other.truncate_seq; truncate_size = other.truncate_size; + lost = other.lost; } void encode(bufferlist& bl) const { @@ -1355,11 +1356,6 @@ struct object_info_t { decode(p); } - object_info_t(const object_info_t &rhs) - : soid(rhs.soid), oloc(rhs.oloc), size(rhs.size), - lost(rhs.lost), truncate_seq(rhs.truncate_seq), - truncate_size(rhs.truncate_size) {} - object_info_t(const sobject_t& s, const object_locator_t& o) : soid(s), oloc(o), size(0), lost(false), truncate_seq(0), truncate_size(0) {} -- 2.39.5