]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: mark_obj_as_lost: don't assume we have obj
authorColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Mon, 29 Nov 2010 19:33:39 +0000 (11:33 -0800)
committerColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Tue, 30 Nov 2010 23:48:48 +0000 (15:48 -0800)
In PG::mark_obj_as_lost, we have to mark a missing object as lost. We
should not assume that we have an old version of the missing object in
the ObjectStore. If the object doesn't exist in the object store, we
have to create it so that recovery can function correctly.

Signed-off-by: Colin McCabe <colinm@hq.newdream.net>
src/osd/PG.cc

index 543d9176b7b807a685ce0d476bacbab015f847a4..2be173c23fca9edaa637bb07d1edcd0dbee64bfc 100644 (file)
@@ -1013,14 +1013,28 @@ 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_t(info.pgid), lost_soid, OI_ATTR, b1);
-  assert(r >= 0);
-  object_info_t oi(b1);
-  oi.lost = true;
-  oi.version.version++;
+  int r = osd->store->getattr(coll, lost_soid, OI_ATTR, b1);
+  auto_ptr < object_info_t > oi;
+  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;
+  }
+  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
+    t.touch(coll, lost_soid);
+  }
+
+  oi->version.version++;
   bufferlist b2;
-  oi.encode(b2);
-  t.setattr(coll_t(info.pgid), lost_soid, OI_ATTR, b2);
+  oi->encode(b2);
+  t.setattr(coll, lost_soid, OI_ATTR, b2);
 }
 
 class CompareSobjectPtrs {