From: Yehuda Sadeh Date: Tue, 22 Sep 2015 22:49:27 +0000 (-0700) Subject: rgw: orphan tool shouldn't clean up head objects X-Git-Tag: v9.1.0~12^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=030f697d196df9963ecf4f05f727da4798c583dc;p=ceph.git rgw: orphan tool shouldn't clean up head objects 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 --- diff --git a/src/rgw/rgw_orphan.cc b/src/rgw/rgw_orphan.cc index 2818d79fc38e..0bf34d8d9412 100644 --- a/src/rgw/rgw_orphan.cc +++ b/src/rgw/rgw_orphan.cc @@ -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 _, + * 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);