From a786252ed9c0e1ba08a88a43902f7aa1e91c10cd Mon Sep 17 00:00:00 2001 From: Zhang Shaowen Date: Tue, 10 Jan 2017 16:36:13 +0800 Subject: [PATCH] rgw: bucket index check in radosgw-admin removes valid index. Fixes: http://tracker.ceph.com/issues/18470 Signed-off-by: Zhang Shaowen --- src/rgw/rgw_bucket.cc | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/rgw/rgw_bucket.cc b/src/rgw/rgw_bucket.cc index 8b2bc5f46df1..86d333e3df61 100644 --- a/src/rgw/rgw_bucket.cc +++ b/src/rgw/rgw_bucket.cc @@ -999,6 +999,7 @@ int RGWBucket::check_bad_index_multipart(RGWBucketAdminOpState& op_state, map common_prefixes; + string ns = "multipart"; bool is_truncated; map meta_objs; map 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 result; @@ -1028,15 +1030,9 @@ int RGWBucket::check_bad_index_multipart(RGWBucketAdminOpState& op_state, vector::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. */ -- 2.47.3