]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: more code removal and api adjustments
authorYehuda Sadeh <yehuda@redhat.com>
Mon, 17 Sep 2018 11:05:02 +0000 (04:05 -0700)
committerYehuda Sadeh <yehuda@redhat.com>
Thu, 8 Nov 2018 17:19:29 +0000 (09:19 -0800)
Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
src/rgw/rgw_cr_rados.cc
src/rgw/rgw_file.h
src/rgw/rgw_lib.h
src/rgw/rgw_op.cc
src/rgw/rgw_putobj_processor.cc
src/rgw/rgw_rados.cc
src/rgw/rgw_rados.h
src/rgw/rgw_rest_s3.cc
src/rgw/rgw_rest_swift.cc
src/rgw/services/svc_rados.cc

index 8d3e452da98eb3b7249a9fcf45063797723c2080..e9355b83c0530c393151cab7c068beb0c2a97f61 100644 (file)
@@ -659,7 +659,7 @@ int RGWAsyncRemoveObj::_send_request()
 
   ldout(store->ctx(), 0) << __func__ << "(): deleting obj=" << obj << dendl;
 
-  obj_ctx.obj.set_atomic(obj);
+  obj_ctx.set_atomic(obj);
 
   RGWObjState *state;
 
index a98d2832e93f435d40b5d9f6cf15c5c2f0a5f7b8..1229e9d9bdefda790e546bdfc7941f1f9565f5ae 100644 (file)
@@ -1269,7 +1269,7 @@ public:
       = static_cast<RGWObjectCtx*>(get_state()->obj_ctx);
     // framework promises to call op_init after parent init
     ceph_assert(rados_ctx);
-    RGWOp::init(rados_ctx->store, get_state(), this);
+    RGWOp::init(rados_ctx->get_store(), get_state(), this);
     op = this; // assign self as op: REQUIRED
     return 0;
   }
@@ -1405,7 +1405,7 @@ public:
       = static_cast<RGWObjectCtx*>(get_state()->obj_ctx);
     // framework promises to call op_init after parent init
     ceph_assert(rados_ctx);
-    RGWOp::init(rados_ctx->store, get_state(), this);
+    RGWOp::init(rados_ctx->get_store(), get_state(), this);
     op = this; // assign self as op: REQUIRED
     return 0;
   }
@@ -1577,7 +1577,7 @@ public:
       = static_cast<RGWObjectCtx*>(get_state()->obj_ctx);
     // framework promises to call op_init after parent init
     ceph_assert(rados_ctx);
-    RGWOp::init(rados_ctx->store, get_state(), this);
+    RGWOp::init(rados_ctx->get_store(), get_state(), this);
     op = this; // assign self as op: REQUIRED
     return 0;
   }
@@ -1662,7 +1662,7 @@ public:
       = static_cast<RGWObjectCtx*>(get_state()->obj_ctx);
     // framework promises to call op_init after parent init
     ceph_assert(rados_ctx);
-    RGWOp::init(rados_ctx->store, get_state(), this);
+    RGWOp::init(rados_ctx->get_store(), get_state(), this);
     op = this; // assign self as op: REQUIRED
     return 0;
   }
@@ -1726,7 +1726,7 @@ public:
       = static_cast<RGWObjectCtx*>(get_state()->obj_ctx);
     // framework promises to call op_init after parent init
     ceph_assert(rados_ctx);
-    RGWOp::init(rados_ctx->store, get_state(), this);
+    RGWOp::init(rados_ctx->get_store(), get_state(), this);
     op = this; // assign self as op: REQUIRED
     return 0;
   }
@@ -1784,7 +1784,7 @@ public:
       = static_cast<RGWObjectCtx*>(get_state()->obj_ctx);
     // framework promises to call op_init after parent init
     ceph_assert(rados_ctx);
-    RGWOp::init(rados_ctx->store, get_state(), this);
+    RGWOp::init(rados_ctx->get_store(), get_state(), this);
     op = this; // assign self as op: REQUIRED
 
     int rc = valid_s3_object_name(obj_name);
@@ -1882,7 +1882,7 @@ public:
       = static_cast<RGWObjectCtx*>(get_state()->obj_ctx);
     // framework promises to call op_init after parent init
     ceph_assert(rados_ctx);
-    RGWOp::init(rados_ctx->store, get_state(), this);
+    RGWOp::init(rados_ctx->get_store(), get_state(), this);
     op = this; // assign self as op: REQUIRED
     return 0;
   }
@@ -1968,7 +1968,7 @@ public:
       = static_cast<RGWObjectCtx*>(get_state()->obj_ctx);
     // framework promises to call op_init after parent init
     ceph_assert(rados_ctx);
-    RGWOp::init(rados_ctx->store, get_state(), this);
+    RGWOp::init(rados_ctx->get_store(), get_state(), this);
     op = this; // assign self as op: REQUIRED
     return 0;
   }
@@ -2050,7 +2050,7 @@ public:
       = static_cast<RGWObjectCtx*>(get_state()->obj_ctx);
     // framework promises to call op_init after parent init
     ceph_assert(rados_ctx);
