]> err.no Git - linux-2.6/blobdiff - fs/ocfs2/dlm/dlmdebug.c
Merge branch 'core/rodata' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux...
[linux-2.6] / fs / ocfs2 / dlm / dlmdebug.c
index e335403800134f311a00409c0d63fb9c77e7aa31..1b81dcba175d083ba5cefad5178c2c1a8a3ef271 100644 (file)
@@ -5,7 +5,7 @@
  *
  * debug functionality for the dlm
  *
- * Copyright (C) 2004 Oracle.  All rights reserved.
+ * Copyright (C) 2004, 2008 Oracle.  All rights reserved.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public
 #define MLOG_MASK_PREFIX ML_DLM
 #include "cluster/masklog.h"
 
+static int stringify_lockname(const char *lockname, int locklen, char *buf,
+                             int len);
+
 void dlm_print_one_lock_resource(struct dlm_lock_resource *res)
 {
-       mlog(ML_NOTICE, "lockres: %.*s, owner=%u, state=%u\n",
-              res->lockname.len, res->lockname.name,
-              res->owner, res->state);
        spin_lock(&res->spinlock);
        __dlm_print_one_lock_resource(res);
        spin_unlock(&res->spinlock);
@@ -59,7 +59,7 @@ static void dlm_print_lockres_refmap(struct dlm_lock_resource *res)
        int bit;
        assert_spin_locked(&res->spinlock);
 
-       mlog(ML_NOTICE, "  refmap nodes: [ ");
+       printk("  refmap nodes: [ ");
        bit = 0;
        while (1) {
                bit = find_next_bit(res->refmap, O2NM_MAX_NODES, bit);
@@ -71,63 +71,66 @@ static void dlm_print_lockres_refmap(struct dlm_lock_resource *res)
        printk("], inflight=%u\n", res->inflight_locks);
 }
 
+static void __dlm_print_lock(struct dlm_lock *lock)
+{
+       spin_lock(&lock->spinlock);
+
+       printk("    type=%d, conv=%d, node=%u, cookie=%u:%llu, "
+              "ref=%u, ast=(empty=%c,pend=%c), bast=(empty=%c,pend=%c), "
+              "pending=(conv=%c,lock=%c,cancel=%c,unlock=%c)\n",
+              lock->ml.type, lock->ml.convert_type, lock->ml.node,
+              dlm_get_lock_cookie_node(be64_to_cpu(lock->ml.cookie)),
+              dlm_get_lock_cookie_seq(be64_to_cpu(lock->ml.cookie)),
+              atomic_read(&lock->lock_refs.refcount),
+              (list_empty(&lock->ast_list) ? 'y' : 'n'),
+              (lock->ast_pending ? 'y' : 'n'),
+              (list_empty(&lock->bast_list) ? 'y' : 'n'),
+              (lock->bast_pending ? 'y' : 'n'),
+              (lock->convert_pending ? 'y' : 'n'),
+              (lock->lock_pending ? 'y' : 'n'),
+              (lock->cancel_pending ? 'y' : 'n'),
+              (lock->unlock_pending ? 'y' : 'n'));
+
+       spin_unlock(&lock->spinlock);
+}
+
 void __dlm_print_one_lock_resource(struct dlm_lock_resource *res)
 {
        struct list_head *iter2;
        struct dlm_lock *lock;
+       char buf[DLM_LOCKID_NAME_MAX];
 
        assert_spin_locked(&res->spinlock);
 
-       mlog(ML_NOTICE, "lockres: %.*s, owner=%u, state=%u\n",
-              res->lockname.len, res->lockname.name,
-              res->owner, res->state);
-       mlog(ML_NOTICE, "  last used: %lu, on purge list: %s\n",
-            res->last_used, list_empty(&res->purge) ? "no" : "yes");
+       stringify_lockname(res->lockname.name, res->lockname.len,
+                          buf, sizeof(buf) - 1);
+       printk("lockres: %s, owner=%u, state=%u\n",
+              buf, res->owner, res->state);
+       printk("  last used: %lu, refcnt: %u, on purge list: %s\n",
+              res->last_used, atomic_read(&res->refs.refcount),
+              list_empty(&res->purge) ? "no" : "yes");
+       printk("  on dirty list: %s, on reco list: %s, "
+              "migrating pending: %s\n",
+              list_empty(&res->dirty) ? "no" : "yes",
+              list_empty(&res->recovering) ? "no" : "yes",
+              res->migration_pending ? "yes" : "no");
+       printk("  inflight locks: %d, asts reserved: %d\n",
+              res->inflight_locks, atomic_read(&res->asts_reserved));
        dlm_print_lockres_refmap(res);
-       mlog(ML_NOTICE, "  granted queue: \n");
+       printk("  granted queue:\n");
        list_for_each(iter2, &res->granted) {
                lock = list_entry(iter2, struct dlm_lock, list);
-               spin_lock(&lock->spinlock);
-               mlog(ML_NOTICE, "    type=%d, conv=%d, node=%u, "
-                      "cookie=%u:%llu, ast=(empty=%c,pend=%c), bast=(empty=%c,pend=%c)\n", 
-                      lock->ml.type, lock->ml.convert_type, lock->ml.node, 
-                    dlm_get_lock_cookie_node(be64_to_cpu(lock->ml.cookie)),
-                    dlm_get_lock_cookie_seq(be64_to_cpu(lock->ml.cookie)),
-                      list_empty(&lock->ast_list) ? 'y' : 'n',
-                      lock->ast_pending ? 'y' : 'n',
-                      list_empty(&lock->bast_list) ? 'y' : 'n',
-                      lock->bast_pending ? 'y' : 'n');
-               spin_unlock(&lock->spinlock);
+               __dlm_print_lock(lock);
        }
-       mlog(ML_NOTICE, "  converting queue: \n");
+       printk("  converting queue:\n");
        list_for_each(iter2, &res->converting) {
                lock = list_entry(iter2, struct dlm_lock, list);
-               spin_lock(&lock->spinlock);
-               mlog(ML_NOTICE, "    type=%d, conv=%d, node=%u, "
-                      "cookie=%u:%llu, ast=(empty=%c,pend=%c), bast=(empty=%c,pend=%c)\n", 
-                      lock->ml.type, lock->ml.convert_type, lock->ml.node, 
-                    dlm_get_lock_cookie_node(be64_to_cpu(lock->ml.cookie)),
-                    dlm_get_lock_cookie_seq(be64_to_cpu(lock->ml.cookie)),
-                      list_empty(&lock->ast_list) ? 'y' : 'n',
-                      lock->ast_pending ? 'y' : 'n',
-                      list_empty(&lock->bast_list) ? 'y' : 'n',
-                      lock->bast_pending ? 'y' : 'n');
-               spin_unlock(&lock->spinlock);
+               __dlm_print_lock(lock);
        }
-       mlog(ML_NOTICE, "  blocked queue: \n");
+       printk("  blocked queue:\n");
        list_for_each(iter2, &res->blocked) {
                lock = list_entry(iter2, struct dlm_lock, list);
-               spin_lock(&lock->spinlock);
-               mlog(ML_NOTICE, "    type=%d, conv=%d, node=%u, "
-                      "cookie=%u:%llu, ast=(empty=%c,pend=%c), bast=(empty=%c,pend=%c)\n", 
-                      lock->ml.type, lock->ml.convert_type, lock->ml.node, 
-                    dlm_get_lock_cookie_node(be64_to_cpu(lock->ml.cookie)),
-                    dlm_get_lock_cookie_seq(be64_to_cpu(lock->ml.cookie)),
-                      list_empty(&lock->ast_list) ? 'y' : 'n',
-                      lock->ast_pending ? 'y' : 'n',
-                      list_empty(&lock->bast_list) ? 'y' : 'n',
-                      lock->bast_pending ? 'y' : 'n');
-               spin_unlock(&lock->spinlock);
+               __dlm_print_lock(lock);
        }
 }
 
@@ -137,31 +140,6 @@ void dlm_print_one_lock(struct dlm_lock *lockid)
 }
 EXPORT_SYMBOL_GPL(dlm_print_one_lock);
 
