Skip to content

Commit 8a7f5f4

Browse files
Gang Hetorvalds
authored andcommitted
ocfs2: add last unlock times in locking_state
ocfs2 file system uses locking_state file under debugfs to dump each ocfs2 file system's dlm lock resources, but the dlm lock resources in memory are becoming more and more after the files were touched by the user. it will become a bit difficult to analyze these dlm lock resource records in locking_state file by the upper scripts, though some files are not active for now, which were accessed long time ago. Then, I'd like to add last pr/ex unlock times in locking_state file for each dlm lock resource record, the the upper scripts can use last unlock time to filter inactive dlm lock resource record. Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Gang He <[email protected]> Reviewed-by: Joseph Qi <[email protected]> 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 0e71666 commit 8a7f5f4

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

fs/ocfs2/dlmglue.c

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,8 @@ static void ocfs2_update_lock_stats(struct ocfs2_lock_res *res, int level,
460460

461461
if (ret)
462462
stats->ls_fail++;
463+
464+
stats->ls_last = ktime_to_us(ktime_get_real());
463465
}
464466

465467
static inline void ocfs2_track_lock_refresh(struct ocfs2_lock_res *lockres)
@@ -3079,8 +3081,10 @@ static void *ocfs2_dlm_seq_next(struct seq_file *m, void *v, loff_t *pos)
30793081
* - Lock stats printed
30803082
* New in version 3
30813083
* - Max time in lock stats is in usecs (instead of nsecs)
3084+
* New in version 4
3085+
* - Add last pr/ex unlock times in usecs
30823086
*/
3083-
#define OCFS2_DLM_DEBUG_STR_VERSION 3
3087+
#define OCFS2_DLM_DEBUG_STR_VERSION 4
30843088
static int ocfs2_dlm_seq_show(struct seq_file *m, void *v)
30853089
{
30863090
int i;
@@ -3131,6 +3135,8 @@ static int ocfs2_dlm_seq_show(struct seq_file *m, void *v)
31313135
# define lock_max_prmode(_l) ((_l)->l_lock_prmode.ls_max)
31323136
# define lock_max_exmode(_l) ((_l)->l_lock_exmode.ls_max)
31333137
# define lock_refresh(_l) ((_l)->l_lock_refresh)
3138+
# define lock_last_prmode(_l) ((_l)->l_lock_prmode.ls_last)
3139+
# define lock_last_exmode(_l) ((_l)->l_lock_exmode.ls_last)
31343140
#else
31353141
# define lock_num_prmode(_l) (0)
31363142
# define lock_num_exmode(_l) (0)
@@ -3141,6 +3147,8 @@ static int ocfs2_dlm_seq_show(struct seq_file *m, void *v)
31413147
# define lock_max_prmode(_l) (0)
31423148
# define lock_max_exmode(_l) (0)
31433149
# define lock_refresh(_l) (0)
3150+
# define lock_last_prmode(_l) (0ULL)
3151+
# define lock_last_exmode(_l) (0ULL)
31443152
#endif
31453153
/* The following seq_print was added in version 2 of this output */
31463154
seq_printf(m, "%u\t"
@@ -3151,7 +3159,9 @@ static int ocfs2_dlm_seq_show(struct seq_file *m, void *v)
31513159
"%llu\t"
31523160
"%u\t"
31533161
"%u\t"
3154-
"%u\t",
3162+
"%u\t"
3163+
"%llu\t"
3164+
"%llu\t",
31553165
lock_num_prmode(lockres),
31563166
lock_num_exmode(lockres),
31573167
lock_num_prmode_failed(lockres),
@@ -3160,7 +3170,9 @@ static int ocfs2_dlm_seq_show(struct seq_file *m, void *v)
31603170
lock_total_exmode(lockres),
31613171
lock_max_prmode(lockres),
31623172
lock_max_exmode(lockres),
3163-
lock_refresh(lockres));
3173+
lock_refresh(lockres),
3174+
lock_last_prmode(lockres),
3175+
lock_last_exmode(lockres));
31643176

31653177
/* End the line */
31663178
seq_printf(m, "\n");

fs/ocfs2/ocfs2.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ struct ocfs2_lock_stats {
150150

151151
/* Storing max wait in usecs saves 24 bytes per inode */
152152
u32 ls_max; /* Max wait in USEC */
153+
u64 ls_last; /* Last unlock time in USEC */
153154
};
154155
#endif
155156

0 commit comments

Comments
 (0)