]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: orphan tool shouldn't clean up head objects 6351/head
authorYehuda Sadeh <yehuda@redhat.com>
Tue, 22 Sep 2015 22:49:27 +0000 (15:49 -0700)
committerAbhishek Lekshmanan <abhishek.lekshmanan@ril.com>
Thu, 22 Oct 2015 13:41:53 +0000 (19:11 +0530)
Fixes: #12958
Head objects are mutable, so removing them can race with object removal
and a later recreation, so we might end up cleaning them up when we don't
need to.

Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
(cherry picked from commit 030f697d196df9963ecf4f05f727da4798c583dc)

src/rgw/rgw_orphan.cc

index 2818d79fc38e4cb0c2587ca8775e1a185db73be5..0bf34d8d94127fc8402a7756efbab85867ae3d4e 100644 (file)
@@ -277,9 +277,28 @@ int RGWOrphanSearch::build_all_oids_index()
     string oid = i->get_oid();
     string locator = i->get_locator();
 
-    string name = oid;
-    if (locator.size())
-      name += " (@" + locator + ")";  
+    ssize_t pos = oid.find('_');
+    if (pos < 0) {
+      cout << "unidentified oid: " << oid << ", skipping" << std::endl;
+      /* what is this object, oids should be in the format of <bucket marker>_<obj>,
+       * skip this entry
+       */
+      continue;
+    }
+    string stripped_oid = oid.substr(pos + 1);
+    string name, instance, ns;
+    if (!rgw_obj::parse_raw_oid(stripped_oid, &name, &instance, &ns)) {
+      cout << "cannot parse oid: " << oid << ", skipping" << std::endl;
+      continue;
+    }
+
+    if (ns.empty()) {
+      /* skipping head objects, we don't want to remove these as they are mutable and
+       * cleaning them up is racy (can race with object removal and a later recreation)
+       */
+      cout << "skipping head object: oid=" << oid << std::endl;
+      continue;
+    }
 
     string oid_fp = obj_fingerprint(oid);