]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
Lifecycle - Fix config locking
authorDaniel Gryniewicz <dang@redhat.com>
Wed, 14 Sep 2016 17:38:36 +0000 (13:38 -0400)
committerDaniel Gryniewicz <dang@redhat.com>
Wed, 21 Sep 2016 13:04:46 +0000 (09:04 -0400)
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 <dang@redhat.com>
src/rgw/rgw_lc.cc
src/rgw/rgw_lc.h
src/rgw/rgw_op.cc
src/rgw/rgw_op.h

index 43ba9f896d1c2e091dc676c24560dad9eec13215..39b25dbbc08e4a15b15f1a3a4d123a36c5c4a303 100644 (file)
@@ -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<string, int >& 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 */
index 30d2f2b02237166907ea95107795c5ccfed01c36..dbe9cabbfc3c13951d75b65d3e7da608987549fd 100644 (file)
@@ -180,6 +180,7 @@ class RGWLC {
   int max_objs;
   string *obj_names;
   atomic_t down_flag;
+  string cookie;
 
   class LCWorker : public Thread {
     CephContext *cct;
index 6152363c3ceb94930aaa8265e48c1ff680a5ca3b..ed0956e3277ad6a13185aa7c2aedcd85164c6c41 100644 (file)
@@ -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);
index 3a70c44dd1bdfb92358fa4bf0c2125da2276b2c2..3119a107feafa781230cdd6932c90d37a3b90274 100644 (file)
@@ -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();