From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45919) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VrSiD-0006al-1K for qemu-devel@nongnu.org; Fri, 13 Dec 2013 08:23:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VrSi6-00024R-1A for qemu-devel@nongnu.org; Fri, 13 Dec 2013 08:23:24 -0500 Received: from mx1.redhat.com ([209.132.183.28]:30004) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VrSi5-00024A-Pt for qemu-devel@nongnu.org; Fri, 13 Dec 2013 08:23:17 -0500 From: Kevin Wolf Date: Fri, 13 Dec 2013 14:22:37 +0100 Message-Id: <1386940979-3824-3-git-send-email-kwolf@redhat.com> In-Reply-To: <1386940979-3824-1-git-send-email-kwolf@redhat.com> References: <1386940979-3824-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PATCH v2 02/24] block: Inherit opt_transfer_length List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, pbonzini@redhat.com, pl@kamp.de, stefanha@redhat.com 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 --- block.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/block.c b/block.c index 3bbcad4..79a325f 100644 --- a/block.c +++ b/block.c @@ -485,7 +485,25 @@ static int bdrv_refresh_limits(BlockDriverState *bs) memset(&bs->bl, 0, sizeof(bs->bl)); - 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 = 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); } -- 1.8.1.4