-#if 0
-void dlm_dump_lock_resources(struct dlm_ctxt *dlm)
-{
-       struct dlm_lock_resource *res;
-       struct hlist_node *iter;
-       struct hlist_head *bucket;
-       int i;
-
-       mlog(ML_NOTICE, "struct dlm_ctxt: %s, node=%u, key=%u\n",
-                 dlm->name, dlm->node_num, dlm->key);
-       if (!dlm || !dlm->name) {
-               mlog(ML_ERROR, "dlm=%p\n", dlm);
-               return;
-       }
-
-       spin_lock(&dlm->spinlock);
-       for (i=0; i<DLM_HASH_BUCKETS; i++) {
-               bucket = dlm_lockres_hash(dlm, i);
-               hlist_for_each_entry(res, iter, bucket, hash_node)
-                       dlm_print_one_lock_resource(res);
-       }
-       spin_unlock(&dlm->spinlock);
-}
-#endif  /*  0  */
-
 static const char *dlm_errnames[] = {
        [DLM_NORMAL] =                  "DLM_NORMAL",
        [DLM_GRANTED] =                 "DLM_GRANTED",
@@ -268,6 +246,109 @@ const char *dlm_errname(enum dlm_status err)
 }
 EXPORT_SYMBOL_GPL(dlm_errname);
 
