15 #include <linux/module.h>
16 #include <linux/ctype.h>
18 #include <linux/slab.h>
23 #define DLM_DEBUG_BUF_LEN 4096
25 static struct mutex debug_buf_lock;
27 static struct dentry *dlm_root;
29 static char *print_lockmode(
int mode)
77 int i, lvblen = res->
res_ls->ls_lvblen, recover_list, root_list;
82 rv =
seq_printf(s,
"\nResource %p Name (len=%d) \"",
95 rv =
seq_printf(s,
"\" \nLocal Copy, Master is node %d\n",
100 rv =
seq_printf(s,
"\" \nLooking up master (lkid %x)\n",
103 rv =
seq_printf(s,
"\" \nInvalid master %d\n",
111 for (i = 0; i < lvblen; i++) {
127 if (root_list || recover_list) {
128 rv =
seq_printf(s,
"Recovery: root %d recover %d flags %lx "
129 "count %d\n", root_list, recover_list,
138 rv = print_format1_lock(s, lkb, res);
145 rv = print_format1_lock(s, lkb, res);
152 rv = print_format1_lock(s, lkb, res);
191 rv =
seq_printf(s,
"%x %d %x %u %llu %x %x %d %d %d %llu %u %d \"%s\"\n",
196 (
unsigned long long)xid,
202 (
unsigned long long)us,
217 rv = print_format2_lock(s, lkb, r);
223 rv = print_format2_lock(s, lkb, r);
229 rv = print_format2_lock(s, lkb, r);
249 rv =
seq_printf(s,
"lkb %x %d %x %u %llu %x %x %d %d %d %d %d %d %u %llu %llu\n",
254 (
unsigned long long)xid,
272 int i, lvblen = r->
res_ls->ls_lvblen;
278 rv =
seq_printf(s,
"rsb %p %d %x %lx %d %d %u %d ",
295 seq_printf(s,
"%s", print_name ?
"str " :
"hex");
312 for (i = 0; i < lvblen; i++)
320 rv = print_format3_lock(s, lkb, 0);
326 rv = print_format3_lock(s, lkb, 0);
332 rv = print_format3_lock(s, lkb, 0);
338 rv = print_format3_lock(s, lkb, 1);
355 rv =
seq_printf(s,
"rsb %p %d %d %d %d %lu %lx %d ",
372 seq_printf(s,
"%s", print_name ?
"str " :
"hex");
399 static int table_seq_show(
struct seq_file *seq,
void *iter_ptr)
406 rv = print_format1(ri->
rsb, seq);
410 seq_printf(seq,
"id nodeid remid pid xid exflags "
411 "flags sts grmode rqmode time_ms "
412 "r_nodeid r_len r_name\n");
415 rv = print_format2(ri->
rsb, seq);
419 seq_printf(seq,
"version rsb 1.1 lvb 1.1 lkb 1.1\n");
422 rv = print_format3(ri->
rsb, seq);
429 rv = print_format4(ri->
rsb, seq);
441 static void *table_seq_start(
struct seq_file *seq, loff_t *
pos)
449 unsigned bucket,
entry;
450 int toss = (seq->
op == &format4_seq_ops);
453 entry = n & ((1
LL << 32) - 1);
455 if (bucket >=
ls->ls_rsbtbl_size)
463 if (
seq->op == &format1_seq_ops)
465 if (
seq->op == &format2_seq_ops)
467 if (
seq->op == &format3_seq_ops)
469 if (
seq->op == &format4_seq_ops)
472 tree = toss ? &
ls->ls_rsbtbl[bucket].toss : &
ls->ls_rsbtbl[bucket].keep;
474 spin_lock(&
ls->ls_rsbtbl[bucket].lock);
482 spin_unlock(&
ls->ls_rsbtbl[bucket].lock);
487 spin_unlock(&
ls->ls_rsbtbl[bucket].lock);
494 n &= ~((1
LL << 32) - 1);
500 if (bucket >=
ls->ls_rsbtbl_size) {
504 tree = toss ? &
ls->ls_rsbtbl[bucket].toss : &
ls->ls_rsbtbl[bucket].keep;
506 spin_lock(&
ls->ls_rsbtbl[bucket].lock);
513 spin_unlock(&
ls->ls_rsbtbl[bucket].lock);
517 spin_unlock(&
ls->ls_rsbtbl[bucket].lock);
521 static void *table_seq_next(
struct seq_file *seq,
void *iter_ptr, loff_t *
pos)
530 int toss = (seq->
op == &format4_seq_ops);
546 spin_unlock(&ls->
ls_rsbtbl[bucket].lock);
551 spin_unlock(&ls->
ls_rsbtbl[bucket].lock);
559 n &= ~((1
LL << 32) - 1);
578 spin_unlock(&ls->
ls_rsbtbl[bucket].lock);
582 spin_unlock(&ls->
ls_rsbtbl[bucket].lock);
586 static void table_seq_stop(
struct seq_file *seq,
void *iter_ptr)
597 .start = table_seq_start,
598 .next = table_seq_next,
599 .stop = table_seq_stop,
600 .show = table_seq_show,
604 .start = table_seq_start,
605 .next = table_seq_next,
606 .stop = table_seq_stop,
607 .show = table_seq_show,
611 .start = table_seq_start,
612 .next = table_seq_next,
613 .stop = table_seq_stop,
614 .show = table_seq_show,
618 .start = table_seq_start,
619 .next = table_seq_next,
620 .stop = table_seq_stop,
621 .show = table_seq_show,
634 if (file->
f_op == &format1_fops)
635 ret =
seq_open(file, &format1_seq_ops);
636 else if (file->
f_op == &format2_fops)
637 ret =
seq_open(file, &format2_seq_ops);
638 else if (file->
f_op == &format3_fops)
639 ret =
seq_open(file, &format3_seq_ops);
640 else if (file->
f_op == &format4_fops)
641 ret =
seq_open(file, &format4_seq_ops);
686 static ssize_t waiters_read(
struct file *file,
char __user *userbuf,
687 size_t count, loff_t *ppos)
695 memset(debug_buf, 0,
sizeof(debug_buf));
698 ret =
snprintf(debug_buf + pos, len - pos,
"%x %d %d %s\n",
701 if (ret >= len - pos)
715 .read = waiters_read,
749 memset(name, 0,
sizeof(name));
762 memset(name, 0,
sizeof(name));
775 memset(name, 0,
sizeof(name));
786 memset(name, 0,
sizeof(name));
808 return dlm_root ? 0 : -
ENOMEM;