From nobody Sat Apr 27 16:56:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1505916273996238.04875396542786; Wed, 20 Sep 2017 07:04:33 -0700 (PDT) Received: from localhost ([::1]:48289 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dufc8-0001f4-Uw for importer@patchew.org; Wed, 20 Sep 2017 10:04:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41757) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dufAW-00024b-Qe for qemu-devel@nongnu.org; Wed, 20 Sep 2017 09:36:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dufAS-00011k-Sx for qemu-devel@nongnu.org; Wed, 20 Sep 2017 09:36:00 -0400 Received: from smtp1.ntua.gr ([2001:648:2000:de::183]:20570) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dufAK-0000sM-51; Wed, 20 Sep 2017 09:35:48 -0400 Received: from mail.ntua.gr (carp0.noc.ntua.gr [147.102.222.60]) (authenticated bits=0) by smtp1.ntua.gr (8.15.2/8.15.2) with ESMTPSA id v8KBhZCv074332 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 20 Sep 2017 14:43:35 +0300 (EEST) (envelope-from el13635@mail.ntua.gr) X-Authentication-Warning: smtp1.ntua.gr: Host carp0.noc.ntua.gr [147.102.222.60] claimed to be mail.ntua.gr From: Manos Pitsidianakis To: qemu-devel Date: Wed, 20 Sep 2017 14:43:09 +0300 Message-Id: <20170920114310.13080-2-el13635@mail.ntua.gr> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170920114310.13080-1-el13635@mail.ntua.gr> References: <20170920114310.13080-1-el13635@mail.ntua.gr> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:648:2000:de::183 Subject: [Qemu-devel] [PATCH 1/2] block/block-backend.c: add blk_check_byte_request call to blk_pread/blk_pwrite 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 , John Snow , qemu-block , Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" blk_check_byte_request() is called from the blk_co_pwritev/blk_co_preadv to check if the request offset and request bytes parameters are valid for the given Blockbackend. Let's do that in blk_pread/blk_pwrite too. Signed-off-by: Manos Pitsidianakis --- block/block-backend.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/block/block-backend.c b/block/block-backend.c index 45d9101be3..110a52d5b1 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -1288,22 +1288,23 @@ BlockAIOCB *blk_aio_pwrite_zeroes(BlockBackend *blk= , int64_t offset, =20 int blk_pread(BlockBackend *blk, int64_t offset, void *buf, int count) { - int ret =3D blk_prw(blk, offset, buf, count, blk_read_entry, 0); + int ret =3D blk_check_byte_request(blk, offset, count); if (ret < 0) { return ret; } - return count; + ret =3D blk_prw(blk, offset, buf, count, blk_read_entry, 0); + return ret < 0 ? ret : count; } =20 int blk_pwrite(BlockBackend *blk, int64_t offset, const void *buf, int cou= nt, BdrvRequestFlags flags) { - int ret =3D blk_prw(blk, offset, (void *) buf, count, blk_write_entry, - flags); + int ret =3D blk_check_byte_request(blk, offset, count); if (ret < 0) { return ret; } - return count; + ret =3D blk_prw(blk, offset, (void *) buf, count, blk_write_entry, fla= gs); + return ret < 0 ? ret : count; } =20 int64_t blk_getlength(BlockBackend *blk) --=20 2.11.0 From nobody Sat Apr 27 16:56:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1505917499625702.977598230498; Wed, 20 Sep 2017 07:24:59 -0700 (PDT) Received: from localhost ([::1]:48430 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dufvu-00041f-71 for importer@patchew.org; Wed, 20 Sep 2017 10:24:58 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41569) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dufAP-0001xs-1n for qemu-devel@nongnu.org; Wed, 20 Sep 2017 09:35:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dufAO-0000yz-5j for qemu-devel@nongnu.org; Wed, 20 Sep 2017 09:35:53 -0400 Received: from smtp1.ntua.gr ([2001:648:2000:de::183]:20570) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dufAK-0000sM-Tp; Wed, 20 Sep 2017 09:35:49 -0400 Received: from mail.ntua.gr (carp0.noc.ntua.gr [147.102.222.60]) (authenticated bits=0) by smtp1.ntua.gr (8.15.2/8.15.2) with ESMTPSA id v8KBhZ69074337 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 20 Sep 2017 14:43:35 +0300 (EEST) (envelope-from el13635@mail.ntua.gr) X-Authentication-Warning: smtp1.ntua.gr: Host carp0.noc.ntua.gr [147.102.222.60] claimed to be mail.ntua.gr From: Manos Pitsidianakis To: qemu-devel Date: Wed, 20 Sep 2017 14:43:10 +0300 Message-Id: <20170920114310.13080-3-el13635@mail.ntua.gr> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170920114310.13080-1-el13635@mail.ntua.gr> References: <20170920114310.13080-1-el13635@mail.ntua.gr> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:648:2000:de::183 Subject: [Qemu-devel] [PATCH 2/2] block/block-backend.c: remove blk_pread_unthrottled() 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 , John Snow , qemu-block , Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" blk_pread_unthrottled was used to bypass I/O throttling on the BlockBackend= in the case of async I/O. This is not needed anymore and we can just call blk_pread() directly. Signed-off-by: Manos Pitsidianakis Acked-by: John Snow Reviewed-by: Kevin Wolf --- include/sysemu/block-backend.h | 2 -- block/block-backend.c | 16 ---------------- hw/block/hd-geometry.c | 7 +------ 3 files changed, 1 insertion(+), 24 deletions(-) diff --git a/include/sysemu/block-backend.h b/include/sysemu/block-backend.h index c4e52a5fa3..c881bfdfe4 100644 --- a/include/sysemu/block-backend.h +++ b/include/sysemu/block-backend.h @@ -117,8 +117,6 @@ char *blk_get_attached_dev_id(BlockBackend *blk); BlockBackend *blk_by_dev(void *dev); BlockBackend *blk_by_qdev_id(const char *id, Error **errp); void blk_set_dev_ops(BlockBackend *blk, const BlockDevOps *ops, void *opaq= ue); -int blk_pread_unthrottled(BlockBackend *blk, int64_t offset, uint8_t *buf, - int bytes); int coroutine_fn blk_co_preadv(BlockBackend *blk, int64_t offset, unsigned int bytes, QEMUIOVector *qiov, BdrvRequestFlags flags); diff --git a/block/block-backend.c b/block/block-backend.c index 110a52d5b1..83329fce15 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -1145,22 +1145,6 @@ static int blk_prw(BlockBackend *blk, int64_t offset= , uint8_t *buf, return rwco.ret; } =20 -int blk_pread_unthrottled(BlockBackend *blk, int64_t offset, uint8_t *buf, - int count) -{ - int ret; - - ret =3D blk_check_byte_request(blk, offset, count); - if (ret < 0) { - return ret; - } - - blk_root_drained_begin(blk->root); - ret =3D blk_pread(blk, offset, buf, count); - blk_root_drained_end(blk->root); - return ret; -} - int blk_pwrite_zeroes(BlockBackend *blk, int64_t offset, int bytes, BdrvRequestFlags flags) { diff --git a/hw/block/hd-geometry.c b/hw/block/hd-geometry.c index 57ad5012a7..211307f73f 100644 --- a/hw/block/hd-geometry.c +++ b/hw/block/hd-geometry.c @@ -62,12 +62,7 @@ static int guess_disk_lchs(BlockBackend *blk, =20 blk_get_geometry(blk, &nb_sectors); =20 - /** - * The function will be invoked during startup not only in sync I/O mo= de, - * but also in async I/O mode. So the I/O throttling function has to - * be disabled temporarily here, not permanently. - */ - if (blk_pread_unthrottled(blk, 0, buf, BDRV_SECTOR_SIZE) < 0) { + if (blk_pread(blk, 0, buf, BDRV_SECTOR_SIZE) < 0) { return -1; } /* test msdos magic */ --=20 2.11.0