From: Alex Ainscow Date: Mon, 24 Nov 2025 21:06:11 +0000 (+0000) Subject: librados: Deprecate librados C-only read op exec functions X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=10e351619f0edaa05a38d9fd97eccfdb919f9295;p=ceph-ci.git librados: Deprecate librados C-only read op exec functions 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 --- diff --git a/src/include/rados/librados.h b/src/include/rados/librados.h index d788e64e2a5..abb6406ab2d 100644 --- a/src/include/rados/librados.h +++ b/src/include/rados/librados.h @@ -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. diff --git a/src/test/librados/c_read_operations.cc b/src/test/librados/c_read_operations.cc index d40be05d209..d8f5a7c41ca 100644 --- a/src/test/librados/c_read_operations.cc +++ b/src/test/librados/c_read_operations.cc @@ -14,6 +14,18 @@ #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();