[Ocfs2-commits] khackel commits r1953 - trunk/fs/ocfs2/dlm
svn-commits at oss.oracle.com
svn-commits at oss.oracle.com
Mon Mar 7 13:30:20 CST 2005
Author: khackel
Signed-off-by: zab
Date: 2005-03-07 13:30:18 -0600 (Mon, 07 Mar 2005)
New Revision: 1953
Modified:
trunk/fs/ocfs2/dlm/dlmmaster.c
trunk/fs/ocfs2/dlm/dlmmod.c
trunk/fs/ocfs2/dlm/dlmmod.h
Log:
* Merged 1935 from dlm-reco-mig branch
- [1935] adds mle debugging in /proc
Signed-off-by: zab
Modified: trunk/fs/ocfs2/dlm/dlmmaster.c
===================================================================
--- trunk/fs/ocfs2/dlm/dlmmaster.c 2005-03-07 19:12:30 UTC (rev 1952)
+++ trunk/fs/ocfs2/dlm/dlmmaster.c 2005-03-07 19:30:18 UTC (rev 1953)
@@ -51,6 +51,100 @@
#include "dlmmod.h"
+#ifdef MLE_DEBUG
+#include <linux/proc_fs.h>
+
+static void dlm_dump_mles(dlm_ctxt *dlm);
+
+static void dlm_dump_mles(dlm_ctxt *dlm)
+{
+ dlm_master_list_entry *mle;
+ struct list_head *iter;
+ int i = 0, refs;
+ char *type;
+ char err, attached;
+ u8 master;
+ unsigned int namelen;
+ const char *name;
+
+ dlmprintk("dumping all mles for domain %s:\n", dlm->name);
+ dlmprintk0(" ####: type refs owner events? err? lockname\n");
+ spin_lock(&dlm->master_lock);
+
+ list_for_each(iter, &dlm->master_list) {
+ mle = list_entry(iter, dlm_master_list_entry, list);
+
+ type = (mle->type == DLM_MLE_BLOCK ? "BLK" : "MAS");
+ err = (mle->error ? 'Y' : 'N');
+ refs = atomic_read(&mle->refcnt);
+ master = mle->master;
+ attached = (list_empty(&mle->hb_events) ? 'N' : 'Y');
+
+ if (mle->type == DLM_MLE_BLOCK) {
+ namelen = mle->u.name.len;
+ name = mle->u.name.name;
+ } else {
+ namelen = mle->u.res->lockname.len;
+ name = mle->u.res->lockname.name;
+ }
+
+ dlmprintk(" #%3d: %3s %3d %3u %c %c (%d)%.*s\n",
+ i, type, refs, master, attached, err,
+ namelen, namelen, name);
+ }
+
+ spin_unlock(&dlm->master_lock);
+}
+
+extern spinlock_t dlm_domain_lock;
+extern struct list_head dlm_domains;
+
+void dlm_dump_all_mles(void)
+{
+ struct list_head *iter;
+ dlm_ctxt *dlm;
+
+ dlmprintk0("welcome to dlm_dump_all_mles\n");
+ spin_lock(&dlm_domain_lock);
+ list_for_each(iter, &dlm_domains) {
+ dlm = list_entry (iter, dlm_ctxt, list);
+ dlmprintk("found dlm: %p, name=%s\n", dlm, dlm->name);
+ dlm_dump_mles(dlm);
+ }
+ spin_unlock(&dlm_domain_lock);
+ dlmprintk0("leaving dlm_dump_all_mles\n");
+}
+EXPORT_SYMBOL(dlm_dump_all_mles);
+
+static ssize_t write_dump_mles(struct file *file, const char __user *buf,
+ size_t count, loff_t *ppos)
+{
+ dlmprintk("write_dump_mles(%p, %p, %u, %lld)\n",
+ file, buf, (unsigned int)count, (long long)*ppos);
+ if (count) {
+ char c;
+ if (get_user(c, buf))
+ return -EFAULT;
+ dlmprintk("woo. you wrote %c to the proc file\n", c);
+ dlm_dump_all_mles();
+ }
+ return count;
+}
+
+static struct file_operations dlm_dump_mles_operations = {
+ .write = write_dump_mles,
+};
+
+
+void dlm_create_dump_mle_proc_entry(void)
+{
+ struct proc_dir_entry *entry;
+ entry = create_proc_entry("dlm-dump-mles", S_IWUSR, NULL);
+ if (entry)
+ entry->proc_fops = &dlm_dump_mles_operations;
+}
+#endif
+
static void dlm_init_mle(dlm_master_list_entry *mle,
enum dlm_mle_type type,
dlm_ctxt *dlm,
Modified: trunk/fs/ocfs2/dlm/dlmmod.c
===================================================================
--- trunk/fs/ocfs2/dlm/dlmmod.c 2005-03-07 19:12:30 UTC (rev 1952)
+++ trunk/fs/ocfs2/dlm/dlmmod.c 2005-03-07 19:30:18 UTC (rev 1953)
@@ -100,6 +100,9 @@
if (dlm_global_index == NM_MAX_NODES)
return -1;
+#ifdef MLE_DEBUG
+ dlm_create_dump_mle_proc_entry();
+#endif
return 0;
} /* dlm_driver_entry */
Modified: trunk/fs/ocfs2/dlm/dlmmod.h
===================================================================
--- trunk/fs/ocfs2/dlm/dlmmod.h 2005-03-07 19:12:30 UTC (rev 1952)
+++ trunk/fs/ocfs2/dlm/dlmmod.h 2005-03-07 19:30:18 UTC (rev 1953)
@@ -680,6 +680,13 @@
unsigned int namelen, void *nodemap);
+#define MLE_DEBUG 1
+#ifdef MLE_DEBUG
+void dlm_dump_all_mles(void);
+void dlm_create_dump_mle_proc_entry(void);
+#endif
+
+
static inline const char * dlm_lock_mode_name(int mode)
{
switch (mode) {
More information about the Ocfs2-commits
mailing list