+/* NOTE: This function converts a lockname into a string. It uses knowledge
+ * of the format of the lockname that should be outside the purview of the dlm.
+ * We are adding only to make dlm debugging slightly easier.
+ *
+ * For more on lockname formats, please refer to dlmglue.c and ocfs2_lockid.h.
+ */
+static int stringify_lockname(const char *lockname, int locklen, char *buf,
+                             int len)
+{
+       int out = 0;
+       __be64 inode_blkno_be;
+
+#define OCFS2_DENTRY_LOCK_INO_START    18
+       if (*lockname == 'N') {
+               memcpy((__be64 *)&inode_blkno_be,
+                      (char *)&lockname[OCFS2_DENTRY_LOCK_INO_START],
+                      sizeof(__be64));
+               out += snprintf(buf + out, len - out, "%.*s%08x",
+                               OCFS2_DENTRY_LOCK_INO_START - 1, lockname,
+                               (unsigned int)be64_to_cpu(inode_blkno_be));
+       } else
+               out += snprintf(buf + out, len - out, "%.*s",
+                               locklen, lockname);
+       return out;
+}
+
+static int stringify_nodemap(unsigned long *nodemap, int maxnodes,
+                            char *buf, int len)
+{
+       int out = 0;
+       int i = -1;
+
+       while ((i = find_next_bit(nodemap, maxnodes, i + 1)) < maxnodes)
+               out += snprintf(buf + out, len - out, "%d ", i);
+
+       return out;
+}
+
+static int dump_mle(struct dlm_master_list_entry *mle, char *buf, int len)
+{
+       int out = 0;
+       unsigned int namelen;
+       const char *name;
+       char *mle_type;
+
+       if (mle->type != DLM_MLE_MASTER) {
+               namelen = mle->u.name.len;
+               name = mle->u.name.name;
+       } else {
+               namelen = mle->u.res->lockname.len;
+               name = mle->u.res->lockname.name;
+       }
+
+       if (mle->type == DLM_MLE_BLOCK)
+               mle_type = "BLK";
+       else if (mle->type == DLM_MLE_MASTER)
+               mle_type = "MAS";
+       else
+               mle_type = "MIG";
+
+       out += stringify_lockname(name, namelen, buf + out, len - out);
+       out += snprintf(buf + out, len - out,
+                       "\t%3s\tmas=%3u\tnew=%3u\tevt=%1d\tuse=%1d\tref=%3d\n",
+                       mle_type, mle->master, mle->new_master,
+                       !list_empty(&mle->hb_events),
+                       !!mle->inuse,
+                       atomic_read(&mle->mle_refs.refcount));
+
+       out += snprintf(buf + out, len - out, "Maybe=");
+       out += stringify_nodemap(mle->maybe_map, O2NM_MAX_NODES,
+                                buf + out, len - out);
+       out += snprintf(buf + out, len - out, "\n");
+
+       out += snprintf(buf + out, len - out, "Vote=");
+       out += stringify_nodemap(mle->vote_map, O2NM_MAX_NODES,
+                                buf + out, len - out);
+       out += snprintf(buf + out, len - out, "\n");
+
+       out += snprintf(buf + out, len - out, "Response=");
+       out += stringify_nodemap(mle->response_map, O2NM_MAX_NODES,
+                                buf + out, len - out);
+       out += snprintf(buf + out, len - out, "\n");
+
+       out += snprintf(buf + out, len - out, "Node=");
+       out += stringify_nodemap(mle->node_map, O2NM_MAX_NODES,
+                                buf + out, len - out);
+       out += snprintf(buf + out, len - out, "\n");
+
+       out += snprintf(buf + out, len - out, "\n");
+
+       return out;
+}
+
+void dlm_print_one_mle(struct dlm_master_list_entry *mle)
+{
+       char *buf;
+
+       buf = (char *) get_zeroed_page(GFP_NOFS);
+       if (buf) {
+               dump_mle(mle, buf, PAGE_SIZE - 1);
+               free_page((unsigned long)buf);
+       }
+}
 
 #ifdef CONFIG_DEBUG_FS
 
