Patchwork [02/22] block: Inherit opt_transfer_length

login
register
mail settings
Submitter Kevin Wolf
Date Dec. 11, 2013, 9:08 p.m.
Message ID <1386796109-15264-3-git-send-email-kwolf@redhat.com>
Download mbox | patch
Permalink /patch/300414/
State New
Headers show

Comments

Kevin Wolf - Dec. 11, 2013, 9:08 p.m.
When there is a format driver between the backend, it's not guaranteed
that exposing the opt_transfer_length for the format driver results in
the optimal requests (because of fragmentation etc.), but it can't make
things worse, so let's just do it.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 block.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)
Wayne Xia - Dec. 12, 2013, 3:02 a.m.
Reviewed-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>

Patch

diff --git a/block.c b/block.c
index c32d856..79a325f 100644
--- a/block.c
+++ b/block.c
@@ -487,7 +487,23 @@  static int bdrv_refresh_limits(BlockDriverState *bs)
 
     if (!drv) {
         return 0;
-    } else if (drv->bdrv_refresh_limits) {
+    }
+
+    /* Take some limits from the children as a default */
+    if (bs->file) {
+        bdrv_refresh_limits(bs->file);
+        bs->bl.opt_transfer_length = bs->file->bl.opt_transfer_length;
+    }
+
+    if (bs->backing_hd) {
+        bdrv_refresh_limits(bs->backing_hd);
+        bs->bl.opt_transfer_length =
+            MAX(bs->bl.opt_transfer_length,
+                bs->backing_hd->bl.opt_transfer_length);
+    }
+
+    /* Then let the driver override it */
+    if (drv->bdrv_refresh_limits) {
         return drv->bdrv_refresh_limits(bs);
     }