Skip to content

Commit d8e459a

Browse files
authored
Merge pull request ceph#59143 from Sean10/fix_rados_pybind_zero_param
pybind/rados: fix the incorrect order of offset,length in WriteOp.zero Reviewed-by: Radoslaw Zarzynski <[email protected]> Reviewed-by: Patrick Donnelly <[email protected]>
2 parents 2d41646 + e9ca8a0 commit d8e459a

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

PendingReleaseNotes

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@
6060
fuse client for `fallocate` for the default case (i.e. mode == 0) since
6161
CephFS does not support disk space reservation. The only flags supported are
6262
`FALLOC_FL_KEEP_SIZE` and `FALLOC_FL_PUNCH_HOLE`.
63+
* pybind/rados: Fixes WriteOp.zero() in the original reversed order of arguments
64+
`offset` and `length`. When pybind calls WriteOp.zero(), the argument passed
65+
does not match rados_write_op_zero, and offset and length are swapped, which
66+
results in an unexpected response.
6367

6468
* The HeadBucket API now reports the `X-RGW-Bytes-Used` and `X-RGW-Object-Count`
6569
headers only when the `read-stats` querystring is explicitly included in the

src/pybind/rados/rados.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1870,7 +1870,7 @@ cdef class WriteOp(object):
18701870
uint64_t _offset = offset
18711871

18721872
with nogil:
1873-
rados_write_op_zero(self.write_op, _length, _offset)
1873+
rados_write_op_zero(self.write_op, _offset, _length)
18741874

18751875
def truncate(self, offset: int):
18761876
"""

src/test/pybind/test_rados.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,11 @@ def test_write_ops(self):
515515
self.ioctx.operate_write_op(write_op, "write_ops")
516516
eq(self.ioctx.read('write_ops'), b'12\x00\x005')
517517

518+
write_op.write_full(b'12345')
519+
write_op.zero(0, 2)
520+
self.ioctx.operate_write_op(write_op, "write_ops")
521+
eq(self.ioctx.read('write_ops'), b'\x00\x00345')
522+
518523
write_op.write_full(b'12345')
519524
write_op.truncate(2)
520525
self.ioctx.operate_write_op(write_op, "write_ops")

0 commit comments

Comments
 (0)