@@ -275,6 +356,9 @@ static struct dentry *dlm_debugfs_root = NULL;
 
 #define DLM_DEBUGFS_DIR                                "o2dlm"
 #define DLM_DEBUGFS_DLM_STATE                  "dlm_state"
+#define DLM_DEBUGFS_LOCKING_STATE              "locking_state"
+#define DLM_DEBUGFS_MLE_STATE                  "mle_state"
+#define DLM_DEBUGFS_PURGE_LIST                 "purge_list"
 
 /* begin - utils funcs */
 static void dlm_debug_free(struct kref *kref)
@@ -286,7 +370,7 @@ static void dlm_debug_free(struct kref *kref)
        kfree(dc);
 }
 
-void dlm_debug_put(struct dlm_debug_ctxt *dc)
+static void dlm_debug_put(struct dlm_debug_ctxt *dc)
 {
        if (dc)
                kref_put(&dc->debug_refcnt, dlm_debug_free);
@@ -297,18 +381,6 @@ static void dlm_debug_get(struct dlm_debug_ctxt *dc)
        kref_get(&dc->debug_refcnt);
 }
 
-static int stringify_nodemap(unsigned long *nodemap, int maxnodes,
-                            char *buf, int len)
-{
-       int out = 0;
-       int i = -1;
-
-       while ((i = find_next_bit(nodemap, maxnodes, i + 1)) < maxnodes)
-               out += snprintf(buf + out, len - out, "%d ", i);
-
-       return out;
-}
-
 static struct debug_buffer *debug_buffer_allocate(void)
 {
        struct debug_buffer *db = NULL;
@@ -368,6 +440,321 @@ static int debug_buffer_release(struct inode *inode, struct file *file)
 }
 /* end - util funcs */
 
