diff options
Diffstat (limited to 'src/rgw/rgw_metadata.cc')
-rw-r--r-- | src/rgw/rgw_metadata.cc | 212 |
1 files changed, 3 insertions, 209 deletions
diff --git a/src/rgw/rgw_metadata.cc b/src/rgw/rgw_metadata.cc index a6d75de0eba..92b03e41bcd 100644 --- a/src/rgw/rgw_metadata.cc +++ b/src/rgw/rgw_metadata.cc @@ -5,10 +5,6 @@ #include "rgw_mdlog.h" - -#include "services/svc_meta.h" -#include "services/svc_meta_be_sobj.h" - #define dout_subsys ceph_subsys_rgw using namespace std; @@ -111,214 +107,16 @@ void RGWMetadataLogData::generate_test_instances(std::list<RGWMetadataLogData *> l.back()->status = MDLOG_STATUS_WRITE; } -RGWMetadataHandler_GenericMetaBE::Put::Put(RGWMetadataHandler_GenericMetaBE *_handler, - RGWSI_MetaBackend_Handler::Op *_op, - string& _entry, RGWMetadataObject *_obj, - RGWObjVersionTracker& _objv_tracker, - optional_yield _y, - RGWMDLogSyncType _type, bool _from_remote_zone): - handler(_handler), op(_op), - entry(_entry), obj(_obj), - objv_tracker(_objv_tracker), - apply_type(_type), - y(_y), - from_remote_zone(_from_remote_zone) -{ -} - -int RGWMetadataHandler_GenericMetaBE::do_put_operate(Put *put_op, const DoutPrefixProvider *dpp) -{ - int r = put_op->put_pre(dpp); - if (r != 0) { /* r can also be STATUS_NO_APPLY */ - return r; - } - - r = put_op->put(dpp); - if (r != 0) { - return r; - } - - r = put_op->put_post(dpp); - if (r != 0) { /* e.g., -error or STATUS_APPLIED */ - return r; - } - - return 0; -} - -int RGWMetadataHandler_GenericMetaBE::get(string& entry, RGWMetadataObject **obj, optional_yield y, const DoutPrefixProvider *dpp) -{ - return be_handler->call([&](RGWSI_MetaBackend_Handler::Op *op) { - return do_get(op, entry, obj, y, dpp); - }); -} - -int RGWMetadataHandler_GenericMetaBE::put(string& entry, RGWMetadataObject *obj, RGWObjVersionTracker& objv_tracker, - optional_yield y, const DoutPrefixProvider *dpp, RGWMDLogSyncType type, bool from_remote_zone) -{ - return be_handler->call([&](RGWSI_MetaBackend_Handler::Op *op) { - return do_put(op, entry, obj, objv_tracker, y, dpp, type, from_remote_zone); - }); -} - -int RGWMetadataHandler_GenericMetaBE::remove(string& entry, RGWObjVersionTracker& objv_tracker, optional_yield y, const DoutPrefixProvider *dpp) -{ - return be_handler->call([&](RGWSI_MetaBackend_Handler::Op *op) { - return do_remove(op, entry, objv_tracker, y, dpp); - }); -} - -int RGWMetadataHandler_GenericMetaBE::mutate(const string& entry, - const ceph::real_time& mtime, - RGWObjVersionTracker *objv_tracker, - optional_yield y, - const DoutPrefixProvider *dpp, - RGWMDLogStatus op_type, - std::function<int()> f) -{ - return be_handler->call([&](RGWSI_MetaBackend_Handler::Op *op) { - RGWSI_MetaBackend::MutateParams params(mtime, op_type); - return op->mutate(entry, - params, - objv_tracker, - y, - f, - dpp); - }); -} - -int RGWMetadataHandler_GenericMetaBE::get_shard_id(const string& entry, int *shard_id) -{ - return be_handler->call([&](RGWSI_MetaBackend_Handler::Op *op) { - return op->get_shard_id(entry, shard_id); - }); -} - -int RGWMetadataHandler_GenericMetaBE::list_keys_init(const DoutPrefixProvider *dpp, const string& marker, void **phandle) -{ - auto op = std::make_unique<RGWSI_MetaBackend_Handler::Op_ManagedCtx>(be_handler); - - int ret = op->list_init(dpp, marker); - if (ret < 0) { - return ret; - } - - *phandle = (void *)op.release(); - - return 0; -} - -int RGWMetadataHandler_GenericMetaBE::list_keys_next(const DoutPrefixProvider *dpp, void *handle, int max, list<string>& keys, bool *truncated) -{ - auto op = static_cast<RGWSI_MetaBackend_Handler::Op_ManagedCtx *>(handle); - - int ret = op->list_next(dpp, max, &keys, truncated); - if (ret < 0 && ret != -ENOENT) { - return ret; - } - if (ret == -ENOENT) { - if (truncated) { - *truncated = false; - } - return 0; - } - - return 0; -} - -void RGWMetadataHandler_GenericMetaBE::list_keys_complete(void *handle) -{ - auto op = static_cast<RGWSI_MetaBackend_Handler::Op_ManagedCtx *>(handle); - delete op; -} - -string RGWMetadataHandler_GenericMetaBE::get_marker(void *handle) -{ - auto op = static_cast<RGWSI_MetaBackend_Handler::Op_ManagedCtx *>(handle); - string marker; - int r = op->list_get_marker(&marker); - if (r < 0) { - ldout(cct, 0) << "ERROR: " << __func__ << "(): list_get_marker() returned: r=" << r << dendl; - /* not much else to do */ - } - - return marker; -} - -RGWMetadataHandlerPut_SObj::RGWMetadataHandlerPut_SObj(RGWMetadataHandler_GenericMetaBE *handler, - RGWSI_MetaBackend_Handler::Op *op, - string& entry, RGWMetadataObject *obj, RGWObjVersionTracker& objv_tracker, - optional_yield y, - RGWMDLogSyncType type, bool from_remote_zone) : Put(handler, op, entry, obj, objv_tracker, y, type, from_remote_zone) { -} - -int RGWMetadataHandlerPut_SObj::put_pre(const DoutPrefixProvider *dpp) -{ - int ret = get(&old_obj, dpp); - if (ret < 0 && ret != -ENOENT) { - return ret; - } - exists = (ret != -ENOENT); - - oo.reset(old_obj); - - auto old_ver = (!old_obj ? obj_version() : old_obj->get_version()); - auto old_mtime = (!old_obj ? ceph::real_time() : old_obj->get_mtime()); - - // are we actually going to perform this put, or is it too old? - if (!handler->check_versions(exists, old_ver, old_mtime, - objv_tracker.write_version, obj->get_mtime(), - apply_type)) { - return STATUS_NO_APPLY; - } - - objv_tracker.read_version = old_ver; /* maintain the obj version we just read */ - - return 0; -} - -int RGWMetadataHandlerPut_SObj::put(const DoutPrefixProvider *dpp) -{ - int ret = put_check(dpp); - if (ret != 0) { - return ret; - } - - return put_checked(dpp); -} - -int RGWMetadataHandlerPut_SObj::put_checked(const DoutPrefixProvider *dpp) -{ - RGWSI_MBSObj_PutParams params(obj->get_pattrs(), obj->get_mtime()); - - encode_obj(¶ms.bl); - - int ret = op->put(entry, params, &objv_tracker, y, dpp); - if (ret < 0) { - return ret; - } - - return 0; -} - class RGWMetadataTopHandler : public RGWMetadataHandler { struct iter_data { set<string> sections; set<string>::iterator iter; }; - struct Svc { - RGWSI_Meta *meta{nullptr}; - } svc; - RGWMetadataManager *mgr; public: - RGWMetadataTopHandler(RGWSI_Meta *meta_svc, - RGWMetadataManager *_mgr) : mgr(_mgr) { - base_init(meta_svc->ctx()); - svc.meta = meta_svc; - } + explicit RGWMetadataTopHandler(RGWMetadataManager *_mgr) : mgr(_mgr) {} string get_type() override { return string(); } @@ -389,8 +187,6 @@ public: } }; -RGWMetadataHandlerPut_SObj::~RGWMetadataHandlerPut_SObj() {} - int RGWMetadataHandler::attach(RGWMetadataManager *manager) { return manager->register_handler(this); @@ -403,10 +199,9 @@ obj_version& RGWMetadataObject::get_version() return objv; } -RGWMetadataManager::RGWMetadataManager(RGWSI_Meta *_meta_svc) - : cct(_meta_svc->ctx()), meta_svc(_meta_svc) +RGWMetadataManager::RGWMetadataManager() { - md_top_handler.reset(new RGWMetadataTopHandler(meta_svc, this)); + md_top_handler.reset(new RGWMetadataTopHandler(this)); } RGWMetadataManager::~RGWMetadataManager() @@ -679,7 +474,6 @@ void RGWMetadataManager::dump_log_entry(cls_log_entry& entry, Formatter *f) encode_json("data", log_data, f); } catch (buffer::error& err) { - lderr(cct) << "failed to decode log entry: " << entry.section << ":" << entry.name<< " ts=" << entry.timestamp << dendl; } f->close_section(); } |