]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: Endian fix for handling old image format resize requests
authorUlrich Weigand <ulrich.weigand@de.ibm.com>
Mon, 2 Sep 2019 19:28:18 +0000 (21:28 +0200)
committerUlrich Weigand <ulrich.weigand@de.ibm.com>
Thu, 5 Sep 2019 08:50:04 +0000 (10:50 +0200)
ResizeRequest<I>::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 <ulrich.weigand@de.ibm.com>
src/librbd/operation/ResizeRequest.cc

index 464dd2af09ce9b302fe19a214b903902ad08389a..8db5afb3393d87c5faae28800b92ff874276ca66 100644 (file)
@@ -401,9 +401,9 @@ void ResizeRequest<I>::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<const char*>(&m_new_size), sizeof(m_new_size));
+    bl.append(reinterpret_cast<const char*>(&new_size), sizeof(new_size));
     op.write(offsetof(rbd_obj_header_ondisk, image_size), bl);
   } else {
     cls_client::set_size(&op, m_new_size);