9ae3a8
From fea907b6897cb3e644dcee3c537ce6e64d7850ed Mon Sep 17 00:00:00 2001
9ae3a8
From: Fam Zheng <famz@redhat.com>
9ae3a8
Date: Mon, 11 Jul 2016 05:33:35 +0200
9ae3a8
Subject: [PATCH 2/7] BlockLimits: introduce max_transfer_length
9ae3a8
9ae3a8
RH-Author: Fam Zheng <famz@redhat.com>
9ae3a8
Message-id: <1468215219-30793-3-git-send-email-famz@redhat.com>
9ae3a8
Patchwork-id: 71106
9ae3a8
O-Subject: [RHEL-7.3 qemu-kvm PATCH 2/6] BlockLimits: introduce max_transfer_length
9ae3a8
Bugzilla: 1318199
9ae3a8
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
9ae3a8
RH-Acked-by: John Snow <jsnow@redhat.com>
9ae3a8
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
9ae3a8
9ae3a8
From: Peter Lieven <pl@kamp.de>
9ae3a8
9ae3a8
Signed-off-by: Peter Lieven <pl@kamp.de>
9ae3a8
Reviewed-by: Max Reitz <mreitz@redhat.com>
9ae3a8
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9ae3a8
(cherry picked from commit 2647fab57d5d5e38b36f8dbda367d688045e6a2d)
9ae3a8
Signed-off-by: Fam Zheng <famz@redhat.com>
9ae3a8
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
9ae3a8
---
9ae3a8
 block.c                   | 4 ++++
9ae3a8
 include/block/block_int.h | 3 +++
9ae3a8
 2 files changed, 7 insertions(+)
9ae3a8
9ae3a8
diff --git a/block.c b/block.c
9ae3a8
index ecb2b09..ae756aa 100644
9ae3a8
--- a/block.c
9ae3a8
+++ b/block.c
9ae3a8
@@ -481,6 +481,7 @@ void bdrv_refresh_limits(BlockDriverState *bs, Error **errp)
9ae3a8
             return;
9ae3a8
         }
9ae3a8
         bs->bl.opt_transfer_length = bs->file->bl.opt_transfer_length;
9ae3a8
+        bs->bl.max_transfer_length = bs->file->bl.max_transfer_length;
9ae3a8
         bs->bl.opt_mem_alignment = bs->file->bl.opt_mem_alignment;
9ae3a8
     } else {
9ae3a8
         bs->bl.opt_mem_alignment = 512;
9ae3a8
@@ -495,6 +496,9 @@ void bdrv_refresh_limits(BlockDriverState *bs, Error **errp)
9ae3a8
         bs->bl.opt_transfer_length =
9ae3a8
             MAX(bs->bl.opt_transfer_length,
9ae3a8
                 bs->backing_hd->bl.opt_transfer_length);
9ae3a8
+        bs->bl.max_transfer_length =
9ae3a8
+            MIN_NON_ZERO(bs->bl.max_transfer_length,
9ae3a8
+                         bs->backing_hd->bl.max_transfer_length);
9ae3a8
         bs->bl.opt_mem_alignment =
9ae3a8
             MAX(bs->bl.opt_mem_alignment,
9ae3a8
                 bs->backing_hd->bl.opt_mem_alignment);
9ae3a8
diff --git a/include/block/block_int.h b/include/block/block_int.h
9ae3a8
index 3f86649..28c34d8 100644
9ae3a8
--- a/include/block/block_int.h
9ae3a8
+++ b/include/block/block_int.h
9ae3a8
@@ -240,6 +240,9 @@ typedef struct BlockLimits {
9ae3a8
     /* optimal transfer length in sectors */
9ae3a8
     int opt_transfer_length;
9ae3a8
 
9ae3a8
+    /* maximal transfer length in sectors */
9ae3a8
+    int max_transfer_length;
9ae3a8
+
9ae3a8
     /* memory alignment so that no bounce buffer is needed */
9ae3a8
     size_t opt_mem_alignment;
9ae3a8
 } BlockLimits;
9ae3a8
-- 
9ae3a8
1.8.3.1
9ae3a8