From nobody Fri May 17 21:24:39 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; arc=pass (i=1dmarc=pass fromdomain=virtuozzo.com); dmarc=pass(p=quarantine dis=none) header.from=virtuozzo.com ARC-Seal: i=2; a=rsa-sha256; t=1607712572; cv=pass; d=zohomail.com; s=zohoarc; b=CZ8O6rqA3kswbeUU1gRzuuixKM9s6YOAfo34DtW3QwS9+AF5L2Gs6MaTqzcbmebBRxM+rI/xn8nOXNiNAkJf/e20hKupB2qOMwBPX6qWM9TwjVFTMhtloVjiD5snPWiNO0djkVMAS9ZuPJPX/KVep38ltb+sDbpv2bsQH22b9qk= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607712572; 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=2JpdCHTK3bZRWATwoEg6jCckd+CehiaAAyYNYOyVKMs=; b=n1NorLIe1i0nWEb6SHhfarVsMzK62OyjtmeUvWOTBt1EvTwoGoyVrdRm/NrCkzyZk5BFPxPSwXFRTmWrabA3mvRVqt+xC4ApngqijbJlf0gtbUQW3Cmw0QKHTTveHcU8lFrLq2YENRK57YMq4jn1bg18/P0/rqO3iDMxRyv/7qI= ARC-Authentication-Results: i=2; 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; arc=pass (i=1dmarc=pass fromdomain=virtuozzo.com); dmarc=pass header.from= (p=quarantine dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1607712572143470.36738928688214; Fri, 11 Dec 2020 10:49:32 -0800 (PST) Received: from localhost ([::1]:50944 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1knnTu-0004yW-Uj for importer@patchew.org; Fri, 11 Dec 2020 13:49:30 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43540) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1knnKi-0006ZX-7P; Fri, 11 Dec 2020 13:40:00 -0500 Received: from mail-eopbgr70097.outbound.protection.outlook.com ([40.107.7.97]:21414 helo=EUR04-HE1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1knnKg-0008BO-52; Fri, 11 Dec 2020 13:39:59 -0500 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB4915.eurprd08.prod.outlook.com (2603:10a6:20b:d1::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3632.18; Fri, 11 Dec 2020 18:39:48 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::d585:99a4:d7a4:d478]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::d585:99a4:d7a4:d478%4]) with mapi id 15.20.3654.016; Fri, 11 Dec 2020 18:39:48 +0000 Received: from kvm.sw.ru (185.215.60.91) by AM0PR04CA0050.eurprd04.prod.outlook.com (2603:10a6:208:1::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3654.12 via Frontend Transport; Fri, 11 Dec 2020 18:39:47 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=I9/XDbyRGvBWyN7jszWJpW1JvGrYxTNv21rVRFTn5RBr5Bhw+yKJW/Th+dmHmUm1CVMTBYKTMAbegxTvkG0P7kYS02bShgeJgD29YeZ0Ngh4eb1K5J3MF/ibyTCeYJiYq1YIdRTlJkULvl9V6ZOxT6qEa27P0CkfWczu26nZPAfdlM75E3CWEQmmzGkwHLHxs4Lk8DiKgTA+qfqe+EQJgPJjUZsEkyMsEV0YAtOCJf/DnVU7/naKnLiwr6b4j57YsOltFz1MWIR81gy6nX1WFynSsyiD+oouhMTn3e+gqb8PiX8JVNm9EN7irLBOcpwkev16/5I7xy11mPelRQWIZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=2JpdCHTK3bZRWATwoEg6jCckd+CehiaAAyYNYOyVKMs=; b=YwdVl2iOC5L0tpD8YGDW8MfBZJ293gO0/32BDvA3YXHO+mXguYTsWzJ2BUH0K+hPiV/Lu/e2izAwtNpBt2p19UVWp+wMCx8KgJDane4R0jnjnSStSbCrggiXf1pNgsAqS4NDjAC5WJ37gUbhocR6ebmmQcUkVBs239/3u89de4iPDoNTdYeWvkm4YAxrWqzLxEkpaa8jgsJRVQ4VBVpIEY/G0jUJcbM7tlJ4rq2Z/RMcWDIzVCXHD3qOd0ruyxci+sazYF7P4h3/9izxHtWr75mxQnbYtL3d3HaHZw+IENB/gQ6dgY5FexSaiHeZYBwpq8d2cS619vbQb7p/9M8fXA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=2JpdCHTK3bZRWATwoEg6jCckd+CehiaAAyYNYOyVKMs=; b=TGxPy2qH4nC+LDn1XaVzJyx2SbUQRG3a0dsVCbM1zt+d53NjxtQz568auGfp+z25kCmI9i3xPIotxVXIV+c1TBY7S/G/CS8sShQJRYzSiSdJAh4NuB4BR8hoRuN0NB9IaeErljCpigOMzGx/EONOXJdKHxvwM7E+VcclHEHjRzw= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Subject: [PATCH v4 01/16] block: refactor bdrv_check_request: add errp Date: Fri, 11 Dec 2020 21:39:19 +0300 Message-Id: <20201211183934.169161-2-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20201211183934.169161-1-vsementsov@virtuozzo.com> References: <20201211183934.169161-1-vsementsov@virtuozzo.com> Content-Transfer-Encoding: quoted-printable X-Originating-IP: [185.215.60.91] X-ClientProxiedBy: AM0PR04CA0050.eurprd04.prod.outlook.com (2603:10a6:208:1::27) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4754144b-06b3-4320-9b42-08d89e04237c X-MS-TrafficTypeDiagnostic: AM6PR08MB4915: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3513; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /KZX3owjgHLX0lnv25eVYcAD5NTFbh+wz32gdcIDrHjgJ0RqrjYMq2o5AGNo8nWGQOHtInlxESSuEDJEiM5nAuE+zKVfGKyfE0UnabafRizvqAccQsrbPjdv5Tty4IiC46yCoJzNfsvwCEq5Ud1ImOm22xJuAVnpUkvpwTvIUHJUbNBd9VTFaF1vCkdG0jx34TK673p2W4tAaHCVvI2NJUVHUCUrWjBirRz0Tk8uacpmJJbSNyBSE9ts98uO5W0l9b+ZEaM0dWJRMENaT4kz3enVBB6UhFpiDf8yG1bDkpzhaJcPHKt34wZn0Pc1l+R3 X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(346002)(39840400004)(136003)(396003)(376002)(66476007)(6506007)(66946007)(956004)(6486002)(86362001)(4326008)(66556008)(6916009)(6512007)(2616005)(6666004)(83380400001)(1076003)(26005)(316002)(16526019)(5660300002)(8676002)(186003)(478600001)(8936002)(2906002)(36756003)(107886003)(52116002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?F2UZex2+/icDGQCu19ZtpZmapg8pue8/rKdgSlf3M52IGn4XrYbJB+zwv2b8?= =?us-ascii?Q?Gg6YaJ3fKAD0Yb06c7MzYGG8UP/BsnCy6uM2IPPs0dYmOX2TU/4LHy4hSRxx?= =?us-ascii?Q?SnPXGfFB8PTepx/TnokZiZrxc72CJJ7hazpYuc2ofYCx8l9j00ekgwvkql6G?= =?us-ascii?Q?Q6n394lwwI4+mZ+CYsNEwDzYuakhilX24FA2pYVc8CVj3X+F7zBDjLmuiHXA?= =?us-ascii?Q?+ankjg5e/pMPIcIbyjlbltaDQbxVrzE2EfeXP9i9bbI5b3pQn2xH/QBhXUME?= =?us-ascii?Q?DR1kNRNs+Z1aORTnDI2VL7t1RrQyHn9lx9z+3NdboNp0ZPWUgNX5yvvoOTnm?= =?us-ascii?Q?IRYjQAaBw3aFc3KrtNycBDiJUgk9LgQcE7ZknoT3Wbnt6QGWVwdBb4XVDocQ?= =?us-ascii?Q?deGyWfF5cGmfaS+TpFuMaSg1Jd+jNIi3kDxh/Y+y0R8GdSjiFoJuyoxG71XC?= =?us-ascii?Q?9Mn5KmlZdu/OAw5EmNXpTVgSQlaPYWz09nV6oaDVfBNyVQpSviFFlHpnR6hL?= =?us-ascii?Q?Vx2xa4+FZ3Ahtm0RGDqAyIUJuZ1ksnRDzvPrpEmSAt2JwFPrS/62J4r7pzyR?= =?us-ascii?Q?rz1kRV9SwbMKimYVWQWBuyFVkGlh01XKWUt9qzYNbF5MGbo+Nz9MWPauL67s?= =?us-ascii?Q?PBJ/v2FFkG9zW9GR/j7H1kdP4V/vwRdSxCHqATKqENfjGsj/95UdNuGpprLB?= =?us-ascii?Q?v+BA+C0dRz3G3v1O9Pbpo0wulcj6dDpy32H8P+OHpVDt6lZRewzhWTLG0DGe?= =?us-ascii?Q?OZcEFF5RI3kIWq5S9XLXVFk3+yyUN+rGfEIL1J3kbiUx116/FKe5SaZdY8mp?= =?us-ascii?Q?ahGNO56WfqkT+WZtTaIv49/FSDZHdbtaW4zkY4B/lHdJwpFK2U6lt3wiTzYA?= =?us-ascii?Q?h8QtXe3AO9HTdjzqTi/U6PLMhcKVTBoYLBR78vxa1iqFwmqfkneZVQjXVYZQ?= =?us-ascii?Q?m4XPoB/DrFFXAF5/x66KvjvIfVrO/YA2gaNLH4qZy0G0rLwTXOkPQTLmJCXt?= =?us-ascii?Q?NUUr?= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Dec 2020 18:39:48.3898 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-Network-Message-Id: 4754144b-06b3-4320-9b42-08d89e04237c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: FihgZj9kXTqsFr14ztEhBNpJ4gI1zbx4mB4vjodZylhHg6INfK8NqwSxCSdbkrI7XDpBr7iKetuBA/wbpl931PVfeLJjNSdbhmyPQz0fcxA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4915 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=40.107.7.97; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-HE1-obe.outbound.protection.outlook.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, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-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: fam@euphon.net, kwolf@redhat.com, vsementsov@virtuozzo.com, berto@igalia.com, qemu-devel@nongnu.org, mreitz@redhat.com, stefanha@redhat.com, den@openvz.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @virtuozzo.com) Content-Type: text/plain; charset="utf-8" It's better to pass &error_abort than just assert that result is 0: on crash, we'll immediately see the reason in the backtrace. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Eric Blake --- include/block/block_int.h | 2 +- block/file-posix.c | 2 +- block/io.c | 29 ++++++++++++++++++++++------- tests/test-write-threshold.c | 5 +++-- 4 files changed, 27 insertions(+), 11 deletions(-) diff --git a/include/block/block_int.h b/include/block/block_int.h index 1eeafc118c..ff29f31451 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -93,7 +93,7 @@ typedef struct BdrvTrackedRequest { struct BdrvTrackedRequest *waiting_for; } BdrvTrackedRequest; =20 -int bdrv_check_request(int64_t offset, int64_t bytes); +int bdrv_check_request(int64_t offset, int64_t bytes, Error **errp); =20 struct BlockDriver { const char *format_name; diff --git a/block/file-posix.c b/block/file-posix.c index 83e2cc5530..fc35a47832 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -2951,7 +2951,7 @@ raw_do_pwrite_zeroes(BlockDriverState *bs, int64_t of= fset, int bytes, =20 req->bytes =3D BDRV_MAX_LENGTH - req->offset; =20 - assert(bdrv_check_request(req->offset, req->bytes) =3D=3D 0); + bdrv_check_request(req->offset, req->bytes, &error_abort); =20 bdrv_mark_request_serialising(req, bs->bl.request_alignment); } diff --git a/block/io.c b/block/io.c index 24205f5168..e076236db2 100644 --- a/block/io.c +++ b/block/io.c @@ -898,17 +898,34 @@ static bool coroutine_fn bdrv_wait_serialising_reques= ts(BdrvTrackedRequest *self return waited; } =20 -int bdrv_check_request(int64_t offset, int64_t bytes) +int bdrv_check_request(int64_t offset, int64_t bytes, Error **errp) { - if (offset < 0 || bytes < 0) { + if (offset < 0) { + error_setg(errp, "offset is negative: %" PRIi64, offset); + return -EIO; + } + + if (bytes < 0) { + error_setg(errp, "bytes is negative: %" PRIi64, bytes); return -EIO; } =20 if (bytes > BDRV_MAX_LENGTH) { + error_setg(errp, "bytes(%" PRIi64 ") exceeds maximum(%" PRIi64 ")", + bytes, BDRV_MAX_LENGTH); + return -EIO; + } + + if (offset > BDRV_MAX_LENGTH) { + error_setg(errp, "offset(%" PRIi64 ") exceeds maximum(%" PRIi64 ")= ", + offset, BDRV_MAX_LENGTH); return -EIO; } =20 if (offset > BDRV_MAX_LENGTH - bytes) { + error_setg(errp, "sum of offset(%" PRIi64 ") and bytes(%" PRIi64 "= ) " + "exceeds maximum(%" PRIi64 ")", offset, bytes, + BDRV_MAX_LENGTH); return -EIO; } =20 @@ -917,7 +934,7 @@ int bdrv_check_request(int64_t offset, int64_t bytes) =20 static int bdrv_check_request32(int64_t offset, int64_t bytes) { - int ret =3D bdrv_check_request(offset, bytes); + int ret =3D bdrv_check_request(offset, bytes, NULL); if (ret < 0) { return ret; } @@ -2819,7 +2836,7 @@ int coroutine_fn bdrv_co_pdiscard(BdrvChild *child, i= nt64_t offset, return -EPERM; } =20 - ret =3D bdrv_check_request(offset, bytes); + ret =3D bdrv_check_request(offset, bytes, NULL); if (ret < 0) { return ret; } @@ -3221,10 +3238,8 @@ int coroutine_fn bdrv_co_truncate(BdrvChild *child, = int64_t offset, bool exact, return -EINVAL; } =20 - ret =3D bdrv_check_request(offset, 0); + ret =3D bdrv_check_request(offset, 0, errp); if (ret < 0) { - error_setg(errp, "Required too big image size, it must be not grea= ter " - "than %" PRId64, BDRV_MAX_LENGTH); return ret; } =20 diff --git a/tests/test-write-threshold.c b/tests/test-write-threshold.c index 4cf032652d..fc1c45a2eb 100644 --- a/tests/test-write-threshold.c +++ b/tests/test-write-threshold.c @@ -7,6 +7,7 @@ */ =20 #include "qemu/osdep.h" +#include "qapi/error.h" #include "block/block_int.h" #include "block/write-threshold.h" =20 @@ -64,7 +65,7 @@ static void test_threshold_not_trigger(void) req.offset =3D 1024; req.bytes =3D 1024; =20 - assert(bdrv_check_request(req.offset, req.bytes) =3D=3D 0); + bdrv_check_request(req.offset, req.bytes, &error_abort); =20 bdrv_write_threshold_set(&bs, threshold); amount =3D bdrv_write_threshold_exceeded(&bs, &req); @@ -84,7 +85,7 @@ static void test_threshold_trigger(void) req.offset =3D (4 * 1024 * 1024) - 1024; req.bytes =3D 2 * 1024; =20 - assert(bdrv_check_request(req.offset, req.bytes) =3D=3D 0); + bdrv_check_request(req.offset, req.bytes, &error_abort); =20 bdrv_write_threshold_set(&bs, threshold); amount =3D bdrv_write_threshold_exceeded(&bs, &req); --=20 2.25.4 From nobody Fri May 17 21:24:39 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; arc=pass (i=1dmarc=pass fromdomain=virtuozzo.com); dmarc=pass(p=quarantine dis=none) header.from=virtuozzo.com ARC-Seal: i=2; a=rsa-sha256; t=1607712677; cv=pass; d=zohomail.com; s=zohoarc; b=O2HFEBwzSt8z/z7OZ+oZYZfnPZasm6dvjEvBc6GMbB5EcgIuJqIBgUnMtHTbrWvmCs581pXJKHoL4aLC72X+VzTxyN61i9r6VDzLuXBW7rt/072nHXysatipu7BXEUFI4Qn+tiT4Oq+P35F0i6U7B02h4aYP/TgIothXPMU5TKw= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607712677; 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=QmAeOA04vqFAyzZNmxOnYC8G07AXDfT0Ry230f2YoNU=; b=PjcUrApVKfASeCiYI2Q9lE1jdDXN5ZYntctAJjhbgHmZ7Lv0QZNCLYLEBDg94DcR9cGIrFPd1wamV06LGj1zGX8f6dggANxd9paVcXkkryQnqrtEtXC9z6Q3GdA/FuE58dflGSQVANhL+5244rq1eBsJ9AhXymB3oxTaWcKMVkY= ARC-Authentication-Results: i=2; 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; arc=pass (i=1dmarc=pass fromdomain=virtuozzo.com); dmarc=pass header.from= (p=quarantine dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1607712677740260.1322072247822; Fri, 11 Dec 2020 10:51:17 -0800 (PST) Received: from localhost ([::1]:54820 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1knnVc-0006bS-KR for importer@patchew.org; Fri, 11 Dec 2020 13:51:16 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43550) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1knnKm-0006cp-TQ; Fri, 11 Dec 2020 13:40:05 -0500 Received: from mail-eopbgr70090.outbound.protection.outlook.com ([40.107.7.90]:11267 helo=EUR04-HE1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1knnKg-00089o-Mk; Fri, 11 Dec 2020 13:40:03 -0500 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB4915.eurprd08.prod.outlook.com (2603:10a6:20b:d1::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3632.18; Fri, 11 Dec 2020 18:39:49 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::d585:99a4:d7a4:d478]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::d585:99a4:d7a4:d478%4]) with mapi id 15.20.3654.016; Fri, 11 Dec 2020 18:39:49 +0000 Received: from kvm.sw.ru (185.215.60.91) by AM0PR04CA0050.eurprd04.prod.outlook.com (2603:10a6:208:1::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3654.12 via Frontend Transport; Fri, 11 Dec 2020 18:39:48 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FzGHv/NbvSpuwf2OjSfARrG+Xb1GFHiJTMEPGKvfgSEMFdoMUPL9sQF+uJ+i2rm/wnsdlTmh6jKEs4PwhFIkOUasKt+9DUPAzagUnbvLLXUTMrOSZcDnZ3m/XsvYwVAt64RXJpwZ+KP8Qmi1mvvKKqMfpUpuQtNefwnkaQs+NyLrZbf+d0qJBOCqTnpn+eGDap8r6Z9Dib98KO+KNOttHSNRWwyiLNXo2vLnSYRhWPJfCmS1jhFGfQ2BG5tmLKk5L/rpfQyM4psucYsqOCvhgTii8At6ryyZ6Ez0DO/2hLAKV5/uPXy58PTlYkkyS5FQXHVzQZ7jneKFiMAp+wML/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=QmAeOA04vqFAyzZNmxOnYC8G07AXDfT0Ry230f2YoNU=; b=moF+VLrE3pTZPjy66WUbWjqtDmqWyREUh0si9HdcxdzLIcpk6sm5sAnktylJMZF1x1WHTwQ/7LRIkkB/2G4c0Ra/KLHqjobtPb6VZMtPece9ADRlPsObqI+e2sptuA6UN4LcLatGbDU+t47011ADi5a89uSbMPYriws+nPxx90YwizfbX0ukMYl93shvhzyBkEJVECB9KCYTJKP/yfw9SIVPk3d7q0vNregaw0unfaS6ozs1wcYQ/KCKyD2tsdfGuddUFnDanmpTwvjk06C4hIM4dVEz15QeDOAbZ9qkhL1Sg5e+6KO0pWJNhgmJW8CSYDgyd0Cs2pPZO5/2V+GfCw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=QmAeOA04vqFAyzZNmxOnYC8G07AXDfT0Ry230f2YoNU=; b=DI4u4iVEIGQxtEILZTxIVDvyn2SNgGfdslVpLSRC7jjn0msnTa9xGTTBBwpOOZ3hF3f72GlVqW7wbatfLoi8xeN/cvQdEBGsNqIv12LLjT6WuzYPGvy40q4jxTwUHPdtVopap/tydvSQPTDSoGlmzZ9eYjwSoDhOWi1oXfRe/Uw= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Subject: [PATCH v4 02/16] util/iov: make qemu_iovec_init_extended() honest Date: Fri, 11 Dec 2020 21:39:20 +0300 Message-Id: <20201211183934.169161-3-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20201211183934.169161-1-vsementsov@virtuozzo.com> References: <20201211183934.169161-1-vsementsov@virtuozzo.com> Content-Transfer-Encoding: quoted-printable X-Originating-IP: [185.215.60.91] X-ClientProxiedBy: AM0PR04CA0050.eurprd04.prod.outlook.com (2603:10a6:208:1::27) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d63e1c9b-b548-4f17-0436-08d89e0423f4 X-MS-TrafficTypeDiagnostic: AM6PR08MB4915: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3513; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: JpLc1VyJDfljAp5LXac/CLaZI3lNOuR3DMuOELN6mGnZQJCTykPL037KhvTfV/98j+S15KxPIFTvhS/RBSAs1n6xoj5ldtw0LCMrfIa0DPoUbwUVMg5wtxERvXKcRwjUopR6L03gqiMJpvyH43R4w8HTLsln2bEi6Y1hnVE0+yFXNVxHvVcam+F2tXdWRgseST7uEL+hM89r/q1uYB+F/4IQ4tSjNTDSAGgTztDz85fM4gLvzPcbbt1MJe0TskFt/99vGL70/sFV10uElnb6KVNI979FaU3cJk+RDdd9YKO0XYSmzQPW76EwfMOk+iGY+LBIFhCI903CCSg/WFG88WnP1aX/x0hlDE7ke6Br1+pf9/sU435irzAZ9rETFnND X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(346002)(39840400004)(136003)(396003)(376002)(66476007)(6506007)(66946007)(956004)(6486002)(86362001)(4326008)(66556008)(6916009)(6512007)(2616005)(6666004)(83380400001)(1076003)(26005)(316002)(16526019)(5660300002)(8676002)(186003)(478600001)(8936002)(2906002)(36756003)(107886003)(52116002)(309714004); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?K3rWXBivjUITgipC9bPUrBpc7FmUyJH2G80w3sAAiyHj4+NETnrB2WW4v9hC?= =?us-ascii?Q?aAqcCysUSbbr82CIZ7qd9fPqFcvQEZjHIQIAWN15pOLyfoqRNOTvkLe4zdQe?= =?us-ascii?Q?qCwO0CEwdJ7rrGvRyQvRPpHtrlWb3Sq1re0CtxCWt+CAkAipw8FHhoVG+BtQ?= =?us-ascii?Q?7Tkjfb+nKcuqBhnyBmseru/srk4paLyFdkai0cGhH1vWsyjMItObyZ85UdUp?= =?us-ascii?Q?uQBb0X489jISJTwdALtfybzQqTuURrDgJg655fniFSsIbArU00bPTfUQ+MYp?= =?us-ascii?Q?Rar8drTy5PInV4DqZdGyoedjuoS/XBRq/FjKLsNhFXj8CbPyoyMdqH2YUkaZ?= =?us-ascii?Q?T38VeONS1ffuo1FIPweVUvZHaeOadYPdaLwHNFD0iBcsOWbyFx7KY4QXUvIO?= =?us-ascii?Q?xhLMAUDxBVW/9mmmK+yexw+/XqUvvicwVxc8TDAr7vIynUofi8Or7nY0Ta7j?= =?us-ascii?Q?WDZVzuD4dz9xMR11pgF39Vug514q6x2/NH4V3UgmcHbY/l8vtFQI9CgvZPdB?= =?us-ascii?Q?IJzI5AND4OQ0EJVE4aQBJCyuwSemKS9y4OUEwa5OnegH5HK7/GVZC3tDabpf?= =?us-ascii?Q?fB5HzYDjJFcIWaU7+pLflAhyXx8vturvT4i6/G63TtS6iKIAIPVhvps8WoIV?= =?us-ascii?Q?cYcaAZrrmc1hZcpJxaXMllxO/7iHATgGiMhsI21UzXzkDxSPmcQjgkgVfXBK?= =?us-ascii?Q?YCHENklm0BS3wRWZR/pv0SyuBA7OnCLiDS/V3C6rIGZ808Zhdb7uLWmFaW9T?= =?us-ascii?Q?ohpDRWIcDr9EbQLy1YTTPWVlCevKFnMEJPDcMtLp6L1OT4dzZ+UWZIG2Lk8O?= =?us-ascii?Q?tzqUBAEiu3zqRvdwpGIw6JH/ZjFrDwxScH460aDl8kS1UIXZgbQkwqvMin4W?= =?us-ascii?Q?ecTAjIVbhYgAyF1W6hkjppf5Ir7zXkFgFB/n0LLC70BtZDntgPma958B6Khw?= =?us-ascii?Q?sUNYCUoSTIK8mtMrRfad6miq3Qhb4Il6kHgYuNIUgpGbBt9C3uWnBwfgjbbX?= =?us-ascii?Q?89za?= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Dec 2020 18:39:49.1863 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-Network-Message-Id: d63e1c9b-b548-4f17-0436-08d89e0423f4 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: N4mf/dDil+97NKQ1CpW+/g3nTMolr0surUOia3n9w2dd/guRd2I6WqyZmCdT6p5if5I1O4TuRG/P6tqucM7xh/Tit0mTAMrLhOrcNE0397g= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4915 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=40.107.7.90; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-HE1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-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: fam@euphon.net, kwolf@redhat.com, vsementsov@virtuozzo.com, berto@igalia.com, qemu-devel@nongnu.org, mreitz@redhat.com, stefanha@redhat.com, den@openvz.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @virtuozzo.com) Content-Type: text/plain; charset="utf-8" Actually, we can't extend the io vector in all cases. Handle possible MAX_IOV and size_t overflows. For now add assertion to callers (actually they rely on success anyway) and fix them in the following patch. Add also some additional good assertions to qemu_iovec_init_slice() while being here. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Eric Blake --- include/qemu/iov.h | 2 +- block/io.c | 10 +++++++--- util/iov.c | 25 +++++++++++++++++++++++-- 3 files changed, 31 insertions(+), 6 deletions(-) diff --git a/include/qemu/iov.h b/include/qemu/iov.h index b6b283a5e5..9330746680 100644 --- a/include/qemu/iov.h +++ b/include/qemu/iov.h @@ -222,7 +222,7 @@ static inline void *qemu_iovec_buf(QEMUIOVector *qiov) =20 void qemu_iovec_init(QEMUIOVector *qiov, int alloc_hint); void qemu_iovec_init_external(QEMUIOVector *qiov, struct iovec *iov, int n= iov); -void qemu_iovec_init_extended( +int qemu_iovec_init_extended( QEMUIOVector *qiov, void *head_buf, size_t head_len, QEMUIOVector *mid_qiov, size_t mid_offset, size_t mid_len, diff --git a/block/io.c b/block/io.c index e076236db2..21e8a50725 100644 --- a/block/io.c +++ b/block/io.c @@ -1652,13 +1652,17 @@ static bool bdrv_pad_request(BlockDriverState *bs, int64_t *offset, unsigned int *bytes, BdrvRequestPadding *pad) { + int ret; + if (!bdrv_init_padding(bs, *offset, *bytes, pad)) { return false; } =20 - qemu_iovec_init_extended(&pad->local_qiov, pad->buf, pad->head, - *qiov, *qiov_offset, *bytes, - pad->buf + pad->buf_len - pad->tail, pad->tai= l); + ret =3D qemu_iovec_init_extended(&pad->local_qiov, pad->buf, pad->head, + *qiov, *qiov_offset, *bytes, + pad->buf + pad->buf_len - pad->tail, + pad->tail); + assert(ret =3D=3D 0); *bytes +=3D pad->head + pad->tail; *offset -=3D pad->head; *qiov =3D &pad->local_qiov; diff --git a/util/iov.c b/util/iov.c index f3a9e92a37..58c7b3eeee 100644 --- a/util/iov.c +++ b/util/iov.c @@ -415,7 +415,7 @@ int qemu_iovec_subvec_niov(QEMUIOVector *qiov, size_t o= ffset, size_t len) * Compile new iovec, combining @head_buf buffer, sub-qiov of @mid_qiov, * and @tail_buf buffer into new qiov. */ -void qemu_iovec_init_extended( +int qemu_iovec_init_extended( QEMUIOVector *qiov, void *head_buf, size_t head_len, QEMUIOVector *mid_qiov, size_t mid_offset, size_t mid_len, @@ -425,12 +425,24 @@ void qemu_iovec_init_extended( int total_niov, mid_niov =3D 0; struct iovec *p, *mid_iov =3D NULL; =20 + assert(mid_qiov->niov <=3D IOV_MAX); + + if (SIZE_MAX - head_len < mid_len || + SIZE_MAX - head_len - mid_len < tail_len) + { + return -EINVAL; + } + if (mid_len) { mid_iov =3D qiov_slice(mid_qiov, mid_offset, mid_len, &mid_head, &mid_tail, &mid_niov); } =20 total_niov =3D !!head_len + mid_niov + !!tail_len; + if (total_niov > IOV_MAX) { + return -EINVAL; + } + if (total_niov =3D=3D 1) { qemu_iovec_init_buf(qiov, NULL, 0); p =3D &qiov->local_iov; @@ -459,6 +471,8 @@ void qemu_iovec_init_extended( p->iov_base =3D tail_buf; p->iov_len =3D tail_len; } + + return 0; } =20 /* @@ -492,7 +506,14 @@ bool qemu_iovec_is_zero(QEMUIOVector *qiov, size_t off= set, size_t bytes) void qemu_iovec_init_slice(QEMUIOVector *qiov, QEMUIOVector *source, size_t offset, size_t len) { - qemu_iovec_init_extended(qiov, NULL, 0, source, offset, len, NULL, 0); + int ret; + + assert(source->size >=3D len); + assert(source->size - len >=3D offset); + + /* We shrink the request, so we can't overflow neither size_t nor MAX_= IOV */ + ret =3D qemu_iovec_init_extended(qiov, NULL, 0, source, offset, len, N= ULL, 0); + assert(ret =3D=3D 0); } =20 void qemu_iovec_destroy(QEMUIOVector *qiov) --=20 2.25.4 From nobody Fri May 17 21:24:39 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; arc=pass (i=1dmarc=pass fromdomain=virtuozzo.com); dmarc=pass(p=quarantine dis=none) header.from=virtuozzo.com ARC-Seal: i=2; a=rsa-sha256; t=1607712908; cv=pass; d=zohomail.com; s=zohoarc; b=ZEM00mGfU4puHgddu6uAOYY+6LljHNhEXQuJSI+Dmgh96eFL8//FW0/PmgcTrWgBez9r5zwHTbUnSuUNhWDYVeW0izakkT8SyszMlyP04MMjuS3qrulmglQXqsTkSODClNEWwCaM7hlGun+G0BqGC3s+zSYk3CEHZ4fxaJWyA4E= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607712908; 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=GX/o/DN5UDKdrDpKGCI6wdyZToVOnCv/fPnvyuimykY=; b=AB49iqDlUqdPWsOn/u0zZWeWagHzRYFCtab1G9vR3bDaX0RyA8tyf9Xsk8+jPy+EqF5dGk/A8M6Yl0kNK11IB88b3Nn40wyW8LcEKHGweYhspbs7e/GOE3X9kYbsZQkBfVgDBjN469MO60+gEiyyDOV7tpxbQB9w6xK299ZEBoM= ARC-Authentication-Results: i=2; 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; arc=pass (i=1dmarc=pass fromdomain=virtuozzo.com); dmarc=pass header.from= (p=quarantine dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1607712908941441.2700595107875; Fri, 11 Dec 2020 10:55:08 -0800 (PST) Received: from localhost ([::1]:33358 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1knnZJ-00016x-Vr for importer@patchew.org; Fri, 11 Dec 2020 13:55:06 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43582) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1knnKp-0006e8-HO; Fri, 11 Dec 2020 13:40:07 -0500 Received: from mail-eopbgr70129.outbound.protection.outlook.com ([40.107.7.129]:29411 helo=EUR04-HE1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1knnKk-0008CX-Dp; Fri, 11 Dec 2020 13:40:07 -0500 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB4915.eurprd08.prod.outlook.com (2603:10a6:20b:d1::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3632.18; Fri, 11 Dec 2020 18:39:50 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::d585:99a4:d7a4:d478]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::d585:99a4:d7a4:d478%4]) with mapi id 15.20.3654.016; Fri, 11 Dec 2020 18:39:50 +0000 Received: from kvm.sw.ru (185.215.60.91) by AM0PR04CA0050.eurprd04.prod.outlook.com (2603:10a6:208:1::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3654.12 via Frontend Transport; Fri, 11 Dec 2020 18:39:49 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=F55Wn6+r+ZDXfhcagQHhLCqvdtmsVZQjKbS3ungDwdihbpnj+Iq/oXwRYdPO2PFYg1iwoer3JUO1Me/EBa+hJY69O0oD8MyFCOKLkUrtZuLfImHB1W5Yq3Niv256EoDnUfdpgIQvkUjEn9i4QgvdcK375cBXFj2z/O7ksitZKdSMHJVpv6TEQS35eeAjCztxh7XcmcD3qfTzaRTTQ8STn2NJtZiP0q3UlgMPwZab+LS3jaF4FLctgmOBw5Zd5L77q81Z3PR/cmqd3QOPW6AsQolNxr462VJ2TCzyjm7Fn+7nnvpgQyaeKr+1BH37QeLlUAtDD97g/xctPPBdgb89zA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=GX/o/DN5UDKdrDpKGCI6wdyZToVOnCv/fPnvyuimykY=; b=A80skK2K1cdpEHf5GsG1nPt9lMsVeROGjGDXY+YwnvGsovxrVeQxaougNXWcGfHkFbQXB5ANgk33rOwpv1zpbztRA8BCiKd7or69gsfuMqFgtyGNLwgk8FAETP/GSfi1tbHptAurBxjtXJy0ypHxXOl7HUmnsQzIZgOYJB9wZi51UtFFUeQ8Tn788lQWW5QxEoALvLq9coXxyeC5PKWPaUx8bPcPhifIEwg1wg4WwEJdt/sYz/d0JKdreZOteBP7FXqUqm5x7gCspbosrCuSEmGdy6/rI/kJRoiLjFJqRTslYasoSN+BmCE/3OYA+ACs3dQHHo8bFxLDAy1iC7yJCw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=GX/o/DN5UDKdrDpKGCI6wdyZToVOnCv/fPnvyuimykY=; b=qE1gr9pKSf99X5hL1838kkh/89rR/+kCgYVQiiOfDMwvYU9Yu4jBYDdxtiRQ1Nm689GrojkU0xdXubTdBsEFV2LjfGQe0K44z6k3tLFy/4kkiYTvbarvDooh99n6rTCBqr6JGZJPz4G5E5FINavG0tz1+UGTx9AW/D/OscAv+BM= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Subject: [PATCH v4 03/16] block: fix theoretical overflow in bdrv_init_padding() Date: Fri, 11 Dec 2020 21:39:21 +0300 Message-Id: <20201211183934.169161-4-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20201211183934.169161-1-vsementsov@virtuozzo.com> References: <20201211183934.169161-1-vsementsov@virtuozzo.com> Content-Transfer-Encoding: quoted-printable X-Originating-IP: [185.215.60.91] X-ClientProxiedBy: AM0PR04CA0050.eurprd04.prod.outlook.com (2603:10a6:208:1::27) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c0c93e3f-0985-46cc-0a80-08d89e04249c X-MS-TrafficTypeDiagnostic: AM6PR08MB4915: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2657; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: IU0cDUjZcFtmLsJ9u6+jIheO7cXhRKWggnwVwEwj/ouBGa7LBoXYW1lUx35qhjS4b8x7TTNwE9Uf+pJzykMVFWweYHULvKv+y5+0V4SP9Rt2TEXeig3tmB3mBJCXfgX1r6/DGIM8/Eq428IAK2Ba4yOOMc0AVFwn7DXAjXMO4ad2KAKaNKl6R7k54HLyKtcet3cam1IzaqI9Z2XXpr7dPLOt12SDtsmUdotWsFH/TmlIMt2PwWJsUG4qDtC8ae9JwgPyNBdglDuFtx8AX9zQ6stnQknrSNL7vlbfY7jzAjlqe/X6jrW71oW6H72B1upYREZPxIGeLOYVgG413DrzkA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(346002)(39840400004)(136003)(396003)(376002)(66476007)(4744005)(6506007)(66946007)(956004)(6486002)(86362001)(4326008)(66556008)(6916009)(6512007)(2616005)(6666004)(83380400001)(1076003)(26005)(316002)(16526019)(5660300002)(8676002)(186003)(478600001)(8936002)(2906002)(36756003)(107886003)(52116002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?tjKfgND3h/UqWnTnPvDtQiX/6YcsyzUVdhncbUFYriNxl5thHP8SfJ80CFiZ?= =?us-ascii?Q?vaeXJegIzsiPFTwYQAhis20XKESLeEEhr3sfCw/P8e1ipfWA0crqeYEUDXrI?= =?us-ascii?Q?EqXNuK6uQEUZK9LNC3iL6GY4W4PQsilpddx/Qot5S2aY58ClWTW7q04qgyTl?= =?us-ascii?Q?oV88wXmSCRa4XIpx1GHgOSfXGI7NuuZCscNAHXOSMHwD7h3kICA5BZoi1HvN?= =?us-ascii?Q?Tj8+90jPv/4jJXn9zso0t11KHP8UwD9tg3g8Zf4cZk8ysr0falX59C1IYttR?= =?us-ascii?Q?iPmXOYcBSZmYql7z+B8rFvAjhVXMW8bH12v6UVCghjveBQeVa3fu3qPMPSy5?= =?us-ascii?Q?kvA0Yrznb08S+RcZPMZRkyPf4ZxM+WpxCOaZeHFu/QGnaU44u7bcokuMBqPp?= =?us-ascii?Q?XS6gP8AA4uacD7vDcEB5DFoHwoIC4MQCijMmMz1xyuGDle8sXZ11spUjKNVx?= =?us-ascii?Q?kjRjkRZUSlOcWpZd/4YmrQIqDkX38ZtRM5F40SYmd8kiYJbqtAmXdCNM4v1p?= =?us-ascii?Q?RineKGCOuDmbmI5H7G69B2Jr0ykYdZ7w1HNmS8ZVwv/mbQSoQ+ryQKdfOhCh?= =?us-ascii?Q?o7R4amtoyx+oF/cLHJpgd/GwFwS5/8v7C81eXgSvrEH2ve9mCzjlMwML9/7C?= =?us-ascii?Q?Tn7sAGLXZGK/otByRTKhH6QuOLnBgKY45my1H+U6aoLbSRMguosTvUcgDldX?= =?us-ascii?Q?WKYV5QlIpE8Vmmr+irx/mjKScaqDRYQDHzflwQuU67GkU0lWBIyQlKagR5UJ?= =?us-ascii?Q?B5dXWJk+kfq+P15xH45mY5hBZh7i5TDEuDcYO6JNhM7+HaCeQwTcQECru34B?= =?us-ascii?Q?E47DlSepzMC4oXz3QB7jbcVr5TJj8CVcJ3fIuo+yKvknqInMD2t0i6JltWAS?= =?us-ascii?Q?/gJBznoGUrH9YMpL9ShswIUEIFPXKugcT/oO09BDwwD8u2pLYumS97EE9SmL?= =?us-ascii?Q?i5LidNlj3VVy1B/4PbJUaBibx8fyKNURNvx1Md8w+9LfLG2xBkLhHSE0JpCu?= =?us-ascii?Q?uC26?= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Dec 2020 18:39:50.3621 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-Network-Message-Id: c0c93e3f-0985-46cc-0a80-08d89e04249c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: PBPHFimVsIlusu8BMiNr5xuMdTbUFoKUC1oFfBeAmYnh4j/FdkE0+qi8QUrnlCnCCxPrUcTCInXedovQ0CHbAlYpMsL6sBbqZa4nFIAHjfU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4915 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=40.107.7.129; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-HE1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-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: fam@euphon.net, kwolf@redhat.com, vsementsov@virtuozzo.com, berto@igalia.com, qemu-devel@nongnu.org, mreitz@redhat.com, stefanha@redhat.com, den@openvz.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @virtuozzo.com) Content-Type: text/plain; charset="utf-8" Calculation of sum may theoretically overflow, so use 64bit type and add some good assertions. Use int64_t constantly. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Eric Blake --- block/io.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/block/io.c b/block/io.c index 21e8a50725..d9bc67f1b0 100644 --- a/block/io.c +++ b/block/io.c @@ -1537,8 +1537,12 @@ static bool bdrv_init_padding(BlockDriverState *bs, int64_t offset, int64_t bytes, BdrvRequestPadding *pad) { - uint64_t align =3D bs->bl.request_alignment; - size_t sum; + int64_t align =3D bs->bl.request_alignment; + int64_t sum; + + bdrv_check_request(offset, bytes, &error_abort); + assert(align <=3D INT_MAX); /* documented in block/block_int.h */ + assert(align * 2 <=3D SIZE_MAX); /* so we can allocate the buffer */ =20 memset(pad, 0, sizeof(*pad)); =20 --=20 2.25.4 From nobody Fri May 17 21:24:39 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; arc=pass (i=1dmarc=pass fromdomain=virtuozzo.com); dmarc=pass(p=quarantine dis=none) header.from=virtuozzo.com ARC-Seal: i=2; a=rsa-sha256; t=1607713199; cv=pass; d=zohomail.com; s=zohoarc; b=Ix574UjJn/8Yfj5UZbXFSwvuGT3gbEUh66AvLJfc3lla5GPBVgfkUrn+Smus+eva/snlKhoVuN1J5DwsTLfV9l8WhqTqwymhWcDHipYNP0fT/hnNI3tMpAjg+CRGEd+X52Buf93eSUPDlbFaFrV2POGMtxqN4dWAuwwGYGs+I+M= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607713199; 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=uRVxsqlcDVMA/yosvYRBrO3+9X8GOnnwkjE5ScJQudM=; b=Bz79u1HleUBzIDnpuVHct9tvLYXXTmm9kFtPxQ39De/DPFAbBd+rg9D7AyfWrVFDtZd1ASKvvR5JjPpPiA3vIjffMsjB0gzFTRvD46gNUM1CnCk5QL0kXkX6MLBPdePVs8NzwAV0uLmYgEOsxFNZqLnaME/xqMKhkbco1l/EzaE= ARC-Authentication-Results: i=2; 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; arc=pass (i=1dmarc=pass fromdomain=virtuozzo.com); dmarc=pass header.from= (p=quarantine dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1607713199806518.4065492258137; Fri, 11 Dec 2020 10:59:59 -0800 (PST) Received: from localhost ([::1]:42148 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1knne2-0004zw-GQ for importer@patchew.org; Fri, 11 Dec 2020 13:59:58 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43570) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1knnKn-0006dt-SN; Fri, 11 Dec 2020 13:40:07 -0500 Received: from mail-eopbgr70097.outbound.protection.outlook.com ([40.107.7.97]:21414 helo=EUR04-HE1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1knnKk-0008BO-Dk; Fri, 11 Dec 2020 13:40:05 -0500 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB4915.eurprd08.prod.outlook.com (2603:10a6:20b:d1::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3632.18; Fri, 11 Dec 2020 18:39:51 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::d585:99a4:d7a4:d478]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::d585:99a4:d7a4:d478%4]) with mapi id 15.20.3654.016; Fri, 11 Dec 2020 18:39:51 +0000 Received: from kvm.sw.ru (185.215.60.91) by AM0PR04CA0050.eurprd04.prod.outlook.com (2603:10a6:208:1::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3654.12 via Frontend Transport; Fri, 11 Dec 2020 18:39:50 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bhOtwmiuciXegVpk0/N59P/cS0YyV3yt0oJRgUjfH7efBkZKGIuopKBPxFUPV5rCKnpmoab7loCAc3hvVnGIGnNHh0MKYL5NYi7dhaMuO1Uv2ssyAnKWZzpDOpSMad4FZBFlriWDUhvdWrs6c1CbRIKUgeyOCvGU2Dq6r9jaj+m8WhuUm5gNYcw3503q+BPG41Ly64Dcwu7Z9m8VGJCc0i+PhBWvR3Fx0Wk41GxK41QGL+BCqVoMIsauDrLYwD3iS97iZDYdGqpSDToGposik64GxJTPZr6Spn5lLCJXa5AUaBxQJFWt1moDUw0qZIYsn9T3po6xH9L/Q/gPtrxoOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=uRVxsqlcDVMA/yosvYRBrO3+9X8GOnnwkjE5ScJQudM=; b=LOP3Nn4remipUlUgIUVajLveBlx0GJ71trqxRj9wYQdby+bCQhIUCoeU+hqKAzrNeRCpG3lKl8/2H/oqtz1XzzrUDGKHpwuxAgDamQZctbmhpVTS8TBnucJojaSd/QUmMjWk4vpaShBL2ybijDy1f0L0bAnTr46kxt6TWslWftiMwU/oxpW45U5KvHtFVncsrmCWxTQoXkD5kFIBDzDdTe3G15oUBU/d+t0mEqFmrB36TyQlpwO8puFf67TVj2j2IZlOzeZmbJdBXHDO0IWuMQXw1H3WK05dM5UCnFvAMEk5eNwQ6IvEYJ6WUZ+TtsRwj/gs8NL+iXIZpiYCaty5fg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=uRVxsqlcDVMA/yosvYRBrO3+9X8GOnnwkjE5ScJQudM=; b=RWaADRfL8bIGb6CIjW3f9dWFVh+HnSsou8CcNa4r/thm38HjzUP7Ru3dnigTHtx5siNqZ3wU+SAFS96NvEDzAOFH7Fvuzb1CGd649TPqrIkoeDaDGPDXAshJpW5KSTg3QibthFEthCAqqNq5ZoaOHqp6hq+MjcNwlq8z+ybTJzU= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Subject: [PATCH v4 04/16] block/io: refactor bdrv_pad_request(): move bdrv_pad_request() up Date: Fri, 11 Dec 2020 21:39:22 +0300 Message-Id: <20201211183934.169161-5-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20201211183934.169161-1-vsementsov@virtuozzo.com> References: <20201211183934.169161-1-vsementsov@virtuozzo.com> Content-Transfer-Encoding: quoted-printable X-Originating-IP: [185.215.60.91] X-ClientProxiedBy: AM0PR04CA0050.eurprd04.prod.outlook.com (2603:10a6:208:1::27) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: fa3541be-5d42-46c3-70e3-08d89e042526 X-MS-TrafficTypeDiagnostic: AM6PR08MB4915: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6430; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: o5Dmu0vvX8wOJJEmpeHWWx2eFNA8m52dI3oVUGf8+tcu3RobcN158uTTofNRt5WXK/N0spKKymM7mRawjyHiuxATyIj61OqON5ja3TV7mV19LrW4QhDtZXgLd7A+T56fKCkb/bmjODhWSLuYJrEqBLQQlwlgtFfUq2zdorIQVHLEg6t6Opm7AwLyHKelWbEKq1qMJGnbUK6Bo+ii5lLZxAVdishu/lcAAa3A5OjR+Szf9+gUwNBJSsLjnuCe0JSbEDjSVGnZMRo2WOrg77OyckYDZ2TaQWJErz+OstF7c8iVv6OsiAzztJORld5FSkGQ25V4zIDi/N+vUtxMdUcxEA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(346002)(39840400004)(136003)(396003)(376002)(66476007)(6506007)(66946007)(956004)(6486002)(86362001)(4326008)(66556008)(6916009)(6512007)(2616005)(6666004)(83380400001)(1076003)(26005)(316002)(16526019)(5660300002)(8676002)(186003)(478600001)(8936002)(2906002)(36756003)(107886003)(52116002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?vhE/yUL8AY8qml8npL7TfL1zioL+0tbt6VUyMDaPf3q5V+ly3ucYQ72/GQJe?= =?us-ascii?Q?2tGbff7tFZCIR19nXT7I9bUMQRVBQsdzp0Z55I81IatoomDzjxVbpucfLOkO?= =?us-ascii?Q?WgZD0Ar4DfftQQBIhvG6kKail1TX3CT/mRzMK0gndIqPpuqLnC6Zs9hvCAEE?= =?us-ascii?Q?Zdg8iInjwtn1Kysa8ChykKXbDh406V4YQHUqf80q6SaN3wpJcuuxhYNcKKdM?= =?us-ascii?Q?zPXNiKuw0O+H91Nn0o2WXCTyyp4IFFZtmmb0dG9J3a3eTQREpHkc1v4pRjBW?= =?us-ascii?Q?B48Uh2/XE3vKhKNODqYY6ZyiIjI0uXXsCbHdpqOVKLLXqngkhqloichj68zu?= =?us-ascii?Q?wuFkuB9xR+0Mm39k7HYTHLByEpuP0kv6FK1qpX0xc2wzBS+SFVQJ4TAgfqEH?= =?us-ascii?Q?zwNGOAuJJHuaZod5nYV4kQK5je2DnQ47bat+v30EGIRelq2DUMMdSi4LLmnb?= =?us-ascii?Q?BcmcuYp3jlBbcWtXDFx9WKysMrhamhAxqdvYH4njZKqGc7q4aFxx7PQe0TXq?= =?us-ascii?Q?K5QsB+bLfKc0ehG4aCmFf9oyEfh/b+72ITs7iWmzXrnLSvsPOzsZPN7XgYi9?= =?us-ascii?Q?EhVyqx4fSBOi4ffNJdbKi784U/BlmS77CdzAQTG5utHskIC7y+vM/t8G1mkS?= =?us-ascii?Q?Hd5rQ07TYlu0+o4UwIgUiFCD2RJ9vRld4+Vkp6Vb9x1oapsLEFq5lQ3D7EYS?= =?us-ascii?Q?J8K16btgvquXEzYXE9qOh7egVYU71uJby8enohQlNc8ywB8v3hfBDi9Vzl7T?= =?us-ascii?Q?KTGhaCSp40bIjGSOivpqVsJyS3FiZEbWgaJpr9Z6+RHGGMQLQHwYkqFFex5l?= =?us-ascii?Q?TJxBh/ve3MQAwvOcvPFds0qxDldYGAdly4imwNM6dJJ4Fz3eWTWgvjEhUepR?= =?us-ascii?Q?dlCawIxco4PGqeYoTVLAlHnJgbvJMQGe+UPT2zSPxAbE0hydxb3nnX2v7mVE?= =?us-ascii?Q?MgeeBL3upvKRwbuelLGbHGSbGiVKVpy6w0yIPleTkDOrVBhHFNocMIw+o/vg?= =?us-ascii?Q?ne2w?= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Dec 2020 18:39:51.2024 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-Network-Message-Id: fa3541be-5d42-46c3-70e3-08d89e042526 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: V46JA60/jPK+1QlOS6OSMdzAEDhZUL6rT/FL6lrXSLZB/6py+JQ4iGv8lkbZk3RaFdGaWfeg0cuxo4p74m2asO6S697uLPxiCmKAnpr7blA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4915 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=40.107.7.97; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-HE1-obe.outbound.protection.outlook.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, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-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: fam@euphon.net, kwolf@redhat.com, vsementsov@virtuozzo.com, berto@igalia.com, qemu-devel@nongnu.org, mreitz@redhat.com, stefanha@redhat.com, den@openvz.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @virtuozzo.com) Content-Type: text/plain; charset="utf-8" Prepare to the following patch when bdrv_pad_request() will be able to fail. Update the comments. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Eric Blake --- block/io.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/block/io.c b/block/io.c index d9bc67f1b0..dcfab267f8 100644 --- a/block/io.c +++ b/block/io.c @@ -2107,6 +2107,7 @@ int coroutine_fn bdrv_co_pwritev_part(BdrvChild *chil= d, uint64_t align =3D bs->bl.request_alignment; BdrvRequestPadding pad; int ret; + bool padded =3D false; =20 trace_bdrv_co_pwritev(child->bs, offset, bytes, flags); =20 @@ -2138,20 +2139,32 @@ int coroutine_fn bdrv_co_pwritev_part(BdrvChild *ch= ild, return 0; } =20 + if (!(flags & BDRV_REQ_ZERO_WRITE)) { + /* + * Pad request for following read-modify-write cycle. + * bdrv_co_do_zero_pwritev() does aligning by itself, so, we do + * alignment only if there is no ZERO flag. + */ + padded =3D bdrv_pad_request(bs, &qiov, &qiov_offset, &offset, &byt= es, + &pad); + } + bdrv_inc_in_flight(bs); - /* - * Align write if necessary by performing a read-modify-write cycle. - * Pad qiov with the read parts and be sure to have a tracked request = not - * only for bdrv_aligned_pwritev, but also for the reads of the RMW cy= cle. - */ tracked_request_begin(&req, bs, offset, bytes, BDRV_TRACKED_WRITE); =20 if (flags & BDRV_REQ_ZERO_WRITE) { + assert(!padded); ret =3D bdrv_co_do_zero_pwritev(child, offset, bytes, flags, &req); goto out; } =20 - if (bdrv_pad_request(bs, &qiov, &qiov_offset, &offset, &bytes, &pad)) { + if (padded) { + /* + * Request was unaligned to request_alignment and therefore padded. + * We are going to do read-modify-write. User is not prepared to w= idened + * request intersections with other requests, so we serialize the + * request. + */ bdrv_mark_request_serialising(&req, align); bdrv_padding_rmw_read(child, &req, &pad, false); } --=20 2.25.4 From nobody Fri May 17 21:24:39 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; arc=pass (i=1dmarc=pass fromdomain=virtuozzo.com); dmarc=pass(p=quarantine dis=none) header.from=virtuozzo.com ARC-Seal: i=2; a=rsa-sha256; t=1607713065; cv=pass; d=zohomail.com; s=zohoarc; b=EXXu9wE3AATBqnkIOF+XTPMiZ+KZou1UWs0RnVvcFYl4lvhrSZrP/BZlJWRpg04/yidxy1BYDHc+3bO9tfy5BRlbfHWIg3FDrcxtUXqSm7rN69cwpfJRQZzLkWQ8EomDQy8hwu7TrEbo/048YzLFnGPkaTWCI/s5rvyyZ701Rpc= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607713065; 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=vYIKvYClPzzTjHvGHqDFEVsB8VPTGFGjCi4+tLeaSow=; b=T3i5MABpGMxLtArIMArOqlDOQDkhBkZYBB/fHgC2WQFKOyFmTq57XeFlDVZ+XPjAOXd7IUbKfyE66V8RB1UliGUf6RFd0dOsS4M+LV/lVSE9WusZZMGNOemmPwEvqx7GbA9lRmmvW1ZZtl4UQ3GDoG3TuI2/wIBIouY8U7XwWr0= ARC-Authentication-Results: i=2; 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; arc=pass (i=1dmarc=pass fromdomain=virtuozzo.com); dmarc=pass header.from= (p=quarantine dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 160771306544021.512389134853947; Fri, 11 Dec 2020 10:57:45 -0800 (PST) Received: from localhost ([::1]:37462 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1knnbk-0002xb-Rg for importer@patchew.org; Fri, 11 Dec 2020 13:57:38 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43610) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1knnKr-0006et-Jb; Fri, 11 Dec 2020 13:40:10 -0500 Received: from mail-eopbgr70090.outbound.protection.outlook.com ([40.107.7.90]:11267 helo=EUR04-HE1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1knnKm-00089o-J2; Fri, 11 Dec 2020 13:40:09 -0500 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB4915.eurprd08.prod.outlook.com (2603:10a6:20b:d1::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3632.18; Fri, 11 Dec 2020 18:39:52 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::d585:99a4:d7a4:d478]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::d585:99a4:d7a4:d478%4]) with mapi id 15.20.3654.016; Fri, 11 Dec 2020 18:39:52 +0000 Received: from kvm.sw.ru (185.215.60.91) by AM0PR04CA0050.eurprd04.prod.outlook.com (2603:10a6:208:1::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3654.12 via Frontend Transport; Fri, 11 Dec 2020 18:39:51 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Tr+cvDGktYIaXcpk/z5+kQZkhsQvEjtD7CD/h/25nUY68A62aeJ7xp/P+vYZHKBNuQpaTmjC5g7zZ+i6fPR39ytQTVXAPnXap+Y1CARgddT1cigkt49ZwND/31nkB9qURSRVNnuwObA3g8q+LVn60vk2TQcx3w4pzc74bWl/RNA8RKdQPEvKsvHhAYIvEO+sQtdGKnRLTE6/AaMlfo/SWDx2XzxgI0LavyWp18D61E+vUiu9WKRdDzI+lmAg1dQxOd5/THSbMTT3UkTRAcwa2ROZNRE5Op24MzabqolEqU8xrd7I7bfoXgtB9KyZxkXIFVrRMIfb+YOeVCGqyFYqUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=vYIKvYClPzzTjHvGHqDFEVsB8VPTGFGjCi4+tLeaSow=; b=KeVEiqt8Fg3wGm/OTXQS0fOpVS1GWEHw71joK2E9+85pvVPrJJtQWa4g+136Kgs40sxB4fPsyyzOVlRr37C5VKyC4+AzijqeYAas4cQyCgnkzKUzGgbHSilTChRIdpwLL5isbriq7yiW+tETU1XF7uNcgef5Q4lj8ownWSK+UAuD8YdNZ45jE5tW+OIRo2aQxOuG5vGnW05uj8vHTYKZvR5DdhxsPO08yDdn6DfYVF89Tn7i6A1BIhEsixMo2deUCyGkDtx5Mz09/QX5CkLUsdB9wiBaRddU3eeUr9o0oB9Ck5NpoZ2FP5zYxAwfV5qWdtZfgpUfRFw45U/mlI82zQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=vYIKvYClPzzTjHvGHqDFEVsB8VPTGFGjCi4+tLeaSow=; b=nNRovmscqD9UFFADBUQDU5fVUxN3J2zMLPJcXbR8aiVP1z20E3LBWJNuXCJPmSUhHw2iZQmn0ThtVDZvNjIDPzBrVEWDODXNkz98/j3d3fF42c6aH51dygHcvNfBxeeS20Sk5iLgwzGW+4jNqXMIIZNXiVCldwafgRJTGQTDWMU= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Subject: [PATCH v4 05/16] block/io: bdrv_pad_request(): support qemu_iovec_init_extended failure Date: Fri, 11 Dec 2020 21:39:23 +0300 Message-Id: <20201211183934.169161-6-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20201211183934.169161-1-vsementsov@virtuozzo.com> References: <20201211183934.169161-1-vsementsov@virtuozzo.com> Content-Transfer-Encoding: quoted-printable X-Originating-IP: [185.215.60.91] X-ClientProxiedBy: AM0PR04CA0050.eurprd04.prod.outlook.com (2603:10a6:208:1::27) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 225f46be-aec6-470e-e99d-08d89e042592 X-MS-TrafficTypeDiagnostic: AM6PR08MB4915: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7691; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +KfCGpM5jlDEXgRSwhk2NevL5staETsYFSpdlyXNglGPp3091siIOubMtYldAuE+AC1vuV9b/QA2ixKq63NVQ5kfIbFtO39EZW6D5wVqdY9F2Gyo+BgwL0WDMkZopLtBGdl295kTQ9tgGF9wyLM6RVCY0ALVzx/8hB3jTe2CV3vAatcXMMKFhQq81VQq2dRv8GkbfhYzzL5Iem1mQca6t0ibNluRq+EpA0JeXtf0LkSSOvlBFjDh6czXLR8k3J7Lv2ZkR6bzrM94bWAo2AtkG7NhA2HIiIujCsY4D9vFwATtT8/Ix0EjDKPYCvSqH2gbSOiE4xuwWaqOY5NZOogSHg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(346002)(39840400004)(136003)(396003)(376002)(66476007)(6506007)(66946007)(956004)(6486002)(86362001)(4326008)(66556008)(6916009)(6512007)(2616005)(6666004)(83380400001)(1076003)(26005)(316002)(16526019)(5660300002)(8676002)(186003)(478600001)(8936002)(2906002)(36756003)(107886003)(52116002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?G1XyYGKK5ke3jzyMwLhyaeBmuYLTMIXnvn82zCVegwHrRdF54LJPJxecSw5q?= =?us-ascii?Q?35Y+IZ47o2vIovyw8dkLm8TQlva+etKpHkTISa9SIpJMtIHED8JoCYxUhhjl?= =?us-ascii?Q?vn4C48BKZAuq0IeFGzy5DCX4JVETIiECAyktRv0IgPF1j6RhIfSRFmhE0r40?= =?us-ascii?Q?BfzbcBAa+aedH2J1k1RrAvKkE/L61FqhEGzs5BDhB8vJCUTqDqddps2zwSBd?= =?us-ascii?Q?+PBc2KE4vD3F8hfwHGsM1s9w5PJEYNvRjIWV4DVlfBum8KY4BUa0/jDeznZS?= =?us-ascii?Q?g2Rn3tLjHv8UPA8FoMG2uSCxJ3pgkvd7Jav4CYL9dUQ3F+geys5zAhabo/ft?= =?us-ascii?Q?Lrc80h3OfGF4/xW2cTN2t03KLIU11nZttZo0TghonHgECuAG/NveZmW7/7r/?= =?us-ascii?Q?9sNo8FTgon3mvnblBzbWCuMSe/I+ceyCUJjLzfFMIqHLEfxcqqZLRqawd9QC?= =?us-ascii?Q?ppndSuz8BcAXJwqgJvr7BnI0c5jRRzwvmfPg4kHBzEOzCKj+mVoO+jt29wSV?= =?us-ascii?Q?OA2IJYQyWZrWrHOx5seeYXlF8aeo3zqmYNM+B9Q5GjlGtT5d684Y6d3f098k?= =?us-ascii?Q?Sopu0iSB9ioxLiV/g4b+Vc8NSxrNuYPTmGoVj9pIiFud66htQG5zXfIo6HQy?= =?us-ascii?Q?ASnW4stTPDmKqqsJGdfWoeGRtUecCQergOgDkW5LiWkY3vLOnRIypvw+lgz6?= =?us-ascii?Q?F9OloEgAbU7n5YktQkUqyApFb5Gu/Dt9Ge3wmGugPImYJUSWkOkN5S9WRMyl?= =?us-ascii?Q?hj/A8H+8QcBueXAsyNAzxkDf1CpiAIAC0d5WRO0G2poRRdXnrj4LaLrpstUa?= =?us-ascii?Q?UeBQ46YNVZJf4ssGUMZcWXRQGjkWT/Ufd4MXvjgJobKcLZKIVaccdrEakL/U?= =?us-ascii?Q?K4PhNL6pFau+aGmx8bMODKUC771VU0k1cP1ZF2iU9/+NXTpqb3vYcnwEendO?= =?us-ascii?Q?vpbcJJuemOwOET4q0BZeqFfHLexTXm+lNwK46+VsWX7wfWgc7XoiVG1Sow48?= =?us-ascii?Q?m/9c?= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Dec 2020 18:39:51.9830 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-Network-Message-Id: 225f46be-aec6-470e-e99d-08d89e042592 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: tF2VOBJy8F/14G16pr+OnjvU/Ckf/Zu7QeMdFhvcVAhF55O6ac0HNv2yGgAs5iK4ZYAR8TWGTj+WpiLVQWoNq1dzFdn59XATxbnzDGoOf6U= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4915 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=40.107.7.90; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-HE1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-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: fam@euphon.net, kwolf@redhat.com, vsementsov@virtuozzo.com, berto@igalia.com, qemu-devel@nongnu.org, mreitz@redhat.com, stefanha@redhat.com, den@openvz.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @virtuozzo.com) Content-Type: text/plain; charset="utf-8" Make bdrv_pad_request() honest: return error if qemu_iovec_init_extended() failed. Update also bdrv_padding_destroy() to clean the structure for safety. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Eric Blake --- block/io.c | 45 +++++++++++++++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 14 deletions(-) diff --git a/block/io.c b/block/io.c index dcfab267f8..4a057660f8 100644 --- a/block/io.c +++ b/block/io.c @@ -1637,6 +1637,7 @@ static void bdrv_padding_destroy(BdrvRequestPadding *= pad) qemu_vfree(pad->buf); qemu_iovec_destroy(&pad->local_qiov); } + memset(pad, 0, sizeof(*pad)); } =20 /* @@ -1646,33 +1647,42 @@ static void bdrv_padding_destroy(BdrvRequestPadding= *pad) * read of padding, bdrv_padding_rmw_read() should be called separately if * needed. * - * All parameters except @bs are in-out: they represent original request at - * function call and padded (if padding needed) at function finish. - * - * Function always succeeds. + * Request parameters (@qiov, &qiov_offset, &offset, &bytes) are in-out: + * - on function start they represent original request + * - on failure or when padding is not needed they are unchanged + * - on success when padding is needed they represent padded request */ -static bool bdrv_pad_request(BlockDriverState *bs, - QEMUIOVector **qiov, size_t *qiov_offset, - int64_t *offset, unsigned int *bytes, - BdrvRequestPadding *pad) +static int bdrv_pad_request(BlockDriverState *bs, + QEMUIOVector **qiov, size_t *qiov_offset, + int64_t *offset, unsigned int *bytes, + BdrvRequestPadding *pad, bool *padded) { int ret; =20 if (!bdrv_init_padding(bs, *offset, *bytes, pad)) { - return false; + if (padded) { + *padded =3D false; + } + return 0; } =20 ret =3D qemu_iovec_init_extended(&pad->local_qiov, pad->buf, pad->head, *qiov, *qiov_offset, *bytes, pad->buf + pad->buf_len - pad->tail, pad->tail); - assert(ret =3D=3D 0); + if (ret < 0) { + bdrv_padding_destroy(pad); + return ret; + } *bytes +=3D pad->head + pad->tail; *offset -=3D pad->head; *qiov =3D &pad->local_qiov; *qiov_offset =3D 0; + if (padded) { + *padded =3D true; + } =20 - return true; + return 0; } =20 int coroutine_fn bdrv_co_preadv(BdrvChild *child, @@ -1722,7 +1732,11 @@ int coroutine_fn bdrv_co_preadv_part(BdrvChild *chil= d, flags |=3D BDRV_REQ_COPY_ON_READ; } =20 - bdrv_pad_request(bs, &qiov, &qiov_offset, &offset, &bytes, &pad); + ret =3D bdrv_pad_request(bs, &qiov, &qiov_offset, &offset, &bytes, &pa= d, + NULL); + if (ret < 0) { + return ret; + } =20 tracked_request_begin(&req, bs, offset, bytes, BDRV_TRACKED_READ); ret =3D bdrv_aligned_preadv(child, &req, offset, bytes, @@ -2145,8 +2159,11 @@ int coroutine_fn bdrv_co_pwritev_part(BdrvChild *chi= ld, * bdrv_co_do_zero_pwritev() does aligning by itself, so, we do * alignment only if there is no ZERO flag. */ - padded =3D bdrv_pad_request(bs, &qiov, &qiov_offset, &offset, &byt= es, - &pad); + ret =3D bdrv_pad_request(bs, &qiov, &qiov_offset, &offset, &bytes,= &pad, + &padded); + if (ret < 0) { + return ret; + } } =20 bdrv_inc_in_flight(bs); --=20 2.25.4 From nobody Fri May 17 21:24:39 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; arc=pass (i=1dmarc=pass fromdomain=virtuozzo.com); dmarc=pass(p=quarantine dis=none) header.from=virtuozzo.com ARC-Seal: i=2; a=rsa-sha256; t=1607713440; cv=pass; d=zohomail.com; s=zohoarc; b=T88qPp3r5TmsJ41cxRTSWlvLgnJ+h6xSw4yoeY1gyPKJPaXokenEGAb/qLzYRsHkMMWeJLxzqTXT2nrJRGiv8lld9oLmJRdPBkJJhQ1e2qBnBj6HNUrhtcsOYMyd4vxZLpSUWz8SlpPW9nmZi0JkIMzKPzjBrftagTGayNVhQSs= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607713440; 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=5y9b5ZSfYfjBLXDRRTfJnjXBs2Zy/1fc9BA33mvrKPU=; b=FAz4q4d5MZyfvOKFgpEGZbGJiz/5UkT6aYez2k+GmLRDe/Gh6QG43VRN+v46bImbAOMIbQlq7uXZ4Ij2uIPQVdTTjk2eBeppM9JgpaijlCfcot3Xg+ibwtSdZWL9MHBIm0GIkk7klAn/xqMvSAGAcmhFlSVLytWn1q0LMtgYoMY= ARC-Authentication-Results: i=2; 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; arc=pass (i=1dmarc=pass fromdomain=virtuozzo.com); dmarc=pass header.from= (p=quarantine dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 160771344046447.97202444759148; Fri, 11 Dec 2020 11:04:00 -0800 (PST) Received: from localhost ([::1]:46450 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1knnht-0006uS-Ev for importer@patchew.org; Fri, 11 Dec 2020 14:03:57 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43664) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1knnL2-0006gx-63; Fri, 11 Dec 2020 13:40:21 -0500 Received: from mail-eopbgr70097.outbound.protection.outlook.com ([40.107.7.97]:21414 helo=EUR04-HE1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1knnKp-0008BO-Fd; Fri, 11 Dec 2020 13:40:15 -0500 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB4915.eurprd08.prod.outlook.com (2603:10a6:20b:d1::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3632.18; Fri, 11 Dec 2020 18:39:52 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::d585:99a4:d7a4:d478]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::d585:99a4:d7a4:d478%4]) with mapi id 15.20.3654.016; Fri, 11 Dec 2020 18:39:52 +0000 Received: from kvm.sw.ru (185.215.60.91) by AM0PR04CA0050.eurprd04.prod.outlook.com (2603:10a6:208:1::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3654.12 via Frontend Transport; Fri, 11 Dec 2020 18:39:52 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dUc+wAu7TqJ9tB5MkiDxQHpheUTzFCqbb4RHGfE2c5D3B87aJyY2fDigghXol3QplP4BvzJGKBmKVFUCQz+sMkrGiibcsW/x7sfKn2+yKh75jzeywnIuprp3/PPtf000WJujuzhL2ngQlta/QC8qU19iZealWqHXuC+p95PzFwpghbxTETy4YEBWMA4iVSXKsKCwKr2rQMlXn5wkx/f+lY5QaApEinYW6T665NXJDxwufMM2Cqt3IwFKk/uEmBcAs+bUhmNWF5WAObEf81afDgN7tp2CsoLnmVWBD7i2JCzv09QnbNXCfEOyLCgVVoZwzz1AjheHTn9otALZfWDRpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5y9b5ZSfYfjBLXDRRTfJnjXBs2Zy/1fc9BA33mvrKPU=; b=CbR5B74FKgbeQY6kGhnB+H9DJAPubCLoNFcKUrBsaLhIuK99tzKBzCb+ps13EmOIuXJH29dOje9doEt92U9zuuqewlQVAXmUBgvQGBFsfcRSknbG5hZgB6PIp13nvoZY6Di5woFUSNWDo8hQkHliUy85SBXziBQcnjGqpLEkjSEg/lWKsaxl1jPgKQCSpI5ZRMhFAOKxcuA25C8S4t2ej4VGvhfdcPMWDCZ9inaU/BWSqUU1A/o2XfJVH6KDHgVvTfcItClzg/TusSM2ZeKvm69WY42pgg2J4EMt/zQH5FOzDVUpUUSw6nbVxKyOdrHFmq0Oec4w63hGZSsBQWBnqg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5y9b5ZSfYfjBLXDRRTfJnjXBs2Zy/1fc9BA33mvrKPU=; b=DDx4l0fMjMOWxXO5BYuKtNcNZjveI7FfLgtHmpTVXgZORIUHgMFTNWqvANtbC06YwIuIS2WIWyh6t/Km2/cdk7E4Xr/Ow7fZth8dogCMp4iSEkr+uGz+lOTL3Lln9oP6DdLGye0oR4ylpTvVf/XYi/qngF0egYPoM4EFiWxJtr4= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Subject: [PATCH v4 06/16] block/throttle-groups: throttle_group_co_io_limits_intercept(): 64bit bytes Date: Fri, 11 Dec 2020 21:39:24 +0300 Message-Id: <20201211183934.169161-7-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20201211183934.169161-1-vsementsov@virtuozzo.com> References: <20201211183934.169161-1-vsementsov@virtuozzo.com> Content-Transfer-Encoding: quoted-printable X-Originating-IP: [185.215.60.91] X-ClientProxiedBy: AM0PR04CA0050.eurprd04.prod.outlook.com (2603:10a6:208:1::27) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2dc80c02-cfb0-4396-cd9e-08d89e042608 X-MS-TrafficTypeDiagnostic: AM6PR08MB4915: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VK/rbujgC+WXOoUMbco/QEhLx5QtTUhSiGMNvlyWzlY89vgX8B/GSbYHoCVR4aD4JilKfgzL+FwGK/a4JlsguW4A7N36Z+YN2nH2eAO/jo72Fj+QDEnVEle1FzyoKTNpO0AocFJzYrLOXrq1D6oifPpHgRTk1qHieeov8GCGEzQK7EbS3Y+/FuNoNX/Bf5GghMGQJWRjgF6zpdl7zwU620AXGEnnXf1BxgXvdzMHlOmXPKvpZ1ezqppLPNcFgvMcVLWbXvp5WE07Nlt/4fVe548VJLtons4jGSyk60qaC3UvnalT2DrDbfJU15cp23DWbDEZBsZbDSU5GdDopctpKw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(346002)(39840400004)(136003)(396003)(376002)(66476007)(6506007)(66946007)(956004)(6486002)(86362001)(4326008)(66556008)(6916009)(6512007)(2616005)(6666004)(83380400001)(1076003)(26005)(316002)(16526019)(5660300002)(8676002)(186003)(478600001)(8936002)(2906002)(36756003)(107886003)(52116002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?qn2mYsntRjXNe4DJgvPoYB1cnn4E5pzYEhKpKp/bcMB8dZ+xRmlT1osBPCse?= =?us-ascii?Q?FDkQSk0PsPeNTHhGIFfUlYvqzh80Sj5Hjjt5pDJOP89F8dzyF3GZNBWPC0Tv?= =?us-ascii?Q?jiyZKMzmwuHqjz1pNxaQnTiNdgITlbGX5UMelx5P3PxSPwk4wKKS8KduiMnT?= =?us-ascii?Q?f+Qg34L7NvOu3rST150KidPUutseXgKwoJLC41D0zC8JSXcTLaAxaqisKcrg?= =?us-ascii?Q?fQKiq9po2OTIERhOBzUAOa6Fh8cta6BhuATd4+SFmeaONvC5d9A5ZRhOhvuU?= =?us-ascii?Q?oEyNEvKuiRQ4tbs7VqxKVaVEklLrc6FPRy79VWsgSagF9wBo32Ss98C2pI06?= =?us-ascii?Q?R3l2OFoN6N7wTvY+XRUO0fLsGLFCIAVFKWSiw2AGN0E+1euEvB/Yj21RQdHd?= =?us-ascii?Q?7UHG7YSq2drfpTPKH4z5IPyTm8mpRqcE/W3gqChMUthib2Xqy/z4veExgGK/?= =?us-ascii?Q?dCMHXnxUu5Hxa/wgLu9e4nMMEa0p3judBAd4CiBzKxEAO74se/Sax6W8FMio?= =?us-ascii?Q?02oTsyytTYyeEkG1sZjm93pjw0gcAOLFMUh4VYR0D6Ioi71e1mSO5eRdjqPQ?= =?us-ascii?Q?sbuc3TqK+P7hK1Vr+2bmkWJ43osueFQ1Z7lGOiz+D1XCd5GF/7OkO8vGk5IZ?= =?us-ascii?Q?kqDbUZBpCFEGBNyG8dU5XBnX0dh0QIS/WKo3xHKSm3vpBsAzbcRAkkub3AbC?= =?us-ascii?Q?GU1Qb821OzWDrnefdX/GuZMN2/QcEWJONMlVkPeFZxMznYS+patq6pzrViNI?= =?us-ascii?Q?mPFdWi16PjNUFgHgqZBZs6jAXUmJ8yN9cfPCgkfw1iMPDh/YLqNKpZVcYZVl?= =?us-ascii?Q?nRdeVpiae89gpG/VEC7Hm1iTDV4aG7mZWmM8IQxRSFHAlHgpXq0svjynLpDm?= =?us-ascii?Q?VXjG1fMbdoovONalpfwL8mdVGAnJE21bJXoqTyMZV248/8/qWsmro5/ee7vY?= =?us-ascii?Q?/vBfFZq+oZD3UtGBiH8LaSuOB6DgFPhfuJzM2vUURagp7B2UMYPETlPgrL/x?= =?us-ascii?Q?KnHJ?= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Dec 2020 18:39:52.7606 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-Network-Message-Id: 2dc80c02-cfb0-4396-cd9e-08d89e042608 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 730b3p9qeWMMM3ZlWB0Y/TLMZqfUQRoVGSQYiZ6e7QZk3E3ncCt9EePE8n4chg5vGhSn8rQ7I2u1CUlll14pTZ2r0N9gC5XVi9cWYU+urAg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4915 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=40.107.7.97; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-HE1-obe.outbound.protection.outlook.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, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-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: fam@euphon.net, kwolf@redhat.com, vsementsov@virtuozzo.com, berto@igalia.com, qemu-devel@nongnu.org, mreitz@redhat.com, stefanha@redhat.com, den@openvz.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @virtuozzo.com) Content-Type: text/plain; charset="utf-8" The function is called from 64bit io handlers, and bytes is just passed to throttle_account() which is 64bit too (unsigned though). So, let's convert intermediate argument to 64bit too. This patch is a first in the 64-bit-blocklayer series, so we are generally moving to int64_t for both offset and bytes parameters on all io paths. Main motivation is realization of 64-bit write_zeroes operation for fast zeroing large disk chunks, up to the whole disk. We chose signed type, to be consistent with off_t (which is signed) and with possibility for signed return type (where negative value means error). Patch-correctness audit by Eric Blake: Caller has 32-bit, this patch now causes widening which is safe: block/block-backend.c: blk_do_preadv() passes 'unsigned int' block/block-backend.c: blk_do_pwritev_part() passes 'unsigned int' block/throttle.c: throttle_co_pwrite_zeroes() passes 'int' block/throttle.c: throttle_co_pdiscard() passes 'int' Caller has 64-bit, this patch fixes potential bug where pre-patch could narrow, except it's easy enough to trace that callers are still capped at 2G actions: block/throttle.c: throttle_co_preadv() passes 'uint64_t' block/throttle.c: throttle_co_pwritev() passes 'uint64_t' Implementation in question: block/throttle-groups.c throttle_group_co_io_limits_intercept() takes 'unsigned int bytes' and uses it: argument to util/throttle.c throttle_account(uint64_t) All safe: it patches a latent bug, and does not introduce any 64-bit gotchas once throttle_co_p{read,write}v are relaxed, and assuming throttle_account() is not buggy. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Eric Blake Reviewed-by: Alberto Garcia --- include/block/throttle-groups.h | 2 +- block/throttle-groups.c | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/include/block/throttle-groups.h b/include/block/throttle-group= s.h index 8bf7d233fa..9541b32432 100644 --- a/include/block/throttle-groups.h +++ b/include/block/throttle-groups.h @@ -77,7 +77,7 @@ void throttle_group_unregister_tgm(ThrottleGroupMember *t= gm); void throttle_group_restart_tgm(ThrottleGroupMember *tgm); =20 void coroutine_fn throttle_group_co_io_limits_intercept(ThrottleGroupMembe= r *tgm, - unsigned int bytes, + int64_t bytes, bool is_write); void throttle_group_attach_aio_context(ThrottleGroupMember *tgm, AioContext *new_context); diff --git a/block/throttle-groups.c b/block/throttle-groups.c index abd16ed9db..fb203c3ced 100644 --- a/block/throttle-groups.c +++ b/block/throttle-groups.c @@ -358,12 +358,15 @@ static void schedule_next_request(ThrottleGroupMember= *tgm, bool is_write) * @is_write: the type of operation (read/write) */ void coroutine_fn throttle_group_co_io_limits_intercept(ThrottleGroupMembe= r *tgm, - unsigned int bytes, + int64_t bytes, bool is_write) { bool must_wait; ThrottleGroupMember *token; ThrottleGroup *tg =3D container_of(tgm->throttle_state, ThrottleGroup,= ts); + + assert(bytes >=3D 0); + qemu_mutex_lock(&tg->lock); =20 /* First we check if this I/O has to be throttled. */ --=20 2.25.4 From nobody Fri May 17 21:24:39 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; arc=pass (i=1dmarc=pass fromdomain=virtuozzo.com); dmarc=pass(p=quarantine dis=none) header.from=virtuozzo.com ARC-Seal: i=2; a=rsa-sha256; t=1607714952; cv=pass; d=zohomail.com; s=zohoarc; b=cOtNmgIRzpVLK+MA2rboKGarnYDOQt811ZrydyR8IM4yvqnvpFsYsvdifHN0sOHesSsmU3Jj88ZEYxThGJfunUZW6S/8nm6kWPtdlMlj5cnzWn6SHw+cgnIh2M3Yuns0cH2VvH04yyC3rdyXNBD4iC98UpNYQNmeTErs7X3vhBw= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607714952; 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=8dGZEplD8X0OJSsgYRnDpaI5SaSyTCY8+npF9Wi7AQE=; b=HlSOJ83amDAmnZuQ+7/lhMi5MPy0hTWhctTKVTAig2bjd3FQv6JjvQwXZIsj/0vwc9ONgclclcskB5yQr/su5U2CUx7Dsw8vEZwFB+5PJhNWgYZEGMRhXcNXsGYJDA0NKaioeLwJw+isEbyawVUK48zYJ3a3NYSPTwfRT4CKgOk= ARC-Authentication-Results: i=2; 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; arc=pass (i=1dmarc=pass fromdomain=virtuozzo.com); dmarc=pass header.from= (p=quarantine dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1607714952030948.5963846414583; Fri, 11 Dec 2020 11:29:12 -0800 (PST) Received: from localhost ([::1]:51548 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1knnmG-0000oa-Cy for importer@patchew.org; Fri, 11 Dec 2020 14:08:28 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43700) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1knnL4-0006i6-Fw; Fri, 11 Dec 2020 13:40:22 -0500 Received: from mail-eopbgr70129.outbound.protection.outlook.com ([40.107.7.129]:29411 helo=EUR04-HE1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1knnKq-0008CX-G6; Fri, 11 Dec 2020 13:40:22 -0500 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB4915.eurprd08.prod.outlook.com (2603:10a6:20b:d1::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3632.18; Fri, 11 Dec 2020 18:39:53 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::d585:99a4:d7a4:d478]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::d585:99a4:d7a4:d478%4]) with mapi id 15.20.3654.016; Fri, 11 Dec 2020 18:39:53 +0000 Received: from kvm.sw.ru (185.215.60.91) by AM0PR04CA0050.eurprd04.prod.outlook.com (2603:10a6:208:1::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3654.12 via Frontend Transport; Fri, 11 Dec 2020 18:39:52 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jcuOr7tkEbGAXO60jT1JmwvorVnTXc7dzOsIK20HfJECFLBd06sq2Z86a5JB8hn2++2nLl/kbzHEdR9XzLI0FBsrm2KauITD5LMEuB9pkY8SbW/7q6O5C55eELLXF1r6vNAZeZJJFXmC/9BaPwa9bQvkBYo0Iq0sJXrlfXiabsM3si50O47MVyuZqUj5y6O7vLf7O38I0vhOsKdHnVcyhPOsVsyJQA+Ryk1KJCqY4F57MiRzX0cHlxnqqFsi0i1fAH6se/ip24i/I7bISQVDG/2SHqG3kptv5ieNyYNcCMZW6usjpID9DU4H32OHlEclbRiml9SGh6rvv1Fr+tKySg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=8dGZEplD8X0OJSsgYRnDpaI5SaSyTCY8+npF9Wi7AQE=; b=hSaCvoT753r8EJf6daNvLXdwfZxDzYiTVqHo+vbzvVU+6HGZeakHJQExqEBEkQKDlpfw3R/yQUwvV79cHLy51X2/i49OxGlT3ppv/eyrkDyjYkHWzE4xfpXXLLDw6D1WYgCsaVVLFao2Gi2/+dAIdncFxEpVyIL6xGg1PK9mtCua4T2Ng/3Mkx6+I0gmn9hXQBcykNPmY+ZBR7cE6PkgtgiPdZTHOdqhDmz6UgY2nPRa2QkRjz6UYu3+kYzFAzvgxJ/O0d/88ikUyRryirAURLNpPL8Au4VHNPSD0TMUXDNfH16UQbQ0sY/b9bA+bwZAvgj4jIQTGbzBRO4trUsucg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=8dGZEplD8X0OJSsgYRnDpaI5SaSyTCY8+npF9Wi7AQE=; b=Tg/Bpa2PQwdnm4taHPNA+Avs1dwvYMKtRdN4fv00xYu+5Qzr3BMzCZ0H6/JuY+c6OluLfOQvXx999PQoE5owruYdLHunASUlVxJ0dd0BeD0kdKuMbelUQxs7p38zrBgO7AeZjOZdchtup2MAQ8QWQ500uAA+GRLPPqU75nV5suQ= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Subject: [PATCH v4 07/16] block/io: improve bdrv_check_request: check qiov too Date: Fri, 11 Dec 2020 21:39:25 +0300 Message-Id: <20201211183934.169161-8-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20201211183934.169161-1-vsementsov@virtuozzo.com> References: <20201211183934.169161-1-vsementsov@virtuozzo.com> Content-Transfer-Encoding: quoted-printable X-Originating-IP: [185.215.60.91] X-ClientProxiedBy: AM0PR04CA0050.eurprd04.prod.outlook.com (2603:10a6:208:1::27) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9cdec300-dd75-4c76-cbaf-08d89e042682 X-MS-TrafficTypeDiagnostic: AM6PR08MB4915: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:198; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: GdrA1IWAN8NDQezLy6AdCtBLGLmGiKifnapFx50Mw5ImGaJ0WbZKYwmkKQsn23N114cSwfdbqNO7UYS381F36Z5vVCn5YhfqJ6tqSj0ZuDPiPi+Ai49MwxPXsUuXPcHGewTWUMGbyPJBQtoE/WUZG4KZssIWg+rqDyvsJgRRkO/QWlz50+ulqirUlEdI3i02bZJR0gPf+1ZV/e6LDOy01w6tolPSJ5ERkhE0CYWCrWytBwcaVNUYXYuOGRzhgEUe4qoWfXthnSOqxs/kEJj31PjYJPxKQanfVQGEC60oyIb0/zlDmDSnHFy/d0bxgnpoyoav+wH9nCvvybaWaWwViw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(346002)(39840400004)(136003)(396003)(376002)(66476007)(6506007)(66946007)(956004)(6486002)(86362001)(4326008)(66556008)(6916009)(6512007)(2616005)(6666004)(83380400001)(1076003)(26005)(316002)(16526019)(5660300002)(8676002)(186003)(478600001)(8936002)(2906002)(36756003)(107886003)(52116002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?HwhyHEr4QmVYSK/SfawY3L2rNpVmF3NNU7T4R7rGxuXpsalHBglESTCN+ftr?= =?us-ascii?Q?zQ+AhVarpKzj4oHaBssKms4x3aP26AZ7/Jlfv1eETry4jlS59KPJ+OfBhARF?= =?us-ascii?Q?yP68U68ujh+iFIipl7SPE0qxe1rzVVEY3kIhz2esPPBunOsQxuRsIAzV6Uhd?= =?us-ascii?Q?j2eEffawoTghtWVpQ8oZl7dXAj4jjHgGwAT2dz5VNGGGoV4zTqlJlhQ8KLm5?= =?us-ascii?Q?TkXYLTME4W+eufaCTMLcahhyZGmiLiCwFaYpazSkr0u6yGuAu6SkJX+JUhff?= =?us-ascii?Q?JbGR7fky38agSOWgxegWyvXZKIuDY7TjrpROY6crzDD2oFTql942rd9oUei9?= =?us-ascii?Q?NiY+RQeu0TpE/Mx6ZuLCZHPl3LfcBLwUY4mzRh2DaSWHOy5kol6Fm4CGBe/k?= =?us-ascii?Q?MD/ULeyLWJbYfBZfH8PU9nFEQa7Dhq96RNZhd416380Ci1gN1pjPcXQ3D3PP?= =?us-ascii?Q?yYHk2VJ6su/4K38CivZUgBBLqb/ewY6I8Al2rrpdJxQFy1iK8MyYMuvBzGls?= =?us-ascii?Q?k3Hm3DEG4aP3gcq5r7VflPsOAkVDS8VNke18LuPwC5e/E6PS28P+bl7m14ZL?= =?us-ascii?Q?rF3ceJvOXu30jwfOTt9FxGT+KvKeApImlAAzu7MwHVvYbkMQKV95+ZMaHISj?= =?us-ascii?Q?SYv5aeZB6b+b/YrUGYOq+ZUpIzaa88xFNCGQ96Trw/XiLV6LnWX05w699rTy?= =?us-ascii?Q?DOfipvK24fvsbBpI4YmbIfTHksc5NUiu9rszqzQm3PkkRlCTQe9wlZ87OS2p?= =?us-ascii?Q?wO1P8HhSWkWdXgBBU9YHt7iItEsMRSdU0awAruOIraeIAy6jG3PUmA9/mhIV?= =?us-ascii?Q?hj9KJqa1I6IS4kAq8yfsr5FCAZz+2hQPkfJj2b/GybQ2EKOKhKoeOjH89iZ6?= =?us-ascii?Q?YWOca3bEBJ7AbQyG5u9DOP/B7NxcnxLyKKs76d8LSPmK6//cCTQGKsFJbrIs?= =?us-ascii?Q?34ii0plP7Ot7O8TsRfq8qEilKCw9Kqve8ZJQ2t9N3RBbC0vIWmOBqGZ9qxSt?= =?us-ascii?Q?wp9C?= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Dec 2020 18:39:53.5640 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-Network-Message-Id: 9cdec300-dd75-4c76-cbaf-08d89e042682 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: WZ0u+7viZz1XJ2J/tTMkJIMxGk8EkFVo0WNI1TcfnyyvicH4oRXuX/2yU16aCqRt2JXYcenkv/o+VX45sVImAf2uH+W1KgJhcpC8267q8Bo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4915 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=40.107.7.129; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-HE1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-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: fam@euphon.net, kwolf@redhat.com, vsementsov@virtuozzo.com, berto@igalia.com, qemu-devel@nongnu.org, mreitz@redhat.com, stefanha@redhat.com, den@openvz.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @virtuozzo.com) Content-Type: text/plain; charset="utf-8" Operations with qiov add more restrictions on bytes, let's cover it. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Eric Blake --- block/io.c | 46 +++++++++++++++++++++++++++++++++++++++------- 1 file changed, 39 insertions(+), 7 deletions(-) diff --git a/block/io.c b/block/io.c index 4a057660f8..42e687a388 100644 --- a/block/io.c +++ b/block/io.c @@ -898,8 +898,14 @@ static bool coroutine_fn bdrv_wait_serialising_request= s(BdrvTrackedRequest *self return waited; } =20 -int bdrv_check_request(int64_t offset, int64_t bytes, Error **errp) +static int bdrv_check_qiov_request(int64_t offset, int64_t bytes, + QEMUIOVector *qiov, size_t qiov_offset, + Error **errp) { + /* + * Check generic offset/bytes correctness + */ + if (offset < 0) { error_setg(errp, "offset is negative: %" PRIi64, offset); return -EIO; @@ -929,12 +935,38 @@ int bdrv_check_request(int64_t offset, int64_t bytes,= Error **errp) return -EIO; } =20 + if (!qiov) { + return 0; + } + + /* + * Check qiov and qiov_offset + */ + + if (qiov_offset > qiov->size) { + error_setg(errp, "qiov_offset(%zu) overflow io vector size(%zu)", + qiov_offset, qiov->size); + return -EIO; + } + + if (bytes > qiov->size - qiov_offset) { + error_setg(errp, "bytes(%" PRIi64 ") + qiov_offset(%zu) overflow i= o " + "vector size(%zu)", bytes, qiov_offset, qiov->size); + return -EIO; + } + return 0; } =20 -static int bdrv_check_request32(int64_t offset, int64_t bytes) +int bdrv_check_request(int64_t offset, int64_t bytes, Error **errp) +{ + return bdrv_check_qiov_request(offset, bytes, NULL, 0, errp); +} + +static int bdrv_check_request32(int64_t offset, int64_t bytes, + QEMUIOVector *qiov, size_t qiov_offset) { - int ret =3D bdrv_check_request(offset, bytes, NULL); + int ret =3D bdrv_check_qiov_request(offset, bytes, qiov, qiov_offset, = NULL); if (ret < 0) { return ret; } @@ -1708,7 +1740,7 @@ int coroutine_fn bdrv_co_preadv_part(BdrvChild *child, return -ENOMEDIUM; } =20 - ret =3D bdrv_check_request32(offset, bytes); + ret =3D bdrv_check_request32(offset, bytes, qiov, qiov_offset); if (ret < 0) { return ret; } @@ -2129,7 +2161,7 @@ int coroutine_fn bdrv_co_pwritev_part(BdrvChild *chil= d, return -ENOMEDIUM; } =20 - ret =3D bdrv_check_request32(offset, bytes); + ret =3D bdrv_check_request32(offset, bytes, qiov, qiov_offset); if (ret < 0) { return ret; } @@ -3135,7 +3167,7 @@ static int coroutine_fn bdrv_co_copy_range_internal( if (!dst || !dst->bs || !bdrv_is_inserted(dst->bs)) { return -ENOMEDIUM; } - ret =3D bdrv_check_request32(dst_offset, bytes); + ret =3D bdrv_check_request32(dst_offset, bytes, NULL, 0); if (ret) { return ret; } @@ -3146,7 +3178,7 @@ static int coroutine_fn bdrv_co_copy_range_internal( if (!src || !src->bs || !bdrv_is_inserted(src->bs)) { return -ENOMEDIUM; } - ret =3D bdrv_check_request32(src_offset, bytes); + ret =3D bdrv_check_request32(src_offset, bytes, NULL, 0); if (ret) { return ret; } --=20 2.25.4 From nobody Fri May 17 21:24:39 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; arc=pass (i=1dmarc=pass fromdomain=virtuozzo.com); dmarc=pass(p=quarantine dis=none) header.from=virtuozzo.com ARC-Seal: i=2; a=rsa-sha256; t=1607716552; cv=pass; d=zohomail.com; s=zohoarc; b=nWgSXdFezX2Xfcny3DtO+GTRooAFkqjgXrapdJzZzr0H1EMcR8J8ujiS5J34SAPjf1McihvVzFaM+gtxpym/cM4RrULf2x8KxyiY3jDSSE1+TO6j+BUYkGsCDlMaH1Vh0XSglq+YCYoNNvn+EvM0kzWQ3v3uE3lFweNc5Cf7M4g= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607716552; 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=9fpKfrQ2GcMX74J1uBIDqrWQTDh6khkW6lExgvhocEg=; b=S2KWKV1uXW5UUm2SLHU6RtwfDMT9dqNYHOIHX5e+LuZckCR09Dv5fg91MLSRtdUVyZfy64xFdPAiLi93tiuzharvKyTNdL4duzkCsoI+ZNl+/K0FNRpQvim7kLdsQQ+9BcTcI6vB9W6nWjeYcYOABHrqVEzAmSO9UrJQm6AwVIs= ARC-Authentication-Results: i=2; 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; arc=pass (i=1dmarc=pass fromdomain=virtuozzo.com); dmarc=pass header.from= (p=quarantine dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1607716552747307.0466345384639; Fri, 11 Dec 2020 11:55:52 -0800 (PST) Received: from localhost ([::1]:60028 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1knnsi-0004g9-Qr for importer@patchew.org; Fri, 11 Dec 2020 14:15:08 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43724) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1knnL5-0006kb-S8; Fri, 11 Dec 2020 13:40:23 -0500 Received: from mail-eopbgr70090.outbound.protection.outlook.com ([40.107.7.90]:11267 helo=EUR04-HE1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1knnKs-00089o-AD; Fri, 11 Dec 2020 13:40:23 -0500 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB4915.eurprd08.prod.outlook.com (2603:10a6:20b:d1::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3632.18; Fri, 11 Dec 2020 18:39:54 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::d585:99a4:d7a4:d478]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::d585:99a4:d7a4:d478%4]) with mapi id 15.20.3654.016; Fri, 11 Dec 2020 18:39:54 +0000 Received: from kvm.sw.ru (185.215.60.91) by AM0PR04CA0050.eurprd04.prod.outlook.com (2603:10a6:208:1::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3654.12 via Frontend Transport; Fri, 11 Dec 2020 18:39:53 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Uy9ioJGKg1yxlJCU9MZVX3HTj97Wv/+Z+T35fw2wrgpfNLtEFR09aZg8r6OeZ653JQr9v++9O7NKPFLArWQb7N55Ui6YWnEpXaoXwbCxOtM0ltzTGhrXwYX3QkOO7k8GldUejBYWbUPjWdD595iki7ks1awqK0hrcYR7gScM9uhb3Ha8tVbEW1P/r9N23eZ1AT2oSJIlH66xOeZ71Ii8PLYbDh6ut83rTkrghUJdoTh3pey4bGdip+dKdtmi18vCGrSInfQr50EJzxoQqrxNjtzuPQpC1n7uRFPIowVFt87OPb8zWAHKkpr/X1wJpOWGzH4D9t+0616ZmT96ud5upQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=9fpKfrQ2GcMX74J1uBIDqrWQTDh6khkW6lExgvhocEg=; b=CcFhGpItO+SfOdx4OeA10+gpcgMaYnzJgG6RRJUssJ7idTi3oeiASAb434LQh/4sbaoa4U9TPIQHP9fhmddRm31ARIo7v1+AQcaFE8MajJAQB1dJVPASTw2NLhqRYQOMBwflCd2YzwlJ7Y37BhhaKmC3yDUn6wp0P1ISTSte1fV5msgIh14xT2XSxB/sF82aO61VQPhU2cLmYyupnIXVzcpLjV5RVEt5gLt9ZFRcdxLjl6ipFmHDxApNZMCvByXruQoxfsjRidF8iDC2sXps3PSlWXkbuiEwg0Gm20L5xUfhPPrIZA9jhSdYZf/nZsYtAzvpHWbnotwfCrgUwpfGFw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=9fpKfrQ2GcMX74J1uBIDqrWQTDh6khkW6lExgvhocEg=; b=AojKft0KEgiq9mgqYvGI6cPEs+qbN1tLeTP+et5WAXRHkAUCyjifsHwSf/aq0ZGim5WlhZvHWDUgcwNuKu+BW5JAD5/6iG6W4KAExxotG/+RemfVa7frL3hhJWV1adsMs+s98TPNhnJbWp8um2y7LlTo7DJUN5vAm4/JEasZhWA= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Subject: [PATCH v4 08/16] block: use int64_t as bytes type in tracked requests Date: Fri, 11 Dec 2020 21:39:26 +0300 Message-Id: <20201211183934.169161-9-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20201211183934.169161-1-vsementsov@virtuozzo.com> References: <20201211183934.169161-1-vsementsov@virtuozzo.com> Content-Transfer-Encoding: quoted-printable X-Originating-IP: [185.215.60.91] X-ClientProxiedBy: AM0PR04CA0050.eurprd04.prod.outlook.com (2603:10a6:208:1::27) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5aee86d2-224e-44f4-acb8-08d89e0426ff X-MS-TrafficTypeDiagnostic: AM6PR08MB4915: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3383; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: DL0DvESihqrxghc/E7eqZsbzyXhIG4hp5mV/UNYo5DrIwRzKU+w89YDqL40AKih4MHUYf8iWAhZlUjYFQhJbx/SdPbLg4GGxCNpaE5gDZDdsapE5NUZni8IRvY8FYpht1SL+IZyTE9OXakffQ5xJjzSgpSaXYdaCXAdPfzhq2fBvLu6tR8hJu0PXfGwcSC3u1VmoaDO6e9BvN8ULxzqlN8NZSmD4KFffLzLfeYM39POwPxtXwDR2pgFjN4gyq3GtG0xRwadWE5pXMOivtmuwSAsMcKAqaEKQmTtY+EhKT8rUIeUvAIRZKg/j4NthwuxSOj71u9fyDy4Lt9sklmLtEQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(346002)(39840400004)(136003)(396003)(376002)(66476007)(6506007)(66946007)(956004)(6486002)(86362001)(4326008)(66556008)(6916009)(6512007)(2616005)(6666004)(83380400001)(1076003)(26005)(316002)(16526019)(5660300002)(8676002)(186003)(478600001)(8936002)(2906002)(36756003)(107886003)(52116002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?ObZfFKX3/BgQKX0WEYy9vdGy5hveyxnXrbDSvkVcTpA+usbNWrfo6BUrsOgt?= =?us-ascii?Q?D2kzGAqLdyhtuvtf6zUcP5V/n9/kg7NKC1mtvea32HJAmuxyg/4jYwmoRshB?= =?us-ascii?Q?P5uWhUbIq/UCwIV22MKBiwWcEIwJs0zXRnMO17zVd3tizsns6jCynpG1tfWe?= =?us-ascii?Q?pIyn1jQlSkEO47KcITbI8Y1wTjUFhClYfhi5ZWR8yi4vFm24+ntkaqo7OJZW?= =?us-ascii?Q?CGoZwRlQtOs2e8JT0Uh29IcU0HJ1s8+UI5YRdPyzlXMUkr0nL76LFRMChUUo?= =?us-ascii?Q?sBIpzdBuMKBlqiRUD00NOSaWZZQ/+KW2Bqy5AZAMYwb49a6meCyvpNSmZ8fi?= =?us-ascii?Q?u/feZa7mlmYAoq/VRO33b41kjzn2ZO8188triXdf3NI4VdyhE5OtTbn7YSU+?= =?us-ascii?Q?TVy14PcSSYVvVE6vcf3pwKdU3NjA5cSOMO7hCuvdt0i18LC2+dSL3sCP2TpX?= =?us-ascii?Q?T34vueqhB5wqcrR1xEg7ULBb2FWVI9/KsEtv6zXANwAwXVDq+WwHIG4ifHrd?= =?us-ascii?Q?ddQDVrHfoowNFlisZ45CWXZOtcKqYZePU1qk/L0lC6EfKbr54jq1pjelz/wM?= =?us-ascii?Q?puDdgAluidbnXzdP2VhEqkGBH3ksV2bAJHrSj83fkipKyPIwQSh5tLdcXmQ1?= =?us-ascii?Q?N/DNIGDIBFrABJQyHV3t4KNBJEOy7iXK2xQxxoeG+vygGV1MJDJaiDE1BC0p?= =?us-ascii?Q?iT+iCg2stX4NLFn2rvetSAcHgYAvORm5pjSZZRO2roOLvctGXIqz2Nyz7yUN?= =?us-ascii?Q?DENYFO6FdHexbd9TEWqeXtQMYUvta+fRd3GI5LAfiLPBa1rwDXwkwyieKWID?= =?us-ascii?Q?V+cjunbMbfpF8p1PTE2SnkrS4kJjKZiD9z36vcM7flocjbMJSBc53zYFGzOP?= =?us-ascii?Q?HDe342XKdnGgueLmy/x7JXhIwg5lqB3SlyD7PNPEj8OMvDTxc8ZzC1I7IyO8?= =?us-ascii?Q?sBBzoPLLjiWiot/U5oNNt+f7fR+CabmOuLf9l33mKLlvCXnnTEV8VdxNfOhA?= =?us-ascii?Q?aDnX?= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Dec 2020 18:39:54.3835 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-Network-Message-Id: 5aee86d2-224e-44f4-acb8-08d89e0426ff X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: GDDUNEF8txIg8Es1COji0KstUo6nFL87YGcwyHQi+i5aAMNyS/7Yk27wfRT8ndjJc0IxU7Jof+lfpBrED6Yq3Gd1uTonRJ7YCacr1MO4L64= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4915 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=40.107.7.90; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-HE1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-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: fam@euphon.net, kwolf@redhat.com, vsementsov@virtuozzo.com, berto@igalia.com, qemu-devel@nongnu.org, mreitz@redhat.com, stefanha@redhat.com, den@openvz.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @virtuozzo.com) Content-Type: text/plain; charset="utf-8" We are generally moving to int64_t for both offset and bytes parameters on all io paths. Main motivation is realization of 64-bit write_zeroes operation for fast zeroing large disk chunks, up to the whole disk. We chose signed type, to be consistent with off_t (which is signed) and with possibility for signed return type (where negative value means error). All requests in block/io must not overflow BDRV_MAX_LENGTH, all external users of BdrvTrackedRequest already have corresponding assertions, so we are safe. Add some assertions still. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Eric Blake --- include/block/block_int.h | 4 ++-- block/io.c | 14 +++++++++----- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/include/block/block_int.h b/include/block/block_int.h index ff29f31451..04c1e5cb58 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -79,12 +79,12 @@ enum BdrvTrackedRequestType { typedef struct BdrvTrackedRequest { BlockDriverState *bs; int64_t offset; - uint64_t bytes; + int64_t bytes; enum BdrvTrackedRequestType type; =20 bool serialising; int64_t overlap_offset; - uint64_t overlap_bytes; + int64_t overlap_bytes; =20 QLIST_ENTRY(BdrvTrackedRequest) list; Coroutine *co; /* owner, used for deadlock detection */ diff --git a/block/io.c b/block/io.c index 42e687a388..5dec6ab925 100644 --- a/block/io.c +++ b/block/io.c @@ -717,10 +717,10 @@ static void tracked_request_end(BdrvTrackedRequest *r= eq) static void tracked_request_begin(BdrvTrackedRequest *req, BlockDriverState *bs, int64_t offset, - uint64_t bytes, + int64_t bytes, enum BdrvTrackedRequestType type) { - assert(bytes <=3D INT64_MAX && offset <=3D INT64_MAX - bytes); + bdrv_check_request(offset, bytes, &error_abort); =20 *req =3D (BdrvTrackedRequest){ .bs =3D bs, @@ -741,8 +741,10 @@ static void tracked_request_begin(BdrvTrackedRequest *= req, } =20 static bool tracked_request_overlaps(BdrvTrackedRequest *req, - int64_t offset, uint64_t bytes) + int64_t offset, int64_t bytes) { + bdrv_check_request(offset, bytes, &error_abort); + /* aaaa bbbb */ if (offset >=3D req->overlap_offset + req->overlap_bytes) { return false; @@ -798,10 +800,12 @@ bool bdrv_mark_request_serialising(BdrvTrackedRequest= *req, uint64_t align) { BlockDriverState *bs =3D req->bs; int64_t overlap_offset =3D req->offset & ~(align - 1); - uint64_t overlap_bytes =3D ROUND_UP(req->offset + req->bytes, align) - - overlap_offset; + int64_t overlap_bytes =3D + ROUND_UP(req->offset + req->bytes, align) - overlap_offset; bool waited; =20 + bdrv_check_request(req->offset, req->bytes, &error_abort); + qemu_co_mutex_lock(&bs->reqs_lock); if (!req->serialising) { qatomic_inc(&req->bs->serialising_in_flight); --=20 2.25.4 From nobody Fri May 17 21:24:39 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; arc=pass (i=1dmarc=pass fromdomain=virtuozzo.com); dmarc=pass(p=quarantine dis=none) header.from=virtuozzo.com ARC-Seal: i=2; a=rsa-sha256; t=1607714663; cv=pass; d=zohomail.com; s=zohoarc; b=IkrcTObtRJR1BBWdjhhy+B1Ez3wgU95TPBk8FGPV5WBp6kjbU5N/RAAFTyrS6cCSc/tOjexd4SPeh0fi6ovKt/OsuTHqKrUYSrK7yw2/uFdTus2jx4hWczuAi6uHxTgROgP9QLr6dfr442ps4y0bC9M9brofrLB5h861R12OJUI= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607714663; 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=Fx/hAaIC2EAKEDXeCBLuq8xobo0AOX2o0mpmedLOCrc=; b=VZnM0EAlqFZfqnHJYjogx5bJx3BZJ7hJaD8npZwIhEULY77oEGnS3H/pA78flqCaVQPkZM10Xv3TKudqXYajo7ptvz/Fd8NhpYvQQj6LcXl9Yp1O+u3XrOk2MskHuDY8fDoTKpKPo3aGMwj2DQwT1+/NB3f8/RshUxXfSViS7yg= ARC-Authentication-Results: i=2; 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; arc=pass (i=1dmarc=pass fromdomain=virtuozzo.com); dmarc=pass header.from= (p=quarantine dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1607714663134613.7284200798995; Fri, 11 Dec 2020 11:24:23 -0800 (PST) Received: from localhost ([::1]:40514 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kno1e-0000N7-2T for importer@patchew.org; Fri, 11 Dec 2020 14:24:22 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43792) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1knnL9-0006rS-Jb; Fri, 11 Dec 2020 13:40:27 -0500 Received: from mail-eopbgr70097.outbound.protection.outlook.com ([40.107.7.97]:21414 helo=EUR04-HE1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1knnL3-0008BO-IY; Fri, 11 Dec 2020 13:40:27 -0500 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB4915.eurprd08.prod.outlook.com (2603:10a6:20b:d1::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3632.18; Fri, 11 Dec 2020 18:39:55 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::d585:99a4:d7a4:d478]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::d585:99a4:d7a4:d478%4]) with mapi id 15.20.3654.016; Fri, 11 Dec 2020 18:39:55 +0000 Received: from kvm.sw.ru (185.215.60.91) by AM0PR04CA0050.eurprd04.prod.outlook.com (2603:10a6:208:1::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3654.12 via Frontend Transport; Fri, 11 Dec 2020 18:39:54 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XDBeE009uxFh+V59r+FEnAqFfyUdKn00p9qe8GrxgvH6SvbactN9H5OOluq9ns2EkLIaGeB5yxufTUM0iEam0s4Kj1NmaPSYPP9RqKRBnvMno90P1oMmPdK2eLojopnUkVHfPtalVpE0iB9T61j03t3esXh7rXhl2+AkPxKE/KEUlKssnqB/bZ10x/iuHpZWhDNwXCf3nDXWnDHY83MuuJycX5nS6ydjlLWSrIHulr0D6hiOvHZao0iyFf5v91ErmQKZWz7+0nneyJUjcBvmtzS8CEP+vRGyB5Tel5Eu6FzabXxDWJZDXUi/xT2rhnR+mCozzVM5mapdWW6PXReZ3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Fx/hAaIC2EAKEDXeCBLuq8xobo0AOX2o0mpmedLOCrc=; b=bElNM/4E+Khb8WaV+nbiKmlGKDMxrOnhilYXeskKdHydctNuPraSUhPmXZ4NTJ4kPl8nBPWDOif/fCYBhq+gl/vCFRntHLxCOLOZArIpXT0LhhhfEWyB+nF1a/9jDQ+/3ukon0YNxnI6opKsTXiIWuu0FhjW4RJRcxjr1F/xzKm8+Q/Ezm9mTIPvqKRUWGA1nUIa9uIJlKd7+CpbwgMyuOgj2Ogv2XN3kA+Dlt4uwKLyDPpB/P/Mdmza7+IN7SJBt19947A99GHidBSZ5JzmI3jPXvFJ54kzyReEKg+N+DniDKALV79lUOpalFp7/biQ18yamF4VHu5Hu/2KlpYr3w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Fx/hAaIC2EAKEDXeCBLuq8xobo0AOX2o0mpmedLOCrc=; b=ZLLRAVaclMdxn52NheRy2KM32YsTCCtLi9qv0/5m0EMQDnuwN+ZU32OuZwhCONgjuqChvHk5G/NdQ2CwcxL0Ba0rcQzCQ+obpHMhIpJk8QyX+jOSZ8qQocgg173hKvwkXgH5ReGbQl3o1lmele2pB3hAid2e7lEIp08LhFJsBYY= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Subject: [PATCH v4 09/16] block/io: use int64_t bytes in driver wrappers Date: Fri, 11 Dec 2020 21:39:27 +0300 Message-Id: <20201211183934.169161-10-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20201211183934.169161-1-vsementsov@virtuozzo.com> References: <20201211183934.169161-1-vsementsov@virtuozzo.com> Content-Transfer-Encoding: quoted-printable X-Originating-IP: [185.215.60.91] X-ClientProxiedBy: AM0PR04CA0050.eurprd04.prod.outlook.com (2603:10a6:208:1::27) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 05063f38-3443-4d50-4a40-08d89e04278b X-MS-TrafficTypeDiagnostic: AM6PR08MB4915: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5236; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: mGKGEcvDxSAzk0gjPIv8V3YnlczJObPHKIZWOYF7DEtoVkmgPOTg25DxRAtqpEqjDURoisLyqJQnPzfeIRqPsVJfXMn20Q85CGcre8TYdyZTPEPH2hz1C0fdqQDuFBA3TzGSilJ4KG4ySIqCSZhDIe+xv7zPjFo1cP9SOY3q7avqTp2/SFC31Ndzf0fEPCoebzFaqqoKizWvjZH7ptxpAjdaM4uNNdkOecu+RR+2iVMoMx+9e6boIAa52wUTP2nMF/PZ5AZVIjFuLL6YxYGTxlDv7R4RSOdcWM90fVFUUJt8ow5c22mhPIKAYqHT6oQXb45yUh/nDQdtL2Pa01PKfA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(346002)(39840400004)(136003)(396003)(376002)(66476007)(6506007)(66946007)(956004)(6486002)(86362001)(4326008)(66556008)(6916009)(6512007)(2616005)(6666004)(83380400001)(1076003)(26005)(316002)(16526019)(5660300002)(8676002)(186003)(478600001)(8936002)(2906002)(36756003)(107886003)(52116002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?jt/dl+Mj1/1V18ac5hSPTg682X7hGehCURh8y+PB2RnM4azYawQEeL7PFraU?= =?us-ascii?Q?S6Z5tVglHCATBn1oxOlj7fCPYPgj5bUdmyuXf49JoiHCHnNKBiphTTsdtVhN?= =?us-ascii?Q?Q2eGRe5ithJ6vRFhf0NQAbzhvOTc0i/rypJ+cGqE4eyI9cgsaDVlhz66GWNd?= =?us-ascii?Q?7h2uXKZMlQ43jFDHMsr7lImAnrq94NFj3QXASru2oAjS2BTPwkyeqSC5/BR8?= =?us-ascii?Q?Nv+Ftp5xe5l2CzJ0x6KyvUB0M0YUlSA2qnTJ07S7MC/WmPpB0zCY9sh+ppaR?= =?us-ascii?Q?3XOMc1qh8AliyB0PLdPyhc2Y5wI/wWTAMOUAHZj1sZtBgp97Cn0D1vVNPyEc?= =?us-ascii?Q?ZaswEWpAFq6v9k47fkSdoXeDSVnWBQKAv+8cIKY8DNP3J9bNeR5Jxxxj9YAm?= =?us-ascii?Q?YZhwGIjrItSTZZ0/5QwgfIupGgRlTyWGnRWm+NLl4VfNfUSen3aU3WvajUQ2?= =?us-ascii?Q?Xr3xc7TcHMAxEggpKZAHsLOJoHLE06cLUTJvc69Hdolajl05cwdk/MNpYcjJ?= =?us-ascii?Q?G1h+H3OFzjCeku0ZRuyZdXr5q+7xBGyL+Url4J5JwyRKJjoCB/jmBsqf1N/J?= =?us-ascii?Q?8YqRF1reS9aBSpZ3PtD1wu8xa6vAu5aFljVBq3nAxShentqcyqclKXUhCGBh?= =?us-ascii?Q?ZOUKSMHgPRHQeaeqS6jAikJqI+DqKdGR8xx2YK8JQOdJEyxqmAznso6nQ2jV?= =?us-ascii?Q?8Bzi7RAbnBSifWToWqqCMF2lnpA2l+D7aOA+y+YZoy5FI9zdZugCBOu4fiKf?= =?us-ascii?Q?zUWAxd+51cu0S8RnO+Kzhrf8dWO8jIv6+VCEFM5i9IBpLaq+epYxfZ+cgLh3?= =?us-ascii?Q?R4Sgkj3k7b9Uno2SF1n88n4Oxu7d5NKCNYBTKx1jcdq0xqnoWcKpJUsHPU/n?= =?us-ascii?Q?XuuyKKYVj7hMYz3YPGy4xFiDWW1GJCMaZXCtqcNJRh4nVajXCd9A2k0YEXEf?= =?us-ascii?Q?xfT9pr8Lk3CJo0x0fReMtWNQGC89OJQdANzTk6N8b4pkSs+B+kpqQb03ZfaG?= =?us-ascii?Q?vD4Q?= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Dec 2020 18:39:55.2188 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-Network-Message-Id: 05063f38-3443-4d50-4a40-08d89e04278b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: hHcVdH/AuaRCJA552h2ZwwHHKlSOzGffo6NMUCqpkS7BZlAe2SwSG8yxOpqxk3OvV7hgR05DtqvU5P796Mua7fiJX9/Li11tqmfOkzbb/9c= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4915 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=40.107.7.97; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-HE1-obe.outbound.protection.outlook.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, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-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: fam@euphon.net, kwolf@redhat.com, vsementsov@virtuozzo.com, berto@igalia.com, qemu-devel@nongnu.org, mreitz@redhat.com, stefanha@redhat.com, den@openvz.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @virtuozzo.com) Content-Type: text/plain; charset="utf-8" We are generally moving to int64_t for both offset and bytes parameters on all io paths. Main motivation is realization of 64-bit write_zeroes operation for fast zeroing large disk chunks, up to the whole disk. We chose signed type, to be consistent with off_t (which is signed) and with possibility for signed return type (where negative value means error). So, convert driver wrappers parameters which are already 64bit to signed type. Requests in block/io.c must never exceed BDRV_MAX_LENGTH (which is less than INT64_MAX), which makes the conversion to signed 64bit type safe. Add corresponding assertions. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Eric Blake --- block/io.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/block/io.c b/block/io.c index 5dec6ab925..b2bf18038b 100644 --- a/block/io.c +++ b/block/io.c @@ -1103,7 +1103,7 @@ static void bdrv_co_io_em_complete(void *opaque, int = ret) } =20 static int coroutine_fn bdrv_driver_preadv(BlockDriverState *bs, - uint64_t offset, uint64_t bytes, + int64_t offset, int64_t bytes, QEMUIOVector *qiov, size_t qiov_offset, int flags) { @@ -1113,6 +1113,7 @@ static int coroutine_fn bdrv_driver_preadv(BlockDrive= rState *bs, QEMUIOVector local_qiov; int ret; =20 + bdrv_check_qiov_request(offset, bytes, qiov, qiov_offset, &error_abort= ); assert(!(flags & ~BDRV_REQ_MASK)); assert(!(flags & BDRV_REQ_NO_FALLBACK)); =20 @@ -1172,7 +1173,7 @@ out: } =20 static int coroutine_fn bdrv_driver_pwritev(BlockDriverState *bs, - uint64_t offset, uint64_t byte= s, + int64_t offset, int64_t bytes, QEMUIOVector *qiov, size_t qiov_offset, int flags) { @@ -1182,6 +1183,7 @@ static int coroutine_fn bdrv_driver_pwritev(BlockDriv= erState *bs, QEMUIOVector local_qiov; int ret; =20 + bdrv_check_qiov_request(offset, bytes, qiov, qiov_offset, &error_abort= ); assert(!(flags & ~BDRV_REQ_MASK)); assert(!(flags & BDRV_REQ_NO_FALLBACK)); =20 @@ -1252,14 +1254,16 @@ emulate_flags: } =20 static int coroutine_fn -bdrv_driver_pwritev_compressed(BlockDriverState *bs, uint64_t offset, - uint64_t bytes, QEMUIOVector *qiov, +bdrv_driver_pwritev_compressed(BlockDriverState *bs, int64_t offset, + int64_t bytes, QEMUIOVector *qiov, size_t qiov_offset) { BlockDriver *drv =3D bs->drv; QEMUIOVector local_qiov; int ret; =20 + bdrv_check_qiov_request(offset, bytes, qiov, qiov_offset, &error_abort= ); + if (!drv) { return -ENOMEDIUM; } --=20 2.25.4 From nobody Fri May 17 21:24:39 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; arc=pass (i=1dmarc=pass fromdomain=virtuozzo.com); dmarc=pass(p=quarantine dis=none) header.from=virtuozzo.com ARC-Seal: i=2; a=rsa-sha256; t=1607714820; cv=pass; d=zohomail.com; s=zohoarc; b=klG8wkI18dDuQA6BPou9CYPt4oiP7V4SzaO19W1uzP+3XYuHymPqnkqcTn/9l0V5KQ/JYCWcswQtrCWSrmVsiRs+6mWMkqkhvX/dncLsZ3uYoicsWtssP6Dxa2rbjQzpPnrh3EnMwvUVseHVkIO+OkomrWx3vPHKOjrf3VSGpH0= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607714820; 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=baEz8qBvtoc2Ph8ut100vz5LhgelwDDVy99aj0SsFDU=; b=RFSvyCx2wMceN9om5ikNNllXRXPraJbIVzKTjYH35quFRnDky8xUzVAfj7dBqQHkA19QN4eOuYbMUK/6xVwkmfjzxCo3qvoeWsOqWCtNjS3vROdjRweY06FdBNi/Fy1KO89GZjOrfXjupb0LhgJ+oMLjeuzUs/d+fdnVch6Zogw= ARC-Authentication-Results: i=2; 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; arc=pass (i=1dmarc=pass fromdomain=virtuozzo.com); dmarc=pass header.from= (p=quarantine dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1607714820733403.98546641828125; Fri, 11 Dec 2020 11:27:00 -0800 (PST) Received: from localhost ([::1]:43578 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kno4B-0001kq-53 for importer@patchew.org; Fri, 11 Dec 2020 14:26:59 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43834) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1knnLF-0006tu-Bm; Fri, 11 Dec 2020 13:40:33 -0500 Received: from mail-eopbgr70129.outbound.protection.outlook.com ([40.107.7.129]:29411 helo=EUR04-HE1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1knnL5-0008CX-Gn; Fri, 11 Dec 2020 13:40:33 -0500 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB4915.eurprd08.prod.outlook.com (2603:10a6:20b:d1::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3632.18; Fri, 11 Dec 2020 18:39:56 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::d585:99a4:d7a4:d478]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::d585:99a4:d7a4:d478%4]) with mapi id 15.20.3654.016; Fri, 11 Dec 2020 18:39:56 +0000 Received: from kvm.sw.ru (185.215.60.91) by AM0PR04CA0050.eurprd04.prod.outlook.com (2603:10a6:208:1::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3654.12 via Frontend Transport; Fri, 11 Dec 2020 18:39:55 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ClMUCyax+B3J3LvXylxyI/ywRt+Rx+MCvr8uM7X/O8nHbiog5K3jVeofLfBTbeelyOjYNJpVT/tct7P46MWjGCMBeMU1GHRkfoNzjW4Gb4psbFgDxmQlFnLeEMy9/VuchFpUBPvetX7TaDKQkqFJNr1SJdGKyOnKjIgMWIKO5njJrc2X/jeebKKzHJxJosQFNd5+63f6flWvqvU2Zj1hseeqmecvG9jpOTWKGtda9MR5dw0e1brnp+/DTWhAEu05fFKBbpc2iUhgXb5YQCTM4Nas0UCe/ftK5L/0yK0vMxB+C+pABTkB4saZn1gqg630QYCBkQhSd/dyzE+vPdeAjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=baEz8qBvtoc2Ph8ut100vz5LhgelwDDVy99aj0SsFDU=; b=ba9Xnrno/dx+c21YoYxZaxSE1TZyrEF7Cbb3cvin2bXXJ5X8uEUm6bNb/B4mmnepf2+eBC5rDtCG1Hpyac0X5MzAapkx9FlIyxghQkyhyenVm/t1rgHbh7ULI/PQianFao2opThALHkVhA6HfhAvs9jZ+KW8VipJ3g6EeHpgZDRCw8P+BPoT3zuoUtcAc+1Z4SszYDFqlI2kuNE8sLGCAFOAJlzOwH8k+FYgZNJDmGY5u1FRuj+NkzewwoyOarR1ukxHO7dnVOjc0kcWKMK+L1F/ONstFT87W6cIWrloCyxioGevy6T19nYdxmBiILxvHzM6Su+mT2YPeMeZJdHmMg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=baEz8qBvtoc2Ph8ut100vz5LhgelwDDVy99aj0SsFDU=; b=kTO34n8DBAXApnK1H4Al4c8n8KAaSR7QZbo0PclSbQKHpzytGNKBra1/dXR5ZZkGIrXp129wu/X9btln0DuIIqL26qGyNtyqx0BsOc+vnijkij+DpKma0+GxC9Tib3o/BcZiusHirqsOmQFe4QGkmqojPht59YHnVLxLw271USQ= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Subject: [PATCH v4 10/16] block/io: support int64_t bytes in bdrv_co_do_pwrite_zeroes() Date: Fri, 11 Dec 2020 21:39:28 +0300 Message-Id: <20201211183934.169161-11-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20201211183934.169161-1-vsementsov@virtuozzo.com> References: <20201211183934.169161-1-vsementsov@virtuozzo.com> Content-Transfer-Encoding: quoted-printable X-Originating-IP: [185.215.60.91] X-ClientProxiedBy: AM0PR04CA0050.eurprd04.prod.outlook.com (2603:10a6:208:1::27) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: af736ae9-98b0-45b0-44ec-08d89e042800 X-MS-TrafficTypeDiagnostic: AM6PR08MB4915: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6790; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: btuWU4vmzFJE8+6UwmriNGNomOW6vDVlHlcOxRnOc3sAC8Pi5r1YXU7CjUZyjLNfAA6CHe6eyPH4+xLR+Wvd/n3ogO7RpbgvyypNjs9qpwBySl6Sv/IKulMB8M9ars3xxOqh6HDcOIxhTrcLsHKaKJSqW0jEzrnWvshdHo5+vRwiu1QpAMXb1unmzNURVNRVTT05Ocr3bGlcgv63pNRdyhK1V0QOnE+3tZuOxkyzVpy05hmS9MXrYh0Y9eAz1h5dgcMmeHtDOrnU0wotfCbxBg1LZIm5WvYuHxGcVoMWtAZBOU5mmSpr4a8ZVPzeDRnspgF/O8MyAHXThnZP5MLPjg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(346002)(39840400004)(136003)(396003)(376002)(66476007)(6506007)(66946007)(956004)(6486002)(86362001)(4326008)(66556008)(6916009)(6512007)(2616005)(6666004)(83380400001)(1076003)(26005)(316002)(16526019)(5660300002)(8676002)(186003)(478600001)(8936002)(2906002)(36756003)(107886003)(52116002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?Tqp9qsWa0qq0ZC5ngjGs59V+7XqZ6lcsl/t750IiU6b45OWlWPpd8HDSeS5S?= =?us-ascii?Q?0HRaaMVCzcnB6ITVHH66TgB0EFRpI6zqvN7gnRiGulKfCHqtuMGq+ohr6jmJ?= =?us-ascii?Q?+3anWw9nd8L9Dfu1LzWxkGFPmJ//T7nbWCYm6fKgrajNa25BU9786Hv9a6Jm?= =?us-ascii?Q?rhF0UYuFe/CtI/SCQGNutMEgn0sSssM4TWCrfWCwgOEd1LQROWS2pqsAx1qJ?= =?us-ascii?Q?RT1xnha9C8/1xwYDnbV08WXvjttn3lYwhEWgWucX8gl7oxcYzZFnn0r2ddTp?= =?us-ascii?Q?+rBUWRssARDnAU4d3wQQ9Cj7+MO5lDbUzAalMLLd5d+kO3wVcYIz20PvUIfp?= =?us-ascii?Q?gqIRQs3YoxEavtqMXsIOaDPwrqRwUf+ojcO3FActCGqMHPsyod6n+reDaqjD?= =?us-ascii?Q?ToSmwLC2mWgFpIex0PI3ojHxdQT9LuS41eG3blafq5i/eaSn7mG5voXwS2Ag?= =?us-ascii?Q?vA7FB/ZqxUqISiMEVJqnKPGJw8nVTFwOIKl1XPZ+pgXzIHy05ObqeOxj4Xpd?= =?us-ascii?Q?cE4eVZM7t3PPShLwZH5rdVfFFAqiqvwCTONSLf6QHBeBsQi93AVmyn4jRLLO?= =?us-ascii?Q?OonPvHZymMmI2+5KmwrTCCVg9uKgAUQdga2c3eEmTp4rHp188lrT+QnBJ5lB?= =?us-ascii?Q?w/3vrCSYxnzRAW1ApzD8jgTX0G04biHnJRg5y71NxpQJTJXxbi26WbEg+Ncb?= =?us-ascii?Q?5smpDi3zKNMePUqDaAPr8+uPKK57b4ktLf3Ps7EyARBoviQx8mClE1OpkjIa?= =?us-ascii?Q?e6tPWJasXFj14PDLSSqYDJsmIqBIoMsKAe6iY/ZmL6gwYqyzEIx3wpbIsgCa?= =?us-ascii?Q?1yJNNmpNcXrQiZlJnC2yXP3H5Ots6cdlSwAIy6gCRgG4uRJRG4wKK9QzUtuG?= =?us-ascii?Q?kHimmSalH3qhwe1nBNiGUtj7W/xHHCHNAFj4wAVFD7sUoe1z9ZUJ/MOIAuwI?= =?us-ascii?Q?65AAOOsKNKQ1pRuXjskKS4Dgs0QMAtR19fkgClkHdx5Qyax8sqNPQ+wDfvyX?= =?us-ascii?Q?ayvM?= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Dec 2020 18:39:55.9904 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-Network-Message-Id: af736ae9-98b0-45b0-44ec-08d89e042800 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: XoqmvKa58X0BKntYCBE86ZgRitdxKBdaARn4F2jpXoZxQeJTUHR1zm14qknXySXuvPFSaJxz/VvvYsV5crkhofqDet9DCRLWChbIn+BIkDA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4915 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=40.107.7.129; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-HE1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-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: fam@euphon.net, kwolf@redhat.com, vsementsov@virtuozzo.com, berto@igalia.com, qemu-devel@nongnu.org, mreitz@redhat.com, stefanha@redhat.com, den@openvz.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @virtuozzo.com) Content-Type: text/plain; charset="utf-8" We are generally moving to int64_t for both offset and bytes parameters on all io paths. Main motivation is realization of 64-bit write_zeroes operation for fast zeroing large disk chunks, up to the whole disk. We chose signed type, to be consistent with off_t (which is signed) and with possibility for signed return type (where negative value means error). So, prepare bdrv_co_do_pwrite_zeroes() now. Callers are safe, as converting int to int64_t is safe. Concentrate on 'bytes' usage in the function (thx to Eric Blake): compute 'int tail' via % 'int alignment' - safe fragmentation loop 'int num' - still fragments with a cap on max_transfer use of 'num' within the loop MIN(bytes, max_transfer) as well as %alignment - still works, so calculations in if (head) {} are safe clamp size by 'int max_write_zeroes' - safe drv->bdrv_co_pwrite_zeroes(int) - safe because of clamping clamp size by 'int max_transfer' - safe buf allocation is still clamped to max_transfer qemu_iovec_init_buf(size_t) - safe because of clamping bdrv_driver_pwritev(uint64_t) - safe Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Eric Blake --- block/io.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/block/io.c b/block/io.c index b2bf18038b..c6a476559a 100644 --- a/block/io.c +++ b/block/io.c @@ -41,7 +41,7 @@ =20 static void bdrv_parent_cb_resize(BlockDriverState *bs); static int coroutine_fn bdrv_co_do_pwrite_zeroes(BlockDriverState *bs, - int64_t offset, int bytes, BdrvRequestFlags flags); + int64_t offset, int64_t bytes, BdrvRequestFlags flags); =20 static void bdrv_parent_drained_begin(BlockDriverState *bs, BdrvChild *ign= ore, bool ignore_bds_parents) @@ -1791,7 +1791,7 @@ int coroutine_fn bdrv_co_preadv_part(BdrvChild *child, } =20 static int coroutine_fn bdrv_co_do_pwrite_zeroes(BlockDriverState *bs, - int64_t offset, int bytes, BdrvRequestFlags flags) + int64_t offset, int64_t bytes, BdrvRequestFlags flags) { BlockDriver *drv =3D bs->drv; QEMUIOVector qiov; @@ -1806,6 +1806,8 @@ static int coroutine_fn bdrv_co_do_pwrite_zeroes(Bloc= kDriverState *bs, bs->bl.request_alignment); int max_transfer =3D MIN_NON_ZERO(bs->bl.max_transfer, MAX_BOUNCE_BUFF= ER); =20 + bdrv_check_request(offset, bytes, &error_abort); + if (!drv) { return -ENOMEDIUM; } @@ -1821,7 +1823,7 @@ static int coroutine_fn bdrv_co_do_pwrite_zeroes(Bloc= kDriverState *bs, assert(max_write_zeroes >=3D bs->bl.request_alignment); =20 while (bytes > 0 && !ret) { - int num =3D bytes; + int64_t num =3D bytes; =20 /* Align request. Block drivers can expect the "bulk" of the requ= est * to be aligned, and that unaligned requests do not cross cluster --=20 2.25.4 From nobody Fri May 17 21:24:39 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; arc=pass (i=1dmarc=pass fromdomain=virtuozzo.com); dmarc=pass(p=quarantine dis=none) header.from=virtuozzo.com ARC-Seal: i=2; a=rsa-sha256; t=1607715004; cv=pass; d=zohomail.com; s=zohoarc; b=LGwhYU6wY/9Givbitt6LA7f7gxUk+/d6GVSPYflUaMq5Q9Hg6vIoG34N3enTrr9kgdEME04OaZcRyQcxR4FEn32I+STtBj292oyGkzu5t6kL3p3/IYe29ZgS8bVinTmvN7513Urx0FvSKDikRKZflDgWg/ZZ59iOoLQIgkqMouQ= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607715004; 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=8BopKFar8T0Yq1EWnUmiHbeEMhZi9E6KAlxSZ0Hg9Po=; b=avd4zzIKR0QqEHKgDn78vsBhYpeRJ/vX+PBbXAKqqgmXb4Li02M1bfmiHhcTPS2wKGuRunS1wFqC8FwV404TXajZGgk5ngz6arh549/mqqbHWuPQTTvt+9azmJ8x8VfCwJ5VW3GQq3O+bi7GMJvgANlSWHvYyJHHglrJct1c0P8= ARC-Authentication-Results: i=2; 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; arc=pass (i=1dmarc=pass fromdomain=virtuozzo.com); dmarc=pass header.from= (p=quarantine dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16077150047421003.4625627677785; Fri, 11 Dec 2020 11:30:04 -0800 (PST) Received: from localhost ([::1]:49692 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kno79-0004UE-3Z for importer@patchew.org; Fri, 11 Dec 2020 14:30:03 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43802) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1knnLA-0006s8-Ex; Fri, 11 Dec 2020 13:40:28 -0500 Received: from mail-eopbgr70090.outbound.protection.outlook.com ([40.107.7.90]:11267 helo=EUR04-HE1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1knnL6-00089o-TE; Fri, 11 Dec 2020 13:40:28 -0500 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB4915.eurprd08.prod.outlook.com (2603:10a6:20b:d1::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3632.18; Fri, 11 Dec 2020 18:39:56 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::d585:99a4:d7a4:d478]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::d585:99a4:d7a4:d478%4]) with mapi id 15.20.3654.016; Fri, 11 Dec 2020 18:39:56 +0000 Received: from kvm.sw.ru (185.215.60.91) by AM0PR04CA0050.eurprd04.prod.outlook.com (2603:10a6:208:1::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3654.12 via Frontend Transport; Fri, 11 Dec 2020 18:39:56 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cW/lW45UNd4zIFuvccEeiPgNeWScXV5VNhfORMVvfhytczASxZXS628v3sY+VWw4KRy91Vv6wQN1vPOaIkcgaHyb+VzHogkyqKPaUDPtcTPM7fiO+fH2YHGZ0Ex7t8KBZTxzPs0vLzKP2+MsSPtj72SS38sQDc+fgP66vQWCB6/WA3EnjsYc0yN9PpJzrDROrNLtCUyra6rH02CqXpHwQtaywKcIACEt8TR1rMfwMp2MBYGEEmFWhlZqF7VUQZrj7tB+dhyGPsEWQI9yEi+1z+t02Kz8iWtZzOM5Y9/TbdDZL5PW4+eqyOzoqHu/cRicnRMKh7euN5MQijjVfzanlw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=8BopKFar8T0Yq1EWnUmiHbeEMhZi9E6KAlxSZ0Hg9Po=; b=YInHZVrhUBtkuNdBeXj/+mlxs8N8Nt6q7vD4i6cqdFivbnhwI1mXXpJoVO4d/pFfiaesfaEOVQzaGDt2mJa0cUlwXF4em8eY2MzEDEXGzYkb9EOX/AKQhwU7B9NRq5TO9BOP89wP6y9gWjZ/J4FjQoORy3BG4ot6AWxafKZs0g+L+jI3A4MZTTBrEcHCEFih/qyBmtOLkCaJeODfl7neer6tc94x+8vpoQI99GAuxZZOPNxjg/YRLn/c04vlTS5G1cxjauh5+AewHXnaR8frn1hP2aKF/Z6HniE3YfP8A1gtPdsNRepu/FIz8OyzxNFrjfKy73NGyqPd3RLfeEH5iQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=8BopKFar8T0Yq1EWnUmiHbeEMhZi9E6KAlxSZ0Hg9Po=; b=eFCqjvHVcPliDz8DD8tdIAE2EXp++bIMI6V5DKXXMlsZY5nh/ntyWHJs/c5iCCYm3CMNr/3PXSFID6wKpqrSKD8eHjDmP8RLC49bzMVG02ihzPTP5ok4NWAuJt04HGBcHymjg30wd0oHWvUdbLCqMh27gq85nPv9vp25i/1rp3w= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Subject: [PATCH v4 11/16] block/io: support int64_t bytes in bdrv_aligned_pwritev() Date: Fri, 11 Dec 2020 21:39:29 +0300 Message-Id: <20201211183934.169161-12-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20201211183934.169161-1-vsementsov@virtuozzo.com> References: <20201211183934.169161-1-vsementsov@virtuozzo.com> Content-Transfer-Encoding: quoted-printable X-Originating-IP: [185.215.60.91] X-ClientProxiedBy: AM0PR04CA0050.eurprd04.prod.outlook.com (2603:10a6:208:1::27) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 12164ef7-61be-4526-0208-08d89e042876 X-MS-TrafficTypeDiagnostic: AM6PR08MB4915: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2733; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: y1pdvBjLAFP5ZuW7MWjXYyIkUhY6Qyr6sIdBDxqqW2tqyWUsD0dMBaE3s20ZFgHsTUGYpVhu33my3LSPwIRXkbK54bbHSqS4R0CA9+3T3KSRG0aroqR2tN2TZeX4oOd3XgXgjoCjPb8Vm0xdJDPqVZI8mGQuVlS1e8xUidbFWnhKMUtXPnO26BlCNxIPQBowSf/aeJDF5t9V5PomNnYYG1m6Bp9agcbkLkGhr9Xsrzgsgk27tr6kuG+yNt5hIK9XYWkEENs+7WkleHsgr4f1qF/jkFZWscTZAiIY+tvpd9pZ55sB39VxTdApgRA+3dXs X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(346002)(39840400004)(136003)(396003)(376002)(66476007)(6506007)(66946007)(956004)(6486002)(86362001)(4326008)(66556008)(6916009)(6512007)(2616005)(6666004)(83380400001)(1076003)(26005)(316002)(16526019)(5660300002)(8676002)(186003)(478600001)(8936002)(2906002)(36756003)(107886003)(52116002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?qO7vWuzcJutdpE2fTN+9KZ8s+3sjE1Cb4tC7/XYdfzOSknEoJiUQwjy9Fzxa?= =?us-ascii?Q?Eb58e0dsAqlnLOUuoq8oLqnN4FWAfEsvQJDyfbuz6pGc0o//wRu1RYzjJLDx?= =?us-ascii?Q?QkMchi5SIxdtRJbFxkbfUCtjeQwXqPSPWnUioiymSNxTLarv/FlI6QzglVeh?= =?us-ascii?Q?8bnX3cmMksPR7aCFUTbaYhVUt8AI+Inu+WPBklpWM6pnziWXuo/vsvcPouK8?= =?us-ascii?Q?G2ZSxsWn91l3Em4A9yPtGBCjlQJXTlR5jS/SmGXdFrPtqekKldZOgniP26HQ?= =?us-ascii?Q?lnrV6293wV1EZyHatb+zXbS6oYEHs4nvvtY2+TzDV2vkOCTWC9fws02BO81t?= =?us-ascii?Q?PUWAl3+LAXs0/H0SAZ/Rv5MSKjJhFlWFdXbYNxfPYsZnSxD62rNZ8+pMUq+l?= =?us-ascii?Q?4ByL+p9FTs+owR98uQz+Z6gQT/nbDHZfaE7H1hVmDUgWTZgz44fuw+zqRjml?= =?us-ascii?Q?eQScW+eV5uPUEozu7YTg2XDwGSsVn84dBnT7LyTBRXDwOs6fEDRJm7Sw6xi8?= =?us-ascii?Q?oT9d4C+XBrQb+p1kNLxqYFnZ6oRJHJKjtlrlyazkWE2snz5u87odNm6sLMQb?= =?us-ascii?Q?OkF/jz5fBuNf1zVeqvYr/pKEvUfKtX6mDIzXXgUcc4ONxkqFBph0sAjuZmOp?= =?us-ascii?Q?CvgzL+W4mU2VurjhxQuxI672jZFUsWj9Erzpy+UDd0zKFi/E9BcdFysz67HS?= =?us-ascii?Q?7AFSaVMGsgmiQxbtBXFzZVCu8rDK/1kkVA9Z5Ft2IKOoUqAbZnX2NK4CRxOB?= =?us-ascii?Q?ZrlD4TFFxSNgM9uXEhDSz1CcNk3eCNvE13c0ipmJxdjiwvIwTpP9SVhPJtxN?= =?us-ascii?Q?v4rc8rwXp9KfliivyhISOP2sctPKOqZLX/1y/u5Dg5tgignmbTjHtjonm2QG?= =?us-ascii?Q?e0asXDXyXZcVkW6xiXKqN+c6vwk5ew6bbbWBiq0jQCC3t/hwOm6trESUoZGC?= =?us-ascii?Q?Oq18B70CcNHs/5Ve2+9G8oluvJP3fLtNWHaM9EBHGyqEYsZVHGL24XOJvt4l?= =?us-ascii?Q?655g?= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Dec 2020 18:39:56.7939 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-Network-Message-Id: 12164ef7-61be-4526-0208-08d89e042876 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: QfJlFSFL2KYqswOkSEEqu/JwrzDAmd+Phq07Mli9+gUZK7VngDC39d4c2xv3TRFKuGaN3TBDWsBYR3k3nRyt4n4yNkkV50SySX3aRzaSmvc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4915 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=40.107.7.90; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-HE1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-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: fam@euphon.net, kwolf@redhat.com, vsementsov@virtuozzo.com, berto@igalia.com, qemu-devel@nongnu.org, mreitz@redhat.com, stefanha@redhat.com, den@openvz.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @virtuozzo.com) Content-Type: text/plain; charset="utf-8" We are generally moving to int64_t for both offset and bytes parameters on all io paths. Main motivation is realization of 64-bit write_zeroes operation for fast zeroing large disk chunks, up to the whole disk. We chose signed type, to be consistent with off_t (which is signed) and with possibility for signed return type (where negative value means error). So, prepare bdrv_aligned_pwritev() now and convert the dependencies: bdrv_co_write_req_prepare() and bdrv_co_write_req_finish() to signed type bytes. Conversion of bdrv_co_write_req_prepare() and bdrv_co_write_req_finish() is definitely safe, as all requests in block/io must not overflow BDRV_MAX_LENGTH. Still add assertions. For bdrv_aligned_pwritev() 'bytes' type is widened, so callers are safe. Let's check usage of the parameter inside the function. Passing to bdrv_co_write_req_prepare() and bdrv_co_write_req_finish() is OK. Passing to qemu_iovec_* is OK after new assertion. All other callees are already updated to int64_t. Checking alignment is not changed, offset + bytes and qiov_offset + bytes calculations are safe (thanks to new assertions). max_transfer is kept to be int for now. It has a default of INT_MAX here, and some drivers may rely on it. It's to be refactored later. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Eric Blake --- block/io.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/block/io.c b/block/io.c index c6a476559a..b499998f54 100644 --- a/block/io.c +++ b/block/io.c @@ -1904,12 +1904,13 @@ fail: } =20 static inline int coroutine_fn -bdrv_co_write_req_prepare(BdrvChild *child, int64_t offset, uint64_t bytes, +bdrv_co_write_req_prepare(BdrvChild *child, int64_t offset, int64_t bytes, BdrvTrackedRequest *req, int flags) { BlockDriverState *bs =3D child->bs; bool waited; - int64_t end_sector =3D DIV_ROUND_UP(offset + bytes, BDRV_SECTOR_SIZE); + + bdrv_check_request(offset, bytes, &error_abort); =20 if (bs->read_only) { return -EPERM; @@ -1935,7 +1936,8 @@ bdrv_co_write_req_prepare(BdrvChild *child, int64_t o= ffset, uint64_t bytes, =20 assert(req->overlap_offset <=3D offset); assert(offset + bytes <=3D req->overlap_offset + req->overlap_bytes); - assert(end_sector <=3D bs->total_sectors || child->perm & BLK_PERM_RES= IZE); + assert(offset + bytes <=3D bs->total_sectors * BDRV_SECTOR_SIZE || + child->perm & BLK_PERM_RESIZE); =20 switch (req->type) { case BDRV_TRACKED_WRITE: @@ -1956,12 +1958,14 @@ bdrv_co_write_req_prepare(BdrvChild *child, int64_t= offset, uint64_t bytes, } =20 static inline void coroutine_fn -bdrv_co_write_req_finish(BdrvChild *child, int64_t offset, uint64_t bytes, +bdrv_co_write_req_finish(BdrvChild *child, int64_t offset, int64_t bytes, BdrvTrackedRequest *req, int ret) { int64_t end_sector =3D DIV_ROUND_UP(offset + bytes, BDRV_SECTOR_SIZE); BlockDriverState *bs =3D child->bs; =20 + bdrv_check_request(offset, bytes, &error_abort); + qatomic_inc(&bs->write_gen); =20 /* @@ -1998,16 +2002,18 @@ bdrv_co_write_req_finish(BdrvChild *child, int64_t = offset, uint64_t bytes, * after possibly fragmenting it. */ static int coroutine_fn bdrv_aligned_pwritev(BdrvChild *child, - BdrvTrackedRequest *req, int64_t offset, unsigned int bytes, + BdrvTrackedRequest *req, int64_t offset, int64_t bytes, int64_t align, QEMUIOVector *qiov, size_t qiov_offset, int flags) { BlockDriverState *bs =3D child->bs; BlockDriver *drv =3D bs->drv; int ret; =20 - uint64_t bytes_remaining =3D bytes; + int64_t bytes_remaining =3D bytes; int max_transfer; =20 + bdrv_check_qiov_request(offset, bytes, qiov, qiov_offset, &error_abort= ); + if (!drv) { return -ENOMEDIUM; } @@ -2019,7 +2025,6 @@ static int coroutine_fn bdrv_aligned_pwritev(BdrvChil= d *child, assert(is_power_of_2(align)); assert((offset & (align - 1)) =3D=3D 0); assert((bytes & (align - 1)) =3D=3D 0); - assert(!qiov || qiov_offset + bytes <=3D qiov->size); max_transfer =3D QEMU_ALIGN_DOWN(MIN_NON_ZERO(bs->bl.max_transfer, INT= _MAX), align); =20 @@ -2118,7 +2123,7 @@ static int coroutine_fn bdrv_co_do_zero_pwritev(BdrvC= hild *child, assert(!bytes || (offset & (align - 1)) =3D=3D 0); if (bytes >=3D align) { /* Write the aligned part in the middle. */ - uint64_t aligned_bytes =3D bytes & ~(align - 1); + int64_t aligned_bytes =3D bytes & ~(align - 1); ret =3D bdrv_aligned_pwritev(child, req, offset, aligned_bytes, al= ign, NULL, 0, flags); if (ret < 0) { --=20 2.25.4 From nobody Fri May 17 21:24:39 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; arc=pass (i=1dmarc=pass fromdomain=virtuozzo.com); dmarc=pass(p=quarantine dis=none) header.from=virtuozzo.com ARC-Seal: i=2; a=rsa-sha256; t=1607716883; cv=pass; d=zohomail.com; s=zohoarc; b=iVR30ikwBJrulfVO58ms2DA19TGg93Q08enOfINtI/xONn0NM4ZuWudw9VdcAB5k/OJRFv0J2Vt1ocTTW1GMotZNBAuSQ63MqGDhy15OfgAKNKK5xCUU1P5BP7KRqMQRrlZE3sBGJMdf8K5EjKCQcAwlq2K/y0qauXGBzBv1Z3w= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607716883; 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=FyqUQlb5+yxhrfQiiyPdKzGzL8y5/JkBIoKXvZ6E+L4=; b=Mh2UqQtaHAhn4IvQQumOKrNj3UnewfBOK2AmEelQc54ZVZCCxoE6iVh7GF2qoiPhOVnv+PuvbBGnaqcg6xFmOXcpm83iv4fj5f+gO9F3HlBDRk3jZSUBRntZzDbZ7zFQcn26CpYe+gcH35WbBc0DIPFdYoLyObkBMkN94X8HYuQ= ARC-Authentication-Results: i=2; 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; arc=pass (i=1dmarc=pass fromdomain=virtuozzo.com); dmarc=pass header.from= (p=quarantine dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1607716882228513.7164461444193; Fri, 11 Dec 2020 12:01:22 -0800 (PST) Received: from localhost ([::1]:53398 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kno9X-0006DR-Si for importer@patchew.org; Fri, 11 Dec 2020 14:32:32 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43870) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1knnLM-0006yX-AO; Fri, 11 Dec 2020 13:40:40 -0500 Received: from mail-eopbgr70097.outbound.protection.outlook.com ([40.107.7.97]:21414 helo=EUR04-HE1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1knnLA-0008BO-KU; Fri, 11 Dec 2020 13:40:38 -0500 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB4915.eurprd08.prod.outlook.com (2603:10a6:20b:d1::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3632.18; Fri, 11 Dec 2020 18:39:57 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::d585:99a4:d7a4:d478]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::d585:99a4:d7a4:d478%4]) with mapi id 15.20.3654.016; Fri, 11 Dec 2020 18:39:57 +0000 Received: from kvm.sw.ru (185.215.60.91) by AM0PR04CA0050.eurprd04.prod.outlook.com (2603:10a6:208:1::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3654.12 via Frontend Transport; Fri, 11 Dec 2020 18:39:56 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NeR6FV1HidLlvBamJvfVcdRG3vmQJIZBVej25Y/fchUbXvSFYhQI1bMxghaG10BsaTAKXxg7VR9sA5fBgn5gxZg2Jk4oO1Esmo2dU+zocx+H6nlsQ6wuRa09rNd8WCB+xUSy9MsKCd5gvddLVrzpxb7y5j/x+TAXaemN2/hryzw963gCUMy7IpUaGz+e1pMRi80NmuKGuNgOrTo9yWmS625kM2shS+qgRwaGaGLId6TuNDHO0I6Dtnx9L+Kh7GkVCrwULtiC7iDmcvWKas0MugZ5kgn4eMARcfDI0znVEcv3VJ9jJ4swGEaOKndMjkNyF2FtPeilIz+CslxlVAAuDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=FyqUQlb5+yxhrfQiiyPdKzGzL8y5/JkBIoKXvZ6E+L4=; b=VmqR3IwKUBb8EM7e4I2TJMNjW8ojZpdwzJr2+KUTQQ2Fh1vIUOWAHvaC/pCXyPc/B9tx0GZfkK+7iQLSU3Ww6J4MUnWAlSfAQshXXhZfa105oE3WSfLT9bDZCW8cJifXULiq/FHblMpf5JgbdJU+EAAzl9/sX7ax27GWgro3mJj4n8TRBBhR9hCDLjrEbv9sAZgtHVaw9Hd9bqFiTYmRvoMVHFt+VZfjPa4ZdJ2DVq5PzVLjgnzOu+RgkDUS8lnJqCvlLnowH1E8FF3pDZH9Rv6TItgG+i/z5zcqAfU7PRvAoRebRXXnE4mLKL3Mr6PsmydWStjkW3cBwfwS+yvvEQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=FyqUQlb5+yxhrfQiiyPdKzGzL8y5/JkBIoKXvZ6E+L4=; b=u3Y7AXV6PjWFrWoHcdPY6L4GydW22GDcehOtRlgeSUyu14sVS/AbBbhZqlFHzGQOdabFhz5q+SOdxp9E334ep3M24FocaB3K7h1TFkfWVIUxu5CJPjWV3/0Nb6FXdLNd3emClJeCpw7W/YhBKa++sclkJTkAkXBsJZ08JOAqx1w= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Subject: [PATCH v4 12/16] block/io: support int64_t bytes in bdrv_co_do_copy_on_readv() Date: Fri, 11 Dec 2020 21:39:30 +0300 Message-Id: <20201211183934.169161-13-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20201211183934.169161-1-vsementsov@virtuozzo.com> References: <20201211183934.169161-1-vsementsov@virtuozzo.com> Content-Transfer-Encoding: quoted-printable X-Originating-IP: [185.215.60.91] X-ClientProxiedBy: AM0PR04CA0050.eurprd04.prod.outlook.com (2603:10a6:208:1::27) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5b001c08-d0a5-4174-dca9-08d89e0428f4 X-MS-TrafficTypeDiagnostic: AM6PR08MB4915: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4303; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: mC7V6IgOlyXtP0HcROYUBZ4T4NcBghFb7hKV1XIZ8i0KBDjQZ/BC1ECcdR0kUDFse88ZTbKGje1uHXZsPsxRiPV8NyQIzp+xPWjpyHTwhDJvwovAkb0MhwhUtgSYoc3zV31uF5YNschlitKNVjoqYN9giIddqiZFVq7IzY/v/0ZC9l1koOMErd0VujDW3FAOhT7+bOJ+KyBeZ/HE0msnMs5E3ZCRzpz2MFE4NjA2b4DLq+xHojMxfaoKe2KiPp8pW4kB1kxAH2dzEVum8NISUVPw1e5uaNI8wG7rjfsHZhOJVQ+7a95Y/Pmz1MywvPlh X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(346002)(39840400004)(136003)(396003)(376002)(66476007)(6506007)(66946007)(956004)(6486002)(86362001)(4326008)(66556008)(6916009)(6512007)(2616005)(6666004)(83380400001)(1076003)(26005)(316002)(16526019)(5660300002)(8676002)(186003)(478600001)(8936002)(2906002)(36756003)(107886003)(52116002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?4wDNFgSCF5CKs3lEyoyn6LI5V3ouVqnkMLMV2XXIIQO8aXkpm5Cr4P7D3xh9?= =?us-ascii?Q?42yLaqFg4k9E9SxvcpHTu3cVd2iudnoo7Y/ZOl/HydgVnMTlXDM6vFBz3zet?= =?us-ascii?Q?xKwc6tglFdh5kQtvQ2t3mkGYOSdiE7qni7aDvdo29Efg0uEh+EfAijpvU4Qd?= =?us-ascii?Q?C3O3aUIeMOV8gfyuE3Bbx/R2YuTGBLOaBBTpCf1lHIZiLZ1GDvNNbdRGJVAZ?= =?us-ascii?Q?nOUznG3sGj4zx7kdDlWlFjLIzYuBBNRLA5Fkpvkdl+25owvmmwcKDI4xevdm?= =?us-ascii?Q?iDs4zxgj5+8mXXoV8Wvj8YIihd4IM7W+FWPZhB+azVruTEiya5swM18+Up7s?= =?us-ascii?Q?uwrvXiuGOy8xIb92BuvUTIjnTsL+EwxGAoPCKuW04251imHjdCefGeN4hX9T?= =?us-ascii?Q?FQcJrgLFvTAKf1wedpHbWMipff5KZOVREcbhrJ/aJJWKHodOoKivIGTqPvsl?= =?us-ascii?Q?jW3rHPQqjPnhNNd2xAJ2V0dVQUDtR+9NzayOwqO+tV2r3B5Alyghqg9906zn?= =?us-ascii?Q?0DrpFY7p8gUoz60T5MkgHrwk4TDuHt5FUemlrg8MHyhrqqcO+4SfnFX0STng?= =?us-ascii?Q?93+yjwO1MAIuA4PfD8vONDjLcRNm9kybvOTaoOjhJtxa8RZw15N6EUvBFkXX?= =?us-ascii?Q?2cWItuse1ZW01TQZm6BgvJXhMxCSk+wAmYJo7cKAtZdqR9QepyUMibUFCRpB?= =?us-ascii?Q?oGS9nBENwKHIV+ax8uwYwrbG9z27mLztT7qFHJzYr0yVCBFY/PA0hwSFa276?= =?us-ascii?Q?d5Ggo45pwEbL3N9OjE1QceAM2R6OvpmYcKlHLAb45dTZoER4N6VaJZPUIAnv?= =?us-ascii?Q?QfOVP8DpzNZ8u/L+dPgvuqUuKfpW+apd8fq4CJZ2zxw7Zmsq+tm5+BVvRpja?= =?us-ascii?Q?jQPp0cZ6jWGdts5y9jrRUfibOPBPfhENFoN5xR5/AmKCwsTDJpugGPt0SkuP?= =?us-ascii?Q?QgXJRj0aS0A/eVZv758e2c/Nq4imuMMTDURUk8HHtmyi0WWEsImUh1s9jG7f?= =?us-ascii?Q?AvB3?= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Dec 2020 18:39:57.5824 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-Network-Message-Id: 5b001c08-d0a5-4174-dca9-08d89e0428f4 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: P85r/WG/HQTt2tMgZjHAMESuAj2cX2ZTdub66mB/ot+bxExPd9X0kMpSDVzC7ri+EHCaT8RvIzqPreB7sSpASWVBKZu6ZA1ALEKugUZWZUw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4915 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=40.107.7.97; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-HE1-obe.outbound.protection.outlook.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, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=unavailable 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: fam@euphon.net, kwolf@redhat.com, vsementsov@virtuozzo.com, berto@igalia.com, qemu-devel@nongnu.org, mreitz@redhat.com, stefanha@redhat.com, den@openvz.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @virtuozzo.com) Content-Type: text/plain; charset="utf-8" We are generally moving to int64_t for both offset and bytes parameters on all io paths. Main motivation is realization of 64-bit write_zeroes operation for fast zeroing large disk chunks, up to the whole disk. We chose signed type, to be consistent with off_t (which is signed) and with possibility for signed return type (where negative value means error). So, prepare bdrv_co_do_copy_on_readv() now. 'bytes' type widening, so callers are safe. Look at the function itself: bytes, skip_bytes and progress become int64_t. bdrv_round_to_clusters() is OK, cluster_bytes now may be large. trace_bdrv_co_do_copy_on_readv() is OK looping through cluster_bytes is still OK. pnum is still capped to max_transfer, and to MAX_BOUNCE_BUFFER when we are going to do COR operation. Therefor calculations in qemu_iovec_from_buf() and bdrv_driver_preadv() should not change. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Eric Blake --- block/io.c | 8 +++++--- block/trace-events | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/block/io.c b/block/io.c index b499998f54..d8c07fac56 100644 --- a/block/io.c +++ b/block/io.c @@ -1289,7 +1289,7 @@ bdrv_driver_pwritev_compressed(BlockDriverState *bs, = int64_t offset, } =20 static int coroutine_fn bdrv_co_do_copy_on_readv(BdrvChild *child, - int64_t offset, unsigned int bytes, QEMUIOVector *qiov, + int64_t offset, int64_t bytes, QEMUIOVector *qiov, size_t qiov_offset, int flags) { BlockDriverState *bs =3D child->bs; @@ -1304,13 +1304,15 @@ static int coroutine_fn bdrv_co_do_copy_on_readv(Bd= rvChild *child, BlockDriver *drv =3D bs->drv; int64_t cluster_offset; int64_t cluster_bytes; - size_t skip_bytes; + int64_t skip_bytes; int ret; int max_transfer =3D MIN_NON_ZERO(bs->bl.max_transfer, BDRV_REQUEST_MAX_BYTES); - unsigned int progress =3D 0; + int64_t progress =3D 0; bool skip_write; =20 + bdrv_check_qiov_request(offset, bytes, qiov, qiov_offset, &error_abort= ); + if (!drv) { return -ENOMEDIUM; } diff --git a/block/trace-events b/block/trace-events index 8368f4acb0..a5f6ffb7da 100644 --- a/block/trace-events +++ b/block/trace-events @@ -14,7 +14,7 @@ blk_root_detach(void *child, void *blk, void *bs) "child = %p blk %p bs %p" bdrv_co_preadv(void *bs, int64_t offset, int64_t nbytes, unsigned int flag= s) "bs %p offset %"PRId64" nbytes %"PRId64" flags 0x%x" bdrv_co_pwritev(void *bs, int64_t offset, int64_t nbytes, unsigned int fla= gs) "bs %p offset %"PRId64" nbytes %"PRId64" flags 0x%x" bdrv_co_pwrite_zeroes(void *bs, int64_t offset, int count, int flags) "bs = %p offset %"PRId64" count %d flags 0x%x" -bdrv_co_do_copy_on_readv(void *bs, int64_t offset, unsigned int bytes, int= 64_t cluster_offset, int64_t cluster_bytes) "bs %p offset %"PRId64" bytes %= u cluster_offset %"PRId64" cluster_bytes %"PRId64 +bdrv_co_do_copy_on_readv(void *bs, int64_t offset, int64_t bytes, int64_t = cluster_offset, int64_t cluster_bytes) "bs %p offset %" PRId64 " bytes %" P= RId64 " cluster_offset %" PRId64 " cluster_bytes %" PRId64 bdrv_co_copy_range_from(void *src, uint64_t src_offset, void *dst, uint64_= t dst_offset, uint64_t bytes, int read_flags, int write_flags) "src %p offs= et %"PRIu64" dst %p offset %"PRIu64" bytes %"PRIu64" rw flags 0x%x 0x%x" bdrv_co_copy_range_to(void *src, uint64_t src_offset, void *dst, uint64_t = dst_offset, uint64_t bytes, int read_flags, int write_flags) "src %p offset= %"PRIu64" dst %p offset %"PRIu64" bytes %"PRIu64" rw flags 0x%x 0x%x" =20 --=20 2.25.4 From nobody Fri May 17 21:24:39 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; arc=pass (i=1dmarc=pass fromdomain=virtuozzo.com); dmarc=pass(p=quarantine dis=none) header.from=virtuozzo.com ARC-Seal: i=2; a=rsa-sha256; t=1607714753; cv=pass; d=zohomail.com; s=zohoarc; b=NmOuQ3J80G88FCN1kuiifu9qfiFiF1qwzjuoKHDZXxZ7CLSvSBIW98UVW/6BNCtEBZVhRkDH3nYUFpadiVlqVHDAE5bpwmSaM5hjY70WsVPJc0TvtsIYIsUn5Rd/oWWR+LiBzbt1oBTVtGTkI9DCxGWuskEyJINZcQjsdSzrfSo= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607714753; 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=dEkmetIL9TcYHBOQbWl8jhNIui6ph+O5zv24qYUh4Hw=; b=Yb6WlTa9oq+rW5vBxI07zy+vJ386QxIOk5ExBVcViaewUAqMdqb9apij6TOqhYXR+BQ/qZUEapnsk/P7WJVgqZK3OoqQejCRpyymoTQOrFrb4Irqe7kEl6LhA5p8EjiBvy7TOoZmqRXeZCH1+5J1GqCXpLmOdv4KUAlkbtFmdmg= ARC-Authentication-Results: i=2; 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; arc=pass (i=1dmarc=pass fromdomain=virtuozzo.com); dmarc=pass header.from= (p=quarantine dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16077147532621000.5406607337671; Fri, 11 Dec 2020 11:25:53 -0800 (PST) Received: from localhost ([::1]:48792 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1knnkK-0007uQ-JS for importer@patchew.org; Fri, 11 Dec 2020 14:06:29 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43854) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1knnLG-0006vK-UU; Fri, 11 Dec 2020 13:40:34 -0500 Received: from mail-eopbgr70090.outbound.protection.outlook.com ([40.107.7.90]:11267 helo=EUR04-HE1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1knnLB-00089o-97; Fri, 11 Dec 2020 13:40:34 -0500 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB4915.eurprd08.prod.outlook.com (2603:10a6:20b:d1::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3632.18; Fri, 11 Dec 2020 18:39:58 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::d585:99a4:d7a4:d478]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::d585:99a4:d7a4:d478%4]) with mapi id 15.20.3654.016; Fri, 11 Dec 2020 18:39:58 +0000 Received: from kvm.sw.ru (185.215.60.91) by AM0PR04CA0050.eurprd04.prod.outlook.com (2603:10a6:208:1::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3654.12 via Frontend Transport; Fri, 11 Dec 2020 18:39:57 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fw82PfIhikMPHnQa18BJYkEwPe4cREzM+Q72V7MHfwIrfg0P/C1dMcecYXf9l+g/6DeD6lT4+FkgslfWZ0T1R8W76P0jD5F0Y11zl29xx+0+1PT1tQIEwhj7SwWjoxZ+tjai/EpO5YuCQDwWycBCBx9Z2goyrd5WbezM1CqJ+5qvWi4xvR2nuTd7MqUeqQEvD8/V4PndtDiColRhJOKnF27TczQY4m7LjypMmRCU1Xgw/F0Dlg2WmIU+sdlQCSOYsJmwtOpjRWGZzQ1nnGgHleCaS6Qwc9kH2A0IuPdPd4esbYNo4KdrdOU8gNE0C9E6dH3eIfuE/8TNyJbzAscdXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=dEkmetIL9TcYHBOQbWl8jhNIui6ph+O5zv24qYUh4Hw=; b=j3zMrZsclkdKz3H3o84T1frY8Nu+RbwlwFWKNZYIbTsWMoJh0DwzR8OhQWzPXFnirCDLEsHCfiybxLnrk9H3CoPW2O37EcCBupfvP6nwZzK+r1vb5xt7WkyOZ4L8c+Przb9JX7ag9/TYBaZFROqppZ1fQUcFqbjEHL5nljwMeWlNYA2fB/H7QBDtHh+//6LGNoFRIOGO55isZiycW/IEdqTohL0upVtUWeBipHg1oNqg1fH2daoXEmm4u+rU6Cl8ULgF1L/q97ueRrZ8AYyAZTk5eRdbxQ6jOyylKxdiEjXMWw+FMER/whDwcZfuE7BmzgW5OWYnOtGPvTehW6aJtQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=dEkmetIL9TcYHBOQbWl8jhNIui6ph+O5zv24qYUh4Hw=; b=jTj7WP7Wkqn7xGsMAxE2hOP2kf94U6w837BVyD75iA4WoL5MjWhTsNgJ6rypbm54urVCXJP//x38Y/3Ra2S3ca3rJUOl/6a1cPm78zmmGVOtBE+UVROxfqq1bCND2vNJ0h/ZAbmsbBOAhES1jLx9AMNaTSQ3c8UjpSpzH98+Qp0= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Subject: [PATCH v4 13/16] block/io: support int64_t bytes in bdrv_aligned_preadv() Date: Fri, 11 Dec 2020 21:39:31 +0300 Message-Id: <20201211183934.169161-14-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20201211183934.169161-1-vsementsov@virtuozzo.com> References: <20201211183934.169161-1-vsementsov@virtuozzo.com> Content-Transfer-Encoding: quoted-printable X-Originating-IP: [185.215.60.91] X-ClientProxiedBy: AM0PR04CA0050.eurprd04.prod.outlook.com (2603:10a6:208:1::27) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8cad1513-8ce8-4458-3f9d-08d89e04297a X-MS-TrafficTypeDiagnostic: AM6PR08MB4915: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3826; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: lTZVvist1TlGIol2w6fRKALxROI+ijJqj2NDq1f2ddRjahyT6s9ATgYy5STpU2E7UdxvxnTm/yUXtCHwOqsPmGD4SXTMhlpUQ8chGC32tFlnMCNq6Fzwf8IkPyOhG6YIbr6zjV7s3v3cqhTZJQbwNUfFF1xpgFjQGZWpd8la1ln7/DPZf0oUYaa2mrZhEButbaOLbu0ci38e5xFJq/2uZ5ERTeR3DXZXBydr6/zeXSeTGfgwP1k5lZoLLhu43Q7s0uQgtN1o3FZWf3ia8kD4EeXTkdAvYOjGGU7pWXiUgAcd/WpAcmQcaV0EaAnGuVnZzqJIY6gjxbkM4LBYSWPWyw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(346002)(39840400004)(136003)(396003)(376002)(66476007)(6506007)(66946007)(956004)(6486002)(86362001)(4326008)(66556008)(6916009)(6512007)(2616005)(6666004)(83380400001)(1076003)(26005)(316002)(16526019)(5660300002)(8676002)(186003)(478600001)(8936002)(2906002)(36756003)(107886003)(52116002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?3sjAzdJJR8X2J5/PtW9Zyk9kqqwWc6gmuPVUX4fgpm82d5DEJQBLvSwyiA7I?= =?us-ascii?Q?66uAvzLWxlPYmhJGI8TvqOj3Sy8r1w54gwHiVR9WLppeaR7EjqFK86VRG4bN?= =?us-ascii?Q?yiNKtRCBwpPDBcRBLHVHCq/H/mj0UuMHWxcmiivkj+KHnNyNqmMyAp+3LkUe?= =?us-ascii?Q?o8JZ4OwPuLzDwX/I8HM33Y1+k7BmvjN//q6Co+/ZSfgpgelO4ExdRG6i048K?= =?us-ascii?Q?pDxOfbpUrutBM47JRk0xFhTQ78Rhnv4jRJTBmHJZmTlBpsIbQSqtbRjawA5u?= =?us-ascii?Q?JDxGoDpr2VHuxLt9wBxvBww8Eip2SJ6UYs81uUP3EzYa4wG2kLC/G3tsYPK0?= =?us-ascii?Q?eQm4pdE3rbdxWOtH9jZxSjw3q5KF6LVw/6UGOqwVKjDymqpKEt6Ba0iLq/79?= =?us-ascii?Q?GdF3QwkbofUS0H4a2AdG/GCiIIHL1hjFL4jzbUCbOGxPzXs8AeGInmwIEeTG?= =?us-ascii?Q?lLtWaBKET75pY/1zD5ChO0W4ovOdFkZ7D81WzVOYLOf9eoc94tDBazijgW/m?= =?us-ascii?Q?gqjBkfWaSOTqcL+B3fnURPirpBWwS+mP253Crb2J1RCTyD6sgrFDzNiJ1nYz?= =?us-ascii?Q?QCCd+kFkq9TNd4HgoGt/fvXH3H7n3uIXNBs9c/dfc/RuNSA+444njubLKCjj?= =?us-ascii?Q?PH8MPPsHHOzMov0OgHXnAe6I8qihmwgNzFlYXvvbWEtR56uPHjTqPwGUcIIf?= =?us-ascii?Q?YXtdOLoegJlyPJajMuGhDV793n/wToACdpmV8zppk6xsTlJ/Qv01TXktmiA5?= =?us-ascii?Q?t96sC9uSvwwzYWtrHt6rwxRPfTE8wdPFlViQ+sDsA5TCfrisahTTzSKKF49c?= =?us-ascii?Q?t+vbqMdsE+lxV5xXaJZmM0LXyu4uVcxiV/yYHhogQB4gnmZ2omY0Wi1XlOUq?= =?us-ascii?Q?MpwedGjn/1PNtb6SfDnZ8BFDNeUfLRx01PEyUCOhffY640kbbAo+Z//AUk8k?= =?us-ascii?Q?cPAux94Jf3CIqKz3VDs3jvywV6WS4BPJn9Xpwn7F8RJBKure7JRQR7lk23d/?= =?us-ascii?Q?9Wry?= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Dec 2020 18:39:58.4566 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-Network-Message-Id: 8cad1513-8ce8-4458-3f9d-08d89e04297a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: dybLb8cUmeuP9AibFfnID0FjYQUSF6qjrlwWgGRvdYUHqs75r9q0HMDeh8koM1U1rKGDr64EYCKq68Djs1IVZkZ/tYDyP0/2Ad98ex855fQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4915 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=40.107.7.90; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-HE1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-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: fam@euphon.net, kwolf@redhat.com, vsementsov@virtuozzo.com, berto@igalia.com, qemu-devel@nongnu.org, mreitz@redhat.com, stefanha@redhat.com, den@openvz.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @virtuozzo.com) Content-Type: text/plain; charset="utf-8" We are generally moving to int64_t for both offset and bytes parameters on all io paths. Main motivation is realization of 64-bit write_zeroes operation for fast zeroing large disk chunks, up to the whole disk. We chose signed type, to be consistent with off_t (which is signed) and with possibility for signed return type (where negative value means error). So, prepare bdrv_aligned_preadv() now. Make byte variable in bdrv_padding_rmw_read() int64_t, as it defined only to be passed to bdrv_aligned_preadv(). All bdrv_aligned_preadv() callers are safe as type is widening. Let's look inside: - add a new-style assertion that request is good. - callees bdrv_is_allocated(), bdrv_co_do_copy_on_readv() supports int64_t bytes - conversion of bytes_remaining is OK, as we never has requests overflowing BDRV_MAX_LENGTH - looping through bytes_remaining is ok, num is updated to int64_t - for bdrv_driver_preadv we have same limit of max_transfer - qemu_iovec_memset is OK, as bytes+qiov_offset should not overflow qiov->size anyway (thanks to bdrv_check_qiov_request()) Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Eric Blake --- block/io.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/block/io.c b/block/io.c index d8c07fac56..93a89a56e3 100644 --- a/block/io.c +++ b/block/io.c @@ -1453,15 +1453,16 @@ err: * reads; any other features must be implemented by the caller. */ static int coroutine_fn bdrv_aligned_preadv(BdrvChild *child, - BdrvTrackedRequest *req, int64_t offset, unsigned int bytes, + BdrvTrackedRequest *req, int64_t offset, int64_t bytes, int64_t align, QEMUIOVector *qiov, size_t qiov_offset, int flags) { BlockDriverState *bs =3D child->bs; int64_t total_bytes, max_bytes; int ret =3D 0; - uint64_t bytes_remaining =3D bytes; + int64_t bytes_remaining =3D bytes; int max_transfer; =20 + bdrv_check_qiov_request(offset, bytes, qiov, qiov_offset, &error_abort= ); assert(is_power_of_2(align)); assert((offset & (align - 1)) =3D=3D 0); assert((bytes & (align - 1)) =3D=3D 0); @@ -1518,7 +1519,7 @@ static int coroutine_fn bdrv_aligned_preadv(BdrvChild= *child, } =20 while (bytes_remaining) { - int num; + int64_t num; =20 if (max_bytes) { num =3D MIN(bytes_remaining, MIN(max_bytes, max_transfer)); @@ -1624,7 +1625,7 @@ static int bdrv_padding_rmw_read(BdrvChild *child, assert(req->serialising && pad->buf); =20 if (pad->head || pad->merge_reads) { - uint64_t bytes =3D pad->merge_reads ? pad->buf_len : align; + int64_t bytes =3D pad->merge_reads ? pad->buf_len : align; =20 qemu_iovec_init_buf(&local_qiov, pad->buf, bytes); =20 --=20 2.25.4 From nobody Fri May 17 21:24:39 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; arc=fail (Bad Signature); dmarc=pass(p=none dis=none) header.from=nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 160771887156856.94520807849483; Fri, 11 Dec 2020 12:34:31 -0800 (PST) Received: from localhost ([::1]:57348 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1knnqU-0003Ym-0a for importer@patchew.org; Fri, 11 Dec 2020 14:12:50 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43872) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1knnLM-0006yh-Dy; Fri, 11 Dec 2020 13:40:40 -0500 Received: from mail-eopbgr70129.outbound.protection.outlook.com ([40.107.7.129]:29411 helo=EUR04-HE1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1knnLH-0008CX-4f; Fri, 11 Dec 2020 13:40:39 -0500 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB4915.eurprd08.prod.outlook.com (2603:10a6:20b:d1::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3632.18; Fri, 11 Dec 2020 18:39:59 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::d585:99a4:d7a4:d478]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::d585:99a4:d7a4:d478%4]) with mapi id 15.20.3654.016; Fri, 11 Dec 2020 18:39:59 +0000 Received: from kvm.sw.ru (185.215.60.91) by AM0PR04CA0050.eurprd04.prod.outlook.com (2603:10a6:208:1::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3654.12 via Frontend Transport; Fri, 11 Dec 2020 18:39:58 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hdz5ow0gD90jsWUGEsDsFIgLswgY+NZaZ9uwd+0Qu+fjD5BljgKPOzpSTD4fk/0b5tLJZrNLm9svDoTJSaj5hXF0M6DaIJdn2dWfNwufYz/lfUcNV9Q0B9NeIA2b9MK2R7TcRoZqNoVboaCVZM+TQN+IVKmEP6A3JU8xTx7pcqv8BBEXIiv/GzOu8IkSu5qJY9bsRoaceN3wuAgvRZUm+P/Mfz8Zc5QnH6qGvVVMUIrWRg15HBioEDAKNCo7Uw9Bi3EA2e11teaEF8dtqUi9SogomYDeeORCYypSFGfOaPDPMKJUZYe0S7/R8lIHgVA+MqGNXVCFwi0ugRCkaGQdug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=jTSfc+E8g2/NKFqqZDnmTcVdcIFBezSaCL0qjDWN8ow=; b=adJv4TKpOdZM5GHsuNVcj+IqCHCgz924hLvqLE7VkCP7F+v91kHQqs47/4vc3wKxIaK15fJ/PJNHsIK0xI+0LL8sxLcaHdfSJsgdTEySMEBvUfhO7U08PWzKCH8gkN67XqtOVcpy8rjPyP80LlduPTcwU1lkKVoI2eSWMMVIexKWFRmX9unbvzyIRrVlAPZAUGwIYnlDKy4VzcMseg3oa2MPQiyFi359W6RmQxEI1QJUDrvtd+S9SxOQN2gU0DgTk4dCRNT383ExEdzOputi6oyb8jj7fQ7PTnbhZT2G3vU4OK61BE0dthbIAS19If6QHau0JDnz5zo3VEhtpag8hA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=jTSfc+E8g2/NKFqqZDnmTcVdcIFBezSaCL0qjDWN8ow=; b=UJLRXCGnKUe1xk26mxZcq2aBHCYXPjJfE3eijm3agR3J7eNUt4eL66f29qDnS88SVSsaKEbD/b01vD+Fg2wY3b8/A9qnxlPr4kcpP4M7ebBlcLZ+woQ6qbenQ9DCkN2FDs+eWr67zT46vnu2oIPZc4iigq7XrmNsrJasa9iFXlg= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; To: qemu-block@nongnu.org Subject: [PATCH v4 14/16] block/io: support int64_t bytes in bdrv_co_p{read, write}v_part() Date: Fri, 11 Dec 2020 21:39:32 +0300 Message-Id: <20201211183934.169161-15-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20201211183934.169161-1-vsementsov@virtuozzo.com> References: <20201211183934.169161-1-vsementsov@virtuozzo.com> Content-Transfer-Encoding: quoted-printable X-Originating-IP: [185.215.60.91] X-ClientProxiedBy: AM0PR04CA0050.eurprd04.prod.outlook.com (2603:10a6:208:1::27) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 366bedbe-2017-4876-ab8a-08d89e0429ea X-MS-TrafficTypeDiagnostic: AM6PR08MB4915: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5516; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: lH6ZzusVT8RBfhsz/C+gCW/O0rlJ5yRrUCNU3Tmyk1w63Mcvfph4tpmJPQD9eK1zkb++jDmiw0xQeFC2U/A/yYp5lusUvpzhSE75I4/Kcwoom2n21j7dKcBIq/IY3JlsA2EqpwzOfFeRSBDrrKDojUIGpo0as9eaalmOOE/8HA8fO4DvVbsZ+e+fAHxl9CnxLyao2wCb8MbV2+OccNbdDp3oq6HgL5ifJYIDSHZMl2pSQCPeb7U/E5v6UsEHFkuzmz5PcpRnThodFocPJnwJZIipgmtlqfoVz9sl1TIvnJjHlQGJ8m0k6o4CrpeX+O/c X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(346002)(39840400004)(136003)(396003)(376002)(66476007)(6506007)(66946007)(956004)(6486002)(86362001)(4326008)(66556008)(6916009)(6512007)(2616005)(6666004)(83380400001)(1076003)(26005)(316002)(16526019)(5660300002)(8676002)(186003)(478600001)(8936002)(2906002)(36756003)(107886003)(52116002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?+yGTTswj25ytM2tzA0zrXa8xUiwZ5FYB3dqOeWREe5128Oi5DSYSX2Kat7Sp?= =?us-ascii?Q?xBcgyYuOVKg2NugtaWaOTctww1ZjKfFOYZfqBXB71h70JOQxrvnW+ORmUU6+?= =?us-ascii?Q?khR9GxCMdFtOZISbZrgYT+qiWIOfpnpooyMqM452ESXpvKPBrXqTA8p3Xu0B?= =?us-ascii?Q?SvcYq/jQ34Bj+mg5Xdi33SMHXUrrme7MC7GygeqriU+q/DbG41O3Nm3Jmj+V?= =?us-ascii?Q?NAdVWwmBudXdRyemh3IslfZPoi9DfHg/2avvsYqN4a83DdOWmHeD6nhgbAYz?= =?us-ascii?Q?DlTsu/08ZUOa66WnVEjUdYM6fiZybYg+uUuhXCRIs0z9p4wZDIE3bnpOFHrE?= =?us-ascii?Q?3Rcvk+AHwQY/Hw+Y/KZdrb7HNrTqALwlyHxBjX3IO6rAeeXM76n2BV8xJoLS?= =?us-ascii?Q?GZI4dxnnJcZRzqtXSPVj46ehNU0lLCpU3Cprut0h1Z837FSpWPZIgDWg+TyP?= =?us-ascii?Q?UPRqJyD8WrWUN17N9IfTThNT5VrYmPkI3x81NxwxFALp3Be9Poj181t2s91G?= =?us-ascii?Q?UBId03dcWMkLbbIe9J+Idlpuqke91anakNyLurNzqZNsfrITLVgZiv1JfJXD?= =?us-ascii?Q?KjSv+sy9+hX3vG/wXde7baMRGi+gkPljkOtuYEKZf3FlerutxXfUriasBl6R?= =?us-ascii?Q?lPfQ62gL9MDv7po77ZPW2xPGp1IWldjQlHUXypA63KBlaaSIkyiwJ3SHVJtq?= =?us-ascii?Q?JXu56mQoVFlDvtBTJFVzKUihMZBWnuC2aEmpyBqV3rUzRl7Zt8tA8TrT/9ws?= =?us-ascii?Q?XnnNAJNuLhmr9U0xDc3Rx0B5sH5NNc2XwQ6H+HzcvHVVgxHexG+L0NWRDYEY?= =?us-ascii?Q?qj4YtdzxTe/I3wZtPFJP8N/HPeoYjEsURMzKvKVHbbtOxGQlWZjZbJHIVsG5?= =?us-ascii?Q?w7ncRetuqPQ09C440tYJtoqYgLIUxMPvwtIUf6eSrYpkRtOz9SVUQy0Nx3fi?= =?us-ascii?Q?VHmc5vZKW1giGKOnTRjxilpNy3VGOc0Wuhlq+CDPF5x1zeOGo1wRQYyZJKQJ?= =?us-ascii?Q?gKIJ?= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Dec 2020 18:39:59.2620 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-Network-Message-Id: 366bedbe-2017-4876-ab8a-08d89e0429ea X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: w0pv7wSERpavysGjS9oYKq0ZBMVjttjZbWwfsr9wa705KUji6yriuW/pCtNA08fJrQ9qNb/5LqtDtgGVt1n8G3MxrA8fQllQCDyGxogcRo0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4915 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=40.107.7.129; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-HE1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-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: fam@euphon.net, kwolf@redhat.com, vsementsov@virtuozzo.com, berto@igalia.com, qemu-devel@nongnu.org, mreitz@redhat.com, stefanha@redhat.com, den@openvz.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Reply-to: Vladimir Sementsov-Ogievskiy From: Vladimir Sementsov-Ogievskiy via X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" We are generally moving to int64_t for both offset and bytes parameters on all io paths. Main motivation is realization of 64-bit write_zeroes operation for fast zeroing large disk chunks, up to the whole disk. We chose signed type, to be consistent with off_t (which is signed) and with possibility for signed return type (where negative value means error). So, prepare bdrv_co_preadv_part() and bdrv_co_pwritev_part() and their remaining dependencies now. bdrv_pad_request() is updated simultaneously, as pointer to bytes passed to it both from bdrv_co_pwritev_part() and bdrv_co_preadv_part(). So, all callers of bdrv_pad_request() are updated to pass 64bit bytes. bdrv_pad_request() is already good for 64bit requests, add corresponding assertion. Look at bdrv_co_preadv_part() and bdrv_co_pwritev_part(). Type is widening, so callers are safe. Let's look inside the functions. In bdrv_co_preadv_part() and bdrv_aligned_pwritev() we only pass bytes to other already int64_t interfaces (and some obviously safe calculations), it's OK. In bdrv_co_do_zero_pwritev() aligned_bytes may become large now, still it's passed to bdrv_aligned_pwritev which supports int64_t bytes. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Eric Blake --- include/block/block_int.h | 4 ++-- block/io.c | 14 ++++++++------ block/trace-events | 4 ++-- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/include/block/block_int.h b/include/block/block_int.h index 04c1e5cb58..55b1039872 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -1031,13 +1031,13 @@ int coroutine_fn bdrv_co_preadv(BdrvChild *child, int64_t offset, unsigned int bytes, QEMUIOVector *qiov, BdrvRequestFlags flags); int coroutine_fn bdrv_co_preadv_part(BdrvChild *child, - int64_t offset, unsigned int bytes, + int64_t offset, int64_t bytes, QEMUIOVector *qiov, size_t qiov_offset, BdrvRequestFlags flags); int coroutine_fn bdrv_co_pwritev(BdrvChild *child, int64_t offset, unsigned int bytes, QEMUIOVector *qiov, BdrvRequestFlags flags); int coroutine_fn bdrv_co_pwritev_part(BdrvChild *child, - int64_t offset, unsigned int bytes, + int64_t offset, int64_t bytes, QEMUIOVector *qiov, size_t qiov_offset, BdrvRequestFlags flags); =20 static inline int coroutine_fn bdrv_co_pread(BdrvChild *child, diff --git a/block/io.c b/block/io.c index 93a89a56e3..5200658224 100644 --- a/block/io.c +++ b/block/io.c @@ -1697,11 +1697,13 @@ static void bdrv_padding_destroy(BdrvRequestPadding= *pad) */ static int bdrv_pad_request(BlockDriverState *bs, QEMUIOVector **qiov, size_t *qiov_offset, - int64_t *offset, unsigned int *bytes, + int64_t *offset, int64_t *bytes, BdrvRequestPadding *pad, bool *padded) { int ret; =20 + bdrv_check_qiov_request(*offset, *bytes, *qiov, *qiov_offset, &error_a= bort); + if (!bdrv_init_padding(bs, *offset, *bytes, pad)) { if (padded) { *padded =3D false; @@ -1736,7 +1738,7 @@ int coroutine_fn bdrv_co_preadv(BdrvChild *child, } =20 int coroutine_fn bdrv_co_preadv_part(BdrvChild *child, - int64_t offset, unsigned int bytes, + int64_t offset, int64_t bytes, QEMUIOVector *qiov, size_t qiov_offset, BdrvRequestFlags flags) { @@ -1745,7 +1747,7 @@ int coroutine_fn bdrv_co_preadv_part(BdrvChild *child, BdrvRequestPadding pad; int ret; =20 - trace_bdrv_co_preadv(bs, offset, bytes, flags); + trace_bdrv_co_preadv_part(bs, offset, bytes, flags); =20 if (!bdrv_is_inserted(bs)) { return -ENOMEDIUM; @@ -2089,7 +2091,7 @@ static int coroutine_fn bdrv_aligned_pwritev(BdrvChil= d *child, =20 static int coroutine_fn bdrv_co_do_zero_pwritev(BdrvChild *child, int64_t offset, - unsigned int bytes, + int64_t bytes, BdrvRequestFlags flags, BdrvTrackedRequest *req) { @@ -2163,7 +2165,7 @@ int coroutine_fn bdrv_co_pwritev(BdrvChild *child, } =20 int coroutine_fn bdrv_co_pwritev_part(BdrvChild *child, - int64_t offset, unsigned int bytes, QEMUIOVector *qiov, size_t qiov_of= fset, + int64_t offset, int64_t bytes, QEMUIOVector *qiov, size_t qiov_offset, BdrvRequestFlags flags) { BlockDriverState *bs =3D child->bs; @@ -2173,7 +2175,7 @@ int coroutine_fn bdrv_co_pwritev_part(BdrvChild *chil= d, int ret; bool padded =3D false; =20 - trace_bdrv_co_pwritev(child->bs, offset, bytes, flags); + trace_bdrv_co_pwritev_part(child->bs, offset, bytes, flags); =20 if (!bdrv_is_inserted(bs)) { return -ENOMEDIUM; diff --git a/block/trace-events b/block/trace-events index a5f6ffb7da..91a0f70575 100644 --- a/block/trace-events +++ b/block/trace-events @@ -11,8 +11,8 @@ blk_root_attach(void *child, void *blk, void *bs) "child = %p blk %p bs %p" blk_root_detach(void *child, void *blk, void *bs) "child %p blk %p bs %p" =20 # io.c -bdrv_co_preadv(void *bs, int64_t offset, int64_t nbytes, unsigned int flag= s) "bs %p offset %"PRId64" nbytes %"PRId64" flags 0x%x" -bdrv_co_pwritev(void *bs, int64_t offset, int64_t nbytes, unsigned int fla= gs) "bs %p offset %"PRId64" nbytes %"PRId64" flags 0x%x" +bdrv_co_preadv_part(void *bs, int64_t offset, int64_t bytes, unsigned int = flags) "bs %p offset %" PRId64 " bytes %" PRId64 " flags 0x%x" +bdrv_co_pwritev_part(void *bs, int64_t offset, int64_t bytes, unsigned int= flags) "bs %p offset %" PRId64 " bytes %" PRId64 " flags 0x%x" bdrv_co_pwrite_zeroes(void *bs, int64_t offset, int count, int flags) "bs = %p offset %"PRId64" count %d flags 0x%x" bdrv_co_do_copy_on_readv(void *bs, int64_t offset, int64_t bytes, int64_t = cluster_offset, int64_t cluster_bytes) "bs %p offset %" PRId64 " bytes %" P= RId64 " cluster_offset %" PRId64 " cluster_bytes %" PRId64 bdrv_co_copy_range_from(void *src, uint64_t src_offset, void *dst, uint64_= t dst_offset, uint64_t bytes, int read_flags, int write_flags) "src %p offs= et %"PRIu64" dst %p offset %"PRIu64" bytes %"PRIu64" rw flags 0x%x 0x%x" --=20 2.25.4 From nobody Fri May 17 21:24:39 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; arc=pass (i=1dmarc=pass fromdomain=virtuozzo.com); dmarc=pass(p=quarantine dis=none) header.from=virtuozzo.com ARC-Seal: i=2; a=rsa-sha256; t=1607713100; cv=pass; d=zohomail.com; s=zohoarc; b=ZzAOW/Hqng/daNZ5GGJnvFmx+0udBmzSFbyWcfLNBlcTDJZ9tDcnbyK+q19qI8IsQRaVndDp6QKCvgd3GdYETI6SQaE9ZqsL+Vssv3CTUnuEWhfoEr5XtTMvvpU3Kgpi6TotHu5DkX66ZAVfjW47GybE/0B9UU6wQ6+zfrR4gZg= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607713100; 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=A8NMNhlHcsLg681LD8TQ2D8/jEwyj88ki/t33Ev8sSI=; b=igjbR2x94muzA/EkBh4G1nRhQt1YshGfRVaxfoD9QC6jjh/pec2+nwZd8l52+hYzK+CkIPJFMDHfzNkTV1Dkg5jmClA5S5jzzk1rYKQQiWJ9KokSHhLPP3NkCgsXBBgnLvLNt03WU34MR5iKUV7SDY5gJMvDN972X/bIu1Gqcgo= ARC-Authentication-Results: i=2; 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; arc=pass (i=1dmarc=pass fromdomain=virtuozzo.com); dmarc=pass header.from= (p=quarantine dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1607713100124758.214997156452; Fri, 11 Dec 2020 10:58:20 -0800 (PST) Received: from localhost ([::1]:38536 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1knncO-0003RU-Qe for importer@patchew.org; Fri, 11 Dec 2020 13:58:17 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43654) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1knnKz-0006gk-E0; Fri, 11 Dec 2020 13:40:21 -0500 Received: from mail-db8eur05on2131.outbound.protection.outlook.com ([40.107.20.131]:25696 helo=EUR05-DB8-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1knnKo-0008Cr-1v; Fri, 11 Dec 2020 13:40:10 -0500 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM5PR0801MB1713.eurprd08.prod.outlook.com (2603:10a6:203:34::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3654.17; Fri, 11 Dec 2020 18:40:00 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::d585:99a4:d7a4:d478]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::d585:99a4:d7a4:d478%4]) with mapi id 15.20.3654.016; Fri, 11 Dec 2020 18:40:00 +0000 Received: from kvm.sw.ru (185.215.60.91) by AM0PR04CA0050.eurprd04.prod.outlook.com (2603:10a6:208:1::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3654.12 via Frontend Transport; Fri, 11 Dec 2020 18:39:59 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gQY3rtbQ46kBNXCEvhKtz8Tf+xp2RNBhm0Lgfli94vd4TYPMqMuTuMeI1P+VLBHkOpkAR4gZfgRlsFZHPktI4c+rjP/QIEjTxDvDWPxmj1G6KaPpd7DRaBm62NnU7K9OvbKpfveXrCol7vCL2srAN8oYxExA4zsuQSGzBCxfc+LJuDAlFcC6BfrEv8NwA9smoHtXanfzmYwgf94OnF1RjfEjgXrEhJZgUKI0K0IOF6Yf5c3KRitUJRRE/gLuFWZv+z8187GkAMziFBmcJrunCQdTAbWyVS3sYLD33fRoUsmGog+rRdhf+9VOSkd54VpkgqBD06VuTmxKkJfihtFTHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=A8NMNhlHcsLg681LD8TQ2D8/jEwyj88ki/t33Ev8sSI=; b=Qrcy99L73oj5tGw4DVsRG0LkW0bCCR4m0VCNOoy4KMUynJfqnBFTrSrylWz2HS6EJddGI9SltYEZ4pY8tB//9u2cX1z+TIPLTbeMsRsLcwAUc+TLvpkUpDzEovSV1uuG9KKhkcmkaSQSJaTuUWkdE3e2iF2iV+faIJFW81H9Xl6UNV/PP5JaP6wBDnie66qe4IBzu6ebJeopUZv4TZOElA525A1AU6s4m8yzfE8wC7k6XTc01cekYTx6NihOu5kIsg9E9LuQ16Cry/3G8WIPZr2b7qsYdGrEc7FeCw9sNrOoceiuvgjDtG2PgsyC7ksFB+siz5pKc8XmCKxQNnZBjA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=A8NMNhlHcsLg681LD8TQ2D8/jEwyj88ki/t33Ev8sSI=; b=msXnl3LLKbVKBbrFynkhgsDwSki4HAww+VDJkmrU82Px2rFAiGw4xtlD4qNuq4hybfE+b3qb4JTJah5orm4wNhomrgXCFP3xjn4E9pNzcoIWL93V5yJwMl2MEfe7OhfNP06YCvsxxGA4yY4XpBwRqVfe27+vqg2OVauPsD7DKiY= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Subject: [PATCH v4 15/16] block/io: support int64_t bytes in read/write wrappers Date: Fri, 11 Dec 2020 21:39:33 +0300 Message-Id: <20201211183934.169161-16-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20201211183934.169161-1-vsementsov@virtuozzo.com> References: <20201211183934.169161-1-vsementsov@virtuozzo.com> Content-Transfer-Encoding: quoted-printable X-Originating-IP: [185.215.60.91] X-ClientProxiedBy: AM0PR04CA0050.eurprd04.prod.outlook.com (2603:10a6:208:1::27) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 89250667-24bd-4079-7cbe-08d89e042a72 X-MS-TrafficTypeDiagnostic: AM5PR0801MB1713: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:792; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: oEi4GngqOcO7SdXhsCQWVekaOZr9zfru+2htffWQtRqx/5hkd5/w0pE29tztScmjyENLbPsNfCuCXXhl5P6yhPxp8yleE0VY43jJ20kyAZQouPy5PTNAhiYkta3V0CdD378Xu/R9eng7lQyDTLXqSfTh0zefvXB41U3MKHNbpVJEKlVu+V9CuUD9IymOSkuXS+kMbGQjWCcXU1CjlA57Za0Z5mb+tUPGOeqtIUVZrdLbNS4kxYDS5NeaL+U/jVwDZHHkdygz44oWGvFQyPnAGVc8AZNB0BELo4SY3DkbpuROGzy/ta9fRQo7rRM09YIf5H1K1zwlFth3VKiK5zm6Gw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(39840400004)(136003)(376002)(396003)(346002)(366004)(2616005)(86362001)(956004)(107886003)(66946007)(6506007)(66476007)(6666004)(6512007)(66556008)(5660300002)(478600001)(8936002)(6486002)(52116002)(36756003)(8676002)(316002)(1076003)(6916009)(83380400001)(26005)(16526019)(2906002)(186003)(4326008); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?y0IJPXGqjcTK+jPgkadm/uA+m/gOENvFctkBhvxA9Mo5gXuKyDHY+H5VOxxY?= =?us-ascii?Q?w0yq/LmrM46HXRs8s2cq0LRBOzsXDJzKAHLVA9a8tFuhTUQss4dgk2Vp8QHJ?= =?us-ascii?Q?gUOyPlu3ziN20byojB4U1L9pkG0W6WNNniVqH+o07zfJpnQymKtMj84inEb9?= =?us-ascii?Q?5tihyaoD1go6dNTtYru1qswzLgiT8QQr07/Lcp0Bwt8y7n8HeJ8R8DEKRsoA?= =?us-ascii?Q?ZQn2PjwmrbSOWSpOpgHKWkHzhGdPXu+59oNRNwcStZ+f9uJtNqOilBNdLSkC?= =?us-ascii?Q?yNTSQeFaLUBSOddmqMs4j27G7Yod4s7ccWtZJbHb7SiihonX4hX7Df7XRkFo?= =?us-ascii?Q?hyuUPRVvUrIer/DfQzdDh++I3JXQs9g1ZkClv3oISgWkmr4UgUlv5eHOpYwU?= =?us-ascii?Q?Gb138V0wI7hUsSICCkgmRvn8Tumrr/DHZ9wtD7KuPH6+G8Q4EEshg05wukG+?= =?us-ascii?Q?zC2oR1rjccsYyjOTOkOZAnLeo9VTiypT50BIaEbm13+SbBxDnBpSFtywzPAZ?= =?us-ascii?Q?zQmNOo5Mo9wGzZKNi7VeBR+G01AKFDqXq32fxYbk6nWwpc2zkJDgNiEiQAbq?= =?us-ascii?Q?xPRhRCsW+z+NlRTv/P1akSR92ci53GQ+0q+LsfPIlfMYEpqtUY157ACtdRYz?= =?us-ascii?Q?eKufu8bGCkPGgC7U0VjsPVFOleOOjk0AfXPs74/vLr00GF47tI44vaNaLyUO?= =?us-ascii?Q?hvXff3Ct/wYYhyq68c6e5hbLG+x6M1EI/9IXB3wvGZJLwfusC5owL1uggL5m?= =?us-ascii?Q?xjCCg3XFoYvnAk/PJuu0ZzoPg2V4Y2AqZVG6y92PR1M5lsrZd8jWhNFIJtoJ?= =?us-ascii?Q?y6MI+B1LcP5ENM2LlVY3c2CRiYcYJYRiCSoSuBYFgTXSWODSqV2JGY7PCXeq?= =?us-ascii?Q?EXXHLU8bDPnzY8ZeEvaymzuW7VB34a7Fyog6fbl3T2j5GeRQP+AyysJZg0BM?= =?us-ascii?Q?Kt2+yQsRROqVAxFH5OIZQL7EJUunfwCG8ePcbpOnLh0rvUGKqsReLbMK0cb6?= =?us-ascii?Q?3dp9?= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Dec 2020 18:40:00.0804 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-Network-Message-Id: 89250667-24bd-4079-7cbe-08d89e042a72 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 6F5T0vjf6eqGMUO0Yk1q7N66MkZ8iRvWIiCkxPJVPCP5eykJaxgk811kBGzCBmDZYGSeLPIXxOVcomY4ISKyma9R0mwDlxXEWSGGNrMiUtU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0801MB1713 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=40.107.20.131; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-DB8-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-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: fam@euphon.net, kwolf@redhat.com, vsementsov@virtuozzo.com, berto@igalia.com, qemu-devel@nongnu.org, mreitz@redhat.com, stefanha@redhat.com, den@openvz.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @virtuozzo.com) Content-Type: text/plain; charset="utf-8" We are generally moving to int64_t for both offset and bytes parameters on all io paths. Main motivation is realization of 64-bit write_zeroes operation for fast zeroing large disk chunks, up to the whole disk. We chose signed type, to be consistent with off_t (which is signed) and with possibility for signed return type (where negative value means error). Now, when bdrv_co_preadv_part() and bdrv_co_pwritev_part() updated, update all their wrappers. For all of them type of 'bytes' is widening, so callers are safe. We have update request_fn in blkverify.c simultaneusly. Still it's just a pointer to on of bdrv_co_pwritev() or bdrv_co_preadv(), and type is widening for callers of the request_fn anyway. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Eric Blake --- include/block/block.h | 11 ++++++----- include/block/block_int.h | 4 ++-- block/blkverify.c | 2 +- block/io.c | 15 ++++++++------- block/trace-events | 2 +- 5 files changed, 18 insertions(+), 16 deletions(-) diff --git a/include/block/block.h b/include/block/block.h index 5b81e33e94..3549125f1d 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -390,12 +390,13 @@ int bdrv_reopen_prepare(BDRVReopenState *reopen_state, void bdrv_reopen_commit(BDRVReopenState *reopen_state); void bdrv_reopen_abort(BDRVReopenState *reopen_state); int bdrv_pwrite_zeroes(BdrvChild *child, int64_t offset, - int bytes, BdrvRequestFlags flags); + int64_t bytes, BdrvRequestFlags flags); int bdrv_make_zero(BdrvChild *child, BdrvRequestFlags flags); -int bdrv_pread(BdrvChild *child, int64_t offset, void *buf, int bytes); -int bdrv_pwrite(BdrvChild *child, int64_t offset, const void *buf, int byt= es); +int bdrv_pread(BdrvChild *child, int64_t offset, void *buf, int64_t bytes); +int bdrv_pwrite(BdrvChild *child, int64_t offset, const void *buf, + int64_t bytes); int bdrv_pwrite_sync(BdrvChild *child, int64_t offset, - const void *buf, int count); + const void *buf, int64_t bytes); /* * Efficiently zero a region of the disk image. Note that this is a regul= ar * I/O request like read or write and should have a reasonable size. This @@ -403,7 +404,7 @@ int bdrv_pwrite_sync(BdrvChild *child, int64_t offset, * because it may allocate memory for the entire region. */ int coroutine_fn bdrv_co_pwrite_zeroes(BdrvChild *child, int64_t offset, - int bytes, BdrvRequestFlags flags); + int64_t bytes, BdrvRequestFlags fla= gs); BlockDriverState *bdrv_find_backing_image(BlockDriverState *bs, const char *backing_file); void bdrv_refresh_filename(BlockDriverState *bs); diff --git a/include/block/block_int.h b/include/block/block_int.h index 55b1039872..5e482a8f08 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -1028,13 +1028,13 @@ extern BlockDriver bdrv_raw; extern BlockDriver bdrv_qcow2; =20 int coroutine_fn bdrv_co_preadv(BdrvChild *child, - int64_t offset, unsigned int bytes, QEMUIOVector *qiov, + int64_t offset, int64_t bytes, QEMUIOVector *qiov, BdrvRequestFlags flags); int coroutine_fn bdrv_co_preadv_part(BdrvChild *child, int64_t offset, int64_t bytes, QEMUIOVector *qiov, size_t qiov_offset, BdrvRequestFlags flags); int coroutine_fn bdrv_co_pwritev(BdrvChild *child, - int64_t offset, unsigned int bytes, QEMUIOVector *qiov, + int64_t offset, int64_t bytes, QEMUIOVector *qiov, BdrvRequestFlags flags); int coroutine_fn bdrv_co_pwritev_part(BdrvChild *child, int64_t offset, int64_t bytes, diff --git a/block/blkverify.c b/block/blkverify.c index 4aed53ab59..943e62be9c 100644 --- a/block/blkverify.c +++ b/block/blkverify.c @@ -31,7 +31,7 @@ typedef struct BlkverifyRequest { uint64_t bytes; int flags; =20 - int (*request_fn)(BdrvChild *, int64_t, unsigned int, QEMUIOVector *, + int (*request_fn)(BdrvChild *, int64_t, int64_t, QEMUIOVector *, BdrvRequestFlags); =20 int ret; /* test image result */ diff --git a/block/io.c b/block/io.c index 5200658224..34dae81fa7 100644 --- a/block/io.c +++ b/block/io.c @@ -983,7 +983,7 @@ static int bdrv_check_request32(int64_t offset, int64_t= bytes, } =20 int bdrv_pwrite_zeroes(BdrvChild *child, int64_t offset, - int bytes, BdrvRequestFlags flags) + int64_t bytes, BdrvRequestFlags flags) { return bdrv_pwritev(child, offset, bytes, NULL, BDRV_REQ_ZERO_WRITE | flags); @@ -1031,7 +1031,7 @@ int bdrv_make_zero(BdrvChild *child, BdrvRequestFlags= flags) } =20 /* See bdrv_pwrite() for the return codes */ -int bdrv_pread(BdrvChild *child, int64_t offset, void *buf, int bytes) +int bdrv_pread(BdrvChild *child, int64_t offset, void *buf, int64_t bytes) { int ret; QEMUIOVector qiov =3D QEMU_IOVEC_INIT_BUF(qiov, buf, bytes); @@ -1051,7 +1051,8 @@ int bdrv_pread(BdrvChild *child, int64_t offset, void= *buf, int bytes) -EINVAL Invalid offset or number of bytes -EACCES Trying to write a read-only device */ -int bdrv_pwrite(BdrvChild *child, int64_t offset, const void *buf, int byt= es) +int bdrv_pwrite(BdrvChild *child, int64_t offset, const void *buf, + int64_t bytes) { int ret; QEMUIOVector qiov =3D QEMU_IOVEC_INIT_BUF(qiov, buf, bytes); @@ -1072,7 +1073,7 @@ int bdrv_pwrite(BdrvChild *child, int64_t offset, con= st void *buf, int bytes) * Returns 0 on success, -errno in error cases. */ int bdrv_pwrite_sync(BdrvChild *child, int64_t offset, - const void *buf, int count) + const void *buf, int64_t count) { int ret; =20 @@ -1731,7 +1732,7 @@ static int bdrv_pad_request(BlockDriverState *bs, } =20 int coroutine_fn bdrv_co_preadv(BdrvChild *child, - int64_t offset, unsigned int bytes, QEMUIOVector *qiov, + int64_t offset, int64_t bytes, QEMUIOVector *qiov, BdrvRequestFlags flags) { return bdrv_co_preadv_part(child, offset, bytes, qiov, 0, flags); @@ -2158,7 +2159,7 @@ out: * Handle a write request in coroutine context */ int coroutine_fn bdrv_co_pwritev(BdrvChild *child, - int64_t offset, unsigned int bytes, QEMUIOVector *qiov, + int64_t offset, int64_t bytes, QEMUIOVector *qiov, BdrvRequestFlags flags) { return bdrv_co_pwritev_part(child, offset, bytes, qiov, 0, flags); @@ -2251,7 +2252,7 @@ out: } =20 int coroutine_fn bdrv_co_pwrite_zeroes(BdrvChild *child, int64_t offset, - int bytes, BdrvRequestFlags flags) + int64_t bytes, BdrvRequestFlags fla= gs) { trace_bdrv_co_pwrite_zeroes(child->bs, offset, bytes, flags); =20 diff --git a/block/trace-events b/block/trace-events index 91a0f70575..a95d711ade 100644 --- a/block/trace-events +++ b/block/trace-events @@ -13,7 +13,7 @@ blk_root_detach(void *child, void *blk, void *bs) "child = %p blk %p bs %p" # io.c bdrv_co_preadv_part(void *bs, int64_t offset, int64_t bytes, unsigned int = flags) "bs %p offset %" PRId64 " bytes %" PRId64 " flags 0x%x" bdrv_co_pwritev_part(void *bs, int64_t offset, int64_t bytes, unsigned int= flags) "bs %p offset %" PRId64 " bytes %" PRId64 " flags 0x%x" -bdrv_co_pwrite_zeroes(void *bs, int64_t offset, int count, int flags) "bs = %p offset %"PRId64" count %d flags 0x%x" +bdrv_co_pwrite_zeroes(void *bs, int64_t offset, int64_t bytes, int flags) = "bs %p offset %" PRId64 " bytes %" PRId64 " flags 0x%x" bdrv_co_do_copy_on_readv(void *bs, int64_t offset, int64_t bytes, int64_t = cluster_offset, int64_t cluster_bytes) "bs %p offset %" PRId64 " bytes %" P= RId64 " cluster_offset %" PRId64 " cluster_bytes %" PRId64 bdrv_co_copy_range_from(void *src, uint64_t src_offset, void *dst, uint64_= t dst_offset, uint64_t bytes, int read_flags, int write_flags) "src %p offs= et %"PRIu64" dst %p offset %"PRIu64" bytes %"PRIu64" rw flags 0x%x 0x%x" bdrv_co_copy_range_to(void *src, uint64_t src_offset, void *dst, uint64_t = dst_offset, uint64_t bytes, int read_flags, int write_flags) "src %p offset= %"PRIu64" dst %p offset %"PRIu64" bytes %"PRIu64" rw flags 0x%x 0x%x" --=20 2.25.4 From nobody Fri May 17 21:24:39 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; arc=pass (i=1dmarc=pass fromdomain=virtuozzo.com); dmarc=pass(p=quarantine dis=none) header.from=virtuozzo.com ARC-Seal: i=2; a=rsa-sha256; t=1607718858; cv=pass; d=zohomail.com; s=zohoarc; b=hs9hiZvRQIHz921cNx9OttIcxoIG3r8XWCLQJL7Hdo9RvolW5nDGRddNCDnhBevUmpbzkNg5SsrWKUMtRPk/lMVmBDrJ4xIkL5Ac9LIumKLXBni3H66S7pSTTsdlmzcvKJVkKKSdkTYy/fCQUQ9kTqKEtd/45XcqrtxDxdwJ/v4= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607718858; 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=hDrKxPkUyb2l6x5FmPWVFVz3b7HtlrBS0E2CuudV/vU=; b=QqqKdkuYjPRlwMNa74d6t2EPVRsCr/HbdNZWz6kXpmEYFF36H/xwSEqZTtPrp0S1cdRIXo28Zvq2Lb5JjMY1VKrQf+a/7cBndjzDqtJZS4o2Wp1TZFaXPFsxHUVSLvX/nTAR8Qtu33JsxDaRqAGjlBBmzXgfMnmK5Thr1Afrguw= ARC-Authentication-Results: i=2; 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; arc=pass (i=1dmarc=pass fromdomain=virtuozzo.com); dmarc=pass header.from= (p=quarantine dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1607718858605428.2660322462216; Fri, 11 Dec 2020 12:34:18 -0800 (PST) Received: from localhost ([::1]:55720 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1knnpt-0002iq-Sv for importer@patchew.org; Fri, 11 Dec 2020 14:12:13 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43752) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1knnL7-0006nE-Nh; Fri, 11 Dec 2020 13:40:25 -0500 Received: from mail-db8eur05on2131.outbound.protection.outlook.com ([40.107.20.131]:25696 helo=EUR05-DB8-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1knnL2-0008Cr-M1; Fri, 11 Dec 2020 13:40:25 -0500 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM5PR0801MB1713.eurprd08.prod.outlook.com (2603:10a6:203:34::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3654.17; Fri, 11 Dec 2020 18:40:01 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::d585:99a4:d7a4:d478]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::d585:99a4:d7a4:d478%4]) with mapi id 15.20.3654.016; Fri, 11 Dec 2020 18:40:01 +0000 Received: from kvm.sw.ru (185.215.60.91) by AM0PR04CA0050.eurprd04.prod.outlook.com (2603:10a6:208:1::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3654.12 via Frontend Transport; Fri, 11 Dec 2020 18:40:00 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oRxhvbImQze31puRz1hiEi762E3p3yyPWRijeQxZnC1JAjsUj0dMZtW3M3uy4nt3YmHNM21nub8J+gVGNwc9zTZO8CvYvIo5aSJPjiOyb8LgOcQ+9s8WzM5hWrkoOHbrabCUg1fLR2qpn/gwnnmuxynuIsqRtIGwdQhgMgPZXl62ubQgOh0MbZt1xtKmnpPCYcNmdxhxd06OAAy4byZXQXHkulQO+GQR/s+b6SBJOcXeDpjsgL3b4CPaqV+qIAxyC+Z406Sxx5KSva8LwsODlkIa/7sZQvTTVxKMw+EBFRxRuhMIKBNshydWf53JNZd3tHx2AJq5V5h2hTOeozmCog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=hDrKxPkUyb2l6x5FmPWVFVz3b7HtlrBS0E2CuudV/vU=; b=G+pWdTAWTvFjEVwdeKDaEVBut62K8ox8mDt427MJldudvXS8dMgDkKAPwHg96PS2jfxhaYX6CyLWIFQwdzZDXaHZ9TEJ3vF7vDBK7U15Oey41OHwEybfFmCq/5C77kpqpqIHHGN2sPfm7Kal7p/fXyyMMOxw1aVPrRS5UeSSDfpp6uiEbSaA9l8faiB4bJGTO3cRrJS5Fq1h6oyUrMmzYvEdxLtYlzhKtLKuWBaUYJVS2gB1yP4jcDBR1a3GmuvF/xwJbYbMKknxRZsFqRaBfwIlgIv/QtGMjCFEw5CoJMXdPIHdIBl98ztBDutlHLt9JAMO5vMSvT7IUxLPGhxN8Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=hDrKxPkUyb2l6x5FmPWVFVz3b7HtlrBS0E2CuudV/vU=; b=L831Z3qJnRAL47V8jg3LGAqU/B/5gckWNETUkZfa6iagQbL9bJ9HINFTN5Xfyac6QCwztXDSVKBlhIA7v9nd/97xwpUQlZnb85H6hE9MoFYQcPjxpJ9PnMnM296CJJhjElSYRDAD42JnSHWKa3kQodNo4WbDpCEjE/z5gpWol7o= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Subject: [PATCH v4 16/16] block/io: use int64_t bytes in copy_range Date: Fri, 11 Dec 2020 21:39:34 +0300 Message-Id: <20201211183934.169161-17-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20201211183934.169161-1-vsementsov@virtuozzo.com> References: <20201211183934.169161-1-vsementsov@virtuozzo.com> Content-Transfer-Encoding: quoted-printable X-Originating-IP: [185.215.60.91] X-ClientProxiedBy: AM0PR04CA0050.eurprd04.prod.outlook.com (2603:10a6:208:1::27) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: dae95e73-e32e-401f-f5e8-08d89e042aea X-MS-TrafficTypeDiagnostic: AM5PR0801MB1713: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1227; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: EuEWYFTPdhXacSnikz+Gv+twd5ZFPXog+7xFwL3ZUFQYpXXu8MACWa2vmboVLNlZumholwg+67UnCO+VFWfCrqJ3RgPdwoNVTjEJW5UNg5CrRWrIGClEdSAck7EYO0CJL9WsaT7/XlnqTZpPwYUTKqDs6B7qRnNRIkPynznY8Fp0ReV7Vxtj60HZPXpqVCA/WBk0LRU/OKfIbgDQUU259RX+ZIngAmtrOpc/33lVyLeQ4p95z9CQSJ9vQ+MbBqg7ZM7d5xEbKBoTDuPjAR2BmHTFKyxfFa7NFLXDY0GCxNBASfE3TY+OAjRYJy80N6NKVVgjdoPlWreiqX84L8Solw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(39840400004)(136003)(376002)(396003)(346002)(366004)(2616005)(86362001)(956004)(107886003)(66946007)(6506007)(66476007)(6666004)(6512007)(66556008)(5660300002)(478600001)(8936002)(6486002)(52116002)(36756003)(8676002)(316002)(1076003)(6916009)(83380400001)(26005)(16526019)(2906002)(186003)(4326008); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?xkvAlA4+nZt1lfbwTz8u6nC1iXGv6FhGO22ASAvNJWtyq7GYgX267xmFRm98?= =?us-ascii?Q?+Wj52g/+Bx/uN9hGmB3EWdr0vrsBMxuflKqjluvromKkfLPOpyQGdhYS6g/L?= =?us-ascii?Q?DwJtOlqQkh7Hoh+2xi7jhpOUY/qsJ3adSeyYNv9j/wfQ4LViKDVWZdyA9gvV?= =?us-ascii?Q?ectB5rb0cMrM6i3xzWGZYafpSOPeqblOtZzo8RcQmyWI5OsRk0fi0lzyBJTd?= =?us-ascii?Q?NG/zFkZ4ETBh8FGhP0nxRIVusnUg3/Hcy89YKItKmpzISf6byg7S13UimYnn?= =?us-ascii?Q?nU5msUd6FnLV81H8FFXbWkLxwH8pKv6VssFOBPqtyA6kCv1ixhmbeN4LNXO+?= =?us-ascii?Q?ghlpIBDgVNR5Qe1uOuXjkDnQ+tJnKu00PnR3MnjALFIUzNbn3dQXaAJmgPTZ?= =?us-ascii?Q?jJSksTQ9rw8ZR8Iimm+Q7M4bIjFrUoKs5kwquNHL1PqK+z9GykIKVHOFfpOU?= =?us-ascii?Q?3EjvvRjTeBIdrCvp44+mm7wNZ6Rh38tq/ASqUBSSYBSbBMjrzENrV6V6jspK?= =?us-ascii?Q?D7BGYCYe20hYq3+l+vZtAgTN+hjO658cX100/+Onrzvc4oMoMyl9ILg49iRe?= =?us-ascii?Q?JzvIlwL/vTzSQbzy4R38s67dcb7IHqEKf/A6Wa+7uZCRg9dTcHoK2FZf9mpD?= =?us-ascii?Q?o5grXe/9LakfcbLjMAi1XU6QgV1G3ZmJTOJvg4DVIlz5hrGNPSh4aQtFx7dq?= =?us-ascii?Q?12kEplf1o4p1Ebf/8vB1Wh9gOG0wWVfen/tKPLDnNsZXeQJFikB6M+HmSeQX?= =?us-ascii?Q?ScMsER6ROYMuGkYzy2EwuIAGin180iD8w87C9F42eot1FZYxarhA+6IcraMB?= =?us-ascii?Q?YcvsTWwPQZmmcMt0GutwwI5m5vWSPTuMUSkNn9WkFEYoK38dd6WHinSGmkRw?= =?us-ascii?Q?kO+806CMqU55j2VV8qY5J9pkgNuE/YmyUXx48DEx1SqUDWJ2I112Z78KLjHD?= =?us-ascii?Q?HZ5P2K6XxHQtrqCjO1ubQ9QGiEJ64OkC1Vc/ZoAQgg2c7wJCgKSbpfmHaK3S?= =?us-ascii?Q?9mwV?= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Dec 2020 18:40:00.8969 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-Network-Message-Id: dae95e73-e32e-401f-f5e8-08d89e042aea X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: yAdfo/QmNIGaKDOcHzuNYnswPixqCms0XcLlfIzW/qoXYZTNcwogL3b86i8FSiUTUBzBLwxHJmMhoOon8TzSYzGIMW7zz24RTOxbs5kQn5Q= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0801MB1713 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=40.107.20.131; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-DB8-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-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: fam@euphon.net, kwolf@redhat.com, vsementsov@virtuozzo.com, berto@igalia.com, qemu-devel@nongnu.org, mreitz@redhat.com, stefanha@redhat.com, den@openvz.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @virtuozzo.com) Content-Type: text/plain; charset="utf-8" We are generally moving to int64_t for both offset and bytes parameters on all io paths. Main motivation is realization of 64-bit write_zeroes operation for fast zeroing large disk chunks, up to the whole disk. We chose signed type, to be consistent with off_t (which is signed) and with possibility for signed return type (where negative value means error). So, convert now copy_range parameters which are already 64bit to signed type. It's safe as we don't work with requests overflowing BDRV_MAX_LENGTH (which is less than INT64_MAX), and do check the requests in bdrv_co_copy_range_internal() (by bdrv_check_request32(), which calls bdrv_check_request()). Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Eric Blake --- include/block/block.h | 6 +++--- include/block/block_int.h | 12 ++++++------ block/io.c | 22 +++++++++++----------- block/trace-events | 4 ++-- 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/include/block/block.h b/include/block/block.h index 3549125f1d..88629eb3a6 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -843,8 +843,8 @@ void bdrv_unregister_buf(BlockDriverState *bs, void *ho= st); * * Returns: 0 if succeeded; negative error code if failed. **/ -int coroutine_fn bdrv_co_copy_range(BdrvChild *src, uint64_t src_offset, - BdrvChild *dst, uint64_t dst_offset, - uint64_t bytes, BdrvRequestFlags read_= flags, +int coroutine_fn bdrv_co_copy_range(BdrvChild *src, int64_t src_offset, + BdrvChild *dst, int64_t dst_offset, + int64_t bytes, BdrvRequestFlags read_f= lags, BdrvRequestFlags write_flags); #endif diff --git a/include/block/block_int.h b/include/block/block_int.h index 5e482a8f08..cee5cb5f85 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -1343,14 +1343,14 @@ void bdrv_dec_in_flight(BlockDriverState *bs); =20 void blockdev_close_all_bdrv_states(void); =20 -int coroutine_fn bdrv_co_copy_range_from(BdrvChild *src, uint64_t src_offs= et, - BdrvChild *dst, uint64_t dst_offs= et, - uint64_t bytes, +int coroutine_fn bdrv_co_copy_range_from(BdrvChild *src, int64_t src_offse= t, + BdrvChild *dst, int64_t dst_offse= t, + int64_t bytes, BdrvRequestFlags read_flags, BdrvRequestFlags write_flags); -int coroutine_fn bdrv_co_copy_range_to(BdrvChild *src, uint64_t src_offset, - BdrvChild *dst, uint64_t dst_offset, - uint64_t bytes, +int coroutine_fn bdrv_co_copy_range_to(BdrvChild *src, int64_t src_offset, + BdrvChild *dst, int64_t dst_offset, + int64_t bytes, BdrvRequestFlags read_flags, BdrvRequestFlags write_flags); =20 diff --git a/block/io.c b/block/io.c index 34dae81fa7..28680a1f64 100644 --- a/block/io.c +++ b/block/io.c @@ -3173,8 +3173,8 @@ void bdrv_unregister_buf(BlockDriverState *bs, void *= host) } =20 static int coroutine_fn bdrv_co_copy_range_internal( - BdrvChild *src, uint64_t src_offset, BdrvChild *dst, - uint64_t dst_offset, uint64_t bytes, + BdrvChild *src, int64_t src_offset, BdrvChild *dst, + int64_t dst_offset, int64_t bytes, BdrvRequestFlags read_flags, BdrvRequestFlags write_flags, bool recurse_src) { @@ -3252,9 +3252,9 @@ static int coroutine_fn bdrv_co_copy_range_internal( * * See the comment of bdrv_co_copy_range for the parameter and return value * semantics. */ -int coroutine_fn bdrv_co_copy_range_from(BdrvChild *src, uint64_t src_offs= et, - BdrvChild *dst, uint64_t dst_offs= et, - uint64_t bytes, +int coroutine_fn bdrv_co_copy_range_from(BdrvChild *src, int64_t src_offse= t, + BdrvChild *dst, int64_t dst_offse= t, + int64_t bytes, BdrvRequestFlags read_flags, BdrvRequestFlags write_flags) { @@ -3268,9 +3268,9 @@ int coroutine_fn bdrv_co_copy_range_from(BdrvChild *s= rc, uint64_t src_offset, * * See the comment of bdrv_co_copy_range for the parameter and return value * semantics. */ -int coroutine_fn bdrv_co_copy_range_to(BdrvChild *src, uint64_t src_offset, - BdrvChild *dst, uint64_t dst_offset, - uint64_t bytes, +int coroutine_fn bdrv_co_copy_range_to(BdrvChild *src, int64_t src_offset, + BdrvChild *dst, int64_t dst_offset, + int64_t bytes, BdrvRequestFlags read_flags, BdrvRequestFlags write_flags) { @@ -3280,9 +3280,9 @@ int coroutine_fn bdrv_co_copy_range_to(BdrvChild *src= , uint64_t src_offset, bytes, read_flags, write_flags, fal= se); } =20 -int coroutine_fn bdrv_co_copy_range(BdrvChild *src, uint64_t src_offset, - BdrvChild *dst, uint64_t dst_offset, - uint64_t bytes, BdrvRequestFlags read_= flags, +int coroutine_fn bdrv_co_copy_range(BdrvChild *src, int64_t src_offset, + BdrvChild *dst, int64_t dst_offset, + int64_t bytes, BdrvRequestFlags read_f= lags, BdrvRequestFlags write_flags) { return bdrv_co_copy_range_from(src, src_offset, diff --git a/block/trace-events b/block/trace-events index a95d711ade..948df081ba 100644 --- a/block/trace-events +++ b/block/trace-events @@ -15,8 +15,8 @@ bdrv_co_preadv_part(void *bs, int64_t offset, int64_t byt= es, unsigned int flags) bdrv_co_pwritev_part(void *bs, int64_t offset, int64_t bytes, unsigned int= flags) "bs %p offset %" PRId64 " bytes %" PRId64 " flags 0x%x" bdrv_co_pwrite_zeroes(void *bs, int64_t offset, int64_t bytes, int flags) = "bs %p offset %" PRId64 " bytes %" PRId64 " flags 0x%x" bdrv_co_do_copy_on_readv(void *bs, int64_t offset, int64_t bytes, int64_t = cluster_offset, int64_t cluster_bytes) "bs %p offset %" PRId64 " bytes %" P= RId64 " cluster_offset %" PRId64 " cluster_bytes %" PRId64 -bdrv_co_copy_range_from(void *src, uint64_t src_offset, void *dst, uint64_= t dst_offset, uint64_t bytes, int read_flags, int write_flags) "src %p offs= et %"PRIu64" dst %p offset %"PRIu64" bytes %"PRIu64" rw flags 0x%x 0x%x" -bdrv_co_copy_range_to(void *src, uint64_t src_offset, void *dst, uint64_t = dst_offset, uint64_t bytes, int read_flags, int write_flags) "src %p offset= %"PRIu64" dst %p offset %"PRIu64" bytes %"PRIu64" rw flags 0x%x 0x%x" +bdrv_co_copy_range_from(void *src, int64_t src_offset, void *dst, int64_t = dst_offset, int64_t bytes, int read_flags, int write_flags) "src %p offset = %" PRId64 " dst %p offset %" PRId64 " bytes %" PRId64 " rw flags 0x%x 0x%x" +bdrv_co_copy_range_to(void *src, int64_t src_offset, void *dst, int64_t ds= t_offset, int64_t bytes, int read_flags, int write_flags) "src %p offset %"= PRId64 " dst %p offset %" PRId64 " bytes %" PRId64 " rw flags 0x%x 0x%x" =20 # stream.c stream_one_iteration(void *s, int64_t offset, uint64_t bytes, int is_alloc= ated) "s %p offset %" PRId64 " bytes %" PRIu64 " is_allocated %d" --=20 2.25.4