+/* begin - purge list funcs */
+static int debug_purgelist_print(struct dlm_ctxt *dlm, struct debug_buffer *db)
+{
+       struct dlm_lock_resource *res;
+       int out = 0;
+       unsigned long total = 0;
+
+       out += snprintf(db->buf + out, db->len - out,
+                       "Dumping Purgelist for Domain: %s\n", dlm->name);
+
+       spin_lock(&dlm->spinlock);
+       list_for_each_entry(res, &dlm->purge_list, purge) {
+               ++total;
+               if (db->len - out < 100)
+                       continue;
+               spin_lock(&res->spinlock);
+               out += stringify_lockname(res->lockname.name,
+                                         res->lockname.len,
+                                         db->buf + out, db->len - out);
+               out += snprintf(db->buf + out, db->len - out, "\t%ld\n",
+                               (jiffies - res->last_used)/HZ);
+               spin_unlock(&res->spinlock);
+       }
+       spin_unlock(&dlm->spinlock);
+
+       out += snprintf(db->buf + out, db->len - out,
+                       "Total on list: %ld\n", total);
+
+       return out;
+}
+
+static int debug_purgelist_open(struct inode *inode, struct file *file)
+{
+       struct dlm_ctxt *dlm = inode->i_private;
+       struct debug_buffer *db;
+
+       db = debug_buffer_allocate();
+       if (!db)
+               goto bail;
+
+       db->len = debug_purgelist_print(dlm, db);
+
+       file->private_data = db;
+
+       return 0;
+bail:
+       return -ENOMEM;
+}
+
+static struct file_operations debug_purgelist_fops = {
+       .open =         debug_purgelist_open,
+       .release =      debug_buffer_release,
+       .read =         debug_buffer_read,
+       .llseek =       debug_buffer_llseek,
+};
+/* end - purge list funcs */
+
+/* begin - debug mle funcs */
+static int debug_mle_print(struct dlm_ctxt *dlm, struct debug_buffer *db)
+{
+       struct dlm_master_list_entry *mle;
+       int out = 0;
+       unsigned long total = 0;
+
+       out += snprintf(db->buf + out, db->len - out,
+                       "Dumping MLEs for Domain: %s\n", dlm->name);
+
+       spin_lock(&dlm->master_lock);
+       list_for_each_entry(mle, &dlm->master_list, list) {
+               ++total;
+               if (db->len - out < 200)
+                       continue;
+               out += dump_mle(mle, db->buf + out, db->len - out);
+       }
+       spin_unlock(&dlm->master_lock);
+
+       out += snprintf(db->buf + out, db->len - out,
+                       "Total on list: %ld\n", total);
+       return out;
+}
+
+static int debug_mle_open(struct inode *inode, struct file *file)
+{
+       struct dlm_ctxt *dlm = inode->i_private;
+       struct debug_buffer *db;
+
+       db = debug_buffer_allocate();
+       if (!db)
+               goto bail;
+
+       db->len = debug_mle_print(dlm, db);
+
+       file->private_data = db;
+
+       return 0;
+bail:
+       return -ENOMEM;
+}
+
+static struct file_operations debug_mle_fops = {
+       .open =         debug_mle_open,
+       .release =      debug_buffer_release,
+       .read =         debug_buffer_read,
+       .llseek =       debug_buffer_llseek,
+};
+
+/* end - debug mle funcs */
+
+/* begin - debug lockres funcs */
+static int dump_lock(struct dlm_lock *lock, int list_type, char *buf, int len)
+{
+       int out;
+
+#define DEBUG_LOCK_VERSION     1
+       spin_lock(&lock->spinlock);
+       out = snprintf(buf, len, "LOCK:%d,%d,%d,%d,%d,%d:%lld,%d,%d,%d,%d,%d,"
+                      "%d,%d,%d,%d\n",
+                      DEBUG_LOCK_VERSION,
+                      list_type, lock->ml.type, lock->ml.convert_type,
+                      lock->ml.node,
+                      dlm_get_lock_cookie_node(be64_to_cpu(lock->ml.cookie)),
+                      dlm_get_lock_cookie_seq(be64_to_cpu(lock->ml.cookie)),
+                      !list_empty(&lock->ast_list),
+                      !list_empty(&lock->bast_list),
+                      lock->ast_pending, lock->bast_pending,
+                      lock->convert_pending, lock->lock_pending,
+                      lock->cancel_pending, lock->unlock_pending,
+                      atomic_read(&lock->lock_refs.refcount));
+       spin_unlock(&lock->spinlock);
+
+       return out;
+}
+
+static int dump_lockres(struct dlm_lock_resource *res, char *buf, int len)
+{
+       struct dlm_lock *lock;
+       int i;
+       int out = 0;
+
+       out += snprintf(buf + out, len - out, "NAME:");
+       out += stringify_lockname(res->lockname.name, res->lockname.len,
+                                 buf + out, len - out);
+       out += snprintf(buf + out, len - out, "\n");
+
+#define DEBUG_LRES_VERSION     1
+       out += snprintf(buf + out, len - out,
+                       "LRES:%d,%d,%d,%ld,%d,%d,%d,%d,%d,%d,%d\n",
+                       DEBUG_LRES_VERSION,
+                       res->owner, res->state, res->last_used,
+                       !list_empty(&res->purge),
+                       !list_empty(&res->dirty),
+                       !list_empty(&res->recovering),
+                       res->inflight_locks, res->migration_pending,
+                       atomic_read(&res->asts_reserved),
+                       atomic_read(&res->refs.refcount));
+
+       /* refmap */
+       out += snprintf(buf + out, len - out, "RMAP:");
+       out += stringify_nodemap(res->refmap, O2NM_MAX_NODES,
+                                buf + out, len - out);
+       out += snprintf(buf + out, len - out, "\n");
+
+       /* lvb */
+       out += snprintf(buf + out, len - out, "LVBX:");
+       for (i = 0; i < DLM_LVB_LEN; i++)
+               out += snprintf(buf + out, len - out,
+                                       "%02x", (unsigned char)res->lvb[i]);
+       out += snprintf(buf + out, len - out, "\n");
+
+       /* granted */
+       list_for_each_entry(lock, &res->granted, list)
+               out += dump_lock(lock, 0, buf + out, len - out);
+
+       /* converting */
+       list_for_each_entry(lock, &res->converting, list)
+               out += dump_lock(lock, 1, buf + out, len - out);
+
+       /* blocked */
+       list_for_each_entry(lock, &res->blocked, list)
+               out += dump_lock(lock, 2, buf + out, len - out);
+
+       out += snprintf(buf + out, len - out, "\n");
+
+       return out;
+}
+
+static void *lockres_seq_start(struct seq_file *m, loff_t *pos)
+{
+       struct debug_lockres *dl = m->private;
+       struct dlm_ctxt *dlm = dl->dl_ctxt;
+       struct dlm_lock_resource *res = NULL;
+
+       spin_lock(&dlm->spinlock);
+
+       if (dl->dl_res) {
+               list_for_each_entry(res, &dl->dl_res->tracking, tracking) {
+                       if (dl->dl_res) {
+                               dlm_lockres_put(dl->dl_res);
+                               dl->dl_res = NULL;
+                       }
+                       if (&res->tracking == &dlm->tracking_list) {
+                               mlog(0, "End of list found, %p\n", res);
+                               dl = NULL;
+                               break;
+                       }
+                       dlm_lockres_get(res);
+                       dl->dl_res = res;
+                       break;
+               }
+       } else {
+               if (!list_empty(&dlm->tracking_list)) {
+                       list_for_each_entry(res, &dlm->tracking_list, tracking)
+                               break;
+                       dlm_lockres_get(res);
+                       dl->dl_res = res;
+               } else
+                       dl = NULL;
+       }
+
+       if (dl) {
+               spin_lock(&dl->dl_res->spinlock);
+               dump_lockres(dl->dl_res, dl->dl_buf, dl->dl_len - 1);
+               spin_unlock(&dl->dl_res->spinlock);
+       }
+
+       spin_unlock(&dlm->spinlock);
+
+       return dl;
+}
+
+static void lockres_seq_stop(struct seq_file *m, void *v)
+{
+}
+
+static void *lockres_seq_next(struct seq_file *m, void *v, loff_t *pos)
+{
+       return NULL;
+}
+
+static int lockres_seq_show(struct seq_file *s, void *v)
+{
+       struct debug_lockres *dl = (struct debug_lockres *)v;
+
+       seq_printf(s, "%s", dl->dl_buf);
+
+       return 0;
+}
+
+static struct seq_operations debug_lockres_ops = {
+       .start =        lockres_seq_start,
+       .stop =         lockres_seq_stop,
+       .next =         lockres_seq_next,
+       .show =         lockres_seq_show,
+};
+
+static int debug_lockres_open(struct inode *inode, struct file *file)
+{
+       struct dlm_ctxt *dlm = inode->i_private;
+       int ret = -ENOMEM;
+       struct seq_file *seq;
+       struct debug_lockres *dl = NULL;
+
+       dl = kzalloc(sizeof(struct debug_lockres), GFP_KERNEL);
+       if (!dl) {
+               mlog_errno(ret);
+               goto bail;
+       }
+
+       dl->dl_len = PAGE_SIZE;
+       dl->dl_buf = kmalloc(dl->dl_len, GFP_KERNEL);
+       if (!dl->dl_buf) {
+               mlog_errno(ret);
+               goto bail;
+       }
+
+       ret = seq_open(file, &debug_lockres_ops);
+       if (ret) {
+               mlog_errno(ret);
+               goto bail;
+       }
+
+       seq = (struct seq_file *) file->private_data;
+       seq->private = dl;
+
+       dlm_grab(dlm);
+       dl->dl_ctxt = dlm;
+
+       return 0;
+bail:
+       if (dl)
+               kfree(dl->dl_buf);
+       kfree(dl);
+       return ret;
+}
+
+static int debug_lockres_release(struct inode *inode, struct file *file)
+{
+       struct seq_file *seq = (struct seq_file *)file->private_data;
+       struct debug_lockres *dl = (struct debug_lockres *)seq->private;
+
+       if (dl->dl_res)
+               dlm_lockres_put(dl->dl_res);
+       dlm_put(dl->dl_ctxt);
+       kfree(dl->dl_buf);
+       return seq_release_private(inode, file);
+}
+
+static struct file_operations debug_lockres_fops = {
+       .open =         debug_lockres_open,
+       .release =      debug_lockres_release,
+       .read =         seq_read,
+       .llseek =       seq_lseek,
+};
+/* end - debug lockres funcs */
+
 /* begin - debug state funcs */
 static int debug_state_print(struct dlm_ctxt *dlm, struct debug_buffer *db)
 {
@@ -544,6 +931,38 @@ int dlm_debug_init(struct dlm_ctxt *dlm)
                goto bail;
        }
 
