]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
rgw: update data log after index completion reshard handling
authorYehuda Sadeh <yehuda@redhat.com>
Tue, 16 May 2017 22:30:32 +0000 (15:30 -0700)
committerYehuda Sadeh <yehuda@redhat.com>
Mon, 5 Jun 2017 20:17:47 +0000 (13:17 -0700)
Also rearrange code a bit.

Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
src/rgw/rgw_rados.cc

index 02d827154ada8586f18fc2ca536a7d3ad5f5a1e5..5bacb037afcbe960cb5fcd1b160648515f7c086d 100644 (file)
@@ -3430,33 +3430,40 @@ int RGWIndexCompletionThread::process()
     completions.swap(comps);
   }
 
-  for (auto c: comps) {
-    if (!going_down()) {
-      ldout(store->ctx(), 20) << __func__ << "(): handling completion for key=" << c->key << dendl;
+  for (auto c : comps) {
+    std::unique_ptr<complete_op_data> up{c};
 
-      RGWRados::BucketShard bs(store);
+    if (going_down()) {
+      continue;
+    }
+    ldout(store->ctx(), 20) << __func__ << "(): handling completion for key=" << c->key << dendl;
 
-      int r = bs.init(c->obj.bucket, c->obj);
-      if (r < 0) {
-        ldout(cct, 0) << "ERROR: " << __func__ << "(): failed to initialize BucketShard, obj=" << c->obj << " r=" << r << dendl;
-        /* not much to do */
-        delete c;
-        continue;
-      }
+    RGWRados::BucketShard bs(store);
 
-      r = store->guard_reshard(&bs, c->obj, [&](RGWRados::BucketShard *bs) -> int { 
-                               librados::ObjectWriteOperation o;
-                               cls_rgw_guard_bucket_resharding(o, -ERR_BUSY_RESHARDING);
-                               cls_rgw_bucket_complete_op(o, c->op, c->tag, c->ver, c->key, c->dir_meta, &c->remove_objs,
-                                                          c->log_op, c->bilog_op);
+    int r = bs.init(c->obj.bucket, c->obj);
+    if (r < 0) {
+      ldout(cct, 0) << "ERROR: " << __func__ << "(): failed to initialize BucketShard, obj=" << c->obj << " r=" << r << dendl;
+      /* not much to do */
+      continue;
+    }
 
-                               return bs->index_ctx.operate(bs->bucket_obj, &o);
-                               });
-      ldout(cct, 0) << "ERROR: " << __func__ << "(): bucket index completion failed, obj=" << c->obj << " r=" << r << dendl;
+    r = store->guard_reshard(&bs, c->obj, [&](RGWRados::BucketShard *bs) -> int { 
+                             librados::ObjectWriteOperation o;
+                             cls_rgw_guard_bucket_resharding(o, -ERR_BUSY_RESHARDING);
+                             cls_rgw_bucket_complete_op(o, c->op, c->tag, c->ver, c->key, c->dir_meta, &c->remove_objs,
+                                                        c->log_op, c->bilog_op);
 
+                             return bs->index_ctx.operate(bs->bucket_obj, &o);
+                             });
+    if (r < 0) {
+      ldout(cct, 0) << "ERROR: " << __func__ << "(): bucket index completion failed, obj=" << c->obj << " r=" << r << dendl;
       /* ignoring error, can't do anything about it */
+      continue;
+    }
+    r = store->data_log->add_entry(bs.bucket, bs.shard_id);
+    if (r < 0) {
+      lderr(store->ctx()) << "ERROR: failed writing data log" << dendl;
     }
-    delete c;
   }
 
   return 0;