Skip to contentSkip to conversation

Much needed changes to o2dlm

Ocfs2-devel New Sunil Mushran 2 participants 14 messages Feb 1, 2008 – Feb 7, 2008 OCFS2

lore
Share & tools
lore
#0 lore raw

1. Moved some dlm structures to their own slab cache.
2. Fixed memleaks uncovered by the above move.
3. Added debugfs support in o2dlm to allow dumpig of dlm state, lockres, purgelist, etc.
4. Removed o2dlm's proc interface.

Sunil

#1 lore raw

PATCH 1/12 ocfs2_dlm: Rename slabcache dlm_mle_cache to o2dlm_mle

This patch renames dlm_mle_slabcache to prevent namespace clashes with fs/dlm.

---
 fs/ocfs2/dlm/dlmdomain.c |    4 +++-
 fs/ocfs2/dlm/dlmmaster.c |    2 +-
 2 files changed, 4 insertions(+), 2 deletions(-)
fs/ocfs2/dlm/dlmdomain.c +3 -1
index 1d854d5..502712b 100644
@@ -1648,8 +1648,10 @@ static int __init dlm_init(void)
 	dlm_print_version();
 
 	status = dlm_init_mle_cache();
-	if (status)
+	if (status) {
+		mlog(ML_ERROR, "Could not create o2dlm_mle slabcache\n");
 		return -1;
+	}
 
 	status = dlm_register_net_handlers();
 	if (status) {
fs/ocfs2/dlm/dlmmaster.c +1 -1
index 42ea5af..cc4e624 100644
@@ -506,7 +506,7 @@ static void dlm_mle_node_up(struct dlm_ctxt *dlm,
 
 int dlm_init_mle_cache(void)
 {
-	dlm_mle_cache = kapi_kmem_cache_create("dlm_mle_cache",
+	dlm_mle_cache = kapi_kmem_cache_create("o2dlm_mle",
 					  sizeof(struct dlm_master_list_entry),
 					  0, SLAB_HWCACHE_ALIGN,
 					  NULL);
Signature · 1 line
1.5.2.5
#2 lore raw

PATCH 2/12 ocfs2_dlm: Creates slabcaches for the lockres' and the locks

In reply to Sunil Mushran

This patch makes the o2dlm allocate memory for lockres, lockname and lock structures from slabcaches rather than kmalloc. This allows us to not only make these allocs more efficient but also allows us to track the memory being consumed by these structures.

---
 fs/ocfs2/dlm/dlmcommon.h |   10 +++++++
 fs/ocfs2/dlm/dlmdomain.c |   33 ++++++++++++++++++++---
 fs/ocfs2/dlm/dlmlock.c   |   23 +++++++++++++++-
 fs/ocfs2/dlm/dlmmaster.c |   65 +++++++++++++++++++++++++++++++++++++--------
 4 files changed, 113 insertions(+), 18 deletions(-)
fs/ocfs2/dlm/dlmcommon.h +10 -0
index f3afb15..041ec68 100644
@@ -944,9 +944,19 @@ static inline void __dlm_wait_on_lockres(struct dlm_lock_resource *res)
 					  DLM_LOCK_RES_MIGRATING));
 }
 
+/* create/destroy slab caches */
+int dlm_init_lockres_cache(void);
+void dlm_destroy_lockres_cache(void);
+
+int dlm_init_lockname_cache(void);
+void dlm_destroy_lockname_cache(void);
+
+int dlm_init_lock_cache(void);
+void dlm_destroy_lock_cache(void);
 
 int dlm_init_mle_cache(void);
 void dlm_destroy_mle_cache(void);
+
 void dlm_hb_event_notify_attached(struct dlm_ctxt *dlm, int idx, int node_up);
 int dlm_drop_lockres_ref(struct dlm_ctxt *dlm,
 			 struct dlm_lock_resource *res);
fs/ocfs2/dlm/dlmdomain.c +29 -4
index 502712b..6d02ef5 100644
@@ -1650,24 +1650,49 @@ static int __init dlm_init(void)
 	status = dlm_init_mle_cache();
 	if (status) {
 		mlog(ML_ERROR, "Could not create o2dlm_mle slabcache\n");
-		return -1;
+		goto error;
 	}
 
-	status = dlm_register_net_handlers();
+	status = dlm_init_lockres_cache();
+	if (status) {
+		mlog(ML_ERROR, "Could not create o2dlm_lockres slabcache\n");
+		goto error;
+	}
+
+	status = dlm_init_lockname_cache();
 	if (status) {
-		dlm_destroy_mle_cache();
-		return -1;
+		mlog(ML_ERROR, "Could not create o2dlm_lockname slabcache\n");
+		goto error;
 	}
 
+	status = dlm_init_lock_cache();
+	if (status) {
+		mlog(ML_ERROR, "Could not create o2dlm_lock slabcache\n");
+		goto error;
+	}
+
+	status = dlm_register_net_handlers();
+	if (status)
+		goto error;
+
 	dlm_init_proc();
 
 	return 0;
+error:
+	dlm_destroy_lock_cache();
+	dlm_destroy_lockname_cache();
+	dlm_destroy_lockres_cache();
+	dlm_destroy_mle_cache();
+	return -1;
 }
 
 static void __exit dlm_exit (void)
 {
 	dlm_remove_proc();
 	dlm_unregister_net_handlers();
+	dlm_destroy_lock_cache();
+	dlm_destroy_lockname_cache();
+	dlm_destroy_lockres_cache();
 	dlm_destroy_mle_cache();
 }
 
fs/ocfs2/dlm/dlmlock.c +21 -2
index 52578d9..ea393b6 100644
@@ -53,6 +53,8 @@
 #define MLOG_MASK_PREFIX ML_DLM
 #include "cluster/masklog.h"
 
