diff options
author | Yehuda Sadeh <yehuda@inktank.com> | 2014-01-13 23:19:27 +0100 |
---|---|---|
committer | Yehuda Sadeh <yehuda@inktank.com> | 2014-01-24 19:28:53 +0100 |
commit | 7545177ab765c8e4f83bfcad6b056a70c0f3dfad (patch) | |
tree | 8b023de6ee46ceec0e9569742da4b109e3acb4da /src/cls | |
parent | radosgw-admin: dump header when requested for user stats (diff) | |
download | ceph-7545177ab765c8e4f83bfcad6b056a70c0f3dfad.tar.xz ceph-7545177ab765c8e4f83bfcad6b056a70c0f3dfad.zip |
rgw, cls_user: fix bucket creation
There's a single op to create and update the user bucket info, however,
the cases differ a bit, as we only need to guard against ENOENT if we're
updating the info.
Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
Diffstat (limited to 'src/cls')
-rw-r--r-- | src/cls/user/cls_user.cc | 6 | ||||
-rw-r--r-- | src/cls/user/cls_user_client.cc | 3 | ||||
-rw-r--r-- | src/cls/user/cls_user_client.h | 2 | ||||
-rw-r--r-- | src/cls/user/cls_user_ops.h | 5 |
4 files changed, 12 insertions, 4 deletions
diff --git a/src/cls/user/cls_user.cc b/src/cls/user/cls_user.cc index 3b82eab4fb7..a72ba33604e 100644 --- a/src/cls/user/cls_user.cc +++ b/src/cls/user/cls_user.cc @@ -144,9 +144,13 @@ static int cls_user_set_buckets_info(cls_method_context_t hctx, bufferlist *in, cls_user_bucket_entry old_entry; ret = get_existing_bucket_entry(hctx, key, old_entry); - if (ret == -ENOENT) + if (ret == -ENOENT) { + if (!op.add) continue; /* racing bucket removal */ + ret = 0; + } + if (ret < 0) { CLS_LOG(0, "ERROR: get_existing_bucket_entry() key=%s returned %d", key.c_str(), ret); return ret; diff --git a/src/cls/user/cls_user_client.cc b/src/cls/user/cls_user_client.cc index a21616007e2..d2f4b366fd7 100644 --- a/src/cls/user/cls_user_client.cc +++ b/src/cls/user/cls_user_client.cc @@ -12,11 +12,12 @@ using namespace librados; -void cls_user_set_buckets(librados::ObjectWriteOperation& op, list<cls_user_bucket_entry>& entries) +void cls_user_set_buckets(librados::ObjectWriteOperation& op, list<cls_user_bucket_entry>& entries, bool add) { bufferlist in; cls_user_set_buckets_op call; call.entries = entries; + call.add = add; call.time = ceph_clock_now(NULL); ::encode(call, in); op.exec("user", "set_buckets_info", in); diff --git a/src/cls/user/cls_user_client.h b/src/cls/user/cls_user_client.h index 34f8278a41c..62e96294997 100644 --- a/src/cls/user/cls_user_client.h +++ b/src/cls/user/cls_user_client.h @@ -19,7 +19,7 @@ public: * user objclass */ -void cls_user_set_buckets(librados::ObjectWriteOperation& op, list<cls_user_bucket_entry>& entries); +void cls_user_set_buckets(librados::ObjectWriteOperation& op, list<cls_user_bucket_entry>& entries, bool add); void cls_user_complete_stats_sync(librados::ObjectWriteOperation& op); void cls_user_remove_bucket(librados::ObjectWriteOperation& op, const cls_user_bucket& bucket); void cls_user_bucket_list(librados::ObjectReadOperation& op, diff --git a/src/cls/user/cls_user_ops.h b/src/cls/user/cls_user_ops.h index 5beb2f17c4e..16cfe81fef3 100644 --- a/src/cls/user/cls_user_ops.h +++ b/src/cls/user/cls_user_ops.h @@ -9,13 +9,15 @@ struct cls_user_set_buckets_op { list<cls_user_bucket_entry> entries; + bool add; utime_t time; /* op time */ - cls_user_set_buckets_op() {} + cls_user_set_buckets_op() : add(false) {} void encode(bufferlist& bl) const { ENCODE_START(1, 1, bl); ::encode(entries, bl); + ::encode(add, bl); ::encode(time, bl); ENCODE_FINISH(bl); } @@ -23,6 +25,7 @@ struct cls_user_set_buckets_op { void decode(bufferlist::iterator& bl) { DECODE_START(1, bl); ::decode(entries, bl); + ::decode(add, bl); ::decode(time, bl); DECODE_FINISH(bl); } |