From patchwork Thu Aug 17 23:23:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 9907301 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 655326038C for ; Thu, 17 Aug 2017 23:25:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 57C7428B58 for ; Thu, 17 Aug 2017 23:25:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4C70028BF6; Thu, 17 Aug 2017 23:25:29 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 86D7E28B58 for ; Thu, 17 Aug 2017 23:25:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753449AbdHQXZ2 (ORCPT ); Thu, 17 Aug 2017 19:25:28 -0400 Received: from esa1.hgst.iphmx.com ([68.232.141.245]:57775 "EHLO esa1.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753342AbdHQXZ1 (ORCPT ); Thu, 17 Aug 2017 19:25:27 -0400 X-IronPort-AV: E=Sophos;i="5.41,390,1498492800"; d="scan'208";a="145464815" Received: from sjappemgw11.hgst.com (HELO sjappemgw12.hgst.com) ([199.255.44.62]) by ob1.hgst.iphmx.com with ESMTP; 18 Aug 2017 07:23:11 +0800 Received: from thinkpad-bart.sdcorp.global.sandisk.com (HELO thinkpad-bart.int.fusionio.com) ([10.11.172.152]) by sjappemgw12.hgst.com with ESMTP; 17 Aug 2017 16:23:12 -0700 From: Bart Van Assche To: Jens Axboe Cc: linux-block@vger.kernel.org, Christoph Hellwig , Bart Van Assche , Omar Sandoval , Hannes Reinecke Subject: [PATCH 06/12] blk-mq-debugfs: Generate name-to-text translation tables Date: Thu, 17 Aug 2017 16:23:05 -0700 Message-Id: <20170817232311.25948-7-bart.vanassche@wdc.com> X-Mailer: git-send-email 2.14.0 In-Reply-To: <20170817232311.25948-1-bart.vanassche@wdc.com> References: <20170817232311.25948-1-bart.vanassche@wdc.com> Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP It is easy to add a flag to one of the block layer headers and to forget to update blk-mq-debugfs.c. E.g. QUEUE_FLAG_SCSI_PASSTHROUGH, QUEUE_FLAG_QUIESCED and REQ_NOWAIT are missing from blk-mq-debugfs.c. Hence generate the symbol-to-text translation tables. Signed-off-by: Bart Van Assche Cc: Omar Sandoval Cc: Hannes Reinecke --- block/.gitignore | 1 + block/Makefile | 58 ++++++++++++++++++++++ block/blk-mq-debugfs.c | 130 +------------------------------------------------ 3 files changed, 61 insertions(+), 128 deletions(-) create mode 100644 block/.gitignore diff --git a/block/.gitignore b/block/.gitignore new file mode 100644 index 000000000000..63b09639ab06 --- /dev/null +++ b/block/.gitignore @@ -0,0 +1 @@ +blk-name-tables.c diff --git a/block/Makefile b/block/Makefile index 2b281cf258a0..f9bd77426ac1 100644 --- a/block/Makefile +++ b/block/Makefile @@ -33,3 +33,61 @@ obj-$(CONFIG_BLK_DEV_ZONED) += blk-zoned.o obj-$(CONFIG_BLK_WBT) += blk-wbt.o obj-$(CONFIG_BLK_DEBUG_FS) += blk-mq-debugfs.o obj-$(CONFIG_BLK_SED_OPAL) += sed-opal.o + +clean-files := blk-name-tables.c + +$(obj)/blk-mq-debugfs.o: $(obj)/blk-name-tables.c + +$(obj)/blk-name-tables.c: block/Makefile block/blk.h include/linux/blk-mq.h \ + include/linux/blk_types.h include/linux/blkdev.h + @( \ + printf "static const char *const blk_queue_flag_name[] = {\n"; \ + s='^#define QUEUE_FLAG_\([^[:blank:]]*\)[[:blank:]]\+[0-9]\+.*';\ + r='\t\[QUEUE_FLAG_\1\] = "\1",'; \ + sed -n "s/$$s/$$r/p" include/linux/blkdev.h; \ + printf "};\n"; \ + printf "\n"; \ + printf "static const char *const hctx_state_name[] = {\n"; \ + s='^[[:blank:]]BLK_MQ_S_\([^[:blank:]]*\)[[:blank:]]\+=[[:blank:]]*[0-9]\+.*'; \ + r='\t\[BLK_MQ_S_\1\] = "\1",'; \ + sed -n "s/$$s/$$r/p" include/linux/blk-mq.h; \ + printf "};\n"; \ + printf "\n"; \ + printf "static const char *const alloc_policy_name[] = {\n"; \ + s='^#define BLK_TAG_ALLOC_\([^[:blank:]]*\)[[:blank:]]\+[0-9]\+.*';\ + r='\t\[BLK_TAG_ALLOC_\1\] = "\1",'; \ + sed -n "s/$$s/$$r/p" include/linux/blkdev.h; \ + printf "};\n"; \ + printf "\n"; \ + printf "static const char *const hctx_flag_name[] = {\n"; \ + s='^[[:blank:]]BLK_MQ_F_\([^[:blank:]]*\)[[:blank:]]\+=[[:blank:]]*[0-9]\+.*'; \ + r='\t\[ilog2(BLK_MQ_F_\1)\] = "\1",'; \ + sed -n "s/$$s/$$r/p" include/linux/blk-mq.h | \ + grep -v BLK_MQ_F_ALLOC_POLICY_; \ + printf "};\n"; \ + printf "\n"; \ + printf "static const char *const op_name[] = {\n"; \ + s='^[[:blank:]]REQ_OP_\([^[:blank:]]*\)[[:blank:]]\+=[[:blank:]]*[0-9]\+.*'; \ + r='\t\[REQ_OP_\1\] = "\1",'; \ + sed -n "s/$$s/$$r/p" include/linux/blk_types.h; \ + printf "};\n"; \ + printf "\n"; \ + printf "static const char *const cmd_flag_name[] = {\n"; \ + s='^#define REQ_\([^[:blank:]]*\)[[:blank:]]*(1.*'; \ + r='\t\[REQ_\1\] = "\1",'; \ + sed -n "s/$$s/$$r/p" include/linux/blk_types.h; \ + printf "};\n"; \ + printf "\n"; \ + printf "static const char *const rqf_name[] = {\n"; \ + s='^#define RQF_\([^[:blank:]]*\)[[:blank:]]\+(.*'; \ + r='\t\[RQF_\1\] = "\1",'; \ + sed -n "s/$$s/$$r/p" include/linux/blkdev.h; \ + printf "};\n"; \ + printf "\n"; \ + printf "static const char *const rqaf_name[] = {\n"; \ + s='^[[:blank:]]REQ_ATOM_\([^[:blank:],]*\).*'; \ + r='\t\[REQ_ATOM_\1\] = "\1",'; \ + sed -n "s/$$s/$$r/p" block/blk.h; \ + printf "};\n"; \ + printf "\n"; \ + ) >$@ diff --git a/block/blk-mq-debugfs.c b/block/blk-mq-debugfs.c index e53b6129ca5a..a3239db953b7 100644 --- a/block/blk-mq-debugfs.c +++ b/block/blk-mq-debugfs.c @@ -24,6 +24,8 @@ #include "blk-mq-debugfs.h" #include "blk-mq-tag.h" +#include "blk-name-tables.c" + static int blk_flags_show(struct seq_file *m, const unsigned long flags, const char *const *flag_name, int flag_name_count) { @@ -44,38 +46,6 @@ static int blk_flags_show(struct seq_file *m, const unsigned long flags, return 0; } -#define QUEUE_FLAG_NAME(name) [QUEUE_FLAG_##name] = #name -static const char *const blk_queue_flag_name[] = { - QUEUE_FLAG_NAME(QUEUED), - QUEUE_FLAG_NAME(STOPPED), - QUEUE_FLAG_NAME(DYING), - QUEUE_FLAG_NAME(BYPASS), - QUEUE_FLAG_NAME(BIDI), - QUEUE_FLAG_NAME(NOMERGES), - QUEUE_FLAG_NAME(SAME_COMP), - QUEUE_FLAG_NAME(FAIL_IO), - QUEUE_FLAG_NAME(STACKABLE), - QUEUE_FLAG_NAME(NONROT), - QUEUE_FLAG_NAME(IO_STAT), - QUEUE_FLAG_NAME(DISCARD), - QUEUE_FLAG_NAME(NOXMERGES), - QUEUE_FLAG_NAME(ADD_RANDOM), - QUEUE_FLAG_NAME(SECERASE), - QUEUE_FLAG_NAME(SAME_FORCE), - QUEUE_FLAG_NAME(DEAD), - QUEUE_FLAG_NAME(INIT_DONE), - QUEUE_FLAG_NAME(NO_SG_MERGE), - QUEUE_FLAG_NAME(POLL), - QUEUE_FLAG_NAME(WC), - QUEUE_FLAG_NAME(FUA), - QUEUE_FLAG_NAME(FLUSH_NQ), - QUEUE_FLAG_NAME(DAX), - QUEUE_FLAG_NAME(STATS), - QUEUE_FLAG_NAME(POLL_STATS), - QUEUE_FLAG_NAME(REGISTERED), -}; -#undef QUEUE_FLAG_NAME - static int queue_state_show(void *data, struct seq_file *m) { struct request_queue *q = data; @@ -173,16 +143,6 @@ static int queue_poll_stat_show(void *data, struct seq_file *m) return 0; } -#define HCTX_STATE_NAME(name) [BLK_MQ_S_##name] = #name -static const char *const hctx_state_name[] = { - HCTX_STATE_NAME(STOPPED), - HCTX_STATE_NAME(TAG_ACTIVE), - HCTX_STATE_NAME(SCHED_RESTART), - HCTX_STATE_NAME(TAG_WAITING), - HCTX_STATE_NAME(START_ON_RUN), -}; -#undef HCTX_STATE_NAME - static int hctx_state_show(void *data, struct seq_file *m) { struct blk_mq_hw_ctx *hctx = data; @@ -193,23 +153,6 @@ static int hctx_state_show(void *data, struct seq_file *m) return 0; } -#define BLK_TAG_ALLOC_NAME(name) [BLK_TAG_ALLOC_##name] = #name -static const char *const alloc_policy_name[] = { - BLK_TAG_ALLOC_NAME(FIFO), - BLK_TAG_ALLOC_NAME(RR), -}; -#undef BLK_TAG_ALLOC_NAME - -#define HCTX_FLAG_NAME(name) [ilog2(BLK_MQ_F_##name)] = #name -static const char *const hctx_flag_name[] = { - HCTX_FLAG_NAME(SHOULD_MERGE), - HCTX_FLAG_NAME(TAG_SHARED), - HCTX_FLAG_NAME(SG_MERGE), - HCTX_FLAG_NAME(BLOCKING), - HCTX_FLAG_NAME(NO_SCHED), -}; -#undef HCTX_FLAG_NAME - static int hctx_flags_show(void *data, struct seq_file *m) { struct blk_mq_hw_ctx *hctx = data; @@ -229,75 +172,6 @@ static int hctx_flags_show(void *data, struct seq_file *m) return 0; } -#define REQ_OP_NAME(name) [REQ_OP_##name] = #name -static const char *const op_name[] = { - REQ_OP_NAME(READ), - REQ_OP_NAME(WRITE), - REQ_OP_NAME(FLUSH), - REQ_OP_NAME(DISCARD), - REQ_OP_NAME(ZONE_REPORT), - REQ_OP_NAME(SECURE_ERASE), - REQ_OP_NAME(ZONE_RESET), - REQ_OP_NAME(WRITE_SAME), - REQ_OP_NAME(WRITE_ZEROES), - REQ_OP_NAME(SCSI_IN), - REQ_OP_NAME(SCSI_OUT), - REQ_OP_NAME(DRV_IN), - REQ_OP_NAME(DRV_OUT), -}; -#undef REQ_OP_NAME - -#define CMD_FLAG_NAME(name) [__REQ_##name] = #name -static const char *const cmd_flag_name[] = { - CMD_FLAG_NAME(FAILFAST_DEV), - CMD_FLAG_NAME(FAILFAST_TRANSPORT), - CMD_FLAG_NAME(FAILFAST_DRIVER), - CMD_FLAG_NAME(SYNC), - CMD_FLAG_NAME(META), - CMD_FLAG_NAME(PRIO), - CMD_FLAG_NAME(NOMERGE), - CMD_FLAG_NAME(IDLE), - CMD_FLAG_NAME(INTEGRITY), - CMD_FLAG_NAME(FUA), - CMD_FLAG_NAME(PREFLUSH), - CMD_FLAG_NAME(RAHEAD), - CMD_FLAG_NAME(BACKGROUND), - CMD_FLAG_NAME(NOUNMAP), -}; -#undef CMD_FLAG_NAME - -#define RQF_NAME(name) [ilog2((__force u32)RQF_##name)] = #name -static const char *const rqf_name[] = { - RQF_NAME(SORTED), - RQF_NAME(STARTED), - RQF_NAME(QUEUED), - RQF_NAME(SOFTBARRIER), - RQF_NAME(FLUSH_SEQ), - RQF_NAME(MIXED_MERGE), - RQF_NAME(MQ_INFLIGHT), - RQF_NAME(DONTPREP), - RQF_NAME(PREEMPT), - RQF_NAME(COPY_USER), - RQF_NAME(FAILED), - RQF_NAME(QUIET), - RQF_NAME(ELVPRIV), - RQF_NAME(IO_STAT), - RQF_NAME(ALLOCED), - RQF_NAME(PM), - RQF_NAME(HASHED), - RQF_NAME(STATS), - RQF_NAME(SPECIAL_PAYLOAD), -}; -#undef RQF_NAME - -#define RQAF_NAME(name) [REQ_ATOM_##name] = #name -static const char *const rqaf_name[] = { - RQAF_NAME(COMPLETE), - RQAF_NAME(STARTED), - RQAF_NAME(POLL_SLEPT), -}; -#undef RQAF_NAME - int __blk_mq_debugfs_rq_show(struct seq_file *m, struct request *rq) { const struct blk_mq_ops *const mq_ops = rq->q->mq_ops;