From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53385) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W6kVJ-000420-Rl for qemu-devel@nongnu.org; Fri, 24 Jan 2014 12:25:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W6kVE-0008Mw-S6 for qemu-devel@nongnu.org; Fri, 24 Jan 2014 12:25:17 -0500 Received: from mx1.redhat.com ([209.132.183.28]:5540) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W6kVE-0008Mn-JA for qemu-devel@nongnu.org; Fri, 24 Jan 2014 12:25:12 -0500 From: Kevin Wolf Date: Fri, 24 Jan 2014 18:21:49 +0100 Message-Id: <1390584136-24703-67-git-send-email-kwolf@redhat.com> In-Reply-To: <1390584136-24703-1-git-send-email-kwolf@redhat.com> References: <1390584136-24703-1-git-send-email-kwolf@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PULL 66/93] block: Inherit opt_transfer_length List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: anthony@codemonkey.ws Cc: kwolf@redhat.com, qemu-devel@nongnu.org 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 Reviewed-by: Wenchao Xia Reviewed-by: Max Reitz Reviewed-by: Beno=C3=AEt Canet --- block.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/block.c b/block.c index 0a3d12c..8a66927 100644 --- a/block.c +++ b/block.c @@ -489,7 +489,25 @@ static int bdrv_refresh_limits(BlockDriverState *bs) =20 memset(&bs->bl, 0, sizeof(bs->bl)); =20 - if (drv && drv->bdrv_refresh_limits) { + if (!drv) { + return 0; + } + + /* Take some limits from the children as a default */ + if (bs->file) { + bdrv_refresh_limits(bs->file); + bs->bl.opt_transfer_length =3D bs->file->bl.opt_transfer_length; + } + + if (bs->backing_hd) { + bdrv_refresh_limits(bs->backing_hd); + bs->bl.opt_transfer_length =3D + 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); } =20 --=20 1.8.1.4