From: Casey Bodley Date: Fri, 5 Jan 2024 15:26:00 +0000 (-0500) Subject: rgw/mdlog: add complete_entry() for most common usage X-Git-Tag: v20.0.0~2440^2~9 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=7827b2527f6b656331ae337ebc196c17b2716e48;p=ceph.git rgw/mdlog: add complete_entry() for most common usage metadata sync ignores entries other than MDLOG_STATUS_COMPLETE, so we don't need to write separate prepare/complete entries. metadata mutations can just call complete_entry() on success Signed-off-by: Casey Bodley --- diff --git a/src/rgw/services/svc_mdlog.cc b/src/rgw/services/svc_mdlog.cc index 46a158ceb77b6..03a967d12673b 100644 --- a/src/rgw/services/svc_mdlog.cc +++ b/src/rgw/services/svc_mdlog.cc @@ -544,6 +544,24 @@ int RGWSI_MDLog::add_entry(const DoutPrefixProvider *dpp, const string& hash_key return current_log->add_entry(dpp, hash_key, section, key, bl, y); } +int RGWSI_MDLog::complete_entry(const DoutPrefixProvider* dpp, optional_yield y, + const std::string& section, const std::string& key, + const RGWObjVersionTracker* objv) +{ + RGWMetadataLogData entry; + if (objv) { + entry.read_version = objv->read_version; + entry.write_version = objv->write_version; + } + entry.status = MDLOG_STATUS_COMPLETE; + + bufferlist bl; + encode(entry, bl); + + const std::string hash_key = fmt::format("{}:{}", section, key); + return add_entry(dpp, hash_key, section, key, bl, y); +} + int RGWSI_MDLog::get_shard_id(const string& hash_key, int *shard_id) { ceph_assert(current_log); // must have called init() diff --git a/src/rgw/services/svc_mdlog.h b/src/rgw/services/svc_mdlog.h index f169ee88db9bc..c8d40b1387428 100644 --- a/src/rgw/services/svc_mdlog.h +++ b/src/rgw/services/svc_mdlog.h @@ -106,6 +106,11 @@ public: int add_entry(const DoutPrefixProvider *dpp, const std::string& hash_key, const std::string& section, const std::string& key, bufferlist& bl, optional_yield y); + // encode a RGWMetadataLogData with MDLOG_STATUS_COMPLETE and add it + int complete_entry(const DoutPrefixProvider* dpp, optional_yield y, + const std::string& section, const std::string& key, + const RGWObjVersionTracker* objv); + int get_shard_id(const std::string& hash_key, int *shard_id); RGWPeriodHistory *get_period_history() {