]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: mark_obj_as_lost: fix oloc init, eversion
authorColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Tue, 30 Nov 2010 21:42:07 +0000 (13:42 -0800)
committerColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Tue, 30 Nov 2010 23:48:48 +0000 (15:48 -0800)
Signed-off-by: Colin McCabe <colinm@hq.newdream.net>
src/include/object.h
src/osd/PG.cc

index d77eae52b41d9ea1bcbc746fd6685f66e9f96bbd..0ddd5df8f470faf5b9bcb40d0449a4a81b69335f 100644 (file)
@@ -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);
index fa70fd0d6afbb60bcdf137c0abe00a4d072a3423..8972e981ce12483f5727b60f43bed5dc3a327d28 100644 (file)
@@ -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);
 }