diff options
-rw-r--r-- | fs/ocfs2/dlm/dlmdebug.c | 119 | ||||
-rw-r--r-- | fs/ocfs2/dlm/dlmdebug.h | 1 |
2 files changed, 120 insertions, 0 deletions
diff --git a/fs/ocfs2/dlm/dlmdebug.c b/fs/ocfs2/dlm/dlmdebug.c index cccb1ce33723..6de326bf603a 100644 --- a/fs/ocfs2/dlm/dlmdebug.c +++ b/fs/ocfs2/dlm/dlmdebug.c | |||
@@ -302,6 +302,7 @@ static int stringify_lockname(const char *lockname, int locklen, | |||
302 | #define DLM_DEBUGFS_DIR "o2dlm" | 302 | #define DLM_DEBUGFS_DIR "o2dlm" |
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 | 306 | ||
306 | /* begin - utils funcs */ | 307 | /* begin - utils funcs */ |
307 | static void dlm_debug_free(struct kref *kref) | 308 | static void dlm_debug_free(struct kref *kref) |
@@ -395,6 +396,112 @@ static int debug_buffer_release(struct inode *inode, struct file *file) | |||
395 | } | 396 | } |
396 | /* end - util funcs */ | 397 | /* end - util funcs */ |
397 | 398 | ||
399 | /* begin - debug mle funcs */ | ||
400 | static int dump_mle(struct dlm_master_list_entry *mle, char *buf, int len) | ||
401 | { | ||
402 | int out = 0; | ||
403 | unsigned int namelen; | ||
404 | const char *name; | ||
405 | char *mle_type; | ||
406 | |||
407 | if (mle->type != DLM_MLE_MASTER) { | ||
408 | namelen = mle->u.name.len; | ||
409 | name = mle->u.name.name; | ||
410 | } else { | ||
411 | namelen = mle->u.res->lockname.len; | ||
412 | name = mle->u.res->lockname.name; | ||
413 | } | ||
414 | |||
415 | if (mle->type == DLM_MLE_BLOCK) | ||
416 | mle_type = "BLK"; | ||
417 | else if (mle->type == DLM_MLE_MASTER) | ||
418 | mle_type = "MAS"; | ||
419 | else | ||
420 | mle_type = "MIG"; | ||
421 | |||
422 | out += stringify_lockname(name, namelen, buf + out, len - out); | ||
423 | out += snprintf(buf + out, len - out, | ||
424 | "\t%3s\tmas=%3u\tnew=%3u\tevt=%1d\tuse=%1d\tref=%3d\n", | ||
425 | mle_type, mle->master, mle->new_master, | ||
426 | !list_empty(&mle->hb_events), | ||
427 | !!mle->inuse, | ||
428 | atomic_read(&mle->mle_refs.refcount)); | ||
429 | |||
430 | out += snprintf(buf + out, len - out, "Maybe="); | ||
431 | out += stringify_nodemap(mle->maybe_map, O2NM_MAX_NODES, | ||
432 | buf + out, len - out); | ||
433 | out += snprintf(buf + out, len - out, "\n"); | ||
434 | |||
435 | out += snprintf(buf + out, len - out, "Vote="); | ||
436 | out += stringify_nodemap(mle->vote_map, O2NM_MAX_NODES, | ||
437 | buf + out, len - out); | ||
438 | out += snprintf(buf + out, len - out, "\n"); | ||
439 | |||
440 | out += snprintf(buf + out, len - out, "Response="); | ||
441 | out += stringify_nodemap(mle->response_map, O2NM_MAX_NODES, | ||
442 | buf + out, len - out); | ||
443 | out += snprintf(buf + out, len - out, "\n"); | ||
444 | |||
445 | out += snprintf(buf + out, len - out, "Node="); | ||
446 | out += stringify_nodemap(mle->node_map, O2NM_MAX_NODES, | ||
447 | buf + out, len - out); | ||
448 | out += snprintf(buf + out, len - out, "\n"); | ||
449 | |||
450 | out += snprintf(buf + out, len - out, "\n"); | ||
451 | |||
452 | return out; | ||
453 | } | ||
454 | |||
455 | static int debug_mle_print(struct dlm_ctxt *dlm, struct debug_buffer *db) | ||
456 | { | ||
457 | struct dlm_master_list_entry *mle; | ||
458 | int out = 0; | ||
459 | unsigned long total = 0; | ||
460 | |||
461 | out += snprintf(db->buf + out, db->len - out, | ||
462 | "Dumping MLEs for Domain: %s\n", dlm->name); | ||
463 | |||
464 | spin_lock(&dlm->master_lock); | ||
465 | list_for_each_entry(mle, &dlm->master_list, list) { | ||
466 | ++total; | ||
467 | if (db->len - out < 200) | ||
468 | continue; | ||
469 | out += dump_mle(mle, db->buf + out, db->len - out); | ||
470 | } | ||
471 | spin_unlock(&dlm->master_lock); | ||
472 | |||
473 | out += snprintf(db->buf + out, db->len - out, | ||
474 | "Total on list: %ld\n", total); | ||
475 | return out; | ||
476 | } | ||
477 | |||
478 | static int debug_mle_open(struct inode *inode, struct file *file) | ||
479 | { | ||
480 | struct dlm_ctxt *dlm = inode->i_private; | ||
481 | struct debug_buffer *db; | ||
482 | |||
483 | db = debug_buffer_allocate(); | ||
484 | if (!db) | ||
485 | goto bail; | ||
486 | |||
487 | db->len = debug_mle_print(dlm, db); | ||
488 | |||
489 | file->private_data = db; | ||
490 | |||
491 | return 0; | ||
492 | bail: | ||
493 | return -ENOMEM; | ||
494 | } | ||
495 | |||
496 | static struct file_operations debug_mle_fops = { | ||
497 | .open = debug_mle_open, | ||
498 | .release = debug_buffer_release, | ||
499 | .read = debug_buffer_read, | ||
500 | .llseek = debug_buffer_llseek, | ||
501 | }; | ||
502 | |||
503 | /* end - debug mle funcs */ | ||
504 | |||
398 | /* begin - debug lockres funcs */ | 505 | /* begin - debug lockres funcs */ |
399 | static int dump_lock(struct dlm_lock *lock, int list_type, char *buf, int len) | 506 | static int dump_lock(struct dlm_lock *lock, int list_type, char *buf, int len) |
400 | { | 507 | { |
@@ -789,6 +896,16 @@ int dlm_debug_init(struct dlm_ctxt *dlm) | |||
789 | goto bail; | 896 | goto bail; |
790 | } | 897 | } |
791 | 898 | ||
899 | /* for dumping mles */ | ||
900 | dc->debug_mle_dentry = debugfs_create_file(DLM_DEBUGFS_MLE_STATE, | ||
901 | S_IFREG|S_IRUSR, | ||
902 | dlm->dlm_debugfs_subroot, | ||
903 | dlm, &debug_mle_fops); | ||
904 | if (!dc->debug_mle_dentry) { | ||
905 | mlog_errno(-ENOMEM); | ||
906 | goto bail; | ||
907 | } | ||
908 | |||
792 | dlm_debug_get(dc); | 909 | dlm_debug_get(dc); |
793 | return 0; | 910 | return 0; |
794 | 911 | ||
@@ -802,6 +919,8 @@ void dlm_debug_shutdown(struct dlm_ctxt *dlm) | |||
802 | struct dlm_debug_ctxt *dc = dlm->dlm_debug_ctxt; | 919 | struct dlm_debug_ctxt *dc = dlm->dlm_debug_ctxt; |
803 | 920 | ||
804 | if (dc) { | 921 | if (dc) { |
922 | if (dc->debug_mle_dentry) | ||
923 | debugfs_remove(dc->debug_mle_dentry); | ||
805 | if (dc->debug_lockres_dentry) | 924 | if (dc->debug_lockres_dentry) |
806 | debugfs_remove(dc->debug_lockres_dentry); | 925 | debugfs_remove(dc->debug_lockres_dentry); |
807 | if (dc->debug_state_dentry) | 926 | if (dc->debug_state_dentry) |
diff --git a/fs/ocfs2/dlm/dlmdebug.h b/fs/ocfs2/dlm/dlmdebug.h index 7c5b2b0a05ed..cbc69f295782 100644 --- a/fs/ocfs2/dlm/dlmdebug.h +++ b/fs/ocfs2/dlm/dlmdebug.h | |||
@@ -31,6 +31,7 @@ struct dlm_debug_ctxt { | |||
31 | struct kref debug_refcnt; | 31 | struct kref debug_refcnt; |
32 | struct dentry *debug_state_dentry; | 32 | struct dentry *debug_state_dentry; |
33 | struct dentry *debug_lockres_dentry; | 33 | struct dentry *debug_lockres_dentry; |
34 | struct dentry *debug_mle_dentry; | ||
34 | }; | 35 | }; |
35 | 36 | ||
36 | struct debug_buffer { | 37 | struct debug_buffer { |