From 6dd7d469000144b499af84bda9b735710bb5cec3 Mon Sep 17 00:00:00 2001 From: Josh Durgin Date: Tue, 4 Jun 2013 13:23:36 -0700 Subject: [PATCH 1/2] rados.py: correct some C types trunc was getting size_t instead of uint64_t, leading to bad results in 32-bit environments. Explicitly cast to the desired type everywhere, so it's clear the correct type is being used. Fixes: #5233 Signed-off-by: Josh Durgin --- src/pybind/rados.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/pybind/rados.py b/src/pybind/rados.py index b465728179e..f18f179d030 100644 --- a/src/pybind/rados.py +++ b/src/pybind/rados.py @@ -217,7 +217,7 @@ Rados object in state %s." % (self.state)) length = 20 while True: ret_buf = create_string_buffer(length) - ret = self.librados.rados_conf_get(self.cluster, option, + ret = self.librados.rados_conf_get(self.cluster, c_char_p(option), ret_buf, c_size_t(length)) if (ret == 0): return ret_buf.value @@ -394,11 +394,11 @@ Rados object in state %s." % (self.state)) :returns: str - cluster fsid """ self.require_state("connected") - fsid_len = 36 - fsid = create_string_buffer(fsid_len + 1) + buf_len = 37 + fsid = create_string_buffer(buf_len) ret = self.librados.rados_cluster_fsid(self.cluster, byref(fsid), - fsid_len + 1) + c_size_t(buf_len)) if ret < 0: raise make_ex(ret, "error getting cluster fsid") return fsid.value @@ -501,7 +501,7 @@ class SnapIterator(object): while True: self.snaps = (ctypes.c_uint64 * num_snaps)() ret = self.ioctx.librados.rados_ioctx_snap_list(self.ioctx.io, - self.snaps, num_snaps) + self.snaps, c_int(num_snaps)) if (ret >= 0): self.max_snap = ret break @@ -528,7 +528,7 @@ ioctx '%s'" % self.ioctx.name) while True: name = create_string_buffer(name_len) ret = self.ioctx.librados.rados_ioctx_snap_get_name(self.ioctx.io, \ - snap_id, byref(name), name_len) + c_uint64(snap_id), byref(name), c_int(name_len)) if (ret == 0): name_len = ret break @@ -1102,7 +1102,7 @@ written." % (self.name, ret, length)) self.require_ioctx_open() if not isinstance(key, str): raise TypeError('key must be a string') - ret = self.librados.rados_trunc(self.io, c_char_p(key), c_size_t(size)) + ret = self.librados.rados_trunc(self.io, c_char_p(key), c_uint64(size)) if ret < 0: raise make_ex(ret, "Ioctx.trunc(%s): failed to truncate %s" % (self.name, key)) return ret From 8c23d8cb46d432ca3c840336e02a9eed868d78f3 Mon Sep 17 00:00:00 2001 From: Dan Mick Date: Tue, 4 Jun 2013 17:23:52 -0700 Subject: [PATCH 2/2] dev/rbd-diff: make formats into bullet lists (solves linebreak probs) Signed-off-by: Dan Mick --- doc/dev/rbd-diff.rst | 37 ++++++++++++++++--------------------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/doc/dev/rbd-diff.rst b/doc/dev/rbd-diff.rst index e258afd100b..e40124a002f 100644 --- a/doc/dev/rbd-diff.rst +++ b/doc/dev/rbd-diff.rst @@ -22,22 +22,22 @@ records. From snap --------- -u8: 'f' -le32: snap name length -snap name +- u8: 'f' +- le32: snap name length +- snap name To snap ------- -u8: 't' -le32: snap name length -snap name +- u8: 't' +- le32: snap name length +- snap name Size ---- -u8: 's' -u64: (ending) image size +- u8: 's' +- u64: (ending) image size Data Records ~~~~~~~~~~~~ @@ -47,17 +47,17 @@ These records come in the second part of the sequence. Updated data ------------ -u8: 'w' -le64: offset -le64: length -length bytes of actual data +- u8: 'w' +- le64: offset +- le64: length +- length bytes of actual data Zero data --------- -u8: 'z' -le64: offset -le64: length +- u8: 'z' +- le64: offset +- le64: length Final Record @@ -66,9 +66,4 @@ Final Record End --- -u8: 'e' - - - - - +- u8: 'e'