-    RGWOp::init(rados_ctx->store, get_state(), this);
+    RGWOp::init(rados_ctx->get_store(), get_state(), this);
     op = this; // assign self as op: REQUIRED
     return 0;
   }
@@ -2131,7 +2131,7 @@ public:
       = static_cast<RGWObjectCtx*>(get_state()->obj_ctx);
     // framework promises to call op_init after parent init
     ceph_assert(rados_ctx);
-    RGWOp::init(rados_ctx->store, get_state(), this);
+    RGWOp::init(rados_ctx->get_store(), get_state(), this);
     op = this; // assign self as op: REQUIRED
     return 0;
   }
@@ -2201,7 +2201,7 @@ public:
       = static_cast<RGWObjectCtx*>(get_state()->obj_ctx);
     // framework promises to call op_init after parent init
     ceph_assert(rados_ctx);
-    RGWOp::init(rados_ctx->store, get_state(), this);
+    RGWOp::init(rados_ctx->get_store(), get_state(), this);
     op = this; // assign self as op: REQUIRED
     return 0;
   }
@@ -2324,7 +2324,7 @@ public:
       = static_cast<RGWObjectCtx*>(get_state()->obj_ctx);
     // framework promises to call op_init after parent init
     ceph_assert(rados_ctx);
-    RGWOp::init(rados_ctx->store, get_state(), this);
+    RGWOp::init(rados_ctx->get_store(), get_state(), this);
     op = this; // assign self as op: REQUIRED
     return 0;
   }
@@ -2419,7 +2419,7 @@ public:
       = static_cast<RGWObjectCtx*>(get_state()->obj_ctx);
     // framework promises to call op_init after parent init
     ceph_assert(rados_ctx);
-    RGWOp::init(rados_ctx->store, get_state(), this);
+    RGWOp::init(rados_ctx->get_store(), get_state(), this);
     op = this; // assign self as op: REQUIRED
 
     return 0;
@@ -2502,7 +2502,7 @@ public:
       = static_cast<RGWObjectCtx*>(get_state()->obj_ctx);
     // framework promises to call op_init after parent init
     ceph_assert(rados_ctx);
-    RGWOp::init(rados_ctx->store, get_state(), this);
+    RGWOp::init(rados_ctx->get_store(), get_state(), this);
     op = this; // assign self as op: REQUIRED
     return 0;
   }
@@ -2555,7 +2555,7 @@ public:
       = static_cast<RGWObjectCtx*>(get_state()->obj_ctx);
     // framework promises to call op_init after parent init
     ceph_assert(rados_ctx);
-    RGWOp::init(rados_ctx->store, get_state(), this);
+    RGWOp::init(rados_ctx->get_store(), get_state(), this);
     op = this; // assign self as op: REQUIRED
     return 0;
   }
