From patchwork Tue Jun 9 21:23:59 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurence Oberman X-Patchwork-Id: 6575271 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: X-Original-To: patchwork-dm-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 1AE33C0020 for ; Tue, 9 Jun 2015 21:27:48 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 354C42054D for ; Tue, 9 Jun 2015 21:27:47 +0000 (UTC) Received: from mx4-phx2.redhat.com (mx4-phx2.redhat.com [209.132.183.25]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0561120497 for ; Tue, 9 Jun 2015 21:27:45 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx4-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id t59LO0fP007474; Tue, 9 Jun 2015 17:24:00 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id t59LNxlR029133 for ; Tue, 9 Jun 2015 17:23:59 -0400 Received: from mx3-phx2.redhat.com (mx01.colomx.prod.int.phx2.redhat.com [10.5.7.1]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t59LNx6A008783 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Tue, 9 Jun 2015 17:23:59 -0400 Received: from zmail22.collab.prod.int.phx2.redhat.com (zmail22.collab.prod.int.phx2.redhat.com [10.5.83.26]) by mx3-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id t59LNxQn021243; Tue, 9 Jun 2015 17:23:59 -0400 Date: Tue, 9 Jun 2015 17:23:59 -0400 (EDT) From: Laurence Oberman To: Mikulas Patocka Message-ID: <1185981540.11910821.1433885039023.JavaMail.zimbra@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Originating-IP: [10.18.33.16] Thread-Topic: dm stats: support statistics on requests-based devices Thread-Index: OTpweESeB4u883TUpa9ZDroFO9JzMg== X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-loop: dm-devel@redhat.com Cc: Mike Snitzer , Tao Ma , Robin Dong , dm-devel@redhat.com, Coly Li , "Alasdair G. Kergon" Subject: Re: [dm-devel] [PATCH 4/4] dm stats: support statistics on requests-based devices X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk Reply-To: device-mapper development 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-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Awesome. Thanks I will pull the patches build and test. Regards Laurence Laurence Oberman Red Hat Global Support Service SEG Team ----- Original Message ----- From: "Mikulas Patocka" To: "Alasdair G. Kergon" , "Mike Snitzer" , "Coly Li" Cc: dm-devel@redhat.com, "Tao Ma" , "Robin Dong" , "Laurence Oberman" Sent: Tuesday, June 9, 2015 5:22:49 PM Subject: [PATCH 4/4] dm stats: support statistics on requests-based devices This patch makes it possible to use dm stats on multipath. Signed-off-by: Mikulas Patocka --- drivers/md/dm-stats.c | 5 ----- drivers/md/dm.c | 27 +++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 5 deletions(-) -- dm-devel mailing list dm-devel@redhat.com https://www.redhat.com/mailman/listinfo/dm-devel Index: linux-4.1-rc7/drivers/md/dm-stats.c =================================================================== --- linux-4.1-rc7.orig/drivers/md/dm-stats.c 2015-06-09 13:53:26.000000000 +0200 +++ linux-4.1-rc7/drivers/md/dm-stats.c 2015-06-09 13:53:35.000000000 +0200 @@ -1155,11 +1155,6 @@ int dm_stats_message(struct mapped_devic { int r; - if (dm_request_based(md)) { - DMWARN("Statistics are only supported for bio-based devices"); - return -EOPNOTSUPP; - } - /* All messages here must start with '@' */ if (!strcasecmp(argv[0], "@stats_create")) r = message_stats_create(md, argc, argv, result, maxlen); Index: linux-4.1-rc7/drivers/md/dm.c =================================================================== --- linux-4.1-rc7.orig/drivers/md/dm.c 2015-06-09 13:53:50.000000000 +0200 +++ linux-4.1-rc7/drivers/md/dm.c 2015-06-09 16:07:35.000000000 +0200 @@ -86,6 +86,9 @@ struct dm_rq_target_io { struct kthread_work work; int error; union map_info info; + struct dm_stats_aux stats_aux; + unsigned long duration_jiffies; + unsigned n_sectors; }; /* @@ -1084,6 +1087,17 @@ static struct dm_rq_target_io *tio_from_ return (rq->q->mq_ops ? blk_mq_rq_to_pdu(rq) : rq->special); } +static void rq_end_stats(struct mapped_device *md, struct request *orig) +{ + if (unlikely(dm_stats_used(&md->stats))) { + struct dm_rq_target_io *tio = tio_from_request(orig); + tio->duration_jiffies = jiffies - tio->duration_jiffies; + dm_stats_account_io(&md->stats, orig->cmd_flags, blk_rq_pos(orig), + tio->n_sectors, true, tio->duration_jiffies, + &tio->stats_aux); + } +} + /* * Don't touch any member of the md after calling this function because * the md may be freed in dm_put() at the end of this function. @@ -1169,6 +1183,7 @@ static void dm_end_request(struct reques } free_rq_clone(clone); + rq_end_stats(md, rq); if (!rq->q->mq_ops) blk_end_request_all(rq, error); else @@ -1211,6 +1226,7 @@ static void dm_requeue_unmapped_original dm_unprep_request(rq); + rq_end_stats(md, rq); if (!rq->q->mq_ops) old_requeue_request(rq); else { @@ -1309,6 +1325,7 @@ static void dm_softirq_done(struct reque int rw; if (!clone) { + rq_end_stats(tio->md, rq); rw = rq_data_dir(rq); if (!rq->q->mq_ops) { blk_end_request_all(rq, tio->error); @@ -2120,6 +2137,15 @@ static void dm_start_request(struct mapp md->last_rq_start_time = ktime_get(); } + if (unlikely(dm_stats_used(&md->stats))) { + struct dm_rq_target_io *tio = tio_from_request(orig); + tio->duration_jiffies = jiffies; + tio->n_sectors = blk_rq_sectors(orig); + dm_stats_account_io(&md->stats, orig->cmd_flags, blk_rq_pos(orig), + tio->n_sectors, false, 0, + &tio->stats_aux); + } + /* * Hold the md reference here for the in-flight I/O. * We can't rely on the reference count by device opener, @@ -2853,6 +2879,7 @@ static int dm_mq_queue_rq(struct blk_mq_ /* Direct call is fine since .queue_rq allows allocations */ if (map_request(tio, rq, md) == DM_MAPIO_REQUEUE) { /* Undo dm_start_request() before requeuing */ + rq_end_stats(md, rq); rq_completed(md, rq_data_dir(rq), false); return BLK_MQ_RQ_QUEUE_BUSY; }