]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
rgw: handle reshard wait logic in cancel() too
authorYehuda Sadeh <yehuda@redhat.com>
Thu, 11 May 2017 22:41:15 +0000 (15:41 -0700)
committerYehuda Sadeh <yehuda@redhat.com>
Mon, 5 Jun 2017 20:17:45 +0000 (13:17 -0700)
Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
src/rgw/rgw_rados.cc
src/rgw/rgw_rados.h

index 441fddd2946d248212dd5f413af6bb96e938132b..af6d46a5f1cbd5abbe75b77ec2de0ea76aa4916b 100644 (file)
@@ -9521,42 +9521,21 @@ int RGWRados::stat_system_obj(RGWObjectCtx& obj_ctx,
   return 0;
 }
 
-int RGWRados::SystemObject::Read::stat(RGWObjVersionTracker *objv_tracker)
-{
-  RGWRados *store = source->get_store();
-  rgw_raw_obj& obj = source->get_obj();
-
-  return store->stat_system_obj(source->get_ctx(), state, obj, stat_params.attrs,
-                                stat_params.lastmod, stat_params.obj_size, objv_tracker);
-}
 
-int RGWRados::Bucket::UpdateIndex::prepare(RGWModifyOp op, const string *write_tag)
+int RGWRados::Bucket::UpdateIndex::guard_reshard(BucketShard *pbs, std::function<int(BucketShard *)> call)
 {
-  if (blind) {
-    return 0;
-  }
   RGWRados *store = target->get_store();
-
-  if (write_tag && write_tag->length()) {
-    optag = string(write_tag->c_str(), write_tag->length());
-  } else {
-    if (optag.empty()) {
-      append_rand_alpha(store->ctx(), optag, optag, 32);
-    }
-  }
-
+  BucketShard *bs;
   int r;
 
 #define NUM_RESHARD_RETRIES 10
-
   for (int i = 0; i < NUM_RESHARD_RETRIES; ++i) {
-    BucketShard *bs;
     int ret = get_bucket_shard(&bs);
     if (ret < 0) {
       ldout(store->ctx(), 5) << "failed to get BucketShard object: ret=" << ret << dendl;
       return ret;
     }
-    r = store->cls_obj_prepare_op(*bs, op, optag, obj, bilog_flags, zones_trace);
+    r = call(bs);
     if (r != -ERR_BUSY_RESHARDING) {
       break;
     }
@@ -9580,6 +9559,45 @@ int RGWRados::Bucket::UpdateIndex::prepare(RGWModifyOp op, const string *write_t
     invalidate_bs();
   }
 
+  if (r < 0) {
+    return r;
+  }
+
+  if (pbs) {
+    *pbs = bs;
+  }
+
+  return 0;
+}
+
+int RGWRados::SystemObject::Read::stat(RGWObjVersionTracker *objv_tracker)
+{
+  RGWRados *store = source->get_store();
+  rgw_raw_obj& obj = source->get_obj();
+
+  return store->stat_system_obj(source->get_ctx(), state, obj, stat_params.attrs,
+                                stat_params.lastmod, stat_params.obj_size, objv_tracker);
+}
+
+int RGWRados::Bucket::UpdateIndex::prepare(RGWModifyOp op, const string *write_tag)
+{
+  if (blind) {
+    return 0;
+  }
+  RGWRados *store = target->get_store();
+
+  if (write_tag && write_tag->length()) {
+    optag = string(write_tag->c_str(), write_tag->length());
+  } else {
+    if (optag.empty()) {
+      append_rand_alpha(store->ctx(), optag, optag, 32);
+    }
+  }
+
+  int r = guard_reshard(nullptr, [&](BucketShard *bs) -> int { 
+    return store->cls_obj_prepare_op(*bs, op, optag, obj, bilog_flags, zones_trace);
+  });
+
   if (r < 0) {
     return r;
   }
@@ -9673,13 +9691,9 @@ int RGWRados::Bucket::UpdateIndex::cancel()
   RGWRados *store = target->get_store();
   BucketShard *bs;
 
-  int ret = get_bucket_shard(&bs);
-  if (ret < 0) {
-    ldout(store->ctx(), 5) << "failed to get BucketShard object: ret=" << ret << dendl;
-    return ret;
-  }
-
-  ret = store->cls_obj_complete_cancel(*bs, optag, obj, bilog_flags, zones_trace);
+  ret = guard_reshard(&bs, [&](BucketShard *bs) -> int { 
+    return store->cls_obj_complete_cancel(*bs, optag, obj, bilog_flags, zones_trace);
+  });
 
   /*
    * need to update data log anyhow, so that whoever follows needs to update its internal markers
index 15b41c2c4f107d392ef27c3184fc31f14f185dbc..da129430bfa2c033749d46b331b403b002d8d831 100644 (file)
@@ -2881,6 +2881,8 @@ public:
       void invalidate_bs() {
         bs_initialized = false;
       }
+
+      int guard_reshard(BucketShard *pbs, std::function<int(BucketShard *)> call);
     public:
 
       UpdateIndex(RGWRados::Bucket *_target, const rgw_obj& _obj) : target(_target), obj(_obj),