#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"
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();
#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"
/// 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`,
/// `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