From: Daniel Gryniewicz Date: Wed, 14 Sep 2016 17:38:36 +0000 (-0400) Subject: Lifecycle - Fix config locking X-Git-Tag: v11.0.1~144^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=1707da2662365efcde110c4736f6b6c85236f06e;p=ceph.git Lifecycle - Fix config locking The lifecycle config lock was not setting a cookie. This means that all instances of that lock conflict, causing errors to be returned to the client. Set a unique cookie on each lock instance. Signed-off-by: Daniel Gryniewicz --- diff --git a/src/rgw/rgw_lc.cc b/src/rgw/rgw_lc.cc index 43ba9f896d1c..39b25dbbc08e 100644 --- a/src/rgw/rgw_lc.cc +++ b/src/rgw/rgw_lc.cc @@ -87,6 +87,11 @@ void RGWLC::initialize(CephContext *_cct, RGWRados *_store) { snprintf(buf, 32, ".%d", i); obj_names[i].append(buf); } + +#define COOKIE_LEN 16 + char cookie_buf[COOKIE_LEN + 1]; + gen_rand_alphanumeric(cct, cookie_buf, sizeof(cookie_buf) - 1); + cookie = cookie_buf; } void RGWLC::finalize() @@ -324,6 +329,7 @@ int RGWLC::bucket_lc_post(int index, int max_lock_sec, cls_rgw_lc_obj_head& head pair& entry, int& result) { rados::cls::lock::Lock l(lc_index_lock_name); + l.set_cookie(cookie); do { int ret = l.lock_exclusive(&store->lc_pool_ctx, obj_names[index]); if (ret == -EBUSY) { /* already locked by another lc processor */ diff --git a/src/rgw/rgw_lc.h b/src/rgw/rgw_lc.h index 30d2f2b02237..dbe9cabbfc3c 100644 --- a/src/rgw/rgw_lc.h +++ b/src/rgw/rgw_lc.h @@ -180,6 +180,7 @@ class RGWLC { int max_objs; string *obj_names; atomic_t down_flag; + string cookie; class LCWorker : public Thread { CephContext *cct; diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc index 6152363c3ceb..ed0956e3277a 100644 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@ -3987,6 +3987,7 @@ void RGWPutLC::execute() rados::cls::lock::Lock l(lc_index_lock_name); utime_t time(max_lock_secs, 0); l.set_duration(time); + l.set_cookie(cookie); librados::IoCtx *ctx = store->get_lc_pool_ctx(); do { ret = l.lock_exclusive(ctx, oid); diff --git a/src/rgw/rgw_op.h b/src/rgw/rgw_op.h index 3a70c44dd1bd..3119a107feaf 100644 --- a/src/rgw/rgw_op.h +++ b/src/rgw/rgw_op.h @@ -1033,6 +1033,7 @@ protected: int ret; size_t len; char *data; + string cookie; public: RGWPutLC() { @@ -1044,6 +1045,15 @@ public: free(data); } + virtual void init(RGWRados *store, struct req_state *s, RGWHandler *dialect_handler) { +#define COOKIE_LEN 16 + char buf[COOKIE_LEN + 1]; + + RGWOp::init(store, s, dialect_handler); + gen_rand_alphanumeric(s->cct, buf, sizeof(buf) - 1); + cookie = buf; + } + int verify_permission(); void pre_exec(); void execute();