From patchwork Fri Mar 4 16:03:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 548461 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B2EA3C433F5 for ; Fri, 4 Mar 2022 16:03:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236443AbiCDQEg (ORCPT ); Fri, 4 Mar 2022 11:04:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232723AbiCDQEe (ORCPT ); Fri, 4 Mar 2022 11:04:34 -0500 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E60E213D90E; Fri, 4 Mar 2022 08:03:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=QQVlxFrmrrWNi3IoqP7GqjAW18JlQybNg4y9LNyfDyU=; b=sFw6O/bHTUm8R2CubCC4k0yNz2 rGwvlRmyZN3HHJFoIC1Vg8/h8xB0E0vZ1zMf+Q/kbGmf7xZ/QAx+Ywxa8jb7zoszYnba0Ulwxq9JV QGrrI4Cuzu6g2ULwZHxX6QAvWNN+0YcoUl5fYqXax1AUUyn9Dqe3RHfYaflsibdXM5ldUAP/OthP7 BKBr6m+Cscw7vzUJ4olljT4NkLyNIth6ZcVFp+4UCkRuAVhXVlObdZSfC+gQhkqZ1e0mk2l0QMfTg KYSFXCuo/Iizh/3kEuzuhLLr8PkyaHEmf+HyHo75G91ECMxdMKm7CbgEibn7WC48lKL/gUMZmPgRI j4nC7Q9Q==; Received: from [2001:4bb8:180:5296:7360:567:acd5:aaa2] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1nQAP2-00Atyx-WF; Fri, 04 Mar 2022 16:03:37 +0000 From: Christoph Hellwig To: Jens Axboe Cc: "Martin K. Petersen" , Ming Lei , Bart Van Assche , linux-block@vger.kernel.org, linux-scsi@vger.kernel.org Subject: [PATCH 01/14] blk-mq: do not include passthrough requests in I/O accounting Date: Fri, 4 Mar 2022 17:03:18 +0100 Message-Id: <20220304160331.399757-2-hch@lst.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220304160331.399757-1-hch@lst.de> References: <20220304160331.399757-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org I/O accounting buckets I/O into the read/write/discard categories into which passthrough I/O does not fit at all. It also accounts to the block_device, which may not even exist for passthrough I/O. Signed-off-by: Christoph Hellwig Reviewed-by: Bart Van Assche Reviewed-by: Chaitanya Kulkarni Reviewed-by: Martin K. Petersen --- block/blk-mq.c | 11 ++++++++--- block/blk.h | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/block/blk-mq.c b/block/blk-mq.c index a05ce77250316..ab4b646551334 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -883,10 +883,15 @@ static inline void blk_account_io_done(struct request *req, u64 now) static void __blk_account_io_start(struct request *rq) { - /* passthrough requests can hold bios that do not have ->bi_bdev set */ - if (rq->bio && rq->bio->bi_bdev) + /* + * All non-passthrough requests are created from a bio with one + * exception: when a flush command that is part of a flush sequence + * generated by the state machine in blk-flush.c is cloned onto the + * lower device by dm-multipath we can get here without a bio. + */ + if (rq->bio) rq->part = rq->bio->bi_bdev; - else if (rq->q->disk) + else rq->part = rq->q->disk->part0; part_stat_lock(); diff --git a/block/blk.h b/block/blk.h index ebaa59ca46ca6..6f21859c7f0ff 100644 --- a/block/blk.h +++ b/block/blk.h @@ -325,7 +325,7 @@ int blk_dev_init(void); */ static inline bool blk_do_io_stat(struct request *rq) { - return (rq->rq_flags & RQF_IO_STAT) && rq->q->disk; + return (rq->rq_flags & RQF_IO_STAT) && !blk_rq_is_passthrough(rq); } void update_io_ticks(struct block_device *part, unsigned long now, bool end);