From patchwork Tue Jun 14 21:30:35 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Blake X-Patchwork-Id: 9176989 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8E3A360573 for ; Tue, 14 Jun 2016 21:38:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6250428337 for ; Tue, 14 Jun 2016 21:38:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5550C2833A; Tue, 14 Jun 2016 21:38:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0F2BF28337 for ; Tue, 14 Jun 2016 21:38:51 +0000 (UTC) Received: from localhost ([::1]:38333 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bCw2s-00066g-4T for patchwork-qemu-devel@patchwork.kernel.org; Tue, 14 Jun 2016 17:38:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58243) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bCvvP-00073K-Dg for qemu-devel@nongnu.org; Tue, 14 Jun 2016 17:31:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bCvvN-0006sX-Hc for qemu-devel@nongnu.org; Tue, 14 Jun 2016 17:31:06 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51947) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bCvvK-0006q3-6M; Tue, 14 Jun 2016 17:31:02 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AB5843DD47; Tue, 14 Jun 2016 21:31:01 +0000 (UTC) Received: from red.redhat.com (ovpn-116-106.phx2.redhat.com [10.3.116.106]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u5ELUl7L019211; Tue, 14 Jun 2016 17:31:01 -0400 From: Eric Blake To: qemu-devel@nongnu.org Date: Tue, 14 Jun 2016 15:30:35 -0600 Message-Id: <1465939839-30097-14-git-send-email-eblake@redhat.com> In-Reply-To: <1465939839-30097-1-git-send-email-eblake@redhat.com> References: <1465939839-30097-1-git-send-email-eblake@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Tue, 14 Jun 2016 21:31:01 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 13/17] block: Set default request_alignment during bdrv_refresh_limits() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, Fam Zheng , Stefan Hajnoczi , qemu-block@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP We want to eventually stick request_alignment alongside other BlockLimits, but first, we must ensure it is populated at the same time as all other limits, rather than being a special case that is set only when a block is first opened. Now that all drivers have been updated to supply an override of request_alignment during their .bdrv_refresh_limits(), as needed, the block layer itself can defer setting the default alignment until part of the overall bdrv_refresh_limits(). Signed-off-by: Eric Blake Reviewed-by: Fam Zheng --- block.c | 1 - block/io.c | 3 +++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/block.c b/block.c index b350794..61fe1df 100644 --- a/block.c +++ b/block.c @@ -937,7 +937,6 @@ static int bdrv_open_common(BlockDriverState *bs, BdrvChild *file, goto fail_opts; } - bs->request_alignment = drv->bdrv_co_preadv ? 1 : 512; bs->read_only = !(bs->open_flags & BDRV_O_RDWR); if (use_bdrv_whitelist && !bdrv_is_whitelisted(drv, bs->read_only)) { diff --git a/block/io.c b/block/io.c index 383154f..c425ce8 100644 --- a/block/io.c +++ b/block/io.c @@ -78,6 +78,9 @@ void bdrv_refresh_limits(BlockDriverState *bs, Error **errp) return; } + /* Default alignment based on whether driver has byte interface */ + bs->request_alignment = drv->bdrv_co_preadv ? 1 : 512; + /* Take some limits from the children as a default */ if (bs->file) { bdrv_refresh_limits(bs->file->bs, &local_err);