From: Ulrich Weigand Date: Mon, 2 Sep 2019 19:28:18 +0000 (+0200) Subject: librbd: Endian fix for handling old image format resize requests X-Git-Tag: v15.1.0~1637^2~2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=cfaa681249b70a96e31b425a81f28aca1dedfebf;p=ceph-ci.git librbd: Endian fix for handling old image format resize requests ResizeRequest::send_update_header contains a comment // NOTE: format 1 image headers are not stored in fixed endian format This statement appears incorrect; Linux kernel code handling the old format headers does assume they are in fixed little-endian format. Fixed by performing a byte-swap as everywhere else; this actually fixes test suite failures on big-endian systems. Fixes (partially): https://tracker.ceph.com/issues/41605 Signed-off-by: Ulrich Weigand --- diff --git a/src/librbd/operation/ResizeRequest.cc b/src/librbd/operation/ResizeRequest.cc index 464dd2af09c..8db5afb3393 100644 --- a/src/librbd/operation/ResizeRequest.cc +++ b/src/librbd/operation/ResizeRequest.cc @@ -401,9 +401,9 @@ void ResizeRequest::send_update_header() { librados::ObjectWriteOperation op; if (image_ctx.old_format) { // rewrite only the size field of the header - // NOTE: format 1 image headers are not stored in fixed endian format + ceph_le64 new_size = init_le64(m_new_size); bufferlist bl; - bl.append(reinterpret_cast(&m_new_size), sizeof(m_new_size)); + bl.append(reinterpret_cast(&new_size), sizeof(new_size)); op.write(offsetof(rbd_obj_header_ondisk, image_size), bl); } else { cls_client::set_size(&op, m_new_size);