diff --git a/src/rgw/rgw_bucket.cc b/src/rgw/rgw_bucket.cc index b2ee30078c3..3d1d106438b 100644 --- a/src/rgw/rgw_bucket.cc +++ b/src/rgw/rgw_bucket.cc @@ -183,7 +183,8 @@ int rgw_link_bucket(RGWRados* const store, const rgw_user& user_id, rgw_bucket& bucket, ceph::real_time creation_time, - bool update_entrypoint) + bool update_entrypoint, + bool update_stats) { int ret; string& tenant_name = bucket.tenant; @@ -216,7 +217,7 @@ int rgw_link_bucket(RGWRados* const store, rgw_get_buckets_obj(user_id, buckets_obj_id); rgw_raw_obj obj(store->get_zone_params().user_uid_pool, buckets_obj_id); - ret = store->cls_user_add_bucket(obj, new_bucket); + ret = store->cls_user_add_bucket(obj, new_bucket, update_stats); if (ret < 0) { ldout(store->ctx(), 0) << "ERROR: error adding bucket to directory: " << cpp_strerror(-ret) << dendl; @@ -890,7 +891,7 @@ int RGWBucket::link(RGWBucketAdminOpState& op_state, std::string *err_msg) } r = rgw_link_bucket(store, user_info.user_id, bucket_info.bucket, - ceph::real_time()); + ceph::real_time(),true, op_state.will_update_stats()); if (r < 0) { return r; } diff --git a/src/rgw/rgw_bucket.h b/src/rgw/rgw_bucket.h index ccc3ee10c59..b654b241129 100644 --- a/src/rgw/rgw_bucket.h +++ b/src/rgw/rgw_bucket.h @@ -180,7 +180,8 @@ extern int rgw_link_bucket(RGWRados* store, const rgw_user& user_id, rgw_bucket& bucket, ceph::real_time creation_time, - bool update_entrypoint = true); + bool update_entrypoint = true, + bool update_stats = true); extern int rgw_unlink_bucket(RGWRados *store, const rgw_user& user_id, const string& tenant_name, const string& bucket_name, bool update_entrypoint = true); @@ -208,6 +209,7 @@ struct RGWBucketAdminOpState { bool delete_child_objects; bool bucket_stored; int max_aio = 0; + bool update_stats; rgw_bucket bucket; @@ -217,6 +219,7 @@ struct RGWBucketAdminOpState { void set_delete_children(bool value) { delete_child_objects = value; } void set_max_aio(int value) { max_aio = value; } + void set_update_stats(bool value) { update_stats = value; } void set_user_id(const rgw_user& user_id) { if (!user_id.empty()) @@ -253,10 +256,11 @@ struct RGWBucketAdminOpState { bool is_system_op() { return uid.empty(); } bool has_bucket_stored() { return bucket_stored; } int get_max_aio() { return max_aio; } + bool will_update_stats() { return update_stats;} RGWBucketAdminOpState() : list_buckets(false), stat_buckets(false), check_objects(false), fix_index(false), delete_child_objects(false), - bucket_stored(false) {} + bucket_stored(false), update_stats(true) {} }; /* diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index 9054f11182a..3b21c8afb58 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -13319,12 +13319,13 @@ int RGWRados::cls_user_complete_stats_sync(rgw_raw_obj& obj) return 0; } -int RGWRados::cls_user_add_bucket(rgw_raw_obj& obj, const cls_user_bucket_entry& entry) +int RGWRados::cls_user_add_bucket(rgw_raw_obj& obj, const cls_user_bucket_entry& entry, + bool update_stats) { list l; l.push_back(entry); - return cls_user_update_buckets(obj, l, true); + return cls_user_update_buckets(obj, l, update_stats); } int RGWRados::cls_user_remove_bucket(rgw_raw_obj& obj, const cls_user_bucket& bucket) diff --git a/src/rgw/rgw_rados.h b/src/rgw/rgw_rados.h index 97a62c65dd3..74d5af32e08 100644 --- a/src/rgw/rgw_rados.h +++ b/src/rgw/rgw_rados.h @@ -3565,7 +3565,7 @@ public: list& entries, string *out_marker, bool *truncated); - int cls_user_add_bucket(rgw_raw_obj& obj, const cls_user_bucket_entry& entry); + int cls_user_add_bucket(rgw_raw_obj& obj, const cls_user_bucket_entry& entry, bool update_stats); int cls_user_update_buckets(rgw_raw_obj& obj, list& entries, bool add); int cls_user_complete_stats_sync(rgw_raw_obj& obj); int complete_sync_user_stats(const rgw_user& user_id); diff --git a/src/rgw/rgw_reshard.cc b/src/rgw/rgw_reshard.cc index 71726634a5a..5788662dffb 100644 --- a/src/rgw/rgw_reshard.cc +++ b/src/rgw/rgw_reshard.cc @@ -474,11 +474,12 @@ int RGWBucketReshard::do_reshard( bucket_op.set_bucket_name(new_bucket_info.bucket.name); bucket_op.set_bucket_id(new_bucket_info.bucket.bucket_id); bucket_op.set_user_id(new_bucket_info.owner); + bucket_op.set_update_stats(false); string err; - int r = RGWBucketAdminOp::link(store, bucket_op, &err); - if (r < 0) { - lderr(store->ctx()) << "failed to link new bucket instance (bucket_id=" << new_bucket_info.bucket.bucket_id << ": " << err << "; " << cpp_strerror(-r) << ")" << dendl; - return -r; + ret = RGWBucketAdminOp::link(store, bucket_op, &err); + if (ret < 0) { + lderr(store->ctx()) << "failed to link new bucket instance (bucket_id=" << new_bucket_info.bucket.bucket_id << ": " << err << "; " << cpp_strerror(-ret) << ")" << dendl; + return -ret; } ret = bucket_info_updater.complete();