From e9ccd7eb0932a3be1edd675f5bbf53afec34992a Mon Sep 17 00:00:00 2001 From: Colin Patrick McCabe Date: Tue, 30 Nov 2010 13:42:07 -0800 Subject: [PATCH] osd: mark_obj_as_lost: fix oloc init, eversion Signed-off-by: Colin McCabe --- src/include/object.h | 6 ++++++ src/osd/PG.cc | 25 +++++++++++++------------ 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/src/include/object.h b/src/include/object.h index d77eae52b41d9..0ddd5df8f470f 100644 --- a/src/include/object.h +++ b/src/include/object.h @@ -121,6 +121,12 @@ struct object_locator_t { return preferred; } + void clear() { + pool = 0; + preferred = 0; + key = ""; + } + void encode(bufferlist& bl) const { __u8 struct_v = 1; ::encode(struct_v, bl); diff --git a/src/osd/PG.cc b/src/osd/PG.cc index fa70fd0d6afbb..8972e981ce124 100644 --- a/src/osd/PG.cc +++ b/src/osd/PG.cc @@ -1010,26 +1010,27 @@ void PG::mark_obj_as_lost(ObjectStore::Transaction& t, // Tell the object store that this object is lost. bufferlist b1; int r = osd->store->getattr(coll, lost_soid, OI_ATTR, b1); - auto_ptr < object_info_t > oi; + + object_locator_t oloc; + oloc.clear(); + oloc.pool = info.pgid.pool(); + object_info_t oi(lost_soid, oloc, true); + if (r >= 0) { // Some version of this lost object exists in our filestore. - // So, we can fetch its attributes. - oi.reset(new object_info_t(b1)); - oi->lost = true; + // So, we can fetch its attributes and preserve most of them. + oi = object_info_t(b1); } else { - // We don't have any version of this object. - // So we'll have to make up our own attributes - object_locator_t oloc; - oi.reset(new object_info_t(lost_soid, oloc, true)); - - // And create the object in the filestore + // The object doesn't exist in the filestore yet. Make sure that + // we create it there. t.touch(coll, lost_soid); } - oi->version.version++; + oi.lost = true; + oi.version = info.last_update; bufferlist b2; - oi->encode(b2); + oi.encode(b2); t.setattr(coll, lost_soid, OI_ATTR, b2); } -- 2.39.5