@@ -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 ;
29942996out :
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 );
32473284out :
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}
0 commit comments