+static struct kmem_cache *dlm_lock_cache = NULL;
+
 static DEFINE_SPINLOCK(dlm_cookie_lock);
 static u64 dlm_next_cookie = 1;
 
@@ -64,6 +66,22 @@ static void dlm_init_lock(struct dlm_lock *newlock, int type,
 static void dlm_lock_release(struct kref *kref);
 static void dlm_lock_detach_lockres(struct dlm_lock *lock);
 
+int dlm_init_lock_cache(void)
+{
+	dlm_lock_cache = kapi_kmem_cache_create("o2dlm_lock",
+						sizeof(struct dlm_lock),
+						0, SLAB_HWCACHE_ALIGN, NULL);
+	if (dlm_lock_cache == NULL)
+		return -ENOMEM;
+	return 0;
+}
+
+void dlm_destroy_lock_cache(void)
+{
+	if (dlm_lock_cache)
+		kmem_cache_destroy(dlm_lock_cache);
+}
+
 /* Tell us whether we can grant a new lock request.
  * locking:
  *   caller needs:  res->spinlock
@@ -353,7 +371,7 @@ static void dlm_lock_release(struct kref *kref)
 		mlog(0, "freeing kernel-allocated lksb\n");
 		kfree(lock->lksb);
 	}
-	kfree(lock);
+	kmem_cache_free(dlm_lock_cache, lock);
 }
 
 /* associate a lock with it's lockres, getting a ref on the lockres */
@@ -412,9 +430,10 @@ struct dlm_lock * dlm_new_lock(int type, u8 node, u64 cookie,
 	struct dlm_lock *lock;
 	int kernel_allocated = 0;
 
-	lock = kzalloc(sizeof(*lock), GFP_NOFS);
+	lock = (struct dlm_lock *) kmem_cache_alloc(dlm_lock_cache, GFP_NOFS);
 	if (!lock)
 		return NULL;
+	memset(lock, 0, sizeof(struct dlm_lock));
 
 	if (!lksb) {
 		/* zero memory only if kernel-allocated */
fs/ocfs2/dlm/dlmmaster.c +53 -12

96 lines not on this page · raw message

Signature · 1 line
1.5.2.5
#3 lore raw

PATCH 3/12 ocfs2_dlm: lockres/lock refcounting fixed

In reply to Sunil Mushran
---
 fs/ocfs2/dlm/dlmmaster.c   |    1 +
 fs/ocfs2/dlm/dlmrecovery.c |    3 +++
 2 files changed, 4 insertions(+), 0 deletions(-)
fs/ocfs2/dlm/dlmmaster.c +1 -0
index 939b863..e469e49 100644
@@ -2973,6 +2973,7 @@ static void dlm_remove_nonlocal_locks(struct dlm_ctxt *dlm,
 				dlm_lockres_clear_refmap_bit(lock->ml.node, res);
 				list_del_init(&lock->list);
 				dlm_lock_put(lock);
+				dlm_lock_put(lock);
 			}
 		}
 		queue++;
fs/ocfs2/dlm/dlmrecovery.c +3 -0
index 4294d76..ae2b2b6 100644
@@ -1515,6 +1515,8 @@ again:
 	}
 
 leave:
+	if (res)
+		dlm_lockres_put(res);
 	kfree(data);
 	mlog_exit(ret);
 }
@@ -1919,6 +1921,7 @@ void dlm_move_lockres_to_recovery_list(struct dlm_ctxt *dlm,
 		     "Recovering res %s:%.*s, is already on recovery list!\n",
 		     dlm->name, res->lockname.len, res->lockname.name);
 		list_del_init(&res->recovering);
+		dlm_lockres_put(res);
 	}
 	/* We need to hold a reference while on the recovery list */
 	dlm_lockres_get(res);
Signature · 1 line
1.5.2.5
#5 lore raw

PATCH 4/12 ocfs2_dlm: Link all lockres' to a tracking list

In reply to Sunil Mushran

This patch links all the lockres' to a tracking list in dlm_ctxt. We will use this in the upcoming patch that will walk the entire list and to dump the lockres states to a debugfs file.

---
 fs/ocfs2/dlm/dlmcommon.h |    6 ++++--
 fs/ocfs2/dlm/dlmdomain.c |    1 +
 fs/ocfs2/dlm/dlmmaster.c |   12 +++++++++---
 fs/ocfs2/dlm/dlmthread.c |    5 +++++
 4 files changed, 19 insertions(+), 5 deletions(-)
fs/ocfs2/dlm/dlmcommon.h +4 -2
index 041ec68..d782b41 100644
@@ -101,6 +101,7 @@ struct dlm_ctxt
 	struct list_head purge_list;
 	struct list_head pending_asts;
 	struct list_head pending_basts;
+	struct list_head tracking_list;
 	unsigned int purge_count;
 	spinlock_t spinlock;
 	spinlock_t ast_lock;
@@ -259,11 +260,12 @@ struct dlm_lock_resource
 	struct list_head purge;
 
 	/*
-	 * These two lists require you to hold an additional reference
+	 * These three lists require you to hold an additional reference
 	 * while they are on the list.
 	 */
 	struct list_head dirty;
-	struct list_head recovering; // dlm_recovery_ctxt.resources list
+	struct list_head recovering;	/* dlm->dlm_recovery_ctxt.resources */
+	struct list_head tracking;	/* dlm->tracking_list */
 
 	/* unused lock resources have their last_used stamped and are
 	 * put on a list for the dlm thread to run. */
