]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: bucket index check in radosgw-admin removes valid index. 12851/head
authorZhang Shaowen <zhangshaowen@cmss.chinamobile.com>
Tue, 10 Jan 2017 08:36:13 +0000 (16:36 +0800)
committerZhang Shaowen <zhangshaowen@cmss.chinamobile.com>
Thu, 13 Apr 2017 03:13:01 +0000 (11:13 +0800)
Fixes: http://tracker.ceph.com/issues/18470
Signed-off-by: Zhang Shaowen <zhangshaowen@cmss.chinamobile.com>
src/rgw/rgw_bucket.cc

index 8b2bc5f46df164cf37b578915a2b49891091dd22..86d333e3df6135ead7f96be1d7843407de34178c 100644 (file)
@@ -999,6 +999,7 @@ int RGWBucket::check_bad_index_multipart(RGWBucketAdminOpState& op_state,
 
   map<string, bool> common_prefixes;
 
+  string ns = "multipart";
   bool is_truncated;
   map<string, bool> meta_objs;
   map<rgw_obj_index_key, string> all_objs;
@@ -1015,6 +1016,7 @@ int RGWBucket::check_bad_index_multipart(RGWBucketAdminOpState& op_state,
   RGWRados::Bucket::List list_op(&target);
 
   list_op.params.list_versions = true;
+  list_op.params.ns = ns;
 
   do {
     vector<rgw_bucket_dir_entry> result;
@@ -1028,15 +1030,9 @@ int RGWBucket::check_bad_index_multipart(RGWBucketAdminOpState& op_state,
 
     vector<rgw_bucket_dir_entry>::iterator iter;
     for (iter = result.begin(); iter != result.end(); ++iter) {
-      rgw_bucket_dir_entry& ent = *iter;
-
-      rgw_obj obj(bucket, ent.key);
-      obj.key.ns.clear();
-
-      rgw_obj_index_key key;
-      obj.key.get_index_key(&key);
-
-      string oid = key.name;
+      rgw_obj_index_key key = iter->key;
+      rgw_obj obj(bucket, key);
+      string oid = obj.get_oid();
 
       int pos = oid.find_last_of('.');
       if (pos < 0) {
@@ -1060,8 +1056,6 @@ int RGWBucket::check_bad_index_multipart(RGWBucketAdminOpState& op_state,
   for (auto aiter = all_objs.begin(); aiter != all_objs.end(); ++aiter) {
     string& name = aiter->second;
 
-    rgw_obj_index_key index_key(aiter->first);
-
     if (meta_objs.find(name) == meta_objs.end()) {
       objs_to_unlink.push_back(aiter->first);
     }
@@ -1994,7 +1988,7 @@ public:
       return ret;
 
     /*
-     * We're unlinking the bucket but we don't want to update the entrypoint here  we're removing
+     * We're unlinking the bucket but we don't want to update the entrypoint here - we're removing
      * it immediately and don't want to invalidate our cached objv_version or the bucket obj removal
      * will incorrectly fail.
      */