From: Casey Bodley Date: Mon, 23 Jan 2017 19:59:33 +0000 (-0500) Subject: rgw: use objv_tracker for mdlog history X-Git-Tag: v12.0.3~20^2~17 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=2c7897309617b29fc24a85ae21efffc387908380;p=ceph.git rgw: use objv_tracker for mdlog history Signed-off-by: Casey Bodley --- diff --git a/src/rgw/rgw_metadata.cc b/src/rgw/rgw_metadata.cc index e26201bc3be4..6ad2d1fd1f67 100644 --- a/src/rgw/rgw_metadata.cc +++ b/src/rgw/rgw_metadata.cc @@ -313,28 +313,6 @@ public: static RGWMetadataTopHandler md_top_handler; -static const std::string mdlog_history_oid = "meta.history"; - -struct RGWMetadataLogHistory { - epoch_t oldest_realm_epoch; - std::string oldest_period_id; - - void encode(bufferlist& bl) const { - ENCODE_START(1, 1, bl); - ::encode(oldest_realm_epoch, bl); - ::encode(oldest_period_id, bl); - ENCODE_FINISH(bl); - } - void decode(bufferlist::iterator& p) { - DECODE_START(1, p); - ::decode(oldest_realm_epoch, p); - ::decode(oldest_period_id, p); - DECODE_FINISH(p); - } -}; -WRITE_CLASS_ENCODER(RGWMetadataLogHistory) - - RGWMetadataManager::RGWMetadataManager(CephContext *_cct, RGWRados *_store) : cct(_cct), store(_store) { @@ -351,15 +329,18 @@ RGWMetadataManager::~RGWMetadataManager() handlers.clear(); } +const std::string RGWMetadataLogHistory::oid = "meta.history"; + namespace { -int read_history(RGWRados *store, RGWMetadataLogHistory *state) +int read_history(RGWRados *store, RGWMetadataLogHistory *state, + RGWObjVersionTracker *objv_tracker) { RGWObjectCtx ctx{store}; auto& pool = store->get_zone_params().log_pool; - const auto& oid = mdlog_history_oid; + const auto& oid = RGWMetadataLogHistory::oid; bufferlist bl; - int ret = rgw_get_system_obj(store, ctx, pool, oid, bl, nullptr, nullptr); + int ret = rgw_get_system_obj(store, ctx, pool, oid, bl, objv_tracker, nullptr); if (ret < 0) { return ret; } @@ -375,15 +356,15 @@ int read_history(RGWRados *store, RGWMetadataLogHistory *state) } int write_history(RGWRados *store, const RGWMetadataLogHistory& state, - bool exclusive = false) + RGWObjVersionTracker *objv_tracker, bool exclusive = false) { bufferlist bl; state.encode(bl); auto& pool = store->get_zone_params().log_pool; - const auto& oid = mdlog_history_oid; + const auto& oid = RGWMetadataLogHistory::oid; return rgw_put_system_obj(store, pool, oid, bl.c_str(), bl.length(), - exclusive, nullptr, real_time{}); + exclusive, objv_tracker, real_time{}); } using Cursor = RGWPeriodHistory::Cursor; @@ -431,7 +412,8 @@ Cursor RGWMetadataManager::init_oldest_log_period() { // read the mdlog history RGWMetadataLogHistory state; - int ret = read_history(store, &state); + RGWObjVersionTracker objv; + int ret = read_history(store, &state, &objv); if (ret == -ENOENT) { // initialize the mdlog history and write it @@ -446,7 +428,7 @@ Cursor RGWMetadataManager::init_oldest_log_period() state.oldest_period_id = cursor.get_period().get_id(); constexpr bool exclusive = true; // don't overwrite - int ret = write_history(store, state, exclusive); + int ret = write_history(store, state, &objv, exclusive); if (ret < 0 && ret != -EEXIST) { ldout(cct, 1) << "failed to write mdlog history: " << cpp_strerror(ret) << dendl; @@ -486,7 +468,7 @@ Cursor RGWMetadataManager::init_oldest_log_period() Cursor RGWMetadataManager::read_oldest_log_period() const { RGWMetadataLogHistory state; - int ret = read_history(store, &state); + int ret = read_history(store, &state, nullptr); if (ret < 0) { ldout(store->ctx(), 1) << "failed to read mdlog history: " << cpp_strerror(ret) << dendl; diff --git a/src/rgw/rgw_metadata.h b/src/rgw/rgw_metadata.h index 8b7526399a8d..d19fa8bfa7bd 100644 --- a/src/rgw/rgw_metadata.h +++ b/src/rgw/rgw_metadata.h @@ -265,6 +265,27 @@ struct RGWMetadataLogData { }; WRITE_CLASS_ENCODER(RGWMetadataLogData) +struct RGWMetadataLogHistory { + epoch_t oldest_realm_epoch; + std::string oldest_period_id; + + void encode(bufferlist& bl) const { + ENCODE_START(1, 1, bl); + ::encode(oldest_realm_epoch, bl); + ::encode(oldest_period_id, bl); + ENCODE_FINISH(bl); + } + void decode(bufferlist::iterator& p) { + DECODE_START(1, p); + ::decode(oldest_realm_epoch, p); + ::decode(oldest_period_id, p); + DECODE_FINISH(p); + } + + static const std::string oid; +}; +WRITE_CLASS_ENCODER(RGWMetadataLogHistory) + class RGWMetadataManager { map handlers; CephContext *cct;