]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: resize should only update image size within header 6630/head
authorJason Dillaman <dillaman@redhat.com>
Mon, 2 Nov 2015 21:50:19 +0000 (16:50 -0500)
committerAbhishek Varshney <abhishek.varshney@flipkart.com>
Wed, 18 Nov 2015 07:42:21 +0000 (13:12 +0530)
Previously, the whole RBD image format 1 header struct was
re-written to disk on a resize operation.

Fixes: #13674
Backport: infernalis, hammer, firefly
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
(cherry picked from commit d5be20b6d4646284571568ab28cbf45b0729390b)

src/librbd/AsyncResizeRequest.cc

index 732e3f734f2a9db5e96f2940edb0bc16324d8d51..998249265cb702fc3c94bc088aa741571d795024 100644 (file)
@@ -243,11 +243,11 @@ void AsyncResizeRequest::send_update_header() {
 
   librados::ObjectWriteOperation op;
   if (m_image_ctx.old_format) {
-    // rewrite header
+    // rewrite only the size field of the header
+    // NOTE: format 1 image headers are not stored in fixed endian format
     bufferlist bl;
-    m_image_ctx.header.image_size = m_new_size;
-    bl.append((const char *)&m_image_ctx.header, sizeof(m_image_ctx.header));
-    op.write(0, bl);
+    bl.append(reinterpret_cast<const char*>(&m_new_size), sizeof(m_new_size));
+    op.write(offsetof(rbd_obj_header_ondisk, image_size), bl);
   } else {
     if (m_image_ctx.image_watcher->is_lock_supported()) {
       m_image_ctx.image_watcher->assert_header_locked(&op);