index 24d273e3cfa64d9b3a144b1294f1f77acc572530..4b3ec267d1e1b1468cdc39c24eaa166054dc8ea8 100644 (file)
@@ -156,7 +156,7 @@ namespace rgw {
             RGWLibIO* io, struct req_state* _s) {
 
       RGWRequest::init_state(_s);
-      RGWHandler::init(rados_ctx->store, _s, io);
+      RGWHandler::init(rados_ctx->get_store(), _s, io);
 
       get_state()->obj_ctx = rados_ctx;
       get_state()->req_id = store->svc.zone_utils->unique_id(id);
@@ -192,7 +192,7 @@ namespace rgw {
        io_ctx.init(_cct);
 
        RGWRequest::init_state(&rstate);
-       RGWHandler::init(rados_ctx.store, &rstate, &io_ctx);
+       RGWHandler::init(rados_ctx.get_store(), &rstate, &io_ctx);
 
        get_state()->obj_ctx = &rados_ctx;
        get_state()->req_id = store->svc.zone_utils->unique_id(id);
index 306a31b1ba4a8cbcce12f3b7ded63bd2995f9b88..cf9601cad9273b46f4818eab3919d3b96bd53786 100644 (file)
@@ -1229,7 +1229,7 @@ int RGWGetObj::read_user_manifest_part(rgw_bucket& bucket,
   ldpp_dout(this, 20) << "reading obj=" << part << " ofs=" << cur_ofs
       << " end=" << cur_end << dendl;
 
-  obj_ctx.obj.set_atomic(part);
+  obj_ctx.set_atomic(part);
   store->set_prefetch_data(&obj_ctx, part);
 
   RGWRados::Object op_target(store, s->bucket_info, obj_ctx, part);
@@ -4350,7 +4350,7 @@ void RGWDeleteObj::execute()
     }
 
     RGWObjectCtx *obj_ctx = static_cast<RGWObjectCtx *>(s->obj_ctx);
-    obj_ctx->obj.set_atomic(obj);
+    obj_ctx->set_atomic(obj);
 
     bool ver_restored = false;
     op_ret = store->swift_versioning_restore(*s->sysobj_ctx, *obj_ctx, s->bucket_owner.get_id(),
@@ -4639,8 +4639,8 @@ void RGWCopyObj::execute()
   rgw_obj dst_obj(dest_bucket, dest_object);
 
   RGWObjectCtx& obj_ctx = *static_cast<RGWObjectCtx *>(s->obj_ctx);
-  obj_ctx.obj.set_atomic(src_obj);
-  obj_ctx.obj.set_atomic(dst_obj);
+  obj_ctx.set_atomic(src_obj);
+  obj_ctx.set_atomic(dst_obj);
 
   encode_delete_at_attr(delete_at, attrs);
 
@@ -5678,7 +5678,7 @@ void RGWCompleteMultipart::execute()
 
   RGWObjectCtx& obj_ctx = *static_cast<RGWObjectCtx *>(s->obj_ctx);
 
-  obj_ctx.obj.set_atomic(target_obj);
+  obj_ctx.set_atomic(target_obj);
 
   RGWRados::Object op_target(store, s->bucket_info, *static_cast<RGWObjectCtx *>(s->obj_ctx), target_obj);
   RGWRados::Object::Write obj_op(&op_target);
@@ -6006,7 +6006,7 @@ void RGWDeleteMultiObj::execute()
       }
     }
 
-    obj_ctx->obj.set_atomic(obj);
+    obj_ctx->set_atomic(obj);
 
     RGWRados::Object del_target(store, s->bucket_info, *obj_ctx, obj);
     RGWRados::Object::Delete del_op(&del_target);
@@ -6081,7 +6081,7 @@ bool RGWBulkDelete::Deleter::delete_single(const acct_path_t& path)
 
   if (!path.obj_key.empty()) {
     rgw_obj obj(binfo.bucket, path.obj_key);
-    obj_ctx.obj.set_atomic(obj);
+    obj_ctx.set_atomic(obj);
 
     RGWRados::Object del_target(store, binfo, obj_ctx, obj);
     RGWRados::Object::Delete del_op(&del_target);
index ba93779769a84ec09624e4d5a4dcdf06780b9931..8bd11a695155f7e8e259cbbdb313677fea0fe334 100644 (file)
@@ -262,7 +262,7 @@ int AtomicObjectProcessor::complete(size_t accounted_size,
     return r;
   }
 
-  obj_ctx.obj.set_atomic(head_obj);
+  obj_ctx.set_atomic(head_obj);
 
   RGWRados::Object op_target(store, bucket_info, obj_ctx, head_obj);
 
index e4910996ce44d2dd7b22396db46099baadca8cde..ffc2f41a855870b026d1b3952cdf89efa9d2d5d4 100644 (file)
@@ -189,36 +189,6 @@ int rgw_init_ioctx(librados::Rados *rados, const rgw_pool& pool, IoCtx& ioctx, b
   return 0;
 }
 
-template<>
-void RGWObjectCtxImpl<rgw_obj, RGWObjState>::invalidate(const rgw_obj& obj) {
-  RWLock::WLocker wl(lock);
-  auto iter = objs_state.find(obj);
-  if (iter == objs_state.end()) {
-    return;
-  }
-  bool is_atomic = iter->second.is_atomic;
-  bool prefetch_data = iter->second.prefetch_data;
-
-  objs_state.erase(iter);
-
-  if (is_atomic || prefetch_data) {
-    auto& s = objs_state[obj];
-    s.is_atomic = is_atomic;
-    s.prefetch_data = prefetch_data;
-  }
-}
-
-template<>
-void RGWObjectCtxImpl<rgw_raw_obj, RGWRawObjState>::invalidate(const rgw_raw_obj& obj) {
-  RWLock::WLocker wl(lock);
-  auto iter = objs_state.find(obj);
-  if (iter == objs_state.end()) {
-    return;
-  }
-
-  objs_state.erase(iter);
-}
-
 void RGWObjVersionTracker::prepare_op_for_read(ObjectReadOperation *op)
 {
   obj_version *check_objv = version_for_check();
@@ -602,7 +572,6 @@ void RGWObjVersionTracker::generate_new_write_ver(CephContext *cct)
   append_rand_alpha(cct, write_version.tag, write_version.tag, TAG_LEN);
 }
 
-
 class RGWMetaNotifierManager : public RGWCoroutinesManager {
   RGWRados *store;
   RGWHTTPManager http_manager;
@@ -1769,28 +1738,6 @@ int RGWRados::initialize()
   return init_complete();
 }
 
-int RGWRados::list_raw_prefixed_objs(const rgw_pool& pool, const string& prefix, list<string>& result)
-{
-  bool is_truncated;
-  RGWListRawObjsCtx ctx;
-  do {
-    list<string> oids;
-    int r = list_raw_objects(pool, prefix, 1000,
-                            ctx, oids, &is_truncated);
-    if (r < 0) {
-      return r;
-    }
-    list<string>::iterator iter;
-    for (iter = oids.begin(); iter != oids.end(); ++iter) {
-      string& val = *iter;
-      if (val.size() > prefix.size())
-        result.push_back(val.substr(prefix.size()));
-    }
-  } while (is_truncated);
-
-  return 0;
-}
-
 /**
  * Open the pool used as root for this gateway
  * Returns: 0 on success, -ERR# otherwise.
@@ -3022,85 +2969,6 @@ bool RGWRados::obj_to_raw(const string& placement_rule, const rgw_obj& obj, rgw_
   return get_obj_data_pool(placement_rule, obj, &raw_obj->pool);
 }
 
-int RGWRados::create_pools(vector<rgw_pool>& pools, vector<int>& retcodes)
-{
-  vector<librados::PoolAsyncCompletion *> completions;
-  vector<int> rets;
-
-  librados::Rados *rad = get_rados_handle();
-  for (auto iter = pools.begin(); iter != pools.end(); ++iter) {
-    librados::PoolAsyncCompletion *c = librados::Rados::pool_async_create_completion();
-    completions.push_back(c);
-    rgw_pool& pool = *iter;
-    int ret = rad->pool_create_async(pool.name.c_str(), c);
-    rets.push_back(ret);
-  }
-
-  vector<int>::iterator riter;
-  vector<librados::PoolAsyncCompletion *>::iterator citer;
-
-  bool error = false;
-  ceph_assert(rets.size() == completions.size());
-  for (riter = rets.begin(), citer = completions.begin(); riter != rets.end(); ++riter, ++citer) {
-    int r = *riter;
-    PoolAsyncCompletion *c = *citer;
-    if (r == 0) {
-      c->wait();
-      r = c->get_return_value();
-      if (r < 0) {
-        ldout(cct, 0) << "WARNING: async pool_create returned " << r << dendl;
-        error = true;
-      }
-    }
-    c->release();
-    retcodes.push_back(r);
-  }
-  if (error) {
-    return 0;
-  }
-
-  std::vector<librados::IoCtx> io_ctxs;
-  retcodes.clear();
-  for (auto pool : pools) {
-    io_ctxs.emplace_back();
-    int ret = rad->ioctx_create(pool.name.c_str(), io_ctxs.back());
-    if (ret < 0) {
-      ldout(cct, 0) << "WARNING: ioctx_create returned " << ret << dendl;
-      error = true;
-    }
-    retcodes.push_back(ret);
-  }
-  if (error) {
-    return 0;
-  }
-
-  completions.clear();
-  for (auto &io_ctx : io_ctxs) {
-    librados::PoolAsyncCompletion *c =
-      librados::Rados::pool_async_create_completion();
-    completions.push_back(c);
-    int ret = io_ctx.application_enable_async(pg_pool_t::APPLICATION_NAME_RGW,
-                                              false, c);
-    ceph_assert(ret == 0);
-  }
-
-  retcodes.clear();
-  for (auto c : completions) {
-    c->wait();
-    int ret = c->get_return_value();
-    if (ret == -EOPNOTSUPP) {
-      ret = 0;
-    } else if (ret < 0) {
-      ldout(cct, 0) << "WARNING: async application_enable returned " << ret
-                    << dendl;
-      error = true;
-    }
-    c->release();
-    retcodes.push_back(ret);
-  }
-  return 0;
-}
-
 int RGWRados::get_obj_head_ioctx(const RGWBucketInfo& bucket_info, const rgw_obj& obj, librados::IoCtx *ioctx)
 {
   string oid, key;
@@ -3530,7 +3398,7 @@ int RGWRados::swift_versioning_copy(RGWObjectCtx& obj_ctx,
     return 0;
   }
 
-  obj_ctx.obj.set_atomic(obj);
+  obj_ctx.set_atomic(obj);
 
   RGWObjState * state = nullptr;
   int r = get_obj_state(&obj_ctx, bucket_info, obj, &state, false);
@@ -3566,7 +3434,7 @@ int RGWRados::swift_versioning_copy(RGWObjectCtx& obj_ctx,
   }
 
   rgw_obj dest_obj(dest_bucket_info.bucket, buf);
-  obj_ctx.obj.set_atomic(dest_obj);
+  obj_ctx.set_atomic(dest_obj);
 
   string no_zone;
 
@@ -3653,8 +3521,8 @@ int RGWRados::swift_versioning_restore(RGWSysObjectCtx& sysobj_ctx,
     std::map<std::string, ceph::bufferlist> no_attrs;
 
     rgw_obj archive_obj(archive_binfo.bucket, entry.key);
-    obj_ctx.obj.set_atomic(archive_obj);
-    obj_ctx.obj.set_atomic(obj);
+    obj_ctx.set_atomic(archive_obj);
+    obj_ctx.set_atomic(obj);
 
     int ret = copy_obj(obj_ctx,
                        user,
@@ -4626,7 +4494,7 @@ int RGWRados::fetch_remote_obj(RGWObjectCtx& obj_ctx,
     }
     if (copy_if_newer && canceled) {
       ldout(cct, 20) << "raced with another write of obj: " << dest_obj << dendl;
-      obj_ctx.obj.invalidate(dest_obj); /* object was overwritten */
+      obj_ctx.invalidate(dest_obj); /* object was overwritten */
       ret = get_obj_state(&obj_ctx, dest_bucket_info, dest_obj, &dest_state, false);
       if (ret < 0) {
         ldout(cct, 0) << "ERROR: " << __func__ << ": get_err_state() returned ret=" << ret << dendl;
@@ -5810,55 +5678,6 @@ int RGWRados::get_olh_target_state(RGWObjectCtx& obj_ctx, const RGWBucketInfo& b
   return 0;
 }
 
-int RGWRados::get_system_obj_state_impl(RGWObjectCtx *rctx, rgw_raw_obj& obj, RGWRawObjState **state, RGWObjVersionTracker *objv_tracker)
-{
-  if (obj.empty()) {
-    return -EINVAL;
-  }
-
-  RGWRawObjState *s = rctx->raw.get_state(obj);
-  ldout(cct, 20) << "get_system_obj_state: rctx=" << (void *)rctx << " obj=" << obj << " state=" << (void *)s << " s->prefetch_data=" << s->prefetch_data << dendl;
-  *state = s;
-  if (s->has_attrs) {
-    return 0;
-  }
-
-  s->obj = obj;
-
-  int r = raw_obj_stat(obj, &s->size, &s->mtime, &s->epoch, &s->attrset, (s->prefetch_data ? &s->data : NULL), objv_tracker);
-  if (r == -ENOENT) {
-    s->exists = false;
-    s->has_attrs = true;
-    s->mtime = real_time();
-    return 0;
-  }
-  if (r < 0)
-    return r;
-
-  s->exists = true;
-  s->has_attrs = true;
-  s->obj_tag = s->attrset[RGW_ATTR_ID_TAG];
-
-  if (s->obj_tag.length())
-    ldout(cct, 20) << "get_system_obj_state: setting s->obj_tag to "
-                   << s->obj_tag.c_str() << dendl;
-  else
-    ldout(cct, 20) << "get_system_obj_state: s->obj_tag was set empty" << dendl;
-
-  return 0;
-}
-
-int RGWRados::get_system_obj_state(RGWObjectCtx *rctx, rgw_raw_obj& obj, RGWRawObjState **state, RGWObjVersionTracker *objv_tracker)
-{
-  int ret;
-
-  do {
-    ret = get_system_obj_state_impl(rctx, obj, state, objv_tracker);
-  } while (ret == -EAGAIN);
-
-  return ret;
-}
-
 int RGWRados::get_obj_state_impl(RGWObjectCtx *rctx, const RGWBucketInfo& bucket_info, const rgw_obj& obj,
                                  RGWObjState **state, bool follow_olh, bool assume_noent)
 {
@@ -5868,7 +5687,7 @@ int RGWRados::get_obj_state_impl(RGWObjectCtx *rctx, const RGWBucketInfo& bucket
 
   bool need_follow_olh = follow_olh && obj.key.instance.empty();
 
-  RGWObjState *s = rctx->obj.get_state(obj);
+  RGWObjState *s = rctx->get_state(obj);
   ldout(cct, 20) << "get_obj_state: rctx=" << (void *)rctx << " obj=" << obj << " state=" << (void *)s << " s->prefetch_data=" << s->prefetch_data << dendl;
   *state = s;
   if (s->has_attrs) {
@@ -6079,7 +5898,7 @@ int RGWRados::Object::Stat::stat_async()
   rgw_obj& obj = source->get_obj();
   RGWRados *store = source->get_store();
 
-  RGWObjState *s = ctx.obj.get_state(obj); /* calling this one directly because otherwise a sync request will be sent */
+  RGWObjState *s = ctx.get_state(obj); /* calling this one directly because otherwise a sync request will be sent */
   result.obj = obj;
   if (s->has_attrs) {
     state.ret = 0;
@@ -6186,7 +6005,7 @@ int RGWRados::Object::get_state(RGWObjState **pstate, bool follow_olh, bool assu
 
 void RGWRados::Object::invalidate_state()
 {
-  ctx.obj.invalidate(obj);
+  ctx.invalidate(obj);
 }
 
 int RGWRados::Object::prepare_atomic_modification(ObjectWriteOperation& op, bool reset_obj, const string *ptag,
@@ -7808,7 +7627,7 @@ int RGWRados::set_olh(RGWObjectCtx& obj_ctx, RGWBucketInfo& bucket_info, const r
 #define MAX_ECANCELED_RETRY 100
   for (i = 0; i < MAX_ECANCELED_RETRY; i++) {
     if (ret == -ECANCELED) {
-      obj_ctx.obj.invalidate(olh_obj);
+      obj_ctx.invalidate(olh_obj);
     }
 
     ret = get_obj_state(&obj_ctx, bucket_info, olh_obj, &state, false); /* don't follow olh */
@@ -7869,7 +7688,7 @@ int RGWRados::unlink_obj_instance(RGWObjectCtx& obj_ctx, RGWBucketInfo& bucket_i
 
   for (i = 0; i < MAX_ECANCELED_RETRY; i++) {
     if (ret == -ECANCELED) {
-      obj_ctx.obj.invalidate(olh_obj);
+      obj_ctx.invalidate(olh_obj);
     }
 
     ret = get_obj_state(&obj_ctx, bucket_info, olh_obj, &state, false); /* don't follow olh */
@@ -10116,9 +9935,13 @@ RGWRados *RGWStoreManager::init_storage_provider(CephContext *cct, bool use_gc_t
 {
   RGWRados *store = new RGWRados;
 
-  store->set_use_cache(use_cache);
-
-  if (store->initialize(cct, use_gc_thread, use_lc_thread, quota_threads, run_sync_thread, run_reshard_thread) < 0) {
+  if ((*store).set_use_cache(use_cache)
+              .set_run_gc_thread(use_gc_thread)
+              .set_run_lc_thread(use_lc_thread)
+              .set_run_quota_threads(quota_threads)
+              .set_run_sync_thread(run_sync_thread)
+              .set_run_reshard_thread(run_reshard_thread)
+              .initialize(cct) < 0) {
     delete store;
     return NULL;
   }
index c01f5b0f505562d1eed86074c3ef721dc92e268d..4230031c377035ac80661fc80587c3ff73ab29e1 100644 (file)
@@ -1064,18 +1064,27 @@ public:
 class RGWGetDirHeader_CB;
 class RGWGetUserHeader_CB;
 
-template <class T, class S>
-class RGWObjectCtxImpl {
+class RGWObjectCtx {
   RGWRados *store;
-  std::map<T, S> objs_state;
-  RWLock lock;
+  RWLock lock{"RGWObjectCtx"};
+  void *s{nullptr};
 
+  std::map<rgw_obj, RGWObjState> objs_state;
 public:
-  explicit RGWObjectCtxImpl(RGWRados *_store) : store(_store), lock("RGWObjectCtxImpl") {}
+  explicit RGWObjectCtx(RGWRados *_store) : store(_store) {}
+  explicit RGWObjectCtx(RGWRados *_store, void *_s) : store(_store), s(_s) {}
 
-  S *get_state(const T& obj) {
-    S *result;
-    typename std::map<T, S>::iterator iter;
+  void *get_private() {
+    return s;
+  }
+
+  RGWRados *get_store() {
+    return store;
+  }
+
+  RGWObjState *get_state(const rgw_obj& obj) {
+    RGWObjState *result;
+    typename std::map<rgw_obj, RGWObjState>::iterator iter;
     lock.get_read();
     assert (!obj.empty());
     iter = objs_state.find(obj);
@@ -1091,34 +1100,34 @@ public:
     return result;
   }
 
-  void set_atomic(T& obj) {
+  void set_atomic(rgw_obj& obj) {
     RWLock::WLocker wl(lock);
     assert (!obj.empty());
     objs_state[obj].is_atomic = true;
   }
-  void set_prefetch_data(T& obj) {
+  void set_prefetch_data(rgw_obj& obj) {
     RWLock::WLocker wl(lock);
     assert (!obj.empty());
     objs_state[obj].prefetch_data = true;
   }
-  void invalidate(const T& obj);
-};
-
-template<>
-void RGWObjectCtxImpl<rgw_obj, RGWObjState>::invalidate(const rgw_obj& obj);
-
-template<>
-void RGWObjectCtxImpl<rgw_raw_obj, RGWRawObjState>::invalidate(const rgw_raw_obj& obj);
-
-struct RGWObjectCtx {
-  RGWRados *store;
-  req_state *s;
 
-  RGWObjectCtxImpl<rgw_obj, RGWObjState> obj;
-  RGWObjectCtxImpl<rgw_raw_obj, RGWRawObjState> raw;
+  void invalidate(const rgw_obj& obj) {
+    RWLock::WLocker wl(lock);
+    auto iter = objs_state.find(obj);
+    if (iter == objs_state.end()) {
+      return;
+    }
+    bool is_atomic = iter->second.is_atomic;
+    bool prefetch_data = iter->second.prefetch_data;
+  
+    objs_state.erase(iter);
 
-  explicit RGWObjectCtx(RGWRados *_store) : store(_store), s(NULL), obj(store), raw(store) { }
-  explicit RGWObjectCtx(RGWRados *_store, req_state *_s) : store(_store), s(_s), obj(store), raw(store) { }
+    if (is_atomic || prefetch_data) {
+      auto& state = objs_state[obj];
+      state.is_atomic = is_atomic;
+      state.prefetch_data = prefetch_data;
+    }
+  }
 };
 
 class RGWAsyncRadosProcessor;
@@ -1248,7 +1257,6 @@ class RGWRados : public AdminSocketHook
 
   int get_olh_target_state(RGWObjectCtx& rctx, const RGWBucketInfo& bucket_info, const rgw_obj& obj,
                            RGWObjState *olh_state, RGWObjState **target_state);
-  int get_system_obj_state_impl(RGWObjectCtx *rctx, rgw_raw_obj& obj, RGWRawObjState **state, RGWObjVersionTracker *objv_tracker);
   int get_obj_state_impl(RGWObjectCtx *rctx, const RGWBucketInfo& bucket_info, const rgw_obj& obj, RGWObjState **state,
                          bool follow_olh, bool assume_noent = false);
   int append_atomic_test(RGWObjectCtx *rctx, const RGWBucketInfo& bucket_info, const rgw_obj& obj,
@@ -1309,8 +1317,34 @@ public:
                cr_registry(NULL),
                meta_mgr(NULL), data_log(NULL), reshard(NULL) {}
 
-  void set_use_cache(bool status) {
+  RGWRados& set_use_cache(bool status) {
     use_cache = status;
+    return *this;
+  }
+
+  RGWRados& set_run_gc_thread(bool _use_gc_thread) {
+    use_gc_thread = _use_gc_thread;
+    return *this;
+  }
+
+  RGWRados& set_run_lc_thread(bool _use_lc_thread) {
+    use_lc_thread = _use_lc_thread;
+    return *this;
+  }
+
+  RGWRados& set_run_quota_threads(bool _run_quota_threads) {
+    quota_threads = _run_quota_threads;
+    return *this;
+  }
+
+  RGWRados& set_run_sync_thread(bool _run_sync_thread) {
+    run_sync_thread = _run_sync_thread;
+    return *this;
+  }
+
+  RGWRados& set_run_reshard_thread(bool _run_reshard_thread) {
+    run_reshard_thread = _run_reshard_thread;
+    return *this;
   }
 
   uint64_t get_new_req_id() {
@@ -1396,17 +1430,10 @@ public:
                        bool *is_truncated);
   string list_raw_objs_get_cursor(RGWListRawObjsCtx& ctx);
 
-  int list_raw_prefixed_objs(const rgw_pool& pool, const string& prefix, list<string>& result);
-
   CephContext *ctx() { return cct; }
   /** do all necessary setup of the storage device */
-  int initialize(CephContext *_cct, bool _use_gc_thread, bool _use_lc_thread, bool _quota_threads, bool _run_sync_thread, bool _run_reshard_thread) {
+  int initialize(CephContext *_cct) {
     set_context(_cct);
-    use_gc_thread = _use_gc_thread;
-    use_lc_thread = _use_lc_thread;
-    quota_threads = _quota_threads;
-    run_sync_thread = _run_sync_thread;
-    run_reshard_thread = _run_reshard_thread;
     return initialize();
   }
   /** Initialize the RADOS instance and prepare to do other ops */
@@ -1418,8 +1445,6 @@ public:
   int register_to_service_map(const string& daemon_type, const map<string, string>& meta);
   int update_service_map(std::map<std::string, std::string>&& status);
 
-  void schedule_context(Context *c);
-
   /** set up a bucket listing. handle is filled in. */
   int list_buckets_init(RGWAccessHandle *handle);
   /** 
@@ -1467,7 +1492,6 @@ public:
                             rgw_bucket *master_bucket,
                             uint32_t *master_num_shards,
                             bool exclusive = true);
-  int create_pools(vector<rgw_pool>& pools, vector<int>& retcodes);
 
   RGWCoroutinesManagerRegistry *get_cr_registry() { return cr_registry; }
 
@@ -1619,7 +1643,7 @@ public:
                      map<std::string, bufferlist>& attrs);
       int write_data(const char *data, uint64_t ofs, uint64_t len, bool exclusive);
       const req_state* get_req_state() {
-        return target->get_ctx().s;
+        return (req_state *)target->get_ctx().get_private();
       }
     };
 
@@ -2017,7 +2041,6 @@ public:
                         map<string, bufferlist>& attrs,
                         map<string, bufferlist>* rmattrs);
 
-  int get_system_obj_state(RGWObjectCtx *rctx, rgw_raw_obj& obj, RGWRawObjState **state, RGWObjVersionTracker *objv_tracker);
   int get_obj_state(RGWObjectCtx *rctx, const RGWBucketInfo& bucket_info, const rgw_obj& obj, RGWObjState **state,
                     bool follow_olh, bool assume_noent = false);
   int get_obj_state(RGWObjectCtx *rctx, const RGWBucketInfo& bucket_info, const rgw_obj& obj, RGWObjState **state) {
@@ -2045,9 +2068,9 @@ public:
    * a simple object read without keeping state
    */
 
-  virtual int raw_obj_stat(rgw_raw_obj& obj, uint64_t *psize, ceph::real_time *pmtime, uint64_t *epoch,
-                       map<string, bufferlist> *attrs, bufferlist *first_chunk,
-                       RGWObjVersionTracker *objv_tracker);
+  int raw_obj_stat(rgw_raw_obj& obj, uint64_t *psize, ceph::real_time *pmtime, uint64_t *epoch,
+                   map<string, bufferlist> *attrs, bufferlist *first_chunk,
+                   RGWObjVersionTracker *objv_tracker);
 
   int obj_operate(const RGWBucketInfo& bucket_info, const rgw_obj& obj, librados::ObjectWriteOperation *op);
   int obj_operate(const RGWBucketInfo& bucket_info, const rgw_obj& obj, librados::ObjectReadOperation *op);
@@ -2098,11 +2121,11 @@ public:
 public:
   void set_atomic(void *ctx, rgw_obj& obj) {
     RGWObjectCtx *rctx = static_cast<RGWObjectCtx *>(ctx);
-    rctx->obj.set_atomic(obj);
+    rctx->set_atomic(obj);
   }
   void set_prefetch_data(void *ctx, rgw_obj& obj) {
     RGWObjectCtx *rctx = static_cast<RGWObjectCtx *>(ctx);
-    rctx->obj.set_prefetch_data(obj);
+    rctx->set_prefetch_data(obj);
   }
   int decode_policy(bufferlist& bl, ACLOwner *owner);
   int get_bucket_stats(RGWBucketInfo& bucket_info, int shard_id, string *bucket_ver, string *master_ver,
@@ -2148,20 +2171,20 @@ protected:
   // `cache_list_dump_helper` with the supplied Formatter on any that
   // include `filter` as a substring.
   //
-  virtual void call_list(const std::optional<std::string>& filter,
+  void call_list(const std::optional<std::string>& filter,
                         Formatter* format);
   // `call_inspect` must look up the requested target and, if found,
   // dump it to the supplied Formatter and return true. If not found,
   // it must return false.
   //
-  virtual bool call_inspect(const std::string& target, Formatter* format);
+  bool call_inspect(const std::string& target, Formatter* format);
 
   // `call_erase` must erase the requested target and return true. If
   // the requested target does not exist, it should return false.
-  virtual bool call_erase(const std::string& target);
+  bool call_erase(const std::string& target);
 
   // `call_zap` must erase the cache.
-  virtual void call_zap();
+  void call_zap();
 public:
 
   int get_bucket_info(RGWSysObjectCtx& obj_ctx,
index df49e500e840ef7fe0df9f43bd56f185aacc9a99..97cbf9a4fc0d2f476de67cf62f6fd86ae1ab770d 100644 (file)
@@ -3559,8 +3559,8 @@ bool RGWHandler_REST_S3Website::web_dir() const {
   rgw_obj obj(s->bucket, subdir_name);
 
   RGWObjectCtx& obj_ctx = *static_cast<RGWObjectCtx *>(s->obj_ctx);
-  obj_ctx.obj.set_atomic(obj);
-  obj_ctx.obj.set_prefetch_data(obj);
+  obj_ctx.set_atomic(obj);
+  obj_ctx.set_prefetch_data(obj);
 
   RGWObjState* state = nullptr;
   if (store->get_obj_state(&obj_ctx, s->bucket_info, obj, &state, false) < 0) {
index 9f4ff3901230b3940ca405813939181f6644d538..3d94fbb7fb085cb61bcc364d5f60871871b50b8b 100644 (file)
@@ -2548,8 +2548,8 @@ bool RGWSwiftWebsiteHandler::is_web_dir() const
 
   /* First, get attrset of the object we'll try to retrieve. */
   RGWObjectCtx& obj_ctx = *static_cast<RGWObjectCtx *>(s->obj_ctx);
-  obj_ctx.obj.set_atomic(obj);
-  obj_ctx.obj.set_prefetch_data(obj);
+  obj_ctx.set_atomic(obj);
+  obj_ctx.set_prefetch_data(obj);
 
   RGWObjState* state = nullptr;
   if (store->get_obj_state(&obj_ctx, s->bucket_info, obj, &state, false) < 0) {
@@ -2578,8 +2578,8 @@ bool RGWSwiftWebsiteHandler::is_index_present(const std::string& index)
   rgw_obj obj(s->bucket, index);
 
   RGWObjectCtx& obj_ctx = *static_cast<RGWObjectCtx *>(s->obj_ctx);
-  obj_ctx.obj.set_atomic(obj);
-  obj_ctx.obj.set_prefetch_data(obj);
+  obj_ctx.set_atomic(obj);
+  obj_ctx.set_prefetch_data(obj);
 
   RGWObjState* state = nullptr;
   if (store->get_obj_state(&obj_ctx, s->bucket_info, obj, &state, false) < 0) {
index 5fea6f0c8e0aa81fc1c0147aadf792740a7c7fb5..54bb81cf36fcfdb3b604569f4e7d0b44ba23273e 100644 (file)
@@ -225,7 +225,7 @@ int RGWSI_RADOS::Pool::create(const vector<rgw_pool>& pools, vector<int> *retcod
   vector<librados::PoolAsyncCompletion *>::iterator citer;
 
   bool error = false;
-  assert(rets.size() == completions.size());
+  ceph_assert(rets.size() == completions.size());
   for (riter = rets.begin(), citer = completions.begin(); riter != rets.end(); ++riter, ++citer) {
     int r = *riter;
     librados::PoolAsyncCompletion *c = *citer;
@@ -266,7 +266,7 @@ int RGWSI_RADOS::Pool::create(const vector<rgw_pool>& pools, vector<int> *retcod
     completions.push_back(c);
     int ret = io_ctx.application_enable_async(pg_pool_t::APPLICATION_NAME_RGW,
                                               false, c);
-    assert(ret == 0);
+    ceph_assert(ret == 0);
   }
 
   retcodes->clear();