aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/ocfs2/dlm/dlmdebug.c154
-rw-r--r--fs/ocfs2/dlm/dlmdebug.h2
-rw-r--r--fs/ocfs2/dlm/dlmmaster.c89
3 files changed, 85 insertions, 160 deletions
diff --git a/fs/ocfs2/dlm/dlmdebug.c b/fs/ocfs2/dlm/dlmdebug.c
index a109005f70da..58e45795a6c6 100644
--- a/fs/ocfs2/dlm/dlmdebug.c
+++ b/fs/ocfs2/dlm/dlmdebug.c
@@ -268,11 +268,6 @@ const char *dlm_errname(enum dlm_status err)
268} 268}
269EXPORT_SYMBOL_GPL(dlm_errname); 269EXPORT_SYMBOL_GPL(dlm_errname);
270 270
271
272#ifdef CONFIG_DEBUG_FS
273
274static struct dentry *dlm_debugfs_root = NULL;
275
276/* NOTE: This function converts a lockname into a string. It uses knowledge 271/* NOTE: This function converts a lockname into a string. It uses knowledge
277 * of the format of the lockname that should be outside the purview of the dlm. 272 * of the format of the lockname that should be outside the purview of the dlm.
278 * We are adding only to make dlm debugging slightly easier. 273 * We are adding only to make dlm debugging slightly easier.
@@ -299,6 +294,88 @@ static int stringify_lockname(const char *lockname, int locklen,
299 return out; 294 return out;
300} 295}
301 296
297static int stringify_nodemap(unsigned long *nodemap, int maxnodes,
298 char *buf, int len)
299{
300 int out = 0;
301 int i = -1;
302
303 while ((i = find_next_bit(nodemap, maxnodes, i + 1)) < maxnodes)
304 out += snprintf(buf + out, len - out, "%d ", i);
305
306 return out;
307}
308
309static int dump_mle(struct dlm_master_list_entry *mle, char *buf, int len)
310{
311 int out = 0;
312 unsigned int namelen;
313 const char *name;
314 char *mle_type;
315
316 if (mle->type != DLM_MLE_MASTER) {
317 namelen = mle->u.name.len;
318 name = mle->u.name.name;
319 } else {
320 namelen = mle->u.res->lockname.len;
321 name = mle->u.res->lockname.name;
322 }
323
324 if (mle->type == DLM_MLE_BLOCK)
325 mle_type = "BLK";
326 else if (mle->type == DLM_MLE_MASTER)
327 mle_type = "MAS";
328 else
329 mle_type = "MIG";
330
331 out += stringify_lockname(name, namelen, buf + out, len - out);
332 out += snprintf(buf + out, len - out,
333 "\t%3s\tmas=%3u\tnew=%3u\tevt=%1d\tuse=%1d\tref=%3d\n",
334 mle_type, mle->master, mle->new_master,
335 !list_empty(&mle->hb_events),
336 !!mle->inuse,
337 atomic_read(&mle->mle_refs.refcount));
338
339 out += snprintf(buf + out, len - out, "Maybe=");
340 out += stringify_nodemap(mle->maybe_map, O2NM_MAX_NODES,
341 buf + out, len - out);
342 out += snprintf(buf + out, len - out, "\n");
343
344 out += snprintf(buf + out, len - out, "Vote=");
345 out += stringify_nodemap(mle->vote_map, O2NM_MAX_NODES,
346 buf + out, len - out);
347 out += snprintf(buf + out, len - out, "\n");
348
349 out += snprintf(buf + out, len - out, "Response=");
350 out += stringify_nodemap(mle->response_map, O2NM_MAX_NODES,
351 buf + out, len - out);
352 out += snprintf(buf + out, len - out, "\n");
353
354 out += snprintf(buf + out, len - out, "Node=");
355 out += stringify_nodemap(mle->node_map, O2NM_MAX_NODES,
356 buf + out, len - out);
357 out += snprintf(buf + out, len - out, "\n");
358
359 out += snprintf(buf + out, len - out, "\n");
360
361 return out;
362}
363
364void dlm_print_one_mle(struct dlm_master_list_entry *mle)
365{
366 char *buf;
367
368 buf = (char *) get_zeroed_page(GFP_NOFS);
369 if (buf) {
370 dump_mle(mle, buf, PAGE_SIZE - 1);
371 free_page((unsigned long)buf);
372 }
373}
374
375#ifdef CONFIG_DEBUG_FS
376
377static struct dentry *dlm_debugfs_root = NULL;
378
302#define DLM_DEBUGFS_DIR "o2dlm" 379#define DLM_DEBUGFS_DIR "o2dlm"
303#define DLM_DEBUGFS_DLM_STATE "dlm_state" 380#define DLM_DEBUGFS_DLM_STATE "dlm_state"
304#define DLM_DEBUGFS_LOCKING_STATE "locking_state" 381#define DLM_DEBUGFS_LOCKING_STATE "locking_state"
@@ -326,18 +403,6 @@ static void dlm_debug_get(struct dlm_debug_ctxt *dc)
326 kref_get(&dc->debug_refcnt); 403 kref_get(&dc->debug_refcnt);
327} 404}
328 405
329static int stringify_nodemap(unsigned long *nodemap, int maxnodes,
330 char *buf, int len)
331{
332 int out = 0;
333 int i = -1;
334
335 while ((i = find_next_bit(nodemap, maxnodes, i + 1)) < maxnodes)
336 out += snprintf(buf + out, len - out, "%d ", i);
337
338 return out;
339}
340
341static struct debug_buffer *debug_buffer_allocate(void) 406static struct debug_buffer *debug_buffer_allocate(void)
342{ 407{
343 struct debug_buffer *db = NULL; 408 struct debug_buffer *db = NULL;
@@ -455,61 +520,6 @@ static struct file_operations debug_purgelist_fops = {
455/* end - purge list funcs */ 520/* end - purge list funcs */
456 521
457/* begin - debug mle funcs */ 522/* begin - debug mle funcs */
458static int dump_mle(struct dlm_master_list_entry *mle, char *buf, int len)
459{
460 int out = 0;
461 unsigned int namelen;
462 const char *name;
463 char *mle_type;
464
465 if (mle->type != DLM_MLE_MASTER) {
466 namelen = mle->u.name.len;
467 name = mle->u.name.name;
468 } else {
469 namelen = mle->u.res->lockname.len;
470 name = mle->u.res->lockname.name;
471 }
472
473 if (mle->type == DLM_MLE_BLOCK)
474 mle_type = "BLK";
475 else if (mle->type == DLM_MLE_MASTER)
476 mle_type = "MAS";
477 else
478 mle_type = "MIG";
479
480 out += stringify_lockname(name, namelen, buf + out, len - out);
481 out += snprintf(buf + out, len - out,
482 "\t%3s\tmas=%3u\tnew=%3u\tevt=%1d\tuse=%1d\tref=%3d\n",
483 mle_type, mle->master, mle->new_master,
484 !list_empty(&mle->hb_events),
485 !!mle->inuse,
486 atomic_read(&mle->mle_refs.refcount));
487
488 out += snprintf(buf + out, len - out, "Maybe=");
489 out += stringify_nodemap(mle->maybe_map, O2NM_MAX_NODES,
490 buf + out, len - out);
491 out += snprintf(buf + out, len - out, "\n");
492
493 out += snprintf(buf + out, len - out, "Vote=");
494 out += stringify_nodemap(mle->vote_map, O2NM_MAX_NODES,
495 buf + out, len - out);
496 out += snprintf(buf + out, len - out, "\n");
497
498 out += snprintf(buf + out, len - out, "Response=");
499 out += stringify_nodemap(mle->response_map, O2NM_MAX_NODES,
500 buf + out, len - out);
501 out += snprintf(buf + out, len - out, "\n");
502
503 out += snprintf(buf + out, len - out, "Node=");
504 out += stringify_nodemap(mle->node_map, O2NM_MAX_NODES,
505 buf + out, len - out);
506 out += snprintf(buf + out, len - out, "\n");
507
508 out += snprintf(buf + out, len - out, "\n");
509
510 return out;
511}
512
513static int debug_mle_print(struct dlm_ctxt *dlm, struct debug_buffer *db) 523static int debug_mle_print(struct dlm_ctxt *dlm, struct debug_buffer *db)
514{ 524{
515 struct dlm_master_list_entry *mle; 525 struct dlm_master_list_entry *mle;
diff --git a/fs/ocfs2/dlm/dlmdebug.h b/fs/ocfs2/dlm/dlmdebug.h
index 8857743e8f32..d34a62a3a625 100644
--- a/fs/ocfs2/dlm/dlmdebug.h
+++ b/fs/ocfs2/dlm/dlmdebug.h
@@ -25,6 +25,8 @@
25#ifndef DLMDEBUG_H 25#ifndef DLMDEBUG_H
26#define DLMDEBUG_H 26#define DLMDEBUG_H
27 27
28void dlm_print_one_mle(struct dlm_master_list_entry *mle);
29
28#ifdef CONFIG_DEBUG_FS 30#ifdef CONFIG_DEBUG_FS
29 31
30struct dlm_debug_ctxt { 32struct dlm_debug_ctxt {
diff --git a/fs/ocfs2/dlm/dlmmaster.c b/fs/ocfs2/dlm/dlmmaster.c
index 94cadcb0cba2..efc015c6128a 100644
--- a/fs/ocfs2/dlm/dlmmaster.c
+++ b/fs/ocfs2/dlm/dlmmaster.c
@@ -48,6 +48,7 @@
48#include "dlmapi.h" 48#include "dlmapi.h"
49#include "dlmcommon.h" 49#include "dlmcommon.h"
50#include "dlmdomain.h" 50#include "dlmdomain.h"
51#include "dlmdebug.h"
51 52
52#define MLOG_MASK_PREFIX (ML_DLM|ML_DLM_MASTER) 53#define MLOG_MASK_PREFIX (ML_DLM|ML_DLM_MASTER)
53#include "cluster/masklog.h" 54#include "cluster/masklog.h"
@@ -91,94 +92,6 @@ static inline int dlm_mle_equal(struct dlm_ctxt *dlm,
91 return 1; 92 return 1;
92} 93}
93 94
94#define dlm_print_nodemap(m) _dlm_print_nodemap(m,#m)
95static void _dlm_print_nodemap(unsigned long *map, const char *mapname)
96{
97 int i;
98 printk("%s=[ ", mapname);
99 for (i=0; i<O2NM_MAX_NODES; i++)
100 if (test_bit(i, map))
101 printk("%d ", i);
102 printk("]");
103}
104
105static void dlm_print_one_mle(struct dlm_master_list_entry *mle)
106{
107 int refs;
108 char *type;
109 char attached;
110 u8 master;
111 unsigned int namelen;
112 const char *name;
113 struct kref *k;
114 unsigned long *maybe = mle->maybe_map,
115 *vote = mle->vote_map,
116 *resp = mle->response_map,
117 *node = mle->node_map;
118
119 k = &mle->mle_refs;
120 if (mle->type == DLM_MLE_BLOCK)
121 type = "BLK";
122 else if (mle->type == DLM_MLE_MASTER)
123 type = "MAS";
124 else
125 type = "MIG";
126 refs = atomic_read(&k->refcount);
127 master = mle->master;
128 attached = (list_empty(&mle->hb_events) ? 'N' : 'Y');
129
130 if (mle->type != DLM_MLE_MASTER) {
131 namelen = mle->u.name.len;
132 name = mle->u.name.name;
133 } else {
134 namelen = mle->u.res->lockname.len;
135 name = mle->u.res->lockname.name;
136 }
137
138 mlog(ML_NOTICE, "%.*s: %3s refs=%3d mas=%3u new=%3u evt=%c inuse=%d ",
139 namelen, name, type, refs, master, mle->new_master, attached,
140 mle->inuse);
141 dlm_print_nodemap(maybe);
142 printk(", ");
143 dlm_print_nodemap(vote);
144 printk(", ");
145 dlm_print_nodemap(resp);
146 printk(", ");
147 dlm_print_nodemap(node);
148 printk(", ");
149 printk("\n");
150}
151
152#if 0
153/* Code here is included but defined out as it aids debugging */
154
155static void dlm_dump_mles(struct dlm_ctxt *dlm)
156{
157 struct dlm_master_list_entry *mle;
158
159 mlog(ML_NOTICE, "dumping all mles for domain %s:\n", dlm->name);
160 spin_lock(&dlm->master_lock);
161 list_for_each_entry(mle, &dlm->master_list, list)
162 dlm_print_one_mle(mle);
163 spin_unlock(&dlm->master_lock);
164}
165
166int dlm_dump_all_mles(const char __user *data, unsigned int len)
167{
168 struct dlm_ctxt *dlm;
169
170 spin_lock(&dlm_domain_lock);
171 list_for_each_entry(dlm, &dlm_domains, list) {
172 mlog(ML_NOTICE, "found dlm: %p, name=%s\n", dlm, dlm->name);
173 dlm_dump_mles(dlm);
174 }
175 spin_unlock(&dlm_domain_lock);
176 return len;
177}
178EXPORT_SYMBOL_GPL(dlm_dump_all_mles);
179
180#endif /* 0 */
181
182static struct kmem_cache *dlm_lockres_cache = NULL; 95static struct kmem_cache *dlm_lockres_cache = NULL;
183static struct kmem_cache *dlm_lockname_cache = NULL; 96static struct kmem_cache *dlm_lockname_cache = NULL;
184static struct kmem_cache *dlm_mle_cache = NULL; 97static struct kmem_cache *dlm_mle_cache = NULL;