From 0a4956e20a2a7fdd18c13402eccdd2708daa14fa Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Wed, 28 Jan 2015 16:10:34 -0800 Subject: [PATCH] rgw: get rid of replicalog index_by_instance param We convert old entries anyway, just complicates everything. Only use that was kept is the one needed for the conversion function. Signed-off-by: Yehuda Sadeh --- src/rgw/rgw_admin.cc | 10 ++---- src/rgw/rgw_replica_log.cc | 27 ++++++++-------- src/rgw/rgw_replica_log.h | 7 ++-- src/rgw/rgw_rest_replica_log.cc | 57 +++------------------------------ 4 files changed, 24 insertions(+), 77 deletions(-) diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc index a20e170447589..ad4122cd5570f 100644 --- a/src/rgw/rgw_admin.cc +++ b/src/rgw/rgw_admin.cc @@ -897,8 +897,6 @@ int main(int argc, char **argv) int sync_stats = false; - int replicalog_index_by_instance = true; - uint64_t min_rewrite_size = 4 * 1024 * 1024; uint64_t max_rewrite_size = ULLONG_MAX; uint64_t min_rewrite_stripe_size = 0; @@ -1048,8 +1046,6 @@ int main(int argc, char **argv) // do nothing } else if (ceph_argparse_binary_flag(args, i, &include_all, NULL, "--include-all", (char*)NULL)) { // do nothing - } else if (ceph_argparse_binary_flag(args, i, &replicalog_index_by_instance, NULL, "--replicalog-index-by-instance", (char*)NULL)) { - // do nothing } else if (ceph_argparse_witharg(args, i, &val, "--caps", (char*)NULL)) { caps = val; } else if (ceph_argparse_witharg(args, i, &val, "-i", "--infile", (char*)NULL)) { @@ -2581,7 +2577,7 @@ next: } RGWReplicaBucketLogger logger(store); - ret = logger.get_bounds(bucket, shard_id, bounds, replicalog_index_by_instance); + ret = logger.get_bounds(bucket, shard_id, bounds); if (ret < 0) return -ret; } else { // shouldn't get here @@ -2632,7 +2628,7 @@ next: } RGWReplicaBucketLogger logger(store); - ret = logger.delete_bound(bucket, shard_id, daemon_id, replicalog_index_by_instance, false); + ret = logger.delete_bound(bucket, shard_id, daemon_id, false); if (ret < 0) return -ret; } @@ -2694,7 +2690,7 @@ next: } RGWReplicaBucketLogger logger(store); - ret = logger.update_bound(bucket, shard_id, daemon_id, marker, time, &entries, replicalog_index_by_instance); + ret = logger.update_bound(bucket, shard_id, daemon_id, marker, time, &entries); if (ret < 0) { cerr << "ERROR: failed to update bounds: " << cpp_strerror(-ret) << std::endl; return -ret; diff --git a/src/rgw/rgw_replica_log.cc b/src/rgw/rgw_replica_log.cc index 747cce68cd2f0..977b2ef96c637 100644 --- a/src/rgw/rgw_replica_log.cc +++ b/src/rgw/rgw_replica_log.cc @@ -191,8 +191,7 @@ string RGWReplicaBucketLogger::obj_name(const rgw_bucket& bucket, int shard_id, int RGWReplicaBucketLogger::update_bound(const rgw_bucket& bucket, int shard_id, const string& daemon_id, const string& marker, const utime_t& time, - const list *entries, - bool index_by_instance) + const list *entries) { if (shard_id >= 0 || !BucketIndexShardsManager::is_shards_marker(marker)) { @@ -216,11 +215,11 @@ int RGWReplicaBucketLogger::update_bound(const rgw_bucket& bucket, int shard_id, map::iterator iter; for (iter = vals.begin(); iter != vals.end(); ++iter) { - bool need_to_exist = index_by_instance && no_shards; /* - * don't need to exist if not indexing by instance, - * also, we only care about non-sharded + bool need_to_exist = no_shards; /* + * we only care about non-sharded * buckets, as these are the ones that - * might not be indexed by instance id + * might not be indexed by instance id, and + * might need conversion */ ldout(cct, 20) << "updating bound: bucket=" << bucket << " shard=" << iter->first << " marker=" << marker << dendl; int r = RGWReplicaLogger::update_bound(obj_name(bucket, iter->first, true), pool, @@ -245,10 +244,10 @@ int RGWReplicaBucketLogger::update_bound(const rgw_bucket& bucket, int shard_id, return ret; } -int RGWReplicaBucketLogger::delete_bound(const rgw_bucket& bucket, int shard_id, const string& daemon_id, bool index_by_instance, bool purge_all) +int RGWReplicaBucketLogger::delete_bound(const rgw_bucket& bucket, int shard_id, const string& daemon_id, bool purge_all) { - bool need_to_exist = index_by_instance; /* don't need to exist if not indexing by instance */ - int r = RGWReplicaLogger::delete_bound(obj_name(bucket, shard_id, index_by_instance), pool, daemon_id, purge_all, need_to_exist); + bool need_to_exist = (shard_id < 0); /* don't need to exist if sharded */ + int r = RGWReplicaLogger::delete_bound(obj_name(bucket, shard_id, true), pool, daemon_id, purge_all, need_to_exist); if (r != -ENOENT) { return r; } @@ -261,12 +260,12 @@ int RGWReplicaBucketLogger::delete_bound(const rgw_bucket& bucket, int shard_id, if (r < 0 && r != -ENOENT) { return r; } - return RGWReplicaLogger::delete_bound(obj_name(bucket, shard_id, index_by_instance), pool, daemon_id, purge_all, false); + return RGWReplicaLogger::delete_bound(obj_name(bucket, shard_id, true), pool, daemon_id, purge_all, false); } -int RGWReplicaBucketLogger::get_bounds(const rgw_bucket& bucket, int shard_id, RGWReplicaBounds& bounds, bool index_by_instance) { - int r = RGWReplicaLogger::get_bounds(obj_name(bucket, shard_id, index_by_instance), pool, bounds); - if (r != -ENOENT || !index_by_instance) { +int RGWReplicaBucketLogger::get_bounds(const rgw_bucket& bucket, int shard_id, RGWReplicaBounds& bounds) { + int r = RGWReplicaLogger::get_bounds(obj_name(bucket, shard_id, true), pool, bounds); + if (r != -ENOENT || shard_id >= 0) { return r; } @@ -275,7 +274,7 @@ int RGWReplicaBucketLogger::get_bounds(const rgw_bucket& bucket, int shard_id, R return r; } - return 0; + return RGWReplicaLogger::get_bounds(obj_name(bucket, shard_id, true), pool, bounds); } int RGWReplicaBucketLogger::convert_old_bounds(const rgw_bucket& bucket, int shard_id, RGWReplicaBounds& bounds) { diff --git a/src/rgw/rgw_replica_log.h b/src/rgw/rgw_replica_log.h index b00080037f2ae..9ea3982ee5593 100644 --- a/src/rgw/rgw_replica_log.h +++ b/src/rgw/rgw_replica_log.h @@ -108,10 +108,9 @@ public: RGWReplicaBucketLogger(RGWRados *_store); int update_bound(const rgw_bucket& bucket, int shard_id, const string& daemon_id, const string& marker, const utime_t& time, - const list *entries, - bool index_by_instance); - int delete_bound(const rgw_bucket& bucket, int shard_id, const string& daemon_id, bool index_by_instance, bool purge_all); - int get_bounds(const rgw_bucket& bucket, int shard_id, RGWReplicaBounds& bounds, bool index_by_instance); + const list *entries); + int delete_bound(const rgw_bucket& bucket, int shard_id, const string& daemon_id, bool purge_all); + int get_bounds(const rgw_bucket& bucket, int shard_id, RGWReplicaBounds& bounds); int convert_old_bounds(const rgw_bucket& bucket, int shard_id, RGWReplicaBounds& bounds); }; diff --git a/src/rgw/rgw_rest_replica_log.cc b/src/rgw/rgw_rest_replica_log.cc index 543974a455c49..aef3311c2af83 100644 --- a/src/rgw/rgw_rest_replica_log.cc +++ b/src/rgw/rgw_rest_replica_log.cc @@ -162,46 +162,6 @@ static int bucket_instance_to_bucket(RGWRados *store, const string& bucket_insta return 0; } -static int get_bucket_for_bounds(RGWRados *store, XMLArgs& args, const string& bucket_instance, rgw_bucket& bucket, bool *index_by_instance) -{ - args.get_bool("index-by-instance", index_by_instance, true); - - if (*index_by_instance) { - int r; - if ((r = bucket_instance_to_bucket(store, bucket_instance, bucket)) < 0) { - return r; - } - } else { - string bucket_name = args.get("bucket"); - - if (bucket_name.empty()) { - bucket_name = bucket_instance; - - ssize_t pos = bucket_name.find(':'); - if (pos >= 0) { - bucket_name = bucket_name.substr(0, pos); - } - } - - if (bucket_name.empty()) { - dout(5) << " Error - invalid parameter list" << dendl; - return -EINVAL; - } - RGWBucketInfo bucket_info; - - int r = store->get_bucket_info(NULL, bucket_name, bucket_info, NULL, NULL); - if (r < 0) { - dout(5) << "could not get bucket info for bucket=" << bucket_name << ": " << cpp_strerror(r) << dendl; - return r; - } - - bucket = bucket_info.bucket; - } - - return 0; - -} - void RGWOp_BILog_SetBounds::execute() { string bucket_instance = s->info.args.get("bucket-instance"), marker = s->info.args.get("marker"), @@ -231,9 +191,8 @@ void RGWOp_BILog_SetBounds::execute() { } rgw_bucket bucket; - bool index_by_instance; - if ((http_ret = get_bucket_for_bounds(store, s->info.args, bucket_instance, bucket, &index_by_instance)) < 0) { + if ((http_ret = bucket_instance_to_bucket(store, bucket_instance, bucket)) < 0) { return; } @@ -246,13 +205,12 @@ void RGWOp_BILog_SetBounds::execute() { return; } - http_ret = rl.update_bound(bucket, shard_id, daemon_id, marker, ut, &markers, index_by_instance); + http_ret = rl.update_bound(bucket, shard_id, daemon_id, marker, ut, &markers); } void RGWOp_BILog_GetBounds::execute() { string bucket_instance = s->info.args.get("bucket-instance"); rgw_bucket bucket; - bool index_by_instance; int shard_id; @@ -262,15 +220,11 @@ void RGWOp_BILog_GetBounds::execute() { return; } - if ((http_ret = get_bucket_for_bounds(store, s->info.args, bucket_instance, bucket, &index_by_instance)) < 0) { - return; - } - if ((http_ret = bucket_instance_to_bucket(store, bucket_instance, bucket)) < 0) return; RGWReplicaBucketLogger rl(store); - http_ret = rl.get_bounds(bucket, shard_id, bounds, index_by_instance); + http_ret = rl.get_bounds(bucket, shard_id, bounds); } void RGWOp_BILog_GetBounds::send_response() { @@ -306,14 +260,13 @@ void RGWOp_BILog_DeleteBounds::execute() { } rgw_bucket bucket; - bool index_by_instance; - if ((http_ret = get_bucket_for_bounds(store, s->info.args, bucket_instance, bucket, &index_by_instance)) < 0) { + if ((http_ret = bucket_instance_to_bucket(store, bucket_instance, bucket)) < 0) { return; } RGWReplicaBucketLogger rl(store); - http_ret = rl.delete_bound(bucket, shard_id, daemon_id, index_by_instance, purge_all); + http_ret = rl.delete_bound(bucket, shard_id, daemon_id, purge_all); } RGWOp *RGWHandler_ReplicaLog::op_get() { -- 2.39.5