0a122b
From 56adc601b22b81ae4c681af6b13f38e560f16867 Mon Sep 17 00:00:00 2001
0a122b
From: Kevin Wolf <kwolf@redhat.com>
0a122b
Date: Wed, 11 Dec 2013 19:50:32 +0100
0a122b
Subject: [PATCH 04/37] block: Inherit opt_transfer_length
0a122b
MIME-Version: 1.0
0a122b
Content-Type: text/plain; charset=UTF-8
0a122b
Content-Transfer-Encoding: 8bit
0a122b
0a122b
Message-id: <1392117622-28812-5-git-send-email-kwolf@redhat.com>
0a122b
Patchwork-id: 57169
0a122b
O-Subject: [RHEL-7.0 qemu-kvm PATCH v2 04/37] block: Inherit opt_transfer_length
0a122b
Bugzilla: 748906
0a122b
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
0a122b
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
0a122b
RH-Acked-by: Max Reitz <mreitz@redhat.com>
0a122b
0a122b
When there is a format driver between the backend, it's not guaranteed
0a122b
that exposing the opt_transfer_length for the format driver results in
0a122b
the optimal requests (because of fragmentation etc.), but it can't make
0a122b
things worse, so let's just do it.
0a122b
0a122b
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
0a122b
Reviewed-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
0a122b
Reviewed-by: Max Reitz <mreitz@redhat.com>
0a122b
Reviewed-by: BenoƮt Canet <benoit@irqsave.net>
0a122b
(cherry picked from commit 466ad822deef3a03757d505218a52993c5d56b5d)
0a122b
0a122b
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
0a122b
---
0a122b
 block.c | 20 +++++++++++++++++++-
0a122b
 1 file changed, 19 insertions(+), 1 deletion(-)
0a122b
---
0a122b
 block.c |   20 +++++++++++++++++++-
0a122b
 1 files changed, 19 insertions(+), 1 deletions(-)
0a122b
0a122b
diff --git a/block.c b/block.c
0a122b
index 26eebcc..8b36d05 100644
0a122b
--- a/block.c
0a122b
+++ b/block.c
0a122b
@@ -452,7 +452,25 @@ static int bdrv_refresh_limits(BlockDriverState *bs)
0a122b
 
0a122b
     memset(&bs->bl, 0, sizeof(bs->bl));
0a122b
 
0a122b
-    if (drv && drv->bdrv_refresh_limits) {
0a122b
+    if (!drv) {
0a122b
+        return 0;
0a122b
+    }
0a122b
+
0a122b
+    /* Take some limits from the children as a default */
0a122b
+    if (bs->file) {
0a122b
+        bdrv_refresh_limits(bs->file);
0a122b
+        bs->bl.opt_transfer_length = bs->file->bl.opt_transfer_length;
0a122b
+    }
0a122b
+
0a122b
+    if (bs->backing_hd) {
0a122b
+        bdrv_refresh_limits(bs->backing_hd);
0a122b
+        bs->bl.opt_transfer_length =
0a122b
+            MAX(bs->bl.opt_transfer_length,
0a122b
+                bs->backing_hd->bl.opt_transfer_length);
0a122b
+    }
0a122b
+
0a122b
+    /* Then let the driver override it */
0a122b
+    if (drv->bdrv_refresh_limits) {
0a122b
         return drv->bdrv_refresh_limits(bs);
0a122b
     }
0a122b
 
0a122b
-- 
0a122b
1.7.1
0a122b