summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGang He <ghe@suse.com>2019-07-11 23:53:05 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2019-07-12 14:05:41 -0400
commit8056773ac4b42f36bae6406030218a5f12749c64 (patch)
tree1b1056870238577f5c65334b21f774edf8424494
parent8a7f5f4c26dd4e969b5f3b30d06c54dc6a520eda (diff)
ocfs2: add locking filter debugfs file
Add locking filter debugfs file, which is used to filter lock resources dump from locking_state debugfs file. We use d_filter_secs field to filter lock resources dump, the default d_filter_secs(0) value filters nothing, otherwise, only dump the last N seconds active lock resources. This enhancement can avoid dumping lots of old records. The d_filter_secs value can be changed via locking_filter file. [akpm@linux-foundation.org: fix undefined reference to `__udivdi3'] Link: http://lkml.kernel.org/r/20190611015414.27754-2-ghe@suse.com Signed-off-by: Gang He <ghe@suse.com> Reviewed-by: Joseph Qi <joseph.qi@linux.alibaba.com> Acked-by: Randy Dunlap <rdunlap@infradead.org> [build-tested] Cc: Mark Fasheh <mark@fasheh.com> Cc: Joel Becker <jlbec@evilplan.org> Cc: Junxiao Bi <junxiao.bi@oracle.com> Cc: Changwei Ge <gechangwei@live.cn> Cc: Gang He <ghe@suse.com> Cc: Jun Piao <piaojun@huawei.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--fs/ocfs2/dlmglue.c38
-rw-r--r--fs/ocfs2/ocfs2.h2
2 files changed, 40 insertions, 0 deletions
diff --git a/fs/ocfs2/dlmglue.c b/fs/ocfs2/dlmglue.c
index 5f696be267e7..4089daba4c6f 100644
--- a/fs/ocfs2/dlmglue.c
+++ b/fs/ocfs2/dlmglue.c
@@ -2991,6 +2991,8 @@ struct ocfs2_dlm_debug *ocfs2_new_dlm_debug(void)
2991 kref_init(&dlm_debug->d_refcnt); 2991 kref_init(&dlm_debug->d_refcnt);
2992 INIT_LIST_HEAD(&dlm_debug->d_lockres_tracking); 2992 INIT_LIST_HEAD(&dlm_debug->d_lockres_tracking);
2993 dlm_debug->d_locking_state = NULL; 2993 dlm_debug->d_locking_state = NULL;
2994 dlm_debug->d_locking_filter = NULL;
2995 dlm_debug->d_filter_secs = 0;
2994out: 2996out:
2995 return dlm_debug; 2997 return dlm_debug;
2996} 2998}
@@ -3090,10 +3092,34 @@ static int ocfs2_dlm_seq_show(struct seq_file *m, void *v)
3090 int i; 3092 int i;
3091 char *lvb; 3093 char *lvb;
3092 struct ocfs2_lock_res *lockres = v; 3094 struct ocfs2_lock_res *lockres = v;
3095#ifdef CONFIG_OCFS2_FS_STATS
3096 u64 now, last;
3097 struct ocfs2_dlm_debug *dlm_debug =
3098 ((struct ocfs2_dlm_seq_priv *)m->private)->p_dlm_debug;
3099#endif
3093 3100
3094 if (!lockres) 3101 if (!lockres)
3095 return -EINVAL; 3102 return -EINVAL;
3096 3103
3104#ifdef CONFIG_OCFS2_FS_STATS
3105 if (dlm_debug->d_filter_secs) {
3106 now = ktime_to_us(ktime_get_real());
3107 if (lockres->l_lock_prmode.ls_last >
3108 lockres->l_lock_exmode.ls_last)
3109 last = lockres->l_lock_prmode.ls_last;
3110 else
3111 last = lockres->l_lock_exmode.ls_last;
3112 /*
3113 * Use d_filter_secs field to filter lock resources dump,
3114 * the default d_filter_secs(0) value filters nothing,
3115 * otherwise, only dump the last N seconds active lock
3116 * resources.
3117 */
3118 if (div_u64(now - last, 1000000) > dlm_debug->d_filter_secs)
3119 return 0;
3120 }
3121#endif
3122
3097 seq_printf(m, "0x%x\t", OCFS2_DLM_DEBUG_STR_VERSION); 3123 seq_printf(m, "0x%x\t", OCFS2_DLM_DEBUG_STR_VERSION);
3098 3124
3099 if (lockres->l_type == OCFS2_LOCK_TYPE_DENTRY) 3125 if (lockres->l_type == OCFS2_LOCK_TYPE_DENTRY)
@@ -3243,6 +3269,17 @@ static int ocfs2_dlm_init_debug(struct ocfs2_super *osb)
3243 goto out; 3269 goto out;
3244 } 3270 }
3245 3271
3272 dlm_debug->d_locking_filter = debugfs_create_u32("locking_filter",
3273 0600,
3274 osb->osb_debug_root,
3275 &dlm_debug->d_filter_secs);
3276 if (!dlm_debug->d_locking_filter) {
3277 ret = -EINVAL;
3278 mlog(ML_ERROR,
3279 "Unable to create locking filter debugfs file.\n");
3280 goto out;
3281 }
3282
3246 ocfs2_get_dlm_debug(dlm_debug); 3283 ocfs2_get_dlm_debug(dlm_debug);
3247out: 3284out:
3248 return ret; 3285 return ret;
@@ -3254,6 +3291,7 @@ static void ocfs2_dlm_shutdown_debug(struct ocfs2_super *osb)
3254 3291
3255 if (dlm_debug) { 3292 if (dlm_debug) {
3256 debugfs_remove(dlm_debug->d_locking_state); 3293 debugfs_remove(dlm_debug->d_locking_state);
3294 debugfs_remove(dlm_debug->d_locking_filter);
3257 ocfs2_put_dlm_debug(dlm_debug); 3295 ocfs2_put_dlm_debug(dlm_debug);
3258 } 3296 }
3259} 3297}
diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h
index 5c111eabaa1d..c7539601555b 100644
--- a/fs/ocfs2/ocfs2.h
+++ b/fs/ocfs2/ocfs2.h
@@ -223,6 +223,8 @@ struct ocfs2_orphan_scan {
223struct ocfs2_dlm_debug { 223struct ocfs2_dlm_debug {
224 struct kref d_refcnt; 224 struct kref d_refcnt;
225 struct dentry *d_locking_state; 225 struct dentry *d_locking_state;
226 struct dentry *d_locking_filter;
227 u32 d_filter_secs;
226 struct list_head d_lockres_tracking; 228 struct list_head d_lockres_tracking;
227}; 229};
228 230