Skip to content

Commit 8056773

Browse files
Gang Hetorvalds
authored andcommitted
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. [[email protected]: fix undefined reference to `__udivdi3'] Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Gang He <[email protected]> Reviewed-by: Joseph Qi <[email protected]> Acked-by: Randy Dunlap <[email protected]> [build-tested] Cc: Mark Fasheh <[email protected]> Cc: Joel Becker <[email protected]> Cc: Junxiao Bi <[email protected]> Cc: Changwei Ge <[email protected]> Cc: Gang He <[email protected]> Cc: Jun Piao <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 8a7f5f4 commit 8056773

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

fs/ocfs2/dlmglue.c

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2991,6 +2991,8 @@ struct ocfs2_dlm_debug *ocfs2_new_dlm_debug(void)
29912991
kref_init(&dlm_debug->d_refcnt);
29922992
INIT_LIST_HEAD(&dlm_debug->d_lockres_tracking);
29932993
dlm_debug->d_locking_state = NULL;
2994+
dlm_debug->d_locking_filter = NULL;
2995+
dlm_debug->d_filter_secs = 0;
29942996
out:
29952997
return dlm_debug;
29962998
}
@@ -3090,10 +3092,34 @@ static int ocfs2_dlm_seq_show(struct seq_file *m, void *v)
30903092
int i;
30913093
char *lvb;
30923094
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
30933100

30943101
if (!lockres)
30953102
return -EINVAL;
30963103

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+
30973123
seq_printf(m, "0x%x\t", OCFS2_DLM_DEBUG_STR_VERSION);
30983124

30993125
if (lockres->l_type == OCFS2_LOCK_TYPE_DENTRY)
@@ -3243,6 +3269,17 @@ static int ocfs2_dlm_init_debug(struct ocfs2_super *osb)
32433269
goto out;
32443270
}
32453271

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+
32463283
ocfs2_get_dlm_debug(dlm_debug);
32473284
out:
32483285
return ret;
@@ -3254,6 +3291,7 @@ static void ocfs2_dlm_shutdown_debug(struct ocfs2_super *osb)
32543291

32553292
if (dlm_debug) {
32563293
debugfs_remove(dlm_debug->d_locking_state);
3294+
debugfs_remove(dlm_debug->d_locking_filter);
32573295
ocfs2_put_dlm_debug(dlm_debug);
32583296
}
32593297
}

fs/ocfs2/ocfs2.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,8 @@ struct ocfs2_orphan_scan {
223223
struct ocfs2_dlm_debug {
224224
struct kref d_refcnt;
225225
struct dentry *d_locking_state;
226+
struct dentry *d_locking_filter;
227+
u32 d_filter_secs;
226228
struct list_head d_lockres_tracking;
227229
};
228230

0 commit comments

Comments
 (0)