+       /* for dumping lockres */
+       dc->debug_lockres_dentry =
+                       debugfs_create_file(DLM_DEBUGFS_LOCKING_STATE,
+                                           S_IFREG|S_IRUSR,
+                                           dlm->dlm_debugfs_subroot,
+                                           dlm, &debug_lockres_fops);
+       if (!dc->debug_lockres_dentry) {
+               mlog_errno(-ENOMEM);
+               goto bail;
+       }
+
+       /* for dumping mles */
+       dc->debug_mle_dentry = debugfs_create_file(DLM_DEBUGFS_MLE_STATE,
+                                                  S_IFREG|S_IRUSR,
+                                                  dlm->dlm_debugfs_subroot,
+                                                  dlm, &debug_mle_fops);
+       if (!dc->debug_mle_dentry) {
+               mlog_errno(-ENOMEM);
+               goto bail;
+       }
+
+       /* for dumping lockres on the purge list */
+       dc->debug_purgelist_dentry =
+                       debugfs_create_file(DLM_DEBUGFS_PURGE_LIST,
+                                           S_IFREG|S_IRUSR,
+                                           dlm->dlm_debugfs_subroot,
+                                           dlm, &debug_purgelist_fops);
+       if (!dc->debug_purgelist_dentry) {
+               mlog_errno(-ENOMEM);
+               goto bail;
+       }
+
        dlm_debug_get(dc);
        return 0;
 
@@ -557,6 +976,12 @@ void dlm_debug_shutdown(struct dlm_ctxt *dlm)
        struct dlm_debug_ctxt *dc = dlm->dlm_debug_ctxt;
 
        if (dc) {
+               if (dc->debug_purgelist_dentry)
+                       debugfs_remove(dc->debug_purgelist_dentry);
+               if (dc->debug_mle_dentry)
+                       debugfs_remove(dc->debug_mle_dentry);
+               if (dc->debug_lockres_dentry)
+                       debugfs_remove(dc->debug_lockres_dentry);
                if (dc->debug_state_dentry)
                        debugfs_remove(dc->debug_state_dentry);
                dlm_debug_put(dc);