[Ocfs2-commits] khackel commits r1942 - branches/dlm-reco-mig/fs/ocfs2/dlm

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Fri Mar 4 20:39:19 CST 2005


Author: khackel
Date: 2005-03-04 20:39:16 -0600 (Fri, 04 Mar 2005)
New Revision: 1942

Modified:
   branches/dlm-reco-mig/fs/ocfs2/dlm/dlmmaster.c
   branches/dlm-reco-mig/fs/ocfs2/dlm/dlmmod.c
   branches/dlm-reco-mig/fs/ocfs2/dlm/dlmmod.h
Log:
* cleaned up debugging interface in /proc a little bit
* changed the file to /proc/dlm-debug, with a special character for
  each type of output (like /proc/sysrq-trigger)
* currently supports 'r' for lockres debugging and 'm' for mle debugging



Modified: branches/dlm-reco-mig/fs/ocfs2/dlm/dlmmaster.c
===================================================================
--- branches/dlm-reco-mig/fs/ocfs2/dlm/dlmmaster.c	2005-03-05 01:26:45 UTC (rev 1941)
+++ branches/dlm-reco-mig/fs/ocfs2/dlm/dlmmaster.c	2005-03-05 02:39:16 UTC (rev 1942)
@@ -51,9 +51,7 @@
 #include "dlmmod.h"
 
 
-#ifdef MLE_DEBUG
-#include <linux/proc_fs.h>
-
+#ifdef DLM_MLE_DEBUG
 static void dlm_dump_mles(dlm_ctxt *dlm);
 
 static void dlm_dump_mles(dlm_ctxt *dlm)
@@ -115,36 +113,9 @@
 	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,
@@ -1045,6 +1016,11 @@
 	dlm_node_iter iter;
 	int ret = 0;
 
+	DLM_ASSERT(namelen <= NM_MAX_NAME_LEN);
+	DLM_ASSERT(dlm);
+	DLM_ASSERT(lockname);
+	DLM_ASSERT(nodemap);
+
 	/* note that if this nodemap is empty, it returns 0 */
 	dlm_node_iter_init(nodemap, &iter);
 	while ((to = dlm_node_iter_next(&iter)) >= 0) {

Modified: branches/dlm-reco-mig/fs/ocfs2/dlm/dlmmod.c
===================================================================
--- branches/dlm-reco-mig/fs/ocfs2/dlm/dlmmod.c	2005-03-05 01:26:45 UTC (rev 1941)
+++ branches/dlm-reco-mig/fs/ocfs2/dlm/dlmmod.c	2005-03-05 02:39:16 UTC (rev 1942)
@@ -39,6 +39,7 @@
 #include <linux/socket.h>
 #include <linux/inet.h>
 #include <linux/spinlock.h>
+#include <linux/proc_fs.h>
 
 #include "util.h"
 
@@ -66,8 +67,11 @@
 static int dlm_read_params(void);
 static void __exit dlm_driver_exit (void);
 
+static void dlm_dump_all_lock_resources(void);
+static void dlm_dump_lock_resources(dlm_ctxt *dlm);
 
 
+
 LIST_HEAD(dlm_domains);
 spinlock_t dlm_domain_lock = SPIN_LOCK_UNLOCKED;
 DECLARE_WAIT_QUEUE_HEAD(dlm_domain_events);
@@ -78,9 +82,66 @@
 
 
 
+typedef void (dlm_debug_func_t)(void);
 
+typedef struct _dlm_debug_funcs
+{
+	char key;
+	dlm_debug_func_t *func;
+} dlm_debug_funcs;
 
 
+
+static dlm_debug_funcs dlm_debug_map[] = {
+	{ 'r', dlm_dump_all_lock_resources },
+#ifdef DLM_MLE_DEBUG
+	{ 'm', dlm_dump_all_mles },
+#endif
+};
+static int dlm_debug_map_sz = (sizeof(dlm_debug_map) / 
+			       sizeof(dlm_debug_funcs));
+
+static ssize_t write_dlm_debug(struct file *file, const char __user *buf,
+                                   size_t count, loff_t *ppos)
+{
+	int i;
+	char c;
+	dlm_debug_func_t *fn;
+
+	dlmprintk("(%p, %p, %u, %lld)\n",
+		  file, buf, (unsigned int)count, (long long)*ppos);
+	if (!count)
+		return 0;
+
+	if (get_user(c, buf))
+		return -EFAULT;
+
+	for (i=0; i < dlm_debug_map_sz; i++) {
+		if (c == dlm_debug_map[i].key) {
+			fn = dlm_debug_map[i].func;
+			if (fn)
+				(fn)();
+			break;
+		}
+	}
+	return count;
+}
+
+static struct file_operations dlm_debug_operations = {
+	.write          = write_dlm_debug,
+};
+
+
+static void dlm_create_dlm_debug_proc_entry(void)
+{
+	struct proc_dir_entry *entry;
+	entry = create_proc_entry("dlm-debug", S_IWUSR, NULL);
+	if (entry)
+		entry->proc_fops = &dlm_debug_operations;
+}
+
+
+
 /*
  * dlm_driver_entry()
  *
@@ -100,9 +161,7 @@
 	if (dlm_global_index == NM_MAX_NODES)
 		return -1;
 
-#ifdef MLE_DEBUG
-	dlm_create_dump_mle_proc_entry();
-#endif
+	dlm_create_dlm_debug_proc_entry();
 	return 0;
 }				/* dlm_driver_entry */
 
@@ -895,7 +954,7 @@
 	current->state = TASK_RUNNING;
 }
 
