From: James Simmons <jsimmons@infradead.org>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
devel@driverdev.osuosl.org,
Andreas Dilger <andreas.dilger@intel.com>,
Oleg Drokin <oleg.drokin@intel.com>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Lustre Development List <lustre-devel@lists.lustre.org>,
Jinshan Xiong <jinshan.xiong@intel.com>,
James Simmons <jsimmons@infradead.org>
Subject: [PATCH 04/18] staging: lustre: libcfs: create array of debug names
Date: Mon, 4 Apr 2016 21:36:49 -0400 [thread overview]
Message-ID: <1459820223-24754-5-git-send-email-jsimmons@infradead.org> (raw)
In-Reply-To: <1459820223-24754-1-git-send-email-jsimmons@infradead.org>
From: Jinshan Xiong <jinshan.xiong@intel.com>
Instead of a using a growing case statement to handle
more debugging options create a array to map debug
flags to string names.
Signed-off-by: Jinshan Xiong <jinshan.xiong@intel.com>
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-3647
Reviewed-on: http://review.whamcloud.com/7243
Reviewed-by: John L. Hammond <john.hammond@intel.com>
Reviewed-by: jacques-Charles Lafoucriere <jacques-charles.lafoucriere@cea.fr>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
---
.../lustre/include/linux/libcfs/libcfs_debug.h | 13 ++
drivers/staging/lustre/lnet/libcfs/debug.c | 126 ++------------------
2 files changed, 23 insertions(+), 116 deletions(-)
diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h
index 7472a31..5e60c6f 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h
@@ -118,6 +118,12 @@ struct ptldebug_header {
#define S_FID 0x40000000 /* b_new_cmd */
#define S_FLD 0x80000000 /* b_new_cmd */
+#define LIBCFS_DEBUG_SUBSYS_NAMES { \
+ "undefined", "mdc", "mds", "osc", "ost", "class", "log", \
+ "llite", "rpc", "mgmt", "lnet", "lnd", "pinger", "filter", "", \
+ "echo", "ldlm", "lov", "lquota", "osd", "lfsck", "", "", "lmv", \
+ "", "sec", "gss", "", "mgc", "mgs", "fid", "fld", NULL }
+
/* Debugging masks (32 bits, non-overlapping) */
#define D_TRACE 0x00000001 /* ENTRY/EXIT markers */
#define D_INODE 0x00000002
@@ -151,6 +157,13 @@ struct ptldebug_header {
#define D_HSM D_TRACE
+#define LIBCFS_DEBUG_MASKS_NAMES { \
+ "trace", "inode", "super", "ext2", "malloc", "cache", "info", \
+ "ioctl", "neterror", "net", "warning", "buffs", "other", \
+ "dentry", "nettrace", "page", "dlmtrace", "error", "emerg", \
+ "ha", "rpctrace", "vfstrace", "reada", "mmap", "config", \
+ "console", "quota", "sec", "lfsck", "hsm", NULL }
+
#define D_CANTMASK (D_ERROR | D_EMERG | D_WARNING | D_CONSOLE)
#ifndef DEBUG_SUBSYSTEM
diff --git a/drivers/staging/lustre/lnet/libcfs/debug.c b/drivers/staging/lustre/lnet/libcfs/debug.c
index c90e510..4753c32 100644
--- a/drivers/staging/lustre/lnet/libcfs/debug.c
+++ b/drivers/staging/lustre/lnet/libcfs/debug.c
@@ -232,130 +232,24 @@ int libcfs_panic_in_progress;
static const char *
libcfs_debug_subsys2str(int subsys)
{
- switch (1 << subsys) {
- default:
+ static const char *libcfs_debug_subsystems[] = LIBCFS_DEBUG_SUBSYS_NAMES;
+
+ if (subsys >= ARRAY_SIZE(libcfs_debug_subsystems))
return NULL;
- case S_UNDEFINED:
- return "undefined";
- case S_MDC:
- return "mdc";
- case S_MDS:
- return "mds";
- case S_OSC:
- return "osc";
- case S_OST:
- return "ost";
- case S_CLASS:
- return "class";
- case S_LOG:
- return "log";
- case S_LLITE:
- return "llite";
- case S_RPC:
- return "rpc";
- case S_LNET:
- return "lnet";
- case S_LND:
- return "lnd";
- case S_PINGER:
- return "pinger";
- case S_FILTER:
- return "filter";
- case S_ECHO:
- return "echo";
- case S_LDLM:
- return "ldlm";
- case S_LOV:
- return "lov";
- case S_LQUOTA:
- return "lquota";
- case S_OSD:
- return "osd";
- case S_LFSCK:
- return "lfsck";
- case S_LMV:
- return "lmv";
- case S_SEC:
- return "sec";
- case S_GSS:
- return "gss";
- case S_MGC:
- return "mgc";
- case S_MGS:
- return "mgs";
- case S_FID:
- return "fid";
- case S_FLD:
- return "fld";
- }
+
+ return libcfs_debug_subsystems[subsys];
}
/* libcfs_debug_token2mask() expects the returned string in lower-case */
static const char *
libcfs_debug_dbg2str(int debug)
{
- switch (1 << debug) {
- default:
+ static const char *libcfs_debug_masks[] = LIBCFS_DEBUG_MASKS_NAMES;
+
+ if (debug >= ARRAY_SIZE(libcfs_debug_masks))
return NULL;
- case D_TRACE:
- return "trace";
- case D_INODE:
- return "inode";
- case D_SUPER:
- return "super";
- case D_EXT2:
- return "ext2";
- case D_MALLOC:
- return "malloc";
- case D_CACHE:
- return "cache";
- case D_INFO:
- return "info";
- case D_IOCTL:
- return "ioctl";
- case D_NETERROR:
- return "neterror";
- case D_NET:
- return "net";
- case D_WARNING:
- return "warning";
- case D_BUFFS:
- return "buffs";
- case D_OTHER:
- return "other";
- case D_DENTRY:
- return "dentry";
- case D_NETTRACE:
- return "nettrace";
- case D_PAGE:
- return "page";
- case D_DLMTRACE:
- return "dlmtrace";
- case D_ERROR:
- return "error";
- case D_EMERG:
- return "emerg";
- case D_HA:
- return "ha";
- case D_RPCTRACE:
- return "rpctrace";
- case D_VFSTRACE:
- return "vfstrace";
- case D_READA:
- return "reada";
- case D_MMAP:
- return "mmap";
- case D_CONFIG:
- return "config";
- case D_CONSOLE:
- return "console";
- case D_QUOTA:
- return "quota";
- case D_SEC:
- return "sec";
- case D_LFSCK:
- return "lfsck";
- }
+
+ return libcfs_debug_masks[debug];
}
int
--
1.7.1
next prev parent reply other threads:[~2016-04-05 1:39 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-05 1:36 [PATCH 00/18] fill in missing patches present in 2.4.92 version James Simmons
2016-04-05 1:36 ` [PATCH 01/18] staging: lustre: ldlm: fix 'deadcode' errors James Simmons
2016-04-05 1:36 ` [PATCH 02/18] staging: lustre: llite: use 64bits flags in ll_lov_setea() James Simmons
2016-04-05 1:36 ` [PATCH 03/18] staging: lustre: libcfs: remove userland comments in libcfs_debug.h James Simmons
2016-04-05 1:36 ` James Simmons [this message]
2016-04-05 1:36 ` [PATCH 05/18] staging: lustre: libcfs: make D_HSM a unique value James Simmons
2016-04-05 1:36 ` [PATCH 06/18] staging: lustre: hsm: Fix lu_ref for lease handle James Simmons
2016-04-05 1:36 ` [PATCH 07/18] staging: lustre: hsm: rename hai_zero() HSM function James Simmons
2016-04-05 1:36 ` [PATCH 08/18] staging: lustre: hsm: copy start error should set HP_FLAG_COMPLETED James Simmons
2016-04-05 1:36 ` [PATCH 09/18] staging: lustre: lov: Get the correct address of lmm_objects James Simmons
2016-04-05 1:36 ` [PATCH 10/18] staging: lustre: llite: reset writeback index in ll_writepages James Simmons
2016-04-05 1:36 ` [PATCH 11/18] staging: lustre: llite: Delaying creation of client side proc entries James Simmons
2016-04-05 1:36 ` [PATCH 12/18] staging: lustre: mdc: document mdc_rpc_lock James Simmons
2016-04-05 1:36 ` [PATCH 13/18] staging: lustre: hsm: Add CLF_RENAME_LAST flag James Simmons
2016-04-05 1:36 ` [PATCH 14/18] staging: lustre: fix 'NULL pointer dereference' errors James Simmons
2016-04-05 1:37 ` [PATCH 15/18] staging: lustre: llite: cancel open lock before closing file James Simmons
2016-04-05 1:37 ` [PATCH 16/18] staging: lustre: hsm: Add support to drop all pages for ll_data_version James Simmons
2016-04-05 1:37 ` [PATCH 17/18] staging: lustre: fix 'no effect' errors James Simmons
2016-04-05 1:37 ` [PATCH 18/18] staging: lustre: osc: Lustre returns EINTR from writes when SA_RESTART is set James Simmons
2016-04-12 3:54 ` Greg Kroah-Hartman
2016-04-12 17:21 ` James Simmons
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1459820223-24754-5-git-send-email-jsimmons@infradead.org \
--to=jsimmons@infradead.org \
--cc=andreas.dilger@intel.com \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@linuxfoundation.org \
--cc=jinshan.xiong@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lustre-devel@lists.lustre.org \
--cc=oleg.drokin@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®