From nobody Fri Mar 29 11:01:41 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1557842339; cv=none; d=zoho.com; s=zohoarc; b=Ir/cUN/yGxQ+eXL8RgHtUrCCoy7/13AqkS27ppBuUjeZkjR73a8morKkkpIAWJrDom1rrzagV3jgaB6/wIR9sbxBuzSJSQ5xRc03OaJVtHf1il2gYVz+sPpHKrGiFhp6we+ya+yxbBD74dXa90b1PvZ1mEIq1WmFctNcU8BruI4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557842339; h=Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:Sender:Subject:To:ARC-Authentication-Results; bh=HWzv6sRcnzm4U/TLcTdcM9s8PCpd1qPmZTvKIICZcUk=; b=T0bZz0/9rYG3vGy3xDrfGoSrnfTFvKe/HZgFf1Jo/93/zXPixnMoQu4e8V2kqY4+O8fFuKKoGyyyd1G50Q6N1090wdzRQgELzdHOhLHwdGX1uhScGk5D0kvhqzvv1uRo1bPNK95EXxZ3wt3QbwyZPbGhj0AKBa77YRPVDFEo2ig= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1557842337956891.6384753430098; Tue, 14 May 2019 06:58:57 -0700 (PDT) Received: from localhost ([127.0.0.1]:48609 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hQXxI-00072m-Rx for importer@patchew.org; Tue, 14 May 2019 09:58:56 -0400 Received: from eggs.gnu.org ([209.51.188.92]:59449) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hQXwS-0006h9-08 for qemu-devel@nongnu.org; Tue, 14 May 2019 09:58:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hQXwQ-0002FR-Ag for qemu-devel@nongnu.org; Tue, 14 May 2019 09:58:03 -0400 Received: from fanzine.igalia.com ([91.117.99.155]:35945) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hQXwP-0002B0-HD; Tue, 14 May 2019 09:58:02 -0400 Received: from mobile-access-bcee32-86.dhcp.inet.fi ([188.238.50.86] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1hQXwN-0002Xc-3z; Tue, 14 May 2019 15:57:59 +0200 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1hQXw9-0003mY-Eu; Tue, 14 May 2019 16:57:45 +0300 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Message-Id:Date:Subject:Cc:To:From; bh=HWzv6sRcnzm4U/TLcTdcM9s8PCpd1qPmZTvKIICZcUk=; b=G+Mq3KO2sEarouMxmlDRPS3dpLt2oDm+Ao+srtY9ZkfEDh9JU9zA8VgrZXyZvSRgXyY6agk6JGfT7gxCE/hq6/hY1tMXQe9lOWMowQva2PchPdEuuGV1T86ymmX6YOT8A3RGI5dWjXARdpGFwCxNPcwQQnWTugcH+Yf++X8BEJNnHxueqFCjKZFGB1bEjLP78Zj4vTh6bWAfj+J+zf2Lw6f1a94JuswFG93Tl0bsjJ/39RHy7H3f7Thot5z/CJlphxNufkL3QkHrKdL3Scf6T6RWfr/r+ClxfW0o08XatUERStp7Jkpxv5WWPRwefBnnh4x9TI8PrNR0IQbqHDHvAA==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Tue, 14 May 2019 16:57:35 +0300 Message-Id: <20190514135735.14497-1-berto@igalia.com> X-Mailer: git-send-email 2.11.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] [fuzzy] X-Received-From: 91.117.99.155 Subject: [Qemu-devel] [PATCH] block: Use BDRV_REQUEST_MAX_BYTES instead of BDRV_REQUEST_MAX_SECTORS X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Alberto Garcia , qemu-block@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" There are a few places in which we turn a number of bytes into sectors in order to compare the result against BDRV_REQUEST_MAX_SECTORS instead of using BDRV_REQUEST_MAX_BYTES directly. Signed-off-by: Alberto Garcia Reviewed-by: Stefano Garzarella --- block/io.c | 6 +++--- qemu-io-cmds.c | 7 +++---- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/block/io.c b/block/io.c index aeebc9c23c..3134a60a48 100644 --- a/block/io.c +++ b/block/io.c @@ -769,7 +769,7 @@ static bool coroutine_fn wait_serialising_requests(Bdrv= TrackedRequest *self) static int bdrv_check_byte_request(BlockDriverState *bs, int64_t offset, size_t size) { - if (size > BDRV_REQUEST_MAX_SECTORS << BDRV_SECTOR_BITS) { + if (size > BDRV_REQUEST_MAX_BYTES) { return -EIO; } =20 @@ -1017,7 +1017,7 @@ static int coroutine_fn bdrv_driver_preadv(BlockDrive= rState *bs, =20 assert((offset & (BDRV_SECTOR_SIZE - 1)) =3D=3D 0); assert((bytes & (BDRV_SECTOR_SIZE - 1)) =3D=3D 0); - assert((bytes >> BDRV_SECTOR_BITS) <=3D BDRV_REQUEST_MAX_SECTORS); + assert(bytes <=3D BDRV_REQUEST_MAX_BYTES); assert(drv->bdrv_co_readv); =20 return drv->bdrv_co_readv(bs, sector_num, nb_sectors, qiov); @@ -1070,7 +1070,7 @@ static int coroutine_fn bdrv_driver_pwritev(BlockDriv= erState *bs, =20 assert((offset & (BDRV_SECTOR_SIZE - 1)) =3D=3D 0); assert((bytes & (BDRV_SECTOR_SIZE - 1)) =3D=3D 0); - assert((bytes >> BDRV_SECTOR_BITS) <=3D BDRV_REQUEST_MAX_SECTORS); + assert(bytes <=3D BDRV_REQUEST_MAX_BYTES); =20 assert(drv->bdrv_co_writev); ret =3D drv->bdrv_co_writev(bs, sector_num, nb_sectors, qiov, diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c index 8826bebaf6..30a7d9a13b 100644 --- a/qemu-io-cmds.c +++ b/qemu-io-cmds.c @@ -538,7 +538,7 @@ static int do_write_compressed(BlockBackend *blk, char = *buf, int64_t offset, { int ret; =20 - if (bytes >> 9 > BDRV_REQUEST_MAX_SECTORS) { + if (bytes > BDRV_REQUEST_MAX_BYTES) { return -ERANGE; } =20 @@ -1781,10 +1781,9 @@ static int discard_f(BlockBackend *blk, int argc, ch= ar **argv) if (bytes < 0) { print_cvtnum_err(bytes, argv[optind]); return bytes; - } else if (bytes >> BDRV_SECTOR_BITS > BDRV_REQUEST_MAX_SECTORS) { + } else if (bytes > BDRV_REQUEST_MAX_BYTES) { printf("length cannot exceed %"PRIu64", given %s\n", - (uint64_t)BDRV_REQUEST_MAX_SECTORS << BDRV_SECTOR_BITS, - argv[optind]); + (uint64_t)BDRV_REQUEST_MAX_BYTES, argv[optind]); return -EINVAL; } =20 --=20 2.11.0