From nobody Tue May 7 08:13:46 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=meta.com ARC-Seal: i=1; a=rsa-sha256; t=1664484281; cv=none; d=zohomail.com; s=zohoarc; b=EkcrjQy562SKOqNjUeEuYpKSiS+dKCiq8rAL9ptKeqwDcYxY8AtYJ/pgjU/hDrsrGoyXrSuWLdI5HsiG9aMewqmRmUQ31I/zKmse8Nnw1xhv9mGZ5nupwPugyKxpFF4HISlRFgeKNTxejCPb41oxIaRy0nSExbKEBAq6GIpYZMM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664484281; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=AoyPjajIpyVidAzljD0XY/jKYrambGL1LiJyA48EaKo=; b=L4B0iQ9R4FlYB8XJpaeIEJccTlh9B+GqG4NQqOoIwozV2wFFpLnhC1u8CqaSoJiairqCp1I/A3hronwwumMIWcALncTfQxmn8USubadqL1gT1+PLDCB/Dol1fGu5hP3jcb9fzu6mCOoLV+1Q25esaMR5sAIs0abEyvzNrCdOfIA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1664484281793910.4221872146907; Thu, 29 Sep 2022 13:44:41 -0700 (PDT) Received: from localhost ([::1]:48330 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oe0Od-0003vT-St for importer@patchew.org; Thu, 29 Sep 2022 16:44:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60274) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1odzmx-0002pq-FJ for qemu-devel@nongnu.org; Thu, 29 Sep 2022 16:05:47 -0400 Received: from mx0b-00082601.pphosted.com ([67.231.153.30]:19868 helo=mx0a-00082601.pphosted.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1odzmv-0005SZ-VU for qemu-devel@nongnu.org; Thu, 29 Sep 2022 16:05:43 -0400 Received: from pps.filterd (m0001303.ppops.net [127.0.0.1]) by m0001303.ppops.net (8.17.1.5/8.17.1.5) with ESMTP id 28TJIahw012015 for ; Thu, 29 Sep 2022 13:05:41 -0700 Received: from mail.thefacebook.com ([163.114.132.120]) by m0001303.ppops.net (PPS) with ESMTPS id 3jvxq2yy4q-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Thu, 29 Sep 2022 13:05:40 -0700 Received: from twshared8247.08.ash8.facebook.com (2620:10d:c085:208::f) 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:36 -0700 Received: by devbig007.nao1.facebook.com (Postfix, from userid 544533) id 40BDC930500A; Thu, 29 Sep 2022 13:05:24 -0700 (PDT) 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== 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 Content-Transfer-Encoding: quoted-printable X-FB-Internal: Safe X-Proofpoint-GUID: 7pozOixM55XP5alTwwLYmuYnHAKFitWS X-Proofpoint-ORIG-GUID: 7pozOixM55XP5alTwwLYmuYnHAKFitWS 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 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=67.231.153.30; envelope-from=prvs=1271248072=kbusch@meta.com; helo=mx0a-00082601.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Thu, 29 Sep 2022 16:42:15 -0400 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @meta.com) X-ZM-MESSAGEID: 1664484282779100002 Content-Type: text/plain; charset="utf-8" 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(Block= DriverState *bs, return thread_pool_submit_co(pool, func, arg); } =20 +/* + * 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 =3D bdrv_min_mem_align(bs); + IO_CODE(); + + for (i =3D 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, siz= e_t size) return mem; } =20 -/* - * Check if all memory in this vector is sector aligned. - */ -bool bdrv_qiov_is_aligned(BlockDriverState *bs, QEMUIOVector *qiov) -{ - int i; - size_t alignment =3D bdrv_min_mem_align(bs); - IO_CODE(); - - for (i =3D 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); =20 void bdrv_enable_copy_on_read(BlockDriverState *bs); void bdrv_disable_copy_on_read(BlockDriverState *bs); --=20 2.30.2 From nobody Tue May 7 08:13:46 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=meta.com ARC-Seal: i=1; a=rsa-sha256; t=1664484281; cv=none; d=zohomail.com; s=zohoarc; b=CRIVZNADHr/g+T9xUBIejrRt+I9ND+9KlZvfrDzHU/s/LTX0K7cKNrtXvUpnNIvMH0h5IRPiApbIoxVWXokFYZkhUl5nhsdbxaHBR60VVol5d359C7Q5v+JM+jiLXsEAlXexnlCJRNpobwcAzmdwwFXpDvEuzqamz2D6pIIfp4U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664484281; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=9DUyzCE+9LcliOjaEta+SPjhznTXiuml9lI23qr5Cbc=; b=i4rF1VgQg8WDjTSJLAIOq5SXG71KNTe81rGUc4SHgYO6uUa8jUdRD7kOrL20mQPvcJkAToOSEQNHiqvzOTWlJx7onqxMSRUsTxjj1nMor33QEfpcCqwe7Up5mJEIKALKMx7owik0sEpeq/isgY5YGHOLf5Gp/PgE2k/wPfReGLc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1664484281547621.153497137854; Thu, 29 Sep 2022 13:44:41 -0700 (PDT) Received: from localhost ([::1]:48332 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oe0Od-0003wk-GW for importer@patchew.org; Thu, 29 Sep 2022 16:44:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60270) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1odzmu-0002mM-65 for qemu-devel@nongnu.org; Thu, 29 Sep 2022 16:05:42 -0400 Received: from mx0a-00082601.pphosted.com ([67.231.145.42]:8430) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1odzmr-0005RT-2R for qemu-devel@nongnu.org; Thu, 29 Sep 2022 16:05:39 -0400 Received: from pps.filterd (m0109334.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 28TJIXvW002781 for ; Thu, 29 Sep 2022 13:05:28 -0700 Received: from mail.thefacebook.com ([163.114.132.120]) by mx0a-00082601.pphosted.com (PPS) with ESMTPS id 3jvtn2hv1w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Thu, 29 Sep 2022 13:05:28 -0700 Received: from twshared10425.14.frc2.facebook.com (2620:10d:c085:108::8) by mail.thefacebook.com (2620:10d:c085:21d::4) 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) 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== 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 Content-Transfer-Encoding: quoted-printable X-FB-Internal: Safe X-Proofpoint-GUID: Hdf2rZFJhIi8hOlpbJyamwZu9aVOeoM5 X-Proofpoint-ORIG-GUID: Hdf2rZFJhIi8hOlpbJyamwZu9aVOeoM5 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 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=67.231.145.42; envelope-from=prvs=1271248072=kbusch@meta.com; helo=mx0a-00082601.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Thu, 29 Sep 2022 16:42:15 -0400 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @meta.com) X-ZM-MESSAGEID: 1664484282746100001 Content-Type: text/plain; charset="utf-8" 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 =3D bdrv_min_mem_align(bs); + size_t len =3D bs->bl.request_alignment; IO_CODE(); =20 for (i =3D 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; } } --=20 2.30.2