Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3352447ybi; Tue, 2 Jul 2019 06:25:49 -0700 (PDT) X-Google-Smtp-Source: APXvYqwl/AZfcVoX5VrQc8hMVV7KsX4Sv/CCBNr27ogKO/ByEzkLHlMlh945V0MmIo6TPfEGONr4 X-Received: by 2002:a17:90a:8984:: with SMTP id v4mr5590032pjn.133.1562073949493; Tue, 02 Jul 2019 06:25:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562073949; cv=none; d=google.com; s=arc-20160816; b=MIAjoBkdngvSrOdg0pIl0AQsvqk9UewdQ7DlpGUcJuQMR5xNzQpYyUmYtczipeiPYY KYDyn4opkurtEd0WiAUebSkZ22A0fWEeBJyLYwdZycKoNWV6ckYiLQU1kLe/jFqciF+5 o9UYNp4sbhL5gymUmlEydkZaUNFTkS697NOODI0RHJP6q2VNm+zPvaXjl6umbAcdDHp7 WMHrWp7dXpC8bKimtY9B1ckPbyL8a/wn/rkUh7CNUaIKN+u/hRIO1ofBefAngBoDHc9b bDsdCg3lBuEeb2xfuXcako3KVhFYvWkwfTouD6qcc7j6g/P92NzNoxp3R0w9ytgircBY tvXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=fOdmhEbuByRsF2R46GDZf67ksM5AIi4WHCSS8KryQDc=; b=fOhkl63vrvAMYCANNjIMrHcfRxzYpRT1y8qZPEV3BqR1Rmk4OM9AGWsTluiwKO43qU wlG8h8A665Va9bZvPlcQorW3Nf4VdCFpd99AuTgeFa/ji2pqaVMxb4SKwtTQ0xwbD/fy ckPbU9UtKcXJB/ZjYV2vAvO42holYNcGJVT1Y9Q9jKrgz2ehrqQUqUs8EtFIf/wYQvZh hXk54qzwGKHckS+bLBGk7AbZYQO7dpJcUDTHDB16Uw6VHRKCp3li1rvbeZGh9sNfceHf i4dhkCu5s3u/uNCXD3SKedK4wwji1SRr6HSuXwBhauiR6nPYYAanqmCjapI0GHiyas3t uNaA== 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 f19si13656258pfd.137.2019.07.02.06.25.34; Tue, 02 Jul 2019 06:25:49 -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 S1727117AbfGBNXz (ORCPT + 99 others); Tue, 2 Jul 2019 09:23:55 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:7688 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727083AbfGBNXw (ORCPT ); Tue, 2 Jul 2019 09:23:52 -0400 Received: from DGGEMS402-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id B56142A725E3A147B9F7; Tue, 2 Jul 2019 21:23:49 +0800 (CST) Received: from huawei.com (10.90.53.225) by DGGEMS402-HUB.china.huawei.com (10.3.19.202) with Microsoft SMTP Server id 14.3.439.0; Tue, 2 Jul 2019 21:23:42 +0800 From: Hou Tao To: , CC: , , , , , , Subject: [RFC PATCH 3/3] raid1: export inflight io counters and internal stats in debugfs Date: Tue, 2 Jul 2019 21:29:18 +0800 Message-ID: <20190702132918.114818-4-houtao1@huawei.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190702132918.114818-1-houtao1@huawei.com> References: <20190702132918.114818-1-houtao1@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.90.53.225] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Just like the previous patch which exports debugfs files for md-core, this patch exports debugfs file for md-raid1 under /sys/kernel/debug/block/mdX/raid1. Signed-off-by: Hou Tao --- drivers/md/raid1.c | 78 ++++++++++++++++++++++++++++++++++++++++++++++ drivers/md/raid1.h | 1 + 2 files changed, 79 insertions(+) diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index 2aa36e570e04..da06bb47195b 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c @@ -35,6 +35,7 @@ #include "md.h" #include "raid1.h" #include "md-bitmap.h" +#include "md-debugfs.h" #define UNSUPPORTED_MDDEV_FLAGS \ ((1L << MD_HAS_JOURNAL) | \ @@ -2901,6 +2902,80 @@ static sector_t raid1_size(struct mddev *mddev, sector_t sectors, int raid_disks return mddev->dev_sectors; } +enum { + IOSTAT_NR_PENDING = 0, + IOSTAT_NR_WAITING, + IOSTAT_NR_QUEUED, + IOSTAT_BARRIER, + IOSTAT_CNT, +}; + +static int raid1_dbg_iostat_show(struct seq_file *m, void *data) +{ + struct r1conf *conf = m->private; + int idx; + int sum[IOSTAT_CNT] = {}; + + seq_printf(m, "retry_list active %d\n", + !list_empty(&conf->retry_list)); + seq_printf(m, "bio_end_io_list active %d\n", + !list_empty(&conf->bio_end_io_list)); + seq_printf(m, "pending_bio_list active %d cnt %d\n", + !bio_list_empty(&conf->pending_bio_list), + conf->pending_count); + + for (idx = 0; idx < BARRIER_BUCKETS_NR; idx++) { + sum[IOSTAT_NR_PENDING] += atomic_read(&conf->nr_pending[idx]); + sum[IOSTAT_NR_WAITING] += atomic_read(&conf->nr_waiting[idx]); + sum[IOSTAT_NR_QUEUED] += atomic_read(&conf->nr_queued[idx]); + sum[IOSTAT_BARRIER] += atomic_read(&conf->barrier[idx]); + } + + seq_printf(m, "sync_pending %d\n", atomic_read(&conf->nr_sync_pending)); + seq_printf(m, "nr_pending %d\n", sum[IOSTAT_NR_PENDING]); + seq_printf(m, "nr_waiting %d\n", sum[IOSTAT_NR_WAITING]); + seq_printf(m, "nr_queued %d\n", sum[IOSTAT_NR_QUEUED]); + seq_printf(m, "barrier %d\n", sum[IOSTAT_BARRIER]); + + return 0; +} + +static int raid1_dbg_stat_show(struct seq_file *m, void *data) +{ + struct r1conf *conf = m->private; + + seq_printf(m, "array_frozen %d\n", conf->array_frozen); + return 0; +} + +static const struct md_debugfs_file raid1_dbg_files[] = { + {.name = "iostat", .show = raid1_dbg_iostat_show}, + {.name = "stat", .show = raid1_dbg_stat_show}, + {}, +}; + +static void raid1_unregister_debugfs(struct r1conf *conf) +{ + debugfs_remove_recursive(conf->debugfs_dir); +} + +static void raid1_register_debugfs(struct mddev *mddev, struct r1conf *conf) +{ + struct dentry *dir; + + conf->debugfs_dir = NULL; + + if (!mddev->debugfs_dir) + return; + + dir = debugfs_create_dir("raid1", mddev->debugfs_dir); + if (IS_ERR_OR_NULL(dir)) + return; + + md_debugfs_create_files(dir, conf, raid1_dbg_files); + conf->debugfs_dir = dir; +} + static struct r1conf *setup_conf(struct mddev *mddev) { struct r1conf *conf; @@ -3022,6 +3097,8 @@ static struct r1conf *setup_conf(struct mddev *mddev) if (!conf->thread) goto abort; + raid1_register_debugfs(mddev, conf); + return conf; abort: @@ -3136,6 +3213,7 @@ static void raid1_free(struct mddev *mddev, void *priv) { struct r1conf *conf = priv; + raid1_unregister_debugfs(conf); mempool_exit(&conf->r1bio_pool); kfree(conf->mirrors); safe_put_page(conf->tmppage); diff --git a/drivers/md/raid1.h b/drivers/md/raid1.h index e7ccad898736..d627020e92d4 100644 --- a/drivers/md/raid1.h +++ b/drivers/md/raid1.h @@ -139,6 +139,7 @@ struct r1conf { sector_t cluster_sync_low; sector_t cluster_sync_high; + struct dentry *debugfs_dir; }; /* -- 2.22.0