From: Abhishek Lekshmanan Date: Wed, 13 Feb 2019 14:32:17 +0000 (+0100) Subject: rgw: orphans find: don't process stale bucket instances X-Git-Tag: v12.2.13~254^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=2475a30cf615d87dde87295248aefb11a154f4b3;p=ceph.git rgw: orphans find: don't process stale bucket instances As a large bucket might have resharded multiple times, check the cur bucket info and ensure that no reshard is in progress before we attempt to log bucket index entries. On a large sized bucket, since a bucket would have undergone reshard multiple times, this avoids wasteful processing of stale bucket instance entries Signed-off-by: Abhishek Lekshmanan (cherry picked from commit 5436ff7fa99061a489f089677c03f63c76bb954b) Conflicts: src/rgw/rgw_orphan.cc sys_objctx dropped as obj_ctx changes are a part of Nautilus. Also similarly with the includes, only `rgw_bucket.h` is included --- diff --git a/src/rgw/rgw_orphan.cc b/src/rgw/rgw_orphan.cc index 1e96d41189b9..942cf5567d41 100644 --- a/src/rgw/rgw_orphan.cc +++ b/src/rgw/rgw_orphan.cc @@ -11,6 +11,7 @@ using namespace std; #include "rgw_rados.h" #include "rgw_orphan.h" +#include "rgw_bucket.h" #define dout_subsys ceph_subsys_rgw @@ -482,10 +483,46 @@ done: int RGWOrphanSearch::build_linked_oids_for_bucket(const string& bucket_instance_id, map >& oids) { - ldout(store->ctx(), 10) << "building linked oids for bucket instance: " << bucket_instance_id << dendl; - RGWBucketInfo bucket_info; RGWObjectCtx obj_ctx(store); - int ret = store->get_bucket_instance_info(obj_ctx, bucket_instance_id, bucket_info, NULL, NULL); + + rgw_bucket orphan_bucket; + int shard_id; + int ret = rgw_bucket_parse_bucket_key(store->ctx(), bucket_instance_id, + &orphan_bucket, &shard_id); + if (ret < 0) { + ldout(store->ctx(),0) << __func__ << " failed to parse bucket instance: " + << bucket_instance_id << " skipping" << dendl; + return ret; + } + + RGWBucketInfo cur_bucket_info; + ret = store->get_bucket_info(obj_ctx, orphan_bucket.tenant, + orphan_bucket.name, cur_bucket_info, nullptr); + if (ret < 0) { + if (ret == -ENOENT) { + /* probably raced with bucket removal */ + return 0; + } + lderr(store->ctx()) << __func__ << ": ERROR: RGWRados::get_bucket_instance_info() returned ret=" << ret << dendl; + return ret; + } + + if (cur_bucket_info.bucket.bucket_id != orphan_bucket.bucket_id) { + ldout(store->ctx(), 0) << __func__ << ": Skipping stale bucket instance: " + << orphan_bucket.name << ": " + << orphan_bucket.bucket_id << dendl; + return 0; + } + + if (cur_bucket_info.reshard_status == CLS_RGW_RESHARD_IN_PROGRESS) { + ldout(store->ctx(), 0) << __func__ << ": reshard in progress. Skipping " + << orphan_bucket.name << ": " + << orphan_bucket.bucket_id << dendl; + return 0; + } + + RGWBucketInfo bucket_info; + ret = store->get_bucket_instance_info(obj_ctx, bucket_instance_id, bucket_info, nullptr, nullptr); if (ret < 0) { if (ret == -ENOENT) { /* probably raced with bucket removal */ @@ -495,6 +532,7 @@ int RGWOrphanSearch::build_linked_oids_for_bucket(const string& bucket_instance_ return ret; } + ldout(store->ctx(), 10) << "building linked oids for bucket instance: " << bucket_instance_id << dendl; RGWRados::Bucket target(store, bucket_info); RGWRados::Bucket::List list_op(&target);