From nobody Mon Apr 29 08:58:48 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 1631950477573641.2446149268627; Sat, 18 Sep 2021 00:34:37 -0700 (PDT) Received: from localhost ([::1]:36632 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mRUrr-0003cJ-W3 for importer@patchew.org; Sat, 18 Sep 2021 03:34:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55520) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mRUqY-00026A-Ac; Sat, 18 Sep 2021 03:33:14 -0400 Received: from szxga03-in.huawei.com ([45.249.212.189]:3165) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mRUqT-0004W9-Fp; Sat, 18 Sep 2021 03:33:14 -0400 Received: from dggeme758-chm.china.huawei.com (unknown [172.30.72.54]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4HBMwP1vBPz8tGN; Sat, 18 Sep 2021 15:32:21 +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 15:33:01 +0800 From: lishan To: Subject: [PATCH] block/file-posix: Limit max_iov to IOV_MAX Date: Sat, 18 Sep 2021 15:33:00 +0800 Message-ID: <20210918073300.30224-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.189; envelope-from=lishan24@huawei.com; helo=szxga03-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-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: kwolf@redhat.com, hreitz@redhat.com, lishan24@huawei.com, qemu-block@nongnu.org, eric.fangyi@huawei.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZM-MESSAGEID: 1631950478336100001 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..27ab8d8784 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, bs->bl.max_iov); } } } --=20 2.19.1.windows.1