fs/ocfs2/dlm/dlmdomain.c +1 -0
index 6d02ef5..71d3946 100644
@@ -1404,6 +1404,7 @@ static struct dlm_ctxt *dlm_alloc_ctxt(const char *domain,
 	INIT_LIST_HEAD(&dlm->reco.node_data);
 	INIT_LIST_HEAD(&dlm->purge_list);
 	INIT_LIST_HEAD(&dlm->dlm_domain_handlers);
+	INIT_LIST_HEAD(&dlm->tracking_list);
 	dlm->reco.state = 0;
 
 	INIT_LIST_HEAD(&dlm->pending_asts);
fs/ocfs2/dlm/dlmmaster.c +9 -3
index e469e49..4f2bf7c 100644
@@ -648,10 +648,11 @@ static void dlm_lockres_release(struct kref *kref)
 	    !list_empty(&res->blocked) ||
 	    !list_empty(&res->dirty) ||
 	    !list_empty(&res->recovering) ||
-	    !list_empty(&res->purge)) {
+	    !list_empty(&res->purge) ||
+	    !list_empty(&res->tracking)) {
 		mlog(ML_ERROR,
 		     "Going to BUG for resource %.*s."
-		     "  We're on a list! [%c%c%c%c%c%c%c]\n",
+		     "  We're on a list! [%c%c%c%c%c%c%c%c]\n",
 		     res->lockname.len, res->lockname.name,
 		     !hlist_unhashed(&res->hash_node) ? 'H' : ' ',
 		     !list_empty(&res->granted) ? 'G' : ' ',
@@ -659,7 +660,8 @@ static void dlm_lockres_release(struct kref *kref)
 		     !list_empty(&res->blocked) ? 'B' : ' ',
 		     !list_empty(&res->dirty) ? 'D' : ' ',
 		     !list_empty(&res->recovering) ? 'R' : ' ',
-		     !list_empty(&res->purge) ? 'P' : ' ');
+		     !list_empty(&res->purge) ? 'P' : ' ',
+		     !list_empty(&res->tracking) ? 'T' : ' ');
 
 		dlm_print_one_lock_resource(res);
 	}
