return -EINVAL;
}
- bufferlist bl;
- ::encode(op.entry, bl);
string key;
generate_reshard_key(op.entry, key);
- int ret = cls_cxx_map_set_val(hctx, key, &bl);
+ bufferlist bl;
+ int ret = cls_cxx_map_get_val(hctx, key, &bl);
+ if (ret < 0 && ret != -ENOENT) {
+ CLS_ERR("error adding reshard job for bucket %s with key %s: %d",op.entry.bucket_name.c_str(), key.c_str()
+ , ret);
+ return ret;
+ } else if (ret != -ENOENT) {
+ return -EEXIST;
+ }
+
+ ::encode(op.entry, 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());
return ret;