diff options
author | Sunil Mushran <sunil.mushran@oracle.com> | 2008-03-10 18:16:27 -0400 |
---|---|---|
committer | Mark Fasheh <mfasheh@suse.com> | 2008-04-18 11:56:09 -0400 |
commit | 7209300a9b987e017cae2ef9d7ef55b0fdd71869 (patch) | |
tree | 928002c58079dc53846248c7c91c293432dfdf8c /fs/ocfs2/dlm/dlmdebug.c | |
parent | d0129aceaecc2b1f5171b8e8036eb469b6e0fe81 (diff) |
ocfs2/dlm: Dumps the purgelist into a debugfs file
This patch dumps all the lockres' on the purgelist it can fit in one page
into a debugfs file. Useful for debugging.
Signed-off-by: Sunil Mushran <sunil.mushran@oracle.com>
Signed-off-by: Joel Becker <joel.becker@oracle.com>
Signed-off-by: Mark Fasheh <mfasheh@suse.com>
Diffstat (limited to 'fs/ocfs2/dlm/dlmdebug.c')
-rw-r--r-- | fs/ocfs2/dlm/dlmdebug.c | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/fs/ocfs2/dlm/dlmdebug.c b/fs/ocfs2/dlm/dlmdebug.c index 6de326bf603a..a109005f70da 100644 --- a/fs/ocfs2/dlm/dlmdebug.c +++ b/fs/ocfs2/dlm/dlmdebug.c | |||
@@ -303,6 +303,7 @@ static int stringify_lockname(const char *lockname, int locklen, | |||
303 | #define DLM_DEBUGFS_DLM_STATE "dlm_state" | 303 | #define DLM_DEBUGFS_DLM_STATE "dlm_state" |
304 | #define DLM_DEBUGFS_LOCKING_STATE "locking_state" | 304 | #define DLM_DEBUGFS_LOCKING_STATE "locking_state" |
305 | #define DLM_DEBUGFS_MLE_STATE "mle_state" | 305 | #define DLM_DEBUGFS_MLE_STATE "mle_state" |
306 | #define DLM_DEBUGFS_PURGE_LIST "purge_list" | ||
306 | 307 | ||
307 | /* begin - utils funcs */ | 308 | /* begin - utils funcs */ |
308 | static void dlm_debug_free(struct kref *kref) | 309 | static void dlm_debug_free(struct kref *kref) |
@@ -396,6 +397,63 @@ static int debug_buffer_release(struct inode *inode, struct file *file) | |||
396 | } | 397 | } |
397 | /* end - util funcs */ | 398 | /* end - util funcs */ |
398 | 399 | ||
400 | /* begin - purge list funcs */ | ||
401 | static int debug_purgelist_print(struct dlm_ctxt *dlm, struct debug_buffer *db) | ||
402 | { | ||
403 | struct dlm_lock_resource *res; | ||
404 | int out = 0; | ||
405 | unsigned long total = 0; | ||
406 | |||
407 | out += snprintf(db->buf + out, db->len - out, | ||
408 | "Dumping Purgelist for Domain: %s\n", dlm->name); | ||
409 | |||
410 | spin_lock(&dlm->spinlock); | ||
411 | list_for_each_entry(res, &dlm->purge_list, purge) { | ||
412 | ++total; | ||
413 | if (db->len - out < 100) | ||
414 | continue; | ||
415 | spin_lock(&res->spinlock); | ||
416 | out += stringify_lockname(res->lockname.name, | ||
417 | res->lockname.len, | ||
418 | db->buf + out, db->len - out); | ||
419 | out += snprintf(db->buf + out, db->len - out, "\t%ld\n", | ||
420 | (jiffies - res->last_used)/HZ); | ||
421 | spin_unlock(&res->spinlock); | ||
422 | } | ||
423 | spin_unlock(&dlm->spinlock); | ||
424 | |||
425 | out += snprintf(db->buf + out, db->len - out, | ||
426 | "Total on list: %ld\n", total); | ||
427 | |||
428 | return out; | ||
429 | } | ||
430 | |||
431 | static int debug_purgelist_open(struct inode *inode, struct file *file) | ||
432 | { | ||
433 | struct dlm_ctxt *dlm = inode->i_private; | ||
434 | struct debug_buffer *db; | ||
435 | |||
436 | db = debug_buffer_allocate(); | ||
437 | if (!db) | ||
438 | goto bail; | ||
439 | |||
440 | db->len = debug_purgelist_print(dlm, db); | ||
441 | |||
442 | file->private_data = db; | ||
443 | |||
444 | return 0; | ||
445 | bail: | ||
446 | return -ENOMEM; | ||
447 | } | ||
448 | |||
449 | static struct file_operations debug_purgelist_fops = { | ||
450 | .open = debug_purgelist_open, | ||
451 | .release = debug_buffer_release, | ||
452 | .read = debug_buffer_read, | ||
453 | .llseek = debug_buffer_llseek, | ||
454 | }; | ||
455 | /* end - purge list funcs */ | ||
456 | |||
399 | /* begin - debug mle funcs */ | 457 | /* begin - debug mle funcs */ |
400 | static int dump_mle(struct dlm_master_list_entry *mle, char *buf, int len) | 458 | static int dump_mle(struct dlm_master_list_entry *mle, char *buf, int len) |
401 | { | 459 | { |
@@ -906,6 +964,17 @@ int dlm_debug_init(struct dlm_ctxt *dlm) | |||
906 | goto bail; | 964 | goto bail; |
907 | } | 965 | } |
908 | 966 | ||
967 | /* for dumping lockres on the purge list */ | ||
968 | dc->debug_purgelist_dentry = | ||
969 | debugfs_create_file(DLM_DEBUGFS_PURGE_LIST, | ||
970 | S_IFREG|S_IRUSR, | ||
971 | dlm->dlm_debugfs_subroot, | ||
972 | dlm, &debug_purgelist_fops); | ||
973 | if (!dc->debug_purgelist_dentry) { | ||
974 | mlog_errno(-ENOMEM); | ||
975 | goto bail; | ||
976 | } | ||
977 | |||
909 | dlm_debug_get(dc); | 978 | dlm_debug_get(dc); |
910 | return 0; | 979 | return 0; |
911 | 980 | ||
@@ -919,6 +988,8 @@ void dlm_debug_shutdown(struct dlm_ctxt *dlm) | |||
919 | struct dlm_debug_ctxt *dc = dlm->dlm_debug_ctxt; | 988 | struct dlm_debug_ctxt *dc = dlm->dlm_debug_ctxt; |
920 | 989 | ||
921 | if (dc) { | 990 | if (dc) { |
991 | if (dc->debug_purgelist_dentry) | ||
992 | debugfs_remove(dc->debug_purgelist_dentry); | ||
922 | if (dc->debug_mle_dentry) | 993 | if (dc->debug_mle_dentry) |
923 | debugfs_remove(dc->debug_mle_dentry); | 994 | debugfs_remove(dc->debug_mle_dentry); |
924 | if (dc->debug_lockres_dentry) | 995 | if (dc->debug_lockres_dentry) |