-void dlm_dump_everything(void)
+static void dlm_dump_all_lock_resources(void)
 {
 	dlm_ctxt *dlm;
 	struct list_head *iter;
@@ -905,12 +964,12 @@
 	spin_lock(&dlm_domain_lock);
 	list_for_each(iter, &dlm_domains) {
 		dlm = list_entry (iter, dlm_ctxt, list);
-		dlm_dump_dlm(dlm);
+		dlm_dump_lock_resources(dlm);
 	}
 	spin_unlock(&dlm_domain_lock);
 }
 
-void dlm_dump_dlm(dlm_ctxt *dlm)
+static void dlm_dump_lock_resources(dlm_ctxt *dlm)
 {
 	dlm_lock_resource *res;
 	dlm_lock *lock;

Modified: branches/dlm-reco-mig/fs/ocfs2/dlm/dlmmod.h
===================================================================
--- branches/dlm-reco-mig/fs/ocfs2/dlm/dlmmod.h	2005-03-05 01:26:45 UTC (rev 1941)
+++ branches/dlm-reco-mig/fs/ocfs2/dlm/dlmmod.h	2005-03-05 02:39:16 UTC (rev 1942)
@@ -655,11 +655,7 @@
 int dlm_master_request_handler(net_msg *msg, u32 len, void *data);
 int dlm_master_request_resp_handler(net_msg *msg, u32 len, void *data);
 int dlm_assert_master_handler(net_msg *msg, u32 len, void *data);
-void dlm_dump_everything(void);
-void dlm_dump_dlm(dlm_ctxt *dlm);
 
-int dlm_lock_owner_broadcast(dlm_ctxt *dlm, dlm_lock_resource *res);
-int dlm_lock_owner_broadcast(dlm_ctxt *dlm, dlm_lock_resource *res);
 
 /* will exit holding res->spinlock, but may drop in function */
 void __dlm_wait_on_lockres_flags(dlm_lock_resource *res, int flags);
@@ -680,10 +676,10 @@
 			 unsigned int namelen, void *nodemap);
 
 
-#define MLE_DEBUG 1
-#ifdef MLE_DEBUG
+#define DLM_MLE_DEBUG 1
+
+#ifdef DLM_MLE_DEBUG
 void dlm_dump_all_mles(void);
-void dlm_create_dump_mle_proc_entry(void);
 #endif
 
 



More information about the Ocfs2-commits mailing list