Skip to content

Commit

Permalink
Merge pull request #19253 from oritwas/wip-rgw-22124
Browse files Browse the repository at this point in the history
rgw: reshard should not update stats when linking new bucket instance

Reviewed-by: Yehuda Sadeh <yehuda@redhat.com>
  • Loading branch information
yehudasa committed Dec 12, 2017
2 parents 4389b55 + fc95210 commit a01c014
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 12 deletions.
7 changes: 4 additions & 3 deletions src/rgw/rgw_bucket.cc
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down
8 changes: 6 additions & 2 deletions src/rgw/rgw_bucket.h
Expand Up @@ -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);

Expand Down Expand Up @@ -208,6 +209,7 @@ struct RGWBucketAdminOpState {
bool delete_child_objects;
bool bucket_stored;
int max_aio = 0;
bool update_stats;

rgw_bucket bucket;

Expand All @@ -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())
Expand Down Expand Up @@ -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) {}
};

/*
Expand Down
5 changes: 3 additions & 2 deletions src/rgw/rgw_rados.cc
Expand Up @@ -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<cls_user_bucket_entry> 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)
Expand Down
2 changes: 1 addition & 1 deletion src/rgw/rgw_rados.h
Expand Up @@ -3565,7 +3565,7 @@ class RGWRados
list<cls_user_bucket_entry>& 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<cls_user_bucket_entry>& entries, bool add);
int cls_user_complete_stats_sync(rgw_raw_obj& obj);
int complete_sync_user_stats(const rgw_user& user_id);
Expand Down
9 changes: 5 additions & 4 deletions src/rgw/rgw_reshard.cc
Expand Up @@ -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();
Expand Down

0 comments on commit a01c014

Please sign in to comment.