From 049d7d35abe0aa2560e3bb9d4fafb43eefb4a0ed Mon Sep 17 00:00:00 2001 From: Wang Chao Date: Sat, 10 Aug 2024 19:40:52 +0800 Subject: pybind/rados: fix the incorrect order of offset,length in WriteOp.zero The offset and length parameters in the rados pybind `WriteOp.zero()` method are being passed to the rados_write_op_zero() function in the incorrect order. Incorrect order cause OP_ZERO not work correctly when use pybind's rados. Signed-off-by: Wang Chao --- src/pybind/rados/rados.pyx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pybind/rados/rados.pyx b/src/pybind/rados/rados.pyx index b54ebb483c6..bcfa6777f3d 100644 --- a/src/pybind/rados/rados.pyx +++ b/src/pybind/rados/rados.pyx @@ -1870,7 +1870,7 @@ cdef class WriteOp(object): uint64_t _offset = offset with nogil: - rados_write_op_zero(self.write_op, _length, _offset) + rados_write_op_zero(self.write_op, _offset, _length) def truncate(self, offset: int): """ -- cgit v1.2.3 From 3a27c3e58fca96d0f0c80a1d264cb3f5f156f5c3 Mon Sep 17 00:00:00 2001 From: Wang Chao Date: Tue, 13 Aug 2024 21:34:12 +0800 Subject: test/pybind/test_rados.py: add test for reversed arguments offset,length in WriteOp.zero Before the fix, zero(0, 2) would have no effect, and read would get '12345' instead of the expected '\x00\x00345'. Signed-off-by: Wang Chao --- src/test/pybind/test_rados.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/test/pybind/test_rados.py b/src/test/pybind/test_rados.py index cb2a4f96101..0288527c4f9 100644 --- a/src/test/pybind/test_rados.py +++ b/src/test/pybind/test_rados.py @@ -515,6 +515,11 @@ class TestIoctx(object): self.ioctx.operate_write_op(write_op, "write_ops") eq(self.ioctx.read('write_ops'), b'12\x00\x005') + write_op.write_full(b'12345') + write_op.zero(0, 2) + self.ioctx.operate_write_op(write_op, "write_ops") + eq(self.ioctx.read('write_ops'), b'\x00\x00345') + write_op.write_full(b'12345') write_op.truncate(2) self.ioctx.operate_write_op(write_op, "write_ops") -- cgit v1.2.3 From e9ca8a01323d49c656c54d622a34280adc5b244b Mon Sep 17 00:00:00 2001 From: Wang Chao Date: Thu, 24 Oct 2024 09:10:44 +0800 Subject: pybind/rados: add note for reversed arguments to WriteOp.zero() Signed-off-by: Wang Chao --- PendingReleaseNotes | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/PendingReleaseNotes b/PendingReleaseNotes index 9736a83ddb5..7831aaa66d0 100644 --- a/PendingReleaseNotes +++ b/PendingReleaseNotes @@ -47,6 +47,10 @@ fuse client for `fallocate` for the default case (i.e. mode == 0) since CephFS does not support disk space reservation. The only flags supported are `FALLOC_FL_KEEP_SIZE` and `FALLOC_FL_PUNCH_HOLE`. +* pybind/rados: Fixes WriteOp.zero() in the original reversed order of arguments + `offset` and `length`. When pybind calls WriteOp.zero(), the argument passed + does not match rados_write_op_zero, and offset and length are swapped, which + results in an unexpected response. >=19.0.0 -- cgit v1.2.3