From patchwork Tue Nov 6 21:35:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mikulas Patocka X-Patchwork-Id: 10671509 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9513614E2 for ; Tue, 6 Nov 2018 21:52:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 83E6A2AD58 for ; Tue, 6 Nov 2018 21:52:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 783552ADCD; Tue, 6 Nov 2018 21:52:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id DBF1B2AD58 for ; Tue, 6 Nov 2018 21:52:14 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C06378830A; Tue, 6 Nov 2018 21:52:13 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1DDF060C5C; Tue, 6 Nov 2018 21:52:13 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 6F40D180B5B7; Tue, 6 Nov 2018 21:52:12 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id wA6LdAIB004285 for ; Tue, 6 Nov 2018 16:39:10 -0500 Received: by smtp.corp.redhat.com (Postfix) id 79FE65D76C; Tue, 6 Nov 2018 21:39:10 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from leontynka.twibright.com (ovpn-204-55.brq.redhat.com [10.40.204.55]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 75D495D760; Tue, 6 Nov 2018 21:39:05 +0000 (UTC) Received: from debian-a64.vm ([192.168.208.2]) by leontynka.twibright.com with smtp (Exim 4.89) (envelope-from ) id 1gK93v-0005Nh-AW; Tue, 06 Nov 2018 22:39:04 +0100 Received: by debian-a64.vm (sSMTP sendmail emulation); Tue, 06 Nov 2018 22:38:58 +0100 Message-Id: <20181106213858.391264280@debian-a64.vm> User-Agent: quilt/0.65 Date: Tue, 06 Nov 2018 22:35:03 +0100 From: Mikulas Patocka To: Mike Snitzer , "Alasdair G. Kergon" MIME-Version: 1.0 Content-Disposition: inline; filename=dm-inflight.patch X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: dm-devel@redhat.com Cc: dm-devel@redhat.com, Mikulas Patocka Subject: [dm-devel] [patch 5/5] block: use a driver-specific handler for the "inflight" value X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Tue, 06 Nov 2018 21:52:14 +0000 (UTC) X-Virus-Scanned: ClamAV using ClamSMTP Device mapper was converted to percpu inflight counters. In order to display the correct values in the "inflight" sysfs file, we need a custom callback that sums the percpu counters. Signed-off-by: Mikulas Patocka --- block/blk-settings.c | 6 ++++++ block/genhd.c | 5 +++++ drivers/md/dm.c | 18 ++++++++++++++++++ include/linux/blkdev.h | 4 ++++ 4 files changed, 33 insertions(+) -- dm-devel mailing list dm-devel@redhat.com https://www.redhat.com/mailman/listinfo/dm-devel Index: linux-2.6/block/genhd.c =================================================================== --- linux-2.6.orig/block/genhd.c 2018-11-06 22:31:46.350000000 +0100 +++ linux-2.6/block/genhd.c 2018-11-06 22:31:46.350000000 +0100 @@ -85,6 +85,11 @@ void part_in_flight(struct request_queue void part_in_flight_rw(struct request_queue *q, struct hd_struct *part, unsigned int inflight[2]) { + if (q->get_inflight_fn) { + q->get_inflight_fn(q, inflight); + return; + } + if (q->mq_ops) { blk_mq_in_flight_rw(q, part, inflight); return; Index: linux-2.6/include/linux/blkdev.h =================================================================== --- linux-2.6.orig/include/linux/blkdev.h 2018-11-06 22:31:46.350000000 +0100 +++ linux-2.6/include/linux/blkdev.h 2018-11-06 22:31:46.350000000 +0100 @@ -324,6 +324,7 @@ typedef int (lld_busy_fn) (struct reques typedef int (bsg_job_fn) (struct bsg_job *); typedef int (init_rq_fn)(struct request_queue *, struct request *, gfp_t); typedef void (exit_rq_fn)(struct request_queue *, struct request *); +typedef void (get_inflight_fn)(struct request_queue *, unsigned int [2]); enum blk_eh_timer_return { BLK_EH_DONE, /* drivers has completed the command */ @@ -466,6 +467,8 @@ struct request_queue { exit_rq_fn *exit_rq_fn; /* Called from inside blk_get_request() */ void (*initialize_rq_fn)(struct request *rq); + /* Called to get the "inflight" values */ + get_inflight_fn *get_inflight_fn; const struct blk_mq_ops *mq_ops; @@ -1232,6 +1235,7 @@ extern int blk_queue_dma_drain(struct re dma_drain_needed_fn *dma_drain_needed, void *buf, unsigned int size); extern void blk_queue_lld_busy(struct request_queue *q, lld_busy_fn *fn); +extern void blk_queue_get_inflight(struct request_queue *q, get_inflight_fn *fn); extern void blk_queue_segment_boundary(struct request_queue *, unsigned long); extern void blk_queue_virt_boundary(struct request_queue *, unsigned long); extern void blk_queue_prep_rq(struct request_queue *, prep_rq_fn *pfn); Index: linux-2.6/block/blk-settings.c =================================================================== --- linux-2.6.orig/block/blk-settings.c 2018-11-06 22:31:46.350000000 +0100 +++ linux-2.6/block/blk-settings.c 2018-11-06 22:31:46.350000000 +0100 @@ -79,6 +79,12 @@ void blk_queue_lld_busy(struct request_q } EXPORT_SYMBOL_GPL(blk_queue_lld_busy); +void blk_queue_get_inflight(struct request_queue *q, get_inflight_fn *fn) +{ + q->get_inflight_fn = fn; +} +EXPORT_SYMBOL_GPL(blk_queue_get_inflight); + /** * blk_set_default_limits - reset limits to default values * @lim: the queue_limits structure to reset Index: linux-2.6/drivers/md/dm.c =================================================================== --- linux-2.6.orig/drivers/md/dm.c 2018-11-06 22:31:46.350000000 +0100 +++ linux-2.6/drivers/md/dm.c 2018-11-06 22:31:46.350000000 +0100 @@ -662,6 +662,23 @@ static void end_io_acct(struct dm_io *io } } +static void dm_get_inflight(struct request_queue *q, unsigned int inflight[2]) +{ + struct mapped_device *md = q->queuedata; + int cpu; + + inflight[READ] = inflight[WRITE] = 0; + for_each_possible_cpu(cpu) { + struct dm_percpu *p = per_cpu_ptr(md->counters, cpu); + inflight[READ] += p->inflight[READ]; + inflight[WRITE] += p->inflight[WRITE]; + } + if ((int)inflight[READ] < 0) + inflight[READ] = 0; + if ((int)inflight[WRITE] < 0) + inflight[WRITE] = 0; +} + /* * Add the bio to the list of deferred io. */ @@ -2242,6 +2259,7 @@ int dm_setup_md_queue(struct mapped_devi case DM_TYPE_NVME_BIO_BASED: dm_init_normal_md_queue(md); blk_queue_make_request(md->queue, dm_make_request); + blk_queue_get_inflight(md->queue, dm_get_inflight); break; case DM_TYPE_NONE: WARN_ON_ONCE(true);