@@ -709,6 +711,7 @@ static void dlm_init_lockres(struct dlm_ctxt *dlm,
 	INIT_LIST_HEAD(&res->dirty);
 	INIT_LIST_HEAD(&res->recovering);
 	INIT_LIST_HEAD(&res->purge);
+	INIT_LIST_HEAD(&res->tracking);
 	atomic_set(&res->asts_reserved, 0);
 	res->migration_pending = 0;
 	res->inflight_locks = 0;
@@ -724,6 +727,9 @@ static void dlm_init_lockres(struct dlm_ctxt *dlm,
 
 	res->last_used = 0;
 
+	dlm_lockres_get(res);
+	list_add_tail(&res->tracking, &dlm->tracking_list);
+
 	memset(res->lvb, 0, DLM_LVB_LEN);
 	memset(res->refmap, 0, sizeof(res->refmap));
 }
fs/ocfs2/dlm/dlmthread.c +5 -0
index cebd089..620d6a3 100644
@@ -204,6 +204,11 @@ static int dlm_purge_lockres(struct dlm_ctxt *dlm,
 	}
 	__dlm_unhash_lockres(res);
 
+	if (!list_empty(&res->tracking)) {
+		list_del_init(&res->tracking);
+		dlm_lockres_put(res);
+	}
+
 	/* lockres is not in the hash now.  drop the flag and wake up
 	 * any processes waiting in dlm_get_lock_resource. */
 	if (!master) {
Signature · 1 line
1.5.2.5
#6 lore raw

PATCH 5/12 ocfs2_dlm: Create debugfs dirs

In reply to Sunil Mushran

This patch creates the debugfs directories that will hold the files to be used to dump the dlm state.

---
 fs/ocfs2/dlm/dlmcommon.h |    2 ++
 fs/ocfs2/dlm/dlmdebug.c  |   42 ++++++++++++++++++++++++++++++++++++++++++
 fs/ocfs2/dlm/dlmdebug.h  |    7 +++++++
 fs/ocfs2/dlm/dlmdomain.c |   20 ++++++++++++++++++++
 4 files changed, 71 insertions(+), 0 deletions(-)
fs/ocfs2/dlm/dlmcommon.h +2 -0
index d782b41..74ee372 100644
@@ -125,6 +125,8 @@ struct dlm_ctxt
 	atomic_t remote_resources;
 	atomic_t unknown_resources;
 
+	struct dentry *dlm_debugfs_subroot;
+
 	/* NOTE: Next three are protected by dlm_domain_lock */
 	struct kref dlm_refs;
 	enum dlm_ctxt_state dlm_state;
fs/ocfs2/dlm/dlmdebug.c +42 -0

57 lines not on this page · raw message

fs/ocfs2/dlm/dlmdebug.h +7 -0
index dbe3a3d..e701499 100644
@@ -31,4 +31,11 @@ void dlm_dump_lock_resources(struct dlm_ctxt *dlm);
 void dlm_proc_add_domain(struct dlm_ctxt *dlm);
 void dlm_proc_del_domain(struct dlm_ctxt *dlm);
 void dlm_dump_work_queue(struct dlm_ctxt *dlm);
+
+int dlm_create_debugfs_subroot(struct dlm_ctxt *dlm);
+void dlm_destroy_debugfs_subroot(struct dlm_ctxt *dlm);
+
+int dlm_create_debugfs_root(void);
+void dlm_destroy_debugfs_root(void);
+
 #endif
fs/ocfs2/dlm/dlmdomain.c +20 -0
index 71d3946..7b2c967 100644
@@ -33,6 +33,7 @@
 #include <linux/spinlock.h>
 #include <linux/delay.h>
 #include <linux/err.h>
+#include <linux/debugfs.h>
 
 #include "cluster/heartbeat.h"
 #include "cluster/nodemanager.h"
@@ -43,6 +44,7 @@
 
 #include "dlmdebug.h"
 #include "dlmdomain.h"
+#include "dlmdebug.h"
 
 #include "dlmver.h"
 
@@ -288,6 +290,8 @@ static void dlm_free_ctxt_mem(struct dlm_ctxt *dlm)
 {
 	dlm_proc_del_domain(dlm);
 
+	dlm_destroy_debugfs_subroot(dlm);
+
 	if (dlm->lockres_hash)
 		dlm_free_pagevec((void **)dlm->lockres_hash, DLM_HASH_PAGES);
 
@@ -1362,6 +1366,7 @@ static struct dlm_ctxt *dlm_alloc_ctxt(const char *domain,
 				u32 key)
 {
 	int i;
+	int ret;
 	struct dlm_ctxt *dlm = NULL;
 
 	dlm = kzalloc(sizeof(*dlm), GFP_KERNEL);
@@ -1394,6 +1399,15 @@ static struct dlm_ctxt *dlm_alloc_ctxt(const char *domain,
 	dlm->key = key;
 	dlm->node_num = o2nm_this_node();
 
+	ret = dlm_create_debugfs_subroot(dlm);
+	if (ret < 0) {
+		dlm_free_pagevec((void **)dlm->lockres_hash, DLM_HASH_PAGES);
+		kfree(dlm->name);
+		kfree(dlm);
+		dlm = NULL;
+		goto leave;
+	}
+
 	spin_lock_init(&dlm->spinlock);
 	spin_lock_init(&dlm->master_lock);
 	spin_lock_init(&dlm->ast_lock);
@@ -1678,8 +1692,13 @@ static int __init dlm_init(void)
 
 	dlm_init_proc();
 
+	status = dlm_create_debugfs_root();
+	if (status)
+		goto error;
+
 	return 0;
 error:
+	dlm_unregister_net_handlers();
 	dlm_destroy_lock_cache();
 	dlm_destroy_lockname_cache();
 	dlm_destroy_lockres_cache();
@@ -1689,6 +1708,7 @@ error:
 
 static void __exit dlm_exit (void)
 {
+	dlm_destroy_debugfs_root();
 	dlm_remove_proc();
 	dlm_unregister_net_handlers();
 	dlm_destroy_lock_cache();
Signature · 1 line
1.5.2.5
#7 lore raw

PATCH 6/12 ocfs2_dlm: Dump the dlm state in a debugfs file

In reply to Sunil Mushran

This patch dumps the dlm state (dlm_ctxt) into a debugfs file. Useful for debugging.

---
 fs/ocfs2/dlm/dlmcommon.h |    1 +
 fs/ocfs2/dlm/dlmdebug.c  |  280 +++++++++++++++++++++++++++++++++++++++++++++-
 fs/ocfs2/dlm/dlmdebug.h  |   14 +++
 fs/ocfs2/dlm/dlmdomain.c |    8 ++
 4 files changed, 302 insertions(+), 1 deletions(-)
fs/ocfs2/dlm/dlmcommon.h +1 -0
index 74ee372..9828722 100644
@@ -125,6 +125,7 @@ struct dlm_ctxt
 	atomic_t remote_resources;
 	atomic_t unknown_resources;
 
+	struct dlm_debug_ctxt *dlm_debug_ctxt;
 	struct dentry *dlm_debugfs_subroot;
 
 	/* NOTE: Next three are protected by dlm_domain_lock */
fs/ocfs2/dlm/dlmdebug.c +279 -1

292 lines not on this page · raw message

fs/ocfs2/dlm/dlmdebug.h +14 -0
index e701499..50cb10f 100644
@@ -25,6 +25,17 @@
 #ifndef DLMDEBUG_H
 #define DLMDEBUG_H
 
+struct dlm_debug_ctxt {
+	struct kref debug_refcnt;
+	struct dentry *debug_state_dentry;
+};
+
+struct debug_buffer
+{
+	int len;
+	char *buf;
+};
+
 void dlm_remove_proc(void);
 void dlm_init_proc(void);
 void dlm_dump_lock_resources(struct dlm_ctxt *dlm);
@@ -32,6 +43,9 @@ void dlm_proc_add_domain(struct dlm_ctxt *dlm);
 void dlm_proc_del_domain(struct dlm_ctxt *dlm);
 void dlm_dump_work_queue(struct dlm_ctxt *dlm);
 
+int dlm_debug_init(struct dlm_ctxt *dlm);
+void dlm_debug_shutdown(struct dlm_ctxt *dlm);
+
 int dlm_create_debugfs_subroot(struct dlm_ctxt *dlm);
 void dlm_destroy_debugfs_subroot(struct dlm_ctxt *dlm);
 
fs/ocfs2/dlm/dlmdomain.c +8 -0
index 7b2c967..b06151e 100644
@@ -389,6 +389,7 @@ static void dlm_destroy_dlm_worker(struct dlm_ctxt *dlm)
 static void dlm_complete_dlm_shutdown(struct dlm_ctxt *dlm)
 {
 	dlm_unregister_domain_handlers(dlm);
+	dlm_debug_shutdown(dlm);
 	dlm_complete_thread(dlm);
 	dlm_complete_recovery_thread(dlm);
 	dlm_destroy_dlm_worker(dlm);
@@ -1287,6 +1288,12 @@ static int dlm_join_domain(struct dlm_ctxt *dlm)
 		goto bail;
 	}
 
+	status = dlm_debug_init(dlm);
+	if (status < 0) {
+		mlog_errno(status);
+		goto bail;
+	}
+
 	status = dlm_launch_thread(dlm);
 	if (status < 0) {
 		mlog_errno(status);
@@ -1354,6 +1361,7 @@ bail:
 
 	if (status) {
 		dlm_unregister_domain_handlers(dlm);
+		dlm_debug_shutdown(dlm);
 		dlm_complete_thread(dlm);
 		dlm_complete_recovery_thread(dlm);
 		dlm_destroy_dlm_worker(dlm);
Signature · 1 line
1.5.2.5
#8 lore raw

PATCH 7/12 ocfs2_dlm: Dumps the lockres' into a debugfs file

In reply to Sunil Mushran

This patch dumps all the lockres' alongwith all the locks into a debugfs file. Useful for debugging.

---
 fs/ocfs2/dlm/dlmdebug.c |  225 +++++++++++++++++++++++++++++++++++++++++++++++
 fs/ocfs2/dlm/dlmdebug.h |    9 ++
 2 files changed, 234 insertions(+), 0 deletions(-)
fs/ocfs2/dlm/dlmdebug.c +225 -0
index 124856b..a89bfe7 100644
@@ -794,6 +794,219 @@ static int debug_buffer_release(struct inode *inode, struct file *file)
 
 /* end - util funcs */
 
+/* begin - debug lockres funcs */
+static int dump_lock(char *buf, int len, int list_type, struct dlm_lock *lock)
+{
+	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\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), lock->ast_pending,
+		       !list_empty(&lock->bast_list), lock->bast_pending);
+	spin_unlock(&lock->spinlock);
+
+	return out;
+}
+
+static int dump_lockres(struct debug_lockres *dl)
+{
+	struct dlm_ctxt *dlm;
+	struct dlm_lock_resource *res;
+	struct dlm_lock *lock;
+	int i;
+	int out = 0;
+
+	if (!dl)
+		return 0;
+
+	dlm = dl->dl_ctxt;
+	res = dl->dl_res;
+
+	assert_spin_locked(&dlm->spinlock);
+	spin_lock(&res->spinlock);
+
+	out += snprintf(dl->dl_buf + out, dl->dl_len - out,
+			"%.*s\n",
+			res->lockname.len, res->lockname.name);
+
+#define DEBUG_LRES_VERSION	1
+	out += snprintf(dl->dl_buf + out, dl->dl_len - out,
+			"LRES:%d,%d,%d,%ld,%d,%d,%d,%d,%d\n",
+			DEBUG_LRES_VERSION,
+			res->owner, res->state, res->last_used,
+			!list_empty(&res->purge), res->inflight_locks,
+			atomic_read(&res->refs.refcount),
+			res->migration_pending,
+			atomic_read(&res->asts_reserved));
+
+	/* refmap */
+	out += snprintf(dl->dl_buf + out, dl->dl_len - out, "REFMAP:");
+	out += stringify_nodemap(res->refmap, O2NM_MAX_NODES,
+				 dl->dl_buf + out, dl->dl_len - out);
+	out += snprintf(dl->dl_buf + out, dl->dl_len - out, "\n");
+
+	/* lvb */
+	out += snprintf(dl->dl_buf + out, dl->dl_len - out, "LVB:");
+	for (i = 0; i < DLM_LVB_LEN; i++)
+		out += snprintf(dl->dl_buf + out, dl->dl_len - out,
+					"%02X", (unsigned char)res->lvb[i]);
+	out += snprintf(dl->dl_buf + out, dl->dl_len - out, "\n");
+
+	/* granted */
+	list_for_each_entry(lock, &res->granted, list)
+		out += dump_lock(dl->dl_buf + out, dl->dl_len - out, 0, lock);
+
+	/* converting */
+	list_for_each_entry(lock, &res->converting, list)
+		out += dump_lock(dl->dl_buf + out, dl->dl_len - out, 1, lock);
+
+	/* blocked */
+	list_for_each_entry(lock, &res->blocked, list)
+		out += dump_lock(dl->dl_buf + out, dl->dl_len - out, 2, lock);
+
+	out += snprintf(dl->dl_buf + out, dl->dl_len - out, "\n");
+
+	spin_unlock(&res->spinlock);
+
+	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;
+			}
+			mlog(0, "res=%p, name=%.*s\n", res,
+			     res->lockname.len, res->lockname.name);
+			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;
+			mlog(0, "res=%p, name=%.*s\n", res,
+			     res->lockname.len, res->lockname.name);
+			dlm_lockres_get(res);
+			dl->dl_res = res;
+		} else
+			dl = NULL;
+	}
+
+	dump_lockres(dl);
+
+	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 && dl->dl_buf)
+		kfree(dl->dl_buf);
+	if (dl)
+		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)
 {
@@ -951,6 +1164,16 @@ int dlm_debug_init(struct dlm_ctxt *dlm)
 		goto bail;
 	}
 
+	/* for dumping lockres */
+	dc->debug_lockres_dentry =
+			debugfs_create_file("lockres", S_IFREG|S_IRUSR,
+					    dlm->dlm_debugfs_subroot,
+					    dlm, &debug_lockres_fops);
+	if (!dc->debug_lockres_dentry) {
+		mlog_errno(-ENOMEM);
+		goto bail;
+	}
+
 	dlm_debug_get(dc);
 	return 0;
 
@@ -964,6 +1187,8 @@ void dlm_debug_shutdown(struct dlm_ctxt *dlm)
 	struct dlm_debug_ctxt *dc = dlm->dlm_debug_ctxt;
 
 	if (dc) {
+		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);
fs/ocfs2/dlm/dlmdebug.h +9 -0
index 50cb10f..86d02f4 100644
@@ -28,6 +28,7 @@
 struct dlm_debug_ctxt {
 	struct kref debug_refcnt;
 	struct dentry *debug_state_dentry;
+	struct dentry *debug_lockres_dentry;
 };
 
 struct debug_buffer
@@ -36,6 +37,14 @@ struct debug_buffer
 	char *buf;
 };
 
+struct debug_lockres
+{
+	int dl_len;
+	char *dl_buf;
+	struct dlm_ctxt *dl_ctxt;
+	struct dlm_lock_resource *dl_res;
+};
+
 void dlm_remove_proc(void);
 void dlm_init_proc(void);
 void dlm_dump_lock_resources(struct dlm_ctxt *dlm);
Signature · 1 line
1.5.2.5
#9 lore raw

PATCH 8/12 ocfs2_dlm: Moves struct dlm_master_list_entry to dlmcommon.h

In reply to Sunil Mushran

This patch moves some mle related definitions from dlmmaster.c to dlmcommon.h.

---
 fs/ocfs2/dlm/dlmcommon.h |   37 +++++++++++++++++++++++++++++++++++++
 fs/ocfs2/dlm/dlmmaster.c |   37 -------------------------------------
 2 files changed, 37 insertions(+), 37 deletions(-)
fs/ocfs2/dlm/dlmcommon.h +37 -0
index 9828722..fb71a32 100644
@@ -49,6 +49,43 @@
 /* Intended to make it easier for us to switch out hash functions */
 #define dlm_lockid_hash(_n, _l) full_name_hash(_n, _l)
 
+enum dlm_mle_type {
+	DLM_MLE_BLOCK,
+	DLM_MLE_MASTER,
+	DLM_MLE_MIGRATION
+};
+
+struct dlm_lock_name
+{
+	u8 len;
+	u8 name[DLM_LOCKID_NAME_MAX];
+};
+
+struct dlm_master_list_entry
+{
+	struct list_head list;
+	struct list_head hb_events;
+	struct dlm_ctxt *dlm;
+	spinlock_t spinlock;
+	wait_queue_head_t wq;
+	atomic_t woken;
+	struct kref mle_refs;
+	int inuse;
+	unsigned long maybe_map[BITS_TO_LONGS(O2NM_MAX_NODES)];
+	unsigned long vote_map[BITS_TO_LONGS(O2NM_MAX_NODES)];
+	unsigned long response_map[BITS_TO_LONGS(O2NM_MAX_NODES)];
+	unsigned long node_map[BITS_TO_LONGS(O2NM_MAX_NODES)];
+	u8 master;
+	u8 new_master;
+	enum dlm_mle_type type;
+	struct o2hb_callback_func mle_hb_up;
+	struct o2hb_callback_func mle_hb_down;
+	union {
+		struct dlm_lock_resource *res;
+		struct dlm_lock_name name;
+	} u;
+};
+
 enum dlm_ast_type {
 	DLM_AST = 0,
 	DLM_BAST,
fs/ocfs2/dlm/dlmmaster.c +0 -37
index 4f2bf7c..05c86f2 100644
@@ -52,43 +52,6 @@
 #define MLOG_MASK_PREFIX (ML_DLM|ML_DLM_MASTER)
 #include "cluster/masklog.h"
 
-enum dlm_mle_type {
-	DLM_MLE_BLOCK,
-	DLM_MLE_MASTER,
-	DLM_MLE_MIGRATION
-};
-
-struct dlm_lock_name
-{
-	u8 len;
-	u8 name[DLM_LOCKID_NAME_MAX];
-};
-
-struct dlm_master_list_entry
-{
-	struct list_head list;
-	struct list_head hb_events;
-	struct dlm_ctxt *dlm;
-	spinlock_t spinlock;
-	wait_queue_head_t wq;
-	atomic_t woken;
-	struct kref mle_refs;
-	int inuse;
-	unsigned long maybe_map[BITS_TO_LONGS(O2NM_MAX_NODES)];
-	unsigned long vote_map[BITS_TO_LONGS(O2NM_MAX_NODES)];
-	unsigned long response_map[BITS_TO_LONGS(O2NM_MAX_NODES)];
-	unsigned long node_map[BITS_TO_LONGS(O2NM_MAX_NODES)];
-	u8 master;
-	u8 new_master;
-	enum dlm_mle_type type;
-	struct o2hb_callback_func mle_hb_up;
-	struct o2hb_callback_func mle_hb_down;
-	union {
-		struct dlm_lock_resource *res;
-		struct dlm_lock_name name;
-	} u;
-};
-
 static void dlm_mle_node_down(struct dlm_ctxt *dlm,
 			      struct dlm_master_list_entry *mle,
 			      struct o2nm_node *node,
Signature · 1 line
1.5.2.5
#10 lore raw

PATCH 9/12 ocfs2_dlm: Dumps the mles into a debugfs file

In reply to Sunil Mushran

This patch dumps all mles it can fit in one page into a debugfs file. Useful for debugging.

---
 fs/ocfs2/dlm/dlmdebug.c |  114 +++++++++++++++++++++++++++++++++++++++++++++++
 fs/ocfs2/dlm/dlmdebug.h |    1 +
 2 files changed, 115 insertions(+), 0 deletions(-)
fs/ocfs2/dlm/dlmdebug.c +114 -0
index a89bfe7..aad35cc 100644
@@ -794,6 +794,109 @@ static int debug_buffer_release(struct inode *inode, struct file *file)
 
 /* end - util funcs */
 
+/* begin - debug mle funcs */
+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 += snprintf(buf + out, len - out,
+			"%.*s\t%3s\tmas=%3u\tnew=%3u\tevt=%1d\tuse=%1d\tref=%3d\n",
+		  	namelen, name,
+			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;
+}
+
+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;
+
+	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(char *buf, int len, int list_type, struct dlm_lock *lock)
 {
@@ -1174,6 +1277,15 @@ int dlm_debug_init(struct dlm_ctxt *dlm)
 		goto bail;
 	}
 
+	/* for dumping mles */
+	dc->debug_mle_dentry = debugfs_create_file("mle", S_IFREG|S_IRUSR,
+						   dlm->dlm_debugfs_subroot,
+						   dlm, &debug_mle_fops);
+	if (!dc->debug_mle_dentry) {
+		mlog_errno(-ENOMEM);
+		goto bail;
+	}
+
 	dlm_debug_get(dc);
 	return 0;
 
@@ -1187,6 +1299,8 @@ void dlm_debug_shutdown(struct dlm_ctxt *dlm)
 	struct dlm_debug_ctxt *dc = dlm->dlm_debug_ctxt;
 
 	if (dc) {
+		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)
fs/ocfs2/dlm/dlmdebug.h +1 -0
index 86d02f4..c6b240f 100644
@@ -29,6 +29,7 @@ struct dlm_debug_ctxt {
 	struct kref debug_refcnt;
 	struct dentry *debug_state_dentry;
 	struct dentry *debug_lockres_dentry;
+	struct dentry *debug_mle_dentry;
 };
 
 struct debug_buffer
Signature · 1 line
1.5.2.5
#11 lore raw

PATCH 10/12 ocfs2_dlm: Dumps the purgelist into a debugfs file

In reply to Sunil Mushran

This patch dumps all the lockres' on the purgelist it can fit in one page into a debugfs file. Useful for debugging.

---
 fs/ocfs2/dlm/dlmdebug.c |   65 +++++++++++++++++++++++++++++++++++++++++++++++
 fs/ocfs2/dlm/dlmdebug.h |    1 +
 2 files changed, 66 insertions(+), 0 deletions(-)
fs/ocfs2/dlm/dlmdebug.c +65 -0
index aad35cc..25334a4 100644
@@ -794,6 +794,59 @@ 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;
+
+	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 += snprintf(db->buf + out, db->len - out,
+				"%.*s\t%ld\n",
+				res->lockname.len, res->lockname.name,
+				(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 dump_mle(struct dlm_master_list_entry *mle, char *buf, int len)
 {
@@ -1286,6 +1339,16 @@ int dlm_debug_init(struct dlm_ctxt *dlm)
 		goto bail;
 	}
 
+	/* for dumping lockres on the purge list */
+	dc->debug_purgelist_dentry =
+			debugfs_create_file("purgelist", 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;
 
@@ -1299,6 +1362,8 @@ 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)
fs/ocfs2/dlm/dlmdebug.h +1 -0
index c6b240f..ca7bc32 100644
@@ -30,6 +30,7 @@ struct dlm_debug_ctxt {
 	struct dentry *debug_state_dentry;
 	struct dentry *debug_lockres_dentry;
 	struct dentry *debug_mle_dentry;
+	struct dentry *debug_purgelist_dentry;
 };
 
 struct debug_buffer
Signature · 1 line
1.5.2.5
#12 lore raw

PATCH 11/12 ocfs2_dlm: Dumps the workqueue into a debugfs file

In reply to Sunil Mushran

This patch dumps all the tasks on the workqueue it can fit in one page into a debugfs file. Useful for debugging.

---
 fs/ocfs2/dlm/dlmdebug.c |   85 +++++++++++++++++++++++++++++++++++++++++++++++
 fs/ocfs2/dlm/dlmdebug.h |    1 +
 2 files changed, 86 insertions(+), 0 deletions(-)
fs/ocfs2/dlm/dlmdebug.c +85 -0
index 25334a4..a05077b 100644
@@ -794,6 +794,79 @@ static int debug_buffer_release(struct inode *inode, struct file *file)
 
 /* end - util funcs */
 
+/* begin - work queue funcs */
+static int debug_workqueue_print(struct dlm_ctxt *dlm, struct debug_buffer *db)
+{
+	struct dlm_work_item *wi;
+	int out = 0;
+	unsigned long total = 0;
+
+	spin_lock(&dlm->work_lock);
+
+	list_for_each_entry(wi, &dlm->work_list, list) {
+		++total;
+		if (db->len - out < 100)
+			continue;
+		if (wi->func == dlm_request_all_locks_worker) {
+			out += snprintf(db->buf + out, db->len - out,
+					"RequestAllLocks, "
+					"recomaster=%d, deadnode=%d\n",
+					wi->u.ral.reco_master,
+					wi->u.ral.dead_node);
+		} else if (wi->func == dlm_mig_lockres_worker) {
+			out += snprintf(db->buf + out, db->len - out,
+					"MigrateLockres, %.*s, master=%d\n",
+					wi->u.ml.lockres->lockname.len,
+					wi->u.ml.lockres->lockname.name,
+					wi->u.ml.real_master);
+		} else if (wi->func == dlm_assert_master_worker) {
+			out += snprintf(db->buf + out, db->len - out,
+					"AssertMaster, %.*s, "
+					"from=%d, flags=0x%X, ignore=%d\n",
+					wi->u.am.lockres->lockname.len,
+					wi->u.am.lockres->lockname.name,
+					wi->u.am.request_from,
+					wi->u.am.flags,
+					wi->u.am.ignore_higher);
+		} else {
+			out += snprintf(db->buf + out, db->len - out,
+					"Unknown, 0x%p\n", wi->func);
+		}
+	}
+	spin_unlock(&dlm->work_lock);
+
+	out += snprintf(db->buf + out, db->len - out,
+			"Total on list: %ld\n", total);
+
+	return out;
+}
+
+static int debug_workqueue_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_workqueue_print(dlm, db);
+
+	file->private_data = db;
+
+	return 0;
+bail:
+	return -ENOMEM;
+}
+
+static struct file_operations debug_workqueue_fops = {
+	.open =		debug_workqueue_open,
+	.release =	debug_buffer_release,
+	.read =		debug_buffer_read,
+	.llseek =	debug_buffer_llseek,
+};
+/* end - work queue funcs */
+
 /* begin - purge list funcs */
 static int debug_purgelist_print(struct dlm_ctxt *dlm, struct debug_buffer *db)
 {
@@ -1349,6 +1422,16 @@ int dlm_debug_init(struct dlm_ctxt *dlm)
 		goto bail;
 	}
 
+	/* for dumping the dlm work queue */
+	dc->debug_workqueue_dentry =
+			debugfs_create_file("workqueue", S_IFREG|S_IRUSR,
+					    dlm->dlm_debugfs_subroot,
+					    dlm, &debug_workqueue_fops);
+	if (!dc->debug_workqueue_dentry) {
+		mlog_errno(-ENOMEM);
+		goto bail;
+	}
+
 	dlm_debug_get(dc);
 	return 0;
 
@@ -1362,6 +1445,8 @@ void dlm_debug_shutdown(struct dlm_ctxt *dlm)
 	struct dlm_debug_ctxt *dc = dlm->dlm_debug_ctxt;
 
 	if (dc) {
+		if (dc->debug_workqueue_dentry)
+			debugfs_remove(dc->debug_workqueue_dentry);
 		if (dc->debug_purgelist_dentry)
 			debugfs_remove(dc->debug_purgelist_dentry);
 		if (dc->debug_mle_dentry)
fs/ocfs2/dlm/dlmdebug.h +1 -0
index ca7bc32..fcc19c8 100644
@@ -31,6 +31,7 @@ struct dlm_debug_ctxt {
 	struct dentry *debug_lockres_dentry;
 	struct dentry *debug_mle_dentry;
 	struct dentry *debug_purgelist_dentry;
+	struct dentry *debug_workqueue_dentry;
 };
 
 struct debug_buffer
Signature · 1 line
1.5.2.5
#13 lore raw

PATCH 12/12 ocfs2_dlm: Remove the proc interface

In reply to Sunil Mushran

The proc debug interface is no longer needed as all the functionality it provided has been moved to the debugfs interface.

---
 fs/ocfs2/dlm/dlmcommon.h |    2 -
 fs/ocfs2/dlm/dlmdebug.c  |  454 ----------------------------------------------
 fs/ocfs2/dlm/dlmdebug.h  |    7 -
 fs/ocfs2/dlm/dlmdomain.c |    8 -
 4 files changed, 0 insertions(+), 471 deletions(-)
fs/ocfs2/dlm/dlmcommon.h +0 -2
index fb71a32..4587876 100644
@@ -155,8 +155,6 @@ struct dlm_ctxt
 	struct list_head master_list;
 	struct list_head mle_hb_events;
 
-	struct proc_dir_entry *dlm_proc;
-
 	/* these give a really vague idea of the system load */
 	atomic_t local_resources;
 	atomic_t remote_resources;
fs/ocfs2/dlm/dlmdebug.c +0 -454

478 lines not on this page · raw message

fs/ocfs2/dlm/dlmdebug.h +0 -7
index fcc19c8..f6537ac 100644
@@ -48,13 +48,6 @@ struct debug_lockres
 	struct dlm_lock_resource *dl_res;
 };
 
-void dlm_remove_proc(void);
-void dlm_init_proc(void);
-void dlm_dump_lock_resources(struct dlm_ctxt *dlm);
-void dlm_proc_add_domain(struct dlm_ctxt *dlm);
-void dlm_proc_del_domain(struct dlm_ctxt *dlm);
-void dlm_dump_work_queue(struct dlm_ctxt *dlm);
-
 int dlm_debug_init(struct dlm_ctxt *dlm);
 void dlm_debug_shutdown(struct dlm_ctxt *dlm);
 
fs/ocfs2/dlm/dlmdomain.c +0 -8
index b06151e..1cad023 100644
@@ -41,8 +41,6 @@
 
 #include "dlmapi.h"
 #include "dlmcommon.h"
-
-#include "dlmdebug.h"
 #include "dlmdomain.h"
 #include "dlmdebug.h"
 
@@ -288,8 +286,6 @@ static int dlm_wait_on_domain_helper(const char *domain)
 
 static void dlm_free_ctxt_mem(struct dlm_ctxt *dlm)
 {
-	dlm_proc_del_domain(dlm);
-
 	dlm_destroy_debugfs_subroot(dlm);
 
 	if (dlm->lockres_hash)
@@ -1467,7 +1463,6 @@ static struct dlm_ctxt *dlm_alloc_ctxt(const char *domain,
 	dlm->dlm_state = DLM_CTXT_NEW;
 
 	INIT_LIST_HEAD(&dlm->dlm_eviction_callbacks);
-	dlm_proc_add_domain(dlm);
 
 	mlog(0, "context init: refcount %u\n",
 		  atomic_read(&dlm->dlm_refs.refcount));
@@ -1698,8 +1693,6 @@ static int __init dlm_init(void)
 	if (status)
 		goto error;
 
-	dlm_init_proc();
-
 	status = dlm_create_debugfs_root();
 	if (status)
 		goto error;
@@ -1717,7 +1710,6 @@ error:
 static void __exit dlm_exit (void)
 {
 	dlm_destroy_debugfs_root();
-	dlm_remove_proc();
 	dlm_unregister_net_handlers();
 	dlm_destroy_lock_cache();
 	dlm_destroy_lockname_cache();
Signature · 1 line
1.5.2.5