]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librados: add rados_aio_write_op_operate2() for high-resolution timestamps
authorCasey Bodley <cbodley@redhat.com>
Tue, 23 May 2023 17:24:42 +0000 (13:24 -0400)
committerCasey Bodley <cbodley@redhat.com>
Mon, 19 Jun 2023 18:31:41 +0000 (14:31 -0400)
expose the aio version of rados_write_op_operate2() for mtimes in timespec form

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 7d58f1832d8d8bc1148240d347be85850b86adfa)

src/include/rados/librados.h
src/librados/librados_c.cc
src/tracing/librados.tp

index e40dc4665367025876d75228c5d064833d7b5172..858804c3a03fa0f508989c6a3de01b596249f7f5 100644 (file)
@@ -3226,6 +3226,22 @@ CEPH_RADOS_API int rados_aio_write_op_operate(rados_write_op_t write_op,
                                               time_t *mtime,
                                              int flags);
 
+/**
+ * Perform a write operation asynchronously
+ * @param write_op operation to perform
+ * @param io the ioctx that the object is in
+ * @param completion what to do when operation has been attempted
+ * @param oid the object id
+ * @param mtime the time to set the mtime to, NULL for the current time
+ * @param flags flags to apply to the entire operation (LIBRADOS_OPERATION_*)
+ */
+CEPH_RADOS_API int rados_aio_write_op_operate2(rados_write_op_t write_op,
+                                               rados_ioctx_t io,
+                                               rados_completion_t completion,
+                                               const char *oid,
+                                               struct timespec *mtime,
+                                               int flags);
+
 /**
  * Create a new rados_read_op_t read operation. This will store all
  * actions to be performed atomically. You must call
index e88d067cae6002918a8cf3de7a201792a8ba4a76..a0eb6e08c5225453fd0d762c332a52f5969ea209 100644 (file)
@@ -4059,6 +4059,31 @@ extern "C" int LIBRADOS_C_API_DEFAULT_F(rados_aio_write_op_operate)(
 }
 LIBRADOS_C_API_BASE_DEFAULT(rados_aio_write_op_operate);
 
+extern "C" int LIBRADOS_C_API_DEFAULT_F(rados_aio_write_op_operate2)(
+  rados_write_op_t write_op,
+  rados_ioctx_t io,
+  rados_completion_t completion,
+  const char *oid,
+  struct timespec *mtime,
+  int flags)
+{
+  tracepoint(librados, rados_aio_write_op_operate2_enter, write_op, io, completion, oid, mtime, flags);
+  object_t obj(oid);
+  auto oimpl = static_cast<librados::ObjectOperationImpl*>(write_op);
+  librados::IoCtxImpl *ctx = (librados::IoCtxImpl *)io;
+  librados::AioCompletionImpl *c = (librados::AioCompletionImpl*)completion;
+
+  if (mtime) {
+    oimpl->rt = ceph::real_clock::from_timespec(*mtime);
+    oimpl->prt = &oimpl->rt;
+  }
+
+  int retval = ctx->aio_operate(obj, &oimpl->o, c, ctx->snapc, oimpl->prt, translate_flags(flags));
+  tracepoint(librados, rados_aio_write_op_operate_exit, retval);
+  return retval;
+}
+LIBRADOS_C_API_BASE_DEFAULT(rados_aio_write_op_operate2);
+
 extern "C" rados_read_op_t LIBRADOS_C_API_DEFAULT_F(rados_create_read_op)()
 {
   tracepoint(librados, rados_create_read_op_enter);
index 42559097b84232df1952f122ad8b336c03f26788..8b5e78ef15d65410131ac0d4cbdfe8564660bbdc 100644 (file)
@@ -3597,6 +3597,24 @@ TRACEPOINT_EVENT(librados, rados_aio_write_op_operate_enter,
     )
 )
 
+TRACEPOINT_EVENT(librados, rados_aio_write_op_operate2_enter,
+    TP_ARGS(
+        rados_write_op_t, op,
+        rados_ioctx_t, ioctx,
+        rados_completion_t, completion,
+        const char*, oid,
+        struct timespec*, ts,
+        int, flags),
+    TP_FIELDS(
+        ctf_integer_hex(rados_write_op_t, op, op)
+        ctf_integer_hex(rados_ioctx_t, ioctx, ioctx)
+        ctf_integer_hex(rados_completion_t, completion, completion)
+        ctf_string(oid, oid)
+        ceph_ctf_timespecp(ts, ts)
+        ctf_integer_hex(int, flags, flags)
+    )
+)
+
 TRACEPOINT_EVENT(librados, rados_aio_write_op_operate_exit,
     TP_ARGS(
         int, retval),