]> 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>
Wed, 2 Oct 2019 16:30:50 +0000 (18:30 +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>
(cherry picked from commit cfaa681249b70a96e31b425a81f28aca1dedfebf)
Signed-off-by: Ulrich Weigand <ulrich.weigand@de.ibm.com>
src/librbd/operation/ResizeRequest.cc

index 881f17376a4525f8b677324ee2484946478a4f71..537436ce27a12325403eb3648ceb775be8dea48e 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);