summaryrefslogtreecommitdiffstats
path: root/src/cls/rgw/cls_rgw.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/cls/rgw/cls_rgw.cc')
-rw-r--r--src/cls/rgw/cls_rgw.cc24
1 files changed, 20 insertions, 4 deletions
diff --git a/src/cls/rgw/cls_rgw.cc b/src/cls/rgw/cls_rgw.cc
index 83c3b824c18..9ad1320e38a 100644
--- a/src/cls/rgw/cls_rgw.cc
+++ b/src/cls/rgw/cls_rgw.cc
@@ -4422,15 +4422,31 @@ static int rgw_reshard_add(cls_method_context_t hctx, bufferlist *in, bufferlist
return -EINVAL;
}
-
- string key;
+ std::string key;
op.entry.get_key(&key);
+ int ret;
bufferlist bl;
+
+ if (op.create_only) {
+ ret = cls_cxx_map_get_val(hctx, key, &bl);
+ if (ret == 0) {
+ // entry already exists; make no changes
+ return -EEXIST;
+ } else if (ret != -ENOENT) {
+ CLS_ERR("error accessing reshard queue for %s with key %s",
+ op.entry.bucket_name.c_str(), key.c_str());
+ return ret;
+ }
+
+ // we got a -ENOENT and can just fall through...
+ }
+
encode(op.entry, bl);
- int ret = cls_cxx_map_set_val(hctx, key, &bl);
+ ret = cls_cxx_map_set_val(hctx, key, &bl);
if (ret < 0) {
- CLS_ERR("error adding reshard job for bucket %s with key %s",op.entry.bucket_name.c_str(), key.c_str());
+ CLS_ERR("error adding reshard job for bucket %s with key %s",
+ op.entry.bucket_name.c_str(), key.c_str());
return ret;
}