diff options
author | Sunil Mushran <sunil.mushran@oracle.com> | 2008-03-10 18:16:28 -0400 |
---|---|---|
committer | Mark Fasheh <mfasheh@suse.com> | 2008-04-18 11:56:09 -0400 |
commit | e5a0334cbd65e27f8dfd9985aa805874fe59e879 (patch) | |
tree | adc51fd08d763c93cbe737e6bb3107b46df4c391 /fs/ocfs2/dlm/dlmdebug.c | |
parent | 7209300a9b987e017cae2ef9d7ef55b0fdd71869 (diff) |
ocfs2/dlm: Move dlm_print_one_mle() from dlmmaster.c to dlmdebug.c
This patch helps in consolidating debugging related functions in dlmdebug.c.
Signed-off-by: Sunil Mushran <sunil.mushran@oracle.com>
Signed-off-by: Joel Becker <joel.becker@oracle.com>
Signed-off-by: Mark Fasheh <mfasheh@suse.com>
Diffstat (limited to 'fs/ocfs2/dlm/dlmdebug.c')
-rw-r--r-- | fs/ocfs2/dlm/dlmdebug.c | 154 |
1 files changed, 82 insertions, 72 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 | } |
269 | EXPORT_SYMBOL_GPL(dlm_errname); | 269 | EXPORT_SYMBOL_GPL(dlm_errname); |
270 | 270 | ||
271 | |||
272 | #ifdef CONFIG_DEBUG_FS | ||
273 | |||
274 | static 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 | ||
297 | static 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 | |||
309 | static 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 | |||
364 | void 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 | |||
377 | static 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 | ||
329 | static 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 | |||
341 | static struct debug_buffer *debug_buffer_allocate(void) | 406 | static 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 */ |
458 | static 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 | |||
513 | static int debug_mle_print(struct dlm_ctxt *dlm, struct debug_buffer *db) | 523 | static 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; |