]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: Add neorados functions to RGWObjVersionTracker
authorAdam Emerson <aemerson@redhat.com>
Sat, 11 May 2024 02:27:25 +0000 (22:27 -0400)
committerAdam C. Emerson <aemerson@redhat.com>
Tue, 1 Apr 2025 15:10:13 +0000 (11:10 -0400)
Signed-off-by: Adam Emerson <aemerson@redhat.com>
src/rgw/driver/rados/rgw_rados.cc
src/rgw/rgw_common.h

index 162387db5d0ce934364fa5093ada08db1651ae74..76fec9236dcaa0ef25b18549f086b9080c36d5b0 100644 (file)
@@ -46,6 +46,8 @@
 #include "cls/version/cls_version_client.h"
 #include "osd/osd_types.h"
 
+#include "neorados/cls/version.h"
+
 #include "rgw_tools.h"
 #include "rgw_coroutine.h"
 #include "rgw_compression.h"
@@ -169,6 +171,33 @@ void RGWObjVersionTracker::prepare_op_for_read(ObjectReadOperation* op)
   cls_version_read(*op, &read_version);
 }
 
+void RGWObjVersionTracker::prepare_read(neorados::ReadOp& op) {
+  namespace version = neorados::cls::version;
+  auto check_objv = version_for_check();
+
+  if (check_objv) {
+    op.exec(version::check(*check_objv, VER_COND_EQ));
+  }
+
+  op.exec(version::read(&read_version));
+}
+
+void RGWObjVersionTracker::prepare_write(neorados::WriteOp& op) {
+  namespace version = neorados::cls::version;
+  auto check_objv = version_for_check();
+  auto modify_version = version_for_write();
+
+  if (check_objv) {
+    op.exec(version::check(*check_objv, VER_COND_EQ));
+  }
+
+  if (modify_version) {
+    op.exec(version::set(*modify_version));
+  } else {
+    op.exec(version::inc());
+  }
+}
+
 void RGWObjVersionTracker::prepare_op_for_write(ObjectWriteOperation *op)
 {
   obj_version* check_objv = version_for_check();
index 9c50d4a04f1b7a640ccb609c72ccbcdbba322cf6..a7d3bbef624806bf6e5c6eb418d5adcb98546eaa 100644 (file)
@@ -27,6 +27,8 @@
 #include <boost/container/flat_set.hpp>
 
 #include "common/dout_fmt.h"
+#include "include/neorados/RADOS.hpp"
+
 #include "common/ceph_crypto.h"
 #include "common/random_string.h"
 #include "common/tracer.h"
@@ -980,6 +982,14 @@ struct RGWObjVersionTracker {
   /// This function is defined in `rgw_rados.cc` rather than `rgw_common.cc`.
   void prepare_op_for_read(librados::ObjectReadOperation* op);
 
+  /// This function is to be called on any read operation. If we have
+  /// a non-empty `read_version`, assert on the OSD that the object
+  /// has the same version. Also reads the version into `read_version`.
+  ///
+  /// This function is defined in `rgw_rados.cc` rather than
+  /// `rgw_common.cc`.
+  void prepare_read(neorados::ReadOp& op);
+
   /// This function is to be called on any write operation. If we have
   /// a non-empty read operation, assert on the OSD that the object
   /// has the same version. If we have a non-empty `write_version`,
@@ -989,6 +999,15 @@ struct RGWObjVersionTracker {
   /// `rgw_common.cc`.
   void prepare_op_for_write(librados::ObjectWriteOperation* op);
 
+  /// This function is to be called on any write operation. If we have
+  /// a non-empty read operation, assert on the OSD that the object
+  /// has the same version. If we have a non-empty `write_version`,
+  /// set the object to it. Otherwise increment the version on the OSD.
+  ///
+  /// This function is defined in `rgw_rados.cc` rather than
+  /// `rgw_common.cc`.
+  void prepare_write(neorados::WriteOp& op);
+
   /// This function is to be called after the completion of any write
   /// operation on which `prepare_op_for_write` was called. If we did
   /// not set the write version explicitly, it increments