From patchwork Thu Sep 29 20:05:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Busch X-Patchwork-Id: 12994592 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DAAEAC433FE for ; Thu, 29 Sep 2022 20:05:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229700AbiI2UFs (ORCPT ); Thu, 29 Sep 2022 16:05:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34460 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229564AbiI2UFq (ORCPT ); Thu, 29 Sep 2022 16:05:46 -0400 Received: from mx0b-00082601.pphosted.com (mx0b-00082601.pphosted.com [67.231.153.30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C5A94F9620 for ; Thu, 29 Sep 2022 13:05:39 -0700 (PDT) Received: from pps.filterd (m0109331.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 28TJIjmW011159 for ; Thu, 29 Sep 2022 13:05:38 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=meta.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=s2048-2021-q4; bh=AoyPjajIpyVidAzljD0XY/jKYrambGL1LiJyA48EaKo=; b=fAgipyfXhA5JnXgmU/lynv9UAAzXV37Di8cw8H6hxmmCULzz3gf8bhxgaVE27RzeL1TX 2XaVMZnkyoD2ihl8j2YrB+L2zNWTzKT7fBVjs9wIgotzymmZmiCC2q9owF9ugywHMw+g aThIthapExAsONzj18r2qfYK5KpMB1fb79ejEJAoMUMy/Ykat5FF5GJuaTrBv8phwQ3P IhfIKF4nNoA+AxfMtG9h6V0Yvi0ZjfJXwv3mUDI99AUkgBr5BQTUTYsAhJrFaHkjjsU/ XSRN/384polgxvP4rZ+NEa7YYEyMPWYTRsOgvdo4hq61EE/39ZvhcQeqjgzh1cKjG8ZJ rQ== Received: from mail.thefacebook.com ([163.114.132.120]) by mx0a-00082601.pphosted.com (PPS) with ESMTPS id 3jw6yc5fde-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Thu, 29 Sep 2022 13:05:38 -0700 Received: from twshared8247.08.ash8.facebook.com (2620:10d:c085:208::f) by mail.thefacebook.com (2620:10d:c085:11d::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Thu, 29 Sep 2022 13:05:36 -0700 Received: by devbig007.nao1.facebook.com (Postfix, from userid 544533) id 40BDC930500A; Thu, 29 Sep 2022 13:05:24 -0700 (PDT) From: Keith Busch To: , Kevin Wolf , , Paolo Bonzini CC: Stefan Hajnoczi , Jens Axboe , Damien Le Moal , Maxim Levitsky , , Keith Busch Subject: [PATCHv3 1/2] block: move bdrv_qiov_is_aligned to file-posix Date: Thu, 29 Sep 2022 13:05:22 -0700 Message-ID: <20220929200523.3218710-2-kbusch@meta.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220929200523.3218710-1-kbusch@meta.com> References: <20220929200523.3218710-1-kbusch@meta.com> MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-GUID: 8A2s2HoQtVNyQJjg5By-8XJ7hFUJ7Pqk X-Proofpoint-ORIG-GUID: 8A2s2HoQtVNyQJjg5By-8XJ7hFUJ7Pqk X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.528,FMLib:17.11.122.1 definitions=2022-09-29_11,2022-09-29_03,2022-06-22_01 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Keith Busch There is only user of bdrv_qiov_is_aligned(), so move the alignment function to there and make it static. Signed-off-by: Keith Busch --- block/file-posix.c | 21 +++++++++++++++++++++ block/io.c | 21 --------------------- include/block/block-io.h | 1 - 3 files changed, 21 insertions(+), 22 deletions(-) diff --git a/block/file-posix.c b/block/file-posix.c index 48cd096624..e3f3de2780 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -2061,6 +2061,27 @@ static int coroutine_fn raw_thread_pool_submit(BlockDriverState *bs, return thread_pool_submit_co(pool, func, arg); } +/* + * Check if all memory in this vector is sector aligned. + */ +static bool bdrv_qiov_is_aligned(BlockDriverState *bs, QEMUIOVector *qiov) +{ + int i; + size_t alignment = bdrv_min_mem_align(bs); + IO_CODE(); + + for (i = 0; i < qiov->niov; i++) { + if ((uintptr_t) qiov->iov[i].iov_base % alignment) { + return false; + } + if (qiov->iov[i].iov_len % alignment) { + return false; + } + } + + return true; +} + static int coroutine_fn raw_co_prw(BlockDriverState *bs, uint64_t offset, uint64_t bytes, QEMUIOVector *qiov, int type) { diff --git a/block/io.c b/block/io.c index 0a8cbefe86..96edc7f7cb 100644 --- a/block/io.c +++ b/block/io.c @@ -3236,27 +3236,6 @@ void *qemu_try_blockalign0(BlockDriverState *bs, size_t size) return mem; } -/* - * Check if all memory in this vector is sector aligned. - */ -bool bdrv_qiov_is_aligned(BlockDriverState *bs, QEMUIOVector *qiov) -{ - int i; - size_t alignment = bdrv_min_mem_align(bs); - IO_CODE(); - - for (i = 0; i < qiov->niov; i++) { - if ((uintptr_t) qiov->iov[i].iov_base % alignment) { - return false; - } - if (qiov->iov[i].iov_len % alignment) { - return false; - } - } - - return true; -} - void bdrv_io_plug(BlockDriverState *bs) { BdrvChild *child; diff --git a/include/block/block-io.h b/include/block/block-io.h index fd25ffa9be..492f95fc05 100644 --- a/include/block/block-io.h +++ b/include/block/block-io.h @@ -150,7 +150,6 @@ void *qemu_blockalign(BlockDriverState *bs, size_t size); void *qemu_blockalign0(BlockDriverState *bs, size_t size); void *qemu_try_blockalign(BlockDriverState *bs, size_t size); void *qemu_try_blockalign0(BlockDriverState *bs, size_t size); -bool bdrv_qiov_is_aligned(BlockDriverState *bs, QEMUIOVector *qiov); void bdrv_enable_copy_on_read(BlockDriverState *bs); void bdrv_disable_copy_on_read(BlockDriverState *bs); From patchwork Thu Sep 29 20:05:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Busch X-Patchwork-Id: 12994590 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8B378C433F5 for ; Thu, 29 Sep 2022 20:05:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229547AbiI2UFg (ORCPT ); Thu, 29 Sep 2022 16:05:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33846 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229495AbiI2UFd (ORCPT ); Thu, 29 Sep 2022 16:05:33 -0400 Received: from mx0a-00082601.pphosted.com (mx0a-00082601.pphosted.com [67.231.145.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 40CB31260E for ; Thu, 29 Sep 2022 13:05:31 -0700 (PDT) Received: from pps.filterd (m0044010.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 28TJIkTL032567 for ; Thu, 29 Sep 2022 13:05:31 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=meta.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=s2048-2021-q4; bh=9DUyzCE+9LcliOjaEta+SPjhznTXiuml9lI23qr5Cbc=; b=iW/EZPJTit9FOYEhY3RKNVkSyH69kYGgpyRoDIbMs/kmpPPXhBI1SfSTPDsXpv5s2y5Q tAUC8B8Z22+pgZTaZecwIe0tWNp0Wx1VhMJwJtQfG99KdUaTGnpxQKytrOCgIGfCLmdH S3WOxHToTz5HFZpGPrBaoMMs44GWLZMb0qmj95QaFxbTMm6cJuqlWVJljUSKqSlRoVKC /Mx/LoiGFJuLdTXc1vC1NMYWN/am9C9GfdIryjGCs1jTzScQ3LAl5nqEfDdT7xG8zJgf arh5fh8wPN6yghGPUjl2d/uVBbUS64stc13+XqI2d0gmbvGgpZroeNZ/dyceZOmus81C DQ== Received: from mail.thefacebook.com ([163.114.132.120]) by mx0a-00082601.pphosted.com (PPS) with ESMTPS id 3jw15sxws6-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Thu, 29 Sep 2022 13:05:30 -0700 Received: from twshared10425.14.frc2.facebook.com (2620:10d:c085:108::8) by mail.thefacebook.com (2620:10d:c085:21d::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Thu, 29 Sep 2022 13:05:28 -0700 Received: by devbig007.nao1.facebook.com (Postfix, from userid 544533) id 96477930500F; Thu, 29 Sep 2022 13:05:24 -0700 (PDT) From: Keith Busch To: , Kevin Wolf , , Paolo Bonzini CC: Stefan Hajnoczi , Jens Axboe , Damien Le Moal , Maxim Levitsky , , Keith Busch Subject: [PATCHv3 2/2] block: use the request length for iov alignment Date: Thu, 29 Sep 2022 13:05:23 -0700 Message-ID: <20220929200523.3218710-3-kbusch@meta.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220929200523.3218710-1-kbusch@meta.com> References: <20220929200523.3218710-1-kbusch@meta.com> MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-GUID: xPKhKS53L_aYHZnSBsiuIs7WyaqUY_L3 X-Proofpoint-ORIG-GUID: xPKhKS53L_aYHZnSBsiuIs7WyaqUY_L3 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.528,FMLib:17.11.122.1 definitions=2022-09-29_11,2022-09-29_03,2022-06-22_01 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Keith Busch An iov length needs to be aligned to the logical block size, which may be larger than the memory alignment. Tested-by: Jens Axboe Signed-off-by: Keith Busch --- block/file-posix.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/block/file-posix.c b/block/file-posix.c index e3f3de2780..af994aba2b 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -2068,13 +2068,14 @@ static bool bdrv_qiov_is_aligned(BlockDriverState *bs, QEMUIOVector *qiov) { int i; size_t alignment = bdrv_min_mem_align(bs); + size_t len = bs->bl.request_alignment; IO_CODE(); for (i = 0; i < qiov->niov; i++) { if ((uintptr_t) qiov->iov[i].iov_base % alignment) { return false; } - if (qiov->iov[i].iov_len % alignment) { + if (qiov->iov[i].iov_len % len) { return false; } }