Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp3762455imm; Mon, 18 Jun 2018 03:44:12 -0700 (PDT) X-Google-Smtp-Source: ADUXVKK0Kk7Z3s3Js6CAeYPnfwBPjZCnqpF0Zr16VIq0IwMRDRy62JWqYT4cM4N1xSNhZ3FgDbvn X-Received: by 2002:a63:842:: with SMTP id 63-v6mr10816415pgi.406.1529318652947; Mon, 18 Jun 2018 03:44:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529318652; cv=none; d=google.com; s=arc-20160816; b=0yd5xeMl0xlePDST2T0YfYtmLFfNGrVPwWUeI20jOZXlHEMl1dAyzQw26pFntxPp26 GGzSPoSJoV3RgWWA/jn+/0nhJlhOAOECpBckjgd5/ri+xwSwGqtMxTYESG168GT/3HzN mxsIFV4aaZKbsC7O8Sxf7t1u4mlGAPgHQC6gynXwR9bFc6uvF6nAqHZlrd7ZqPLQNgsN f6JTm7con48Ceo8vnWcl6ZGNQELv/d2ZIj7CxDGiYbeGK+GDsCo0wd4boWpEn7aneBum wtsJfBXIsGTzXej/dpTfgQhZe1RbQIIXf/si+ZCCBL+R12eJwLhfQjzBwabD3y90ZjCx yX2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=w8hGsvE+wPGBW6F/XFf8m8Usn4ZXW94dAAG/P3T4PuU=; b=FD3pWhubmj9cMQwcJMHknQreMoM6kCrG3b6pqihQFe889cWcJCPXBVYq6WKEz4r9Bz aryB3zab0aTqX8qyHscJb7iBKk7ww8UrefEwEfJaLwtfdPjfEP1CpKaMAndOkNH+cGnL sRpGoZ0NDGuoPbLEjSEh4ME+DLfhrD4HgdLPnpXiuVWquluhlu1l1Om+BCsOuhjN6SWo pC1xNIM2n4GLFFN/34BoQxnnfw4rFVLBxQCnoRn7b0w6TCBxp9VO2puPHo5LH63s4NDX Ckd1cAZ2lO0euYkqFZp7p7ttm7GvjS6tsRbr5SYDdPB/hCuPmxKWHeVTVi/K556jbu2Z 9bZA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f6-v6si15377298plm.448.2018.06.18.03.43.59; Mon, 18 Jun 2018 03:44:12 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935597AbeFRITx (ORCPT + 99 others); Mon, 18 Jun 2018 04:19:53 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:54946 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935001AbeFRITs (ORCPT ); Mon, 18 Jun 2018 04:19:48 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 9FD6DBAD; Mon, 18 Jun 2018 08:19:47 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Omar Sandoval , Jens Axboe , Sasha Levin Subject: [PATCH 4.16 105/279] blk-mq: fix sysfs inflight counter Date: Mon, 18 Jun 2018 10:11:30 +0200 Message-Id: <20180618080613.170418891@linuxfoundation.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180618080608.851973560@linuxfoundation.org> References: <20180618080608.851973560@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.16-stable review patch. If anyone has any objections, please let me know. ------------------ From: Omar Sandoval [ Upstream commit bf0ddaba65ddbb2715af97041da8e7a45b2d8628 ] When the blk-mq inflight implementation was added, /proc/diskstats was converted to use it, but /sys/block/$dev/inflight was not. Fix it by adding another helper to count in-flight requests by data direction. Fixes: f299b7c7a9de ("blk-mq: provide internal in-flight variant") Signed-off-by: Omar Sandoval Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- block/blk-mq.c | 19 +++++++++++++++++++ block/blk-mq.h | 4 +++- block/genhd.c | 12 ++++++++++++ block/partition-generic.c | 10 ++++++---- include/linux/genhd.h | 4 +++- 5 files changed, 43 insertions(+), 6 deletions(-) --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -118,6 +118,25 @@ void blk_mq_in_flight(struct request_que blk_mq_queue_tag_busy_iter(q, blk_mq_check_inflight, &mi); } +static void blk_mq_check_inflight_rw(struct blk_mq_hw_ctx *hctx, + struct request *rq, void *priv, + bool reserved) +{ + struct mq_inflight *mi = priv; + + if (rq->part == mi->part) + mi->inflight[rq_data_dir(rq)]++; +} + +void blk_mq_in_flight_rw(struct request_queue *q, struct hd_struct *part, + unsigned int inflight[2]) +{ + struct mq_inflight mi = { .part = part, .inflight = inflight, }; + + inflight[0] = inflight[1] = 0; + blk_mq_queue_tag_busy_iter(q, blk_mq_check_inflight_rw, &mi); +} + void blk_freeze_queue_start(struct request_queue *q) { int freeze_depth; --- a/block/blk-mq.h +++ b/block/blk-mq.h @@ -185,7 +185,9 @@ static inline bool blk_mq_hw_queue_mappe } void blk_mq_in_flight(struct request_queue *q, struct hd_struct *part, - unsigned int inflight[2]); + unsigned int inflight[2]); +void blk_mq_in_flight_rw(struct request_queue *q, struct hd_struct *part, + unsigned int inflight[2]); static inline void blk_mq_put_dispatch_budget(struct blk_mq_hw_ctx *hctx) { --- a/block/genhd.c +++ b/block/genhd.c @@ -82,6 +82,18 @@ 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->mq_ops) { + blk_mq_in_flight_rw(q, part, inflight); + return; + } + + inflight[0] = atomic_read(&part->in_flight[0]); + inflight[1] = atomic_read(&part->in_flight[1]); +} + struct hd_struct *__disk_get_part(struct gendisk *disk, int partno) { struct disk_part_tbl *ptbl = rcu_dereference(disk->part_tbl); --- a/block/partition-generic.c +++ b/block/partition-generic.c @@ -145,13 +145,15 @@ ssize_t part_stat_show(struct device *de jiffies_to_msecs(part_stat_read(p, time_in_queue))); } -ssize_t part_inflight_show(struct device *dev, - struct device_attribute *attr, char *buf) +ssize_t part_inflight_show(struct device *dev, struct device_attribute *attr, + char *buf) { struct hd_struct *p = dev_to_part(dev); + struct request_queue *q = part_to_disk(p)->queue; + unsigned int inflight[2]; - return sprintf(buf, "%8u %8u\n", atomic_read(&p->in_flight[0]), - atomic_read(&p->in_flight[1])); + part_in_flight_rw(q, p, inflight); + return sprintf(buf, "%8u %8u\n", inflight[0], inflight[1]); } #ifdef CONFIG_FAIL_MAKE_REQUEST --- a/include/linux/genhd.h +++ b/include/linux/genhd.h @@ -368,7 +368,9 @@ static inline void free_part_stats(struc part_stat_add(cpu, gendiskp, field, -subnd) void part_in_flight(struct request_queue *q, struct hd_struct *part, - unsigned int inflight[2]); + unsigned int inflight[2]); +void part_in_flight_rw(struct request_queue *q, struct hd_struct *part, + unsigned int inflight[2]); void part_dec_in_flight(struct request_queue *q, struct hd_struct *part, int rw); void part_inc_in_flight(struct request_queue *q, struct hd_struct *part,