]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
librados: Deprecate librados C-only read op exec functions
authorAlex Ainscow <aainscow@uk.ibm.com>
Mon, 24 Nov 2025 21:06:11 +0000 (21:06 +0000)
committerAlex Ainscow <aainscow@uk.ibm.com>
Fri, 28 Nov 2025 14:28:19 +0000 (14:28 +0000)
These read op exec functions are dangerous, in that they do not check that the operation
is really read only.  There are no clients that use these interfaces in the Ceph code
base. However, this forms part of the API and therefore must be maintained for now.

Signed-off-by: Alex Ainscow <aainscow@uk.ibm.com>
src/include/rados/librados.h
src/test/librados/c_read_operations.cc

index d788e64e2a5278b97a5b3bbc7f57a625df148adb..abb6406ab2d57bf75fcfc04adac8901109fc864d 100644 (file)
@@ -377,7 +377,7 @@ typedef void *rados_write_op_t;
  *   rados_read_op_assert_version()
  * - IO on objects: rados_read_op_read(), rados_read_op_checksum(),
  *   rados_read_op_cmpext()
- * - Custom operations: rados_read_op_exec(), rados_read_op_exec_user_buf()
+ * - Deprecated operations: rados_read_op_exec(), rados_read_op_exec_user_buf()
  * - Request properties: rados_read_op_set_flags()
  * - Performing the operation: rados_read_op_operate(),
  *   rados_aio_read_op_operate()
@@ -3439,6 +3439,11 @@ CEPH_RADOS_API void rados_read_op_checksum(rados_read_op_t read_op,
                                           size_t checksum_len, int *prval);
 
 /**
+ * Deprecated because this op does not prevent the client specifying a cls op
+ * that includes a write operation. This could allow the op to be routed to
+ * invalid OSD. Reads are permitted as part of write ops. If performance is a
+ * concern, consider moving to the C++ interface, which provides safety.
+ *
  * Execute an OSD class method on an object
  * See rados_exec() for general description.
  *
@@ -3463,9 +3468,15 @@ CEPH_RADOS_API void rados_read_op_exec(rados_read_op_t read_op,
                                       size_t in_len,
                                       char **out_buf,
                                       size_t *out_len,
-                                      int *prval);
+                                      int *prval)
+  __attribute__((deprecated("Use write ops instead")));
 
 /**
+  * * Deprecated because this op does not prevent the client specifying a cls op
+   * that includes a write operation. This could allow the op to be routed to
+   * invalid OSD. Reads are permitted as part of write ops. If performance is a
+   * concern, consider moving to the C++ interface, which provides safety.
+   *
  * Execute an OSD class method on an object
  * See rados_exec() for general description.
  *
@@ -3490,7 +3501,8 @@ CEPH_RADOS_API void rados_read_op_exec_user_buf(rados_read_op_t read_op,
                                                char *out_buf,
                                                size_t out_len,
                                                size_t *used_len,
-                                               int *prval);
+                                               int *prval)
+  __attribute__((deprecated("Use write ops instead")));
 
 /**
  * Start iterating over key/value pairs on an object.
index d40be05d209ceaad11cc6ee9e0dcccd8c2ef80f5..d8f5a7c41ca43469a3941689ee68022bfa9dabfe 100644 (file)
 #include "test/librados/TestCase.h"
 #include "test/librados/test.h"
 
+// Some tests are performed on deprecated interfaces that have not yet
+// been removed and form part of the ABI/API.
+#define IGNORE_DEPRECATED \
+_Pragma("GCC diagnostic push") \
+_Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\" ") \
+_Pragma("clang diagnostic push") \
+_Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"")
+
+#define END_IGNORE_DEPRECATED \
+_Pragma("clang pop") \
+_Pragma("GCC pop")
+
 const char *data = "testdata";
 const char *obj = "testobj";
 const size_t len = strlen(data);
@@ -187,6 +199,7 @@ TEST_F(CReadOpsTest, NewDelete) {
   rados_release_read_op(op);
 }
 
+IGNORE_DEPRECATED
 TEST_F(CReadOpsTest, SetOpFlags) {
   write_object();
 
@@ -205,6 +218,7 @@ TEST_F(CReadOpsTest, SetOpFlags) {
 
   remove_object();
 }
+END_IGNORE_DEPRECATED
 
 TEST_F(CReadOpsTest, AssertExists) {
   rados_read_op_t op = rados_create_read_op();
@@ -511,6 +525,7 @@ TEST_F(CReadOpsTest, ShortRead) {
   remove_object();
 }
 
+IGNORE_DEPRECATED
 TEST_F(CReadOpsTest, Exec) {
   // create object so we don't get -ENOENT
   write_object();
@@ -574,6 +589,7 @@ TEST_F(CReadOpsTest, ExecUserBuf) {
 
   remove_object();
 }
+END_IGNORE_DEPRECATED
 
 TEST_F(CReadOpsTest, Stat) {
   rados_read_op_t op = rados_create_read_op();