From nobody Thu May 2 05:46:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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=fail(p=none dis=none) header.from=huawei.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1631953374416733.1244593285066; Sat, 18 Sep 2021 01:22:54 -0700 (PDT) Received: from localhost ([::1]:58744 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mRVca-0003wv-W9 for importer@patchew.org; Sat, 18 Sep 2021 04:22:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36944) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mRRdD-0000Sf-8V for qemu-devel@nongnu.org; Sat, 18 Sep 2021 00:07:15 -0400 Received: from szxga02-in.huawei.com ([45.249.212.188]:2799) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mRRd9-0000ki-7R for qemu-devel@nongnu.org; Sat, 18 Sep 2021 00:07:15 -0400 Received: from dggeme758-chm.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4HBHGf4S9LzQjB5 for ; Sat, 18 Sep 2021 12:02:50 +0800 (CST) Received: from huawei.com (10.174.186.67) by dggeme758-chm.china.huawei.com (10.3.19.104) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.8; Sat, 18 Sep 2021 12:06:58 +0800 From: lishan To: Subject: [PATCH] block/file-posix: Limit max_iov to IOV_MAX Date: Sat, 18 Sep 2021 12:06:58 +0800 Message-ID: <20210918040658.19484-1-lishan24@huawei.com> X-Mailer: git-send-email 2.19.1.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.174.186.67] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggeme758-chm.china.huawei.com (10.3.19.104) X-CFilter-Loop: Reflected 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=45.249.212.188; envelope-from=lishan24@huawei.com; helo=szxga02-in.huawei.com X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=-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: Sat, 18 Sep 2021 04:20:25 -0400 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: eric.fangyi@huawei.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZM-MESSAGEID: 1631953376172100001 Content-Type: text/plain; charset="utf-8" AIO read/write. The size of iocb->aio_nbytes in the kernel cannot exceed UI= O_MAXIOV =3D 1024. max_segments read from the block device layer may be greater than UIO_MAXIO= V, this causes the ioq_submit interface to return a -22(-EINVAL) error result. --- 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 d81e15efa4..137e27e47b 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -1273,7 +1273,8 @@ static void raw_refresh_limits(BlockDriverState *bs, = Error **errp) =20 ret =3D hdev_get_max_segments(s->fd, &st); if (ret > 0) { - bs->bl.max_iov =3D ret; + /* The maximum segment size allowed by the kernel is UIO_MAXIO= V =3D 1024. */ + bs->bl.max_iov =3D MIN(ret, IOV_MAX); } } } --=20 2.19.1.windows.1