}
};
-static int init_bucket(string& bucket_name, RGWBucketInfo& bucket_info, rgw_bucket& bucket)
+static int init_bucket(const string& bucket_name, const string& bucket_id,
+ RGWBucketInfo& bucket_info, rgw_bucket& bucket)
{
if (!bucket_name.empty()) {
- int r = store->get_bucket_info(NULL, bucket_name, bucket_info, NULL);
+ int r;
+ if (bucket_id.empty()) {
+ r = store->get_bucket_info(NULL, bucket_name, bucket_info, NULL);
+ } else {
+ string bucket_instance_id = bucket_name + ":" + bucket_id;
+ r = store->get_bucket_instance_info(NULL, bucket_instance_id, bucket_info, NULL, NULL);
+ }
if (r < 0) {
cerr << "could not get bucket info for bucket=" << bucket_name << std::endl;
return r;
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;
// 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)) {
RGWBucketAdminOp::info(store, bucket_op, f);
} else {
RGWBucketInfo bucket_info;
- int ret = init_bucket(bucket_name, bucket_info, bucket);
+ int ret = init_bucket(bucket_name, bucket_id, bucket_info, bucket);
if (ret < 0) {
cerr << "ERROR: could not init bucket: " << cpp_strerror(-ret) << std::endl;
return -ret;
if (opt_cmd == OPT_OBJECT_RM) {
RGWBucketInfo bucket_info;
- int ret = init_bucket(bucket_name, bucket_info, bucket);
+ int ret = init_bucket(bucket_name, bucket_id, bucket_info, bucket);
if (ret < 0) {
cerr << "ERROR: could not init bucket: " << cpp_strerror(-ret) << std::endl;
return -ret;
}
RGWBucketInfo bucket_info;
- int ret = init_bucket(bucket_name, bucket_info, bucket);
+ int ret = init_bucket(bucket_name, bucket_id, bucket_info, bucket);
if (ret < 0) {
cerr << "ERROR: could not init bucket: " << cpp_strerror(-ret) << std::endl;
return -ret;
}
RGWBucketInfo bucket_info;
- int ret = init_bucket(bucket_name, bucket_info, bucket);
+ int ret = init_bucket(bucket_name, bucket_id, bucket_info, bucket);
if (ret < 0) {
cerr << "ERROR: could not init bucket: " << cpp_strerror(-ret) << std::endl;
return -ret;
if (opt_cmd == OPT_OBJECT_UNLINK) {
RGWBucketInfo bucket_info;
- int ret = init_bucket(bucket_name, bucket_info, bucket);
+ int ret = init_bucket(bucket_name, bucket_id, bucket_info, bucket);
if (ret < 0) {
cerr << "ERROR: could not init bucket: " << cpp_strerror(-ret) << std::endl;
return -ret;
if (opt_cmd == OPT_OBJECT_STAT) {
RGWBucketInfo bucket_info;
- int ret = init_bucket(bucket_name, bucket_info, bucket);
+ int ret = init_bucket(bucket_name, bucket_id, bucket_info, bucket);
if (ret < 0) {
cerr << "ERROR: could not init bucket: " << cpp_strerror(-ret) << std::endl;
return -ret;
return -EINVAL;
}
RGWBucketInfo bucket_info;
- int ret = init_bucket(bucket_name, bucket_info, bucket);
+ int ret = init_bucket(bucket_name, bucket_id, bucket_info, bucket);
if (ret < 0) {
cerr << "ERROR: could not init bucket: " << cpp_strerror(-ret) << std::endl;
return -ret;
return -EINVAL;
}
RGWBucketInfo bucket_info;
- int ret = init_bucket(bucket_name, bucket_info, bucket);
+ int ret = init_bucket(bucket_name, bucket_id, bucket_info, bucket);
if (ret < 0) {
cerr << "ERROR: could not init bucket: " << cpp_strerror(-ret) << std::endl;
return -ret;
return -EINVAL;
}
RGWBucketInfo bucket_info;
- int ret = init_bucket(bucket_name, bucket_info, bucket);
+ int ret = init_bucket(bucket_name, bucket_id, bucket_info, bucket);
if (ret < 0) {
cerr << "ERROR: could not init bucket: " << cpp_strerror(-ret) << std::endl;
return -ret;
}
RGWReplicaBucketLogger logger(store);
- ret = logger.get_bounds(bucket, shard_id, bounds);
+ ret = logger.get_bounds(bucket, shard_id, bounds, replicalog_index_by_instance);
if (ret < 0)
return -ret;
} else { // shouldn't get here
return -EINVAL;
}
RGWBucketInfo bucket_info;
- int ret = init_bucket(bucket_name, bucket_info, bucket);
+ int ret = init_bucket(bucket_name, bucket_id, bucket_info, bucket);
if (ret < 0) {
cerr << "ERROR: could not init bucket: " << cpp_strerror(-ret) << std::endl;
return -ret;
}
RGWReplicaBucketLogger logger(store);
- ret = logger.delete_bound(bucket, shard_id, daemon_id);
+ ret = logger.delete_bound(bucket, shard_id, daemon_id, replicalog_index_by_instance);
if (ret < 0)
return -ret;
}
return get_bool(s, val, exists);
}
+void XMLArgs::get_bool(const char *name, bool *val, bool def_val)
+{
+ bool exists = false;
+ if ((get_bool(name, val, &exists) < 0) ||
+ !exists) {
+ *val = def_val;
+ }
+}
+
bool verify_bucket_permission(struct req_state *s, int perm)
{
if (!s->bucket_acl)
string& get(const char *name, bool *exists = NULL);
int get_bool(const string& name, bool *val, bool *exists);
int get_bool(const char *name, bool *val, bool *exists);
+ void get_bool(const char *name, bool *val, bool def_val);
/** see if a parameter is contained in this XMLArgs */
bool exists(const char *name) {
prefix.append(".");
}
-string RGWReplicaBucketLogger::obj_name(const rgw_bucket& bucket, int shard_id)
+string RGWReplicaBucketLogger::obj_name(const rgw_bucket& bucket, int shard_id, bool index_by_instance)
{
- string s = prefix + bucket.name;
+ string s;
+
+ if (index_by_instance) {
+ s = prefix + bucket.name + ":" + bucket.bucket_id;
+ } else {
+ s = prefix + bucket.name;
+ }
if (shard_id >= 0) {
char buf[16];
{
if (shard_id >= 0 ||
!BucketIndexShardsManager::is_shards_marker(marker)) {
- return RGWReplicaLogger::update_bound(obj_name(bucket, shard_id), pool,
+ return RGWReplicaLogger::update_bound(obj_name(bucket, shard_id, true), pool,
daemon_id, marker, time, entries);
}
map<int, string>::iterator iter;
for (iter = vals.begin(); iter != vals.end(); ++iter) {
ldout(cct, 20) << "updating bound: bucket=" << bucket << " shard=" << iter->first << " marker=" << marker << dendl;
- int r = RGWReplicaLogger::update_bound(obj_name(bucket, iter->first), pool,
+ int r = RGWReplicaLogger::update_bound(obj_name(bucket, iter->first, true), pool,
daemon_id, iter->second, time, entries);
if (r < 0) {
ldout(cct, 0) << "failed to update bound: bucket=" << bucket << " shard=" << iter->first << " marker=" << marker << dendl;
string pool;
string prefix;
- string obj_name(const rgw_bucket& bucket, int shard_id);
+ string obj_name(const rgw_bucket& bucket, int shard_id, bool index_by_instance);
+
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<RGWReplicaItemMarker> *entries);
- int delete_bound(const rgw_bucket& bucket, int shard_id, const string& daemon_id) {
- return RGWReplicaLogger::delete_bound(obj_name(bucket, shard_id), pool,
+ int delete_bound(const rgw_bucket& bucket, int shard_id, const string& daemon_id, bool index_by_instance) {
+ return RGWReplicaLogger::delete_bound(obj_name(bucket, shard_id, index_by_instance), pool,
daemon_id);
}
- int get_bounds(const rgw_bucket& bucket, int shard_id, RGWReplicaBounds& bounds) {
- return RGWReplicaLogger::get_bounds(obj_name(bucket, shard_id), pool,
+ int get_bounds(const rgw_bucket& bucket, int shard_id, RGWReplicaBounds& bounds, bool index_by_instance) {
+ return RGWReplicaLogger::get_bounds(obj_name(bucket, shard_id, index_by_instance), pool,
bounds);
}
};
return 0;
}
+static int get_bucket_for_bounds(RGWRados *store, XMLArgs& args, rgw_bucket& bucket, bool *index_by_instance)
+{
+ string bucket_instance = args.get("bucket-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"),
time = s->info.args.get("time"),
daemon_id = s->info.args.get("daemon_id");
- if (bucket_instance.empty() ||
- marker.empty() ||
+ if (marker.empty() ||
time.empty() ||
daemon_id.empty()) {
dout(5) << "Error - invalid parameter list" << dendl;
http_ret = -EINVAL;
return;
}
-
+
utime_t ut;
if (parse_to_utime(time, ut) < 0) {
}
rgw_bucket bucket;
- if ((http_ret = bucket_instance_to_bucket(store, bucket_instance, bucket)) < 0)
- return;
+ bool index_by_instance;
+ if ((http_ret = get_bucket_for_bounds(store, s->info.args, bucket, &index_by_instance)) < 0) {
+ return;
+ }
+
RGWReplicaBucketLogger rl(store);
bufferlist bl;
list<RGWReplicaItemMarker> markers;
void RGWOp_BILog_GetBounds::execute() {
string bucket_instance = s->info.args.get("bucket-instance");
+ rgw_bucket bucket;
+ bool index_by_instance;
- if (bucket_instance.empty()) {
- dout(5) << " Error - invalid parameter list" << dendl;
- http_ret = -EINVAL;
+ if ((http_ret = get_bucket_for_bounds(store, s->info.args, bucket, &index_by_instance)) < 0) {
return;
}
return;
}
- rgw_bucket bucket;
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);
+ http_ret = rl.get_bounds(bucket, shard_id, bounds, index_by_instance);
}
void RGWOp_BILog_GetBounds::send_response() {
}
void RGWOp_BILog_DeleteBounds::execute() {
- string bucket_instance = s->info.args.get("bucket-instance"),
- daemon_id = s->info.args.get("daemon_id");
+ string bucket_instance = s->info.args.get("bucket-instance");
+ string daemon_id = s->info.args.get("daemon_id");
- if (bucket_instance.empty() ||
- daemon_id.empty()) {
+ if (daemon_id.empty()) {
dout(5) << "Error - invalid parameter list" << dendl;
http_ret = -EINVAL;
return;
}
rgw_bucket bucket;
- if ((http_ret = bucket_instance_to_bucket(store, bucket_instance, bucket)) < 0)
+ bool index_by_instance;
+
+ if ((http_ret = get_bucket_for_bounds(store, s->info.args, bucket, &index_by_instance)) < 0) {
return;
+ }
RGWReplicaBucketLogger rl(store);
- http_ret = rl.delete_bound(bucket, shard_id, daemon_id);
+ http_ret = rl.delete_bound(bucket, shard_id, daemon_id, index_by_instance);
}
RGWOp *RGWHandler_ReplicaLog::op_get() {