From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 76ACACD128A for ; Mon, 8 Apr 2024 01:41:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:To:From:Reply-To: Cc:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=aXpJ8CbshAstMDUdZs+MOEA3/4rC+S/HLEoYxCsJB/Y=; b=OsDn9227XJcIEiby1YKm2YG2wn StocI9rlSrxBp8JAd0o0Rqnf5YjFlojTkNfF9ubxb/mhQ0oLyA/Yeynln2dJ+JjlLvzuALhkbe8Ip UyTqPIfIEWOa0LzjoeqKRiDtwDPcQQqAMdOXPvl16Bu6A78u8dag1qL1alZ18DssHbiCZvvB3W7wu th5YcKteeIW3UflwuDsGbXMwiOzKhrUsgAJvBuK/1V5eaqT4FUFbhJVlRTTekBqigqu++7zVrSjM8 W23zb8rWozIMoJS8Szvl1+BQdXdaT+qcWf9O3k9VJw4RyMm3RNQsuObFRHGz29LrE//lLgUob7zC+ MYgHThGg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rte13-0000000DvJx-33cy; Mon, 08 Apr 2024 01:41:45 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rte0v-0000000DvF3-1TKv for linux-nvme@lists.infradead.org; Mon, 08 Apr 2024 01:41:38 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id D6B4F60DC5; Mon, 8 Apr 2024 01:41:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 23955C433C7; Mon, 8 Apr 2024 01:41:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712540496; bh=XQ/FNxqBFsNDlzV6H2tAFcwOhY/mOWu7k7PYStCXqLo=; h=From:To:Subject:Date:In-Reply-To:References:From; b=UHJHrTLCbfLA/GmpvVLdUTRbDEjnwt2qA3rgk3U/Px6Q/SvVwaUmw4FyiNKOuV3Pe PBD8/G2VwKZmxpXW6IL6d6QmOwQ41flmIS/mQzn3ajQoJs6+XxVolcACr7ArISDx3K Ou+gq4qQM9D8JYfdzk34gfu4k055sNm2KVuNL8XKNQiDdx5boWRljB4ruLqD2EPX+S R8VtOQsMDMUQRsGdQlaK4FqSB1Bs602qX/k2EnWR1dXsgkH1Rsf3ccBjL7jnf62w5J KTDOv0lLMrWRe5KwJqCO1d0X1hTXIAlCusj67MEExbxvzJZp68hP0xIMwvc2gBK84P BO2XtFjz1wojg== From: Damien Le Moal To: linux-block@vger.kernel.org, Jens Axboe , linux-scsi@vger.kernel.org, "Martin K . Petersen" , dm-devel@lists.linux.dev, Mike Snitzer , linux-nvme@lists.infradead.org, Keith Busch , Christoph Hellwig Subject: [PATCH v7 03/28] block: Introduce blk_zone_update_request_bio() Date: Mon, 8 Apr 2024 10:41:03 +0900 Message-ID: <20240408014128.205141-4-dlemoal@kernel.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240408014128.205141-1-dlemoal@kernel.org> References: <20240408014128.205141-1-dlemoal@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240407_184137_500539_D829935C X-CRM114-Status: GOOD ( 15.30 ) X-BeenThere: linux-nvme@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-nvme" Errors-To: linux-nvme-bounces+linux-nvme=archiver.kernel.org@lists.infradead.org On completion of a zone append request, the request sector indicates the location of the written data. This value must be returned to the user through the BIO iter sector. This is done in 2 places: in blk_complete_request() and in blk_update_request(). Introduce the inline helper function blk_zone_update_request_bio() to avoid duplicating this BIO update for zone append requests, and to compile out this helper call when CONFIG_BLK_DEV_ZONED is not enabled. Signed-off-by: Damien Le Moal Reviewed-by: Hannes Reinecke Reviewed-by: Christoph Hellwig Reviewed-by: Bart Van Assche Tested-by: Hans Holmberg Tested-by: Dennis Maisenbacher Reviewed-by: Martin K. Petersen --- block/blk-mq.c | 11 +++++------ block/blk.h | 19 ++++++++++++++++++- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/block/blk-mq.c b/block/blk-mq.c index fcbf0953a179..88b541e8873f 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -821,8 +821,7 @@ static void blk_complete_request(struct request *req) /* Completion has already been traced */ bio_clear_flag(bio, BIO_TRACE_COMPLETION); - if (req_op(req) == REQ_OP_ZONE_APPEND) - bio->bi_iter.bi_sector = req->__sector; + blk_zone_update_request_bio(req, bio); if (!is_flush) bio_endio(bio); @@ -923,10 +922,10 @@ bool blk_update_request(struct request *req, blk_status_t error, bio_advance(bio, bio_bytes); /* Don't actually finish bio if it's part of flush sequence */ - if (!bio->bi_iter.bi_size && !is_flush) { - if (req_op(req) == REQ_OP_ZONE_APPEND) - bio->bi_iter.bi_sector = req->__sector; - bio_endio(bio); + if (!bio->bi_iter.bi_size) { + blk_zone_update_request_bio(req, bio); + if (!is_flush) + bio_endio(bio); } total_bytes += bio_bytes; diff --git a/block/blk.h b/block/blk.h index d9f584984bc4..17786052f32d 100644 --- a/block/blk.h +++ b/block/blk.h @@ -408,12 +408,29 @@ static inline struct bio *blk_queue_bounce(struct bio *bio, #ifdef CONFIG_BLK_DEV_ZONED void disk_free_zone_bitmaps(struct gendisk *disk); +static inline void blk_zone_update_request_bio(struct request *rq, + struct bio *bio) +{ + /* + * For zone append requests, the request sector indicates the location + * at which the BIO data was written. Return this value to the BIO + * issuer through the BIO iter sector. + */ + if (req_op(rq) == REQ_OP_ZONE_APPEND) + bio->bi_iter.bi_sector = rq->__sector; +} int blkdev_report_zones_ioctl(struct block_device *bdev, unsigned int cmd, unsigned long arg); int blkdev_zone_mgmt_ioctl(struct block_device *bdev, blk_mode_t mode, unsigned int cmd, unsigned long arg); #else /* CONFIG_BLK_DEV_ZONED */ -static inline void disk_free_zone_bitmaps(struct gendisk *disk) {} +static inline void disk_free_zone_bitmaps(struct gendisk *disk) +{ +} +static inline void blk_zone_update_request_bio(struct request *rq, + struct bio *bio) +{ +} static inline int blkdev_report_zones_ioctl(struct block_device *bdev, unsigned int cmd, unsigned long arg) { -- 2.44.0