From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:32978) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bGDG0-0004kN-P0 for qemu-devel@nongnu.org; Thu, 23 Jun 2016 18:37:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bGDFr-0005xu-Vz for qemu-devel@nongnu.org; Thu, 23 Jun 2016 18:37:56 -0400 From: Eric Blake Date: Thu, 23 Jun 2016 16:37:18 -0600 Message-Id: <1466721446-27737-15-git-send-email-eblake@redhat.com> In-Reply-To: <1466721446-27737-1-git-send-email-eblake@redhat.com> References: <1466721446-27737-1-git-send-email-eblake@redhat.com> Subject: [Qemu-devel] [PATCH v3 14/22] block: Set default request_alignment during bdrv_refresh_limits() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, kwolf@redhat.com, famz@redhat.com, stefanha@redhat.com, Max Reitz 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: Kevin Wolf Reviewed-by: Fam Zheng --- v3: no change v2: new patch --- block.c | 1 - block/io.c | 3 +++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/block.c b/block.c index f4648e9..c2fbf06 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 82c9ff0..323e822 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); -- 2.5.5