]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw/mdlog: add complete_entry() for most common usage
authorCasey Bodley <cbodley@redhat.com>
Fri, 5 Jan 2024 15:26:00 +0000 (10:26 -0500)
committerCasey Bodley <cbodley@redhat.com>
Tue, 5 Mar 2024 17:55:25 +0000 (12:55 -0500)
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 <cbodley@redhat.com>
src/rgw/services/svc_mdlog.cc
src/rgw/services/svc_mdlog.h

index 46a158ceb77b6ee0aea3093180c29d5ce8ceb4ca..03a967d12673bd9dd9969cf671f8c23a5b2d9871 100644 (file)
@@ -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()
index f169ee88db9bc66b82510d33f6d156c7fc2186d2..c8d40b1387428ca435466145265ae71bae74c929 100644 (file)
@@ -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() {