Skip to content

Commit 541adb0

Browse files
Alexander Aringteigland
authored andcommitted
fs: dlm: debugfs for queued callbacks
It was useful to debug an issue with the callback queue to check if any callbacks in any lkb are for some reason not processed by the callback workqueue. The mentioned issue was fixed by commit a034c13 ("fs: dlm: fix DLM_IFL_CB_PENDING gets overwritten"). If there are similar issue that looks like a ast callback was not processed, we can confirm now that it is not sitting to be processed by the callback workqueue anymore. Signed-off-by: Alexander Aring <[email protected]> Signed-off-by: David Teigland <[email protected]>
1 parent 4b056db commit 541adb0

File tree

2 files changed

+101
-1
lines changed

2 files changed

+101
-1
lines changed

fs/dlm/debug_fs.c

Lines changed: 100 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "dlm_internal.h"
1919
#include "midcomms.h"
2020
#include "lock.h"
21+
#include "ast.h"
2122

2223
#define DLM_DEBUG_BUF_LEN 4096
2324
static char debug_buf[DLM_DEBUG_BUF_LEN];
@@ -365,6 +366,52 @@ static void print_format4(struct dlm_rsb *r, struct seq_file *s)
365366
unlock_rsb(r);
366367
}
367368

369+
static void print_format5_lock(struct seq_file *s, struct dlm_lkb *lkb)
370+
{
371+
struct dlm_callback *cb;
372+
373+
/* lkb_id lkb_flags mode flags sb_status sb_flags */
374+
375+
spin_lock(&lkb->lkb_cb_lock);
376+
list_for_each_entry(cb, &lkb->lkb_callbacks, list) {
377+
seq_printf(s, "%x %x %d %x %d %x\n",
378+
lkb->lkb_id,
379+
dlm_iflags_val(lkb),
380+
cb->mode,
381+
cb->flags,
382+
cb->sb_status,
383+
cb->sb_flags);
384+
}
385+
spin_unlock(&lkb->lkb_cb_lock);
386+
}
387+
388+
static void print_format5(struct dlm_rsb *r, struct seq_file *s)
389+
{
390+
struct dlm_lkb *lkb;
391+
392+
lock_rsb(r);
393+
394+
list_for_each_entry(lkb, &r->res_grantqueue, lkb_statequeue) {
395+
print_format5_lock(s, lkb);
396+
if (seq_has_overflowed(s))
397+
goto out;
398+
}
399+
400+
list_for_each_entry(lkb, &r->res_convertqueue, lkb_statequeue) {
401+
print_format5_lock(s, lkb);
402+
if (seq_has_overflowed(s))
403+
goto out;
404+
}
405+
406+
list_for_each_entry(lkb, &r->res_waitqueue, lkb_statequeue) {
407+
print_format5_lock(s, lkb);
408+
if (seq_has_overflowed(s))
409+
goto out;
410+
}
411+
out:
412+
unlock_rsb(r);
413+
}
414+
368415
struct rsbtbl_iter {
369416
struct dlm_rsb *rsb;
370417
unsigned bucket;
@@ -408,6 +455,13 @@ static int table_seq_show(struct seq_file *seq, void *iter_ptr)
408455
}
409456
print_format4(ri->rsb, seq);
410457
break;
458+
case 5:
459+
if (ri->header) {
460+
seq_puts(seq, "lkb_id lkb_flags mode flags sb_status sb_flags\n");
461+
ri->header = 0;
462+
}
463+
print_format5(ri->rsb, seq);
464+
break;
411465
}
412466

413467
return 0;
@@ -417,6 +471,7 @@ static const struct seq_operations format1_seq_ops;
417471
static const struct seq_operations format2_seq_ops;
418472
static const struct seq_operations format3_seq_ops;
419473
static const struct seq_operations format4_seq_ops;
474+
static const struct seq_operations format5_seq_ops;
420475

421476
static void *table_seq_start(struct seq_file *seq, loff_t *pos)
422477
{
@@ -448,6 +503,8 @@ static void *table_seq_start(struct seq_file *seq, loff_t *pos)
448503
ri->format = 3;
449504
if (seq->op == &format4_seq_ops)
450505
ri->format = 4;
506+
if (seq->op == &format5_seq_ops)
507+
ri->format = 5;
451508

452509
tree = toss ? &ls->ls_rsbtbl[bucket].toss : &ls->ls_rsbtbl[bucket].keep;
453510

@@ -602,10 +659,18 @@ static const struct seq_operations format4_seq_ops = {
602659
.show = table_seq_show,
603660
};
604661

662+
static const struct seq_operations format5_seq_ops = {
663+
.start = table_seq_start,
664+
.next = table_seq_next,
665+
.stop = table_seq_stop,
666+
.show = table_seq_show,
667+
};
668+
605669
static const struct file_operations format1_fops;
606670
static const struct file_operations format2_fops;
607671
static const struct file_operations format3_fops;
608672
static const struct file_operations format4_fops;
673+
static const struct file_operations format5_fops;
609674

610675
static int table_open1(struct inode *inode, struct file *file)
611676
{
@@ -683,7 +748,21 @@ static int table_open4(struct inode *inode, struct file *file)
683748
struct seq_file *seq;
684749
int ret;
685750

686-
ret = seq_open(file, &format4_seq_ops);
751+
ret = seq_open(file, &format5_seq_ops);
752+
if (ret)
753+
return ret;
754+
755+
seq = file->private_data;
756+
seq->private = inode->i_private; /* the dlm_ls */
757+
return 0;
758+
}
759+
760+
static int table_open5(struct inode *inode, struct file *file)
761+
{
762+
struct seq_file *seq;
763+
int ret;
764+
765+
ret = seq_open(file, &format5_seq_ops);
687766
if (ret)
688767
return ret;
689768

@@ -725,6 +804,14 @@ static const struct file_operations format4_fops = {
725804
.release = seq_release
726805
};
727806

807+
static const struct file_operations format5_fops = {
808+
.owner = THIS_MODULE,
809+
.open = table_open5,
810+
.read = seq_read,
811+
.llseek = seq_lseek,
812+
.release = seq_release
813+
};
814+
728815
/*
729816
* dump lkb's on the ls_waiters list
730817
*/
@@ -793,6 +880,7 @@ void dlm_delete_debug_file(struct dlm_ls *ls)
793880
debugfs_remove(ls->ls_debug_locks_dentry);
794881
debugfs_remove(ls->ls_debug_all_dentry);
795882
debugfs_remove(ls->ls_debug_toss_dentry);
883+
debugfs_remove(ls->ls_debug_queued_asts_dentry);
796884
}
797885

798886
static int dlm_state_show(struct seq_file *file, void *offset)
@@ -936,6 +1024,17 @@ void dlm_create_debug_file(struct dlm_ls *ls)
9361024
dlm_root,
9371025
ls,
9381026
&waiters_fops);
1027+
1028+
/* format 5 */
1029+
1030+
memset(name, 0, sizeof(name));
1031+
snprintf(name, DLM_LOCKSPACE_LEN + 8, "%s_queued_asts", ls->ls_name);
1032+
1033+
ls->ls_debug_queued_asts_dentry = debugfs_create_file(name,
1034+
0644,
1035+
dlm_root,
1036+
ls,
1037+
&format5_fops);
9391038
}
9401039

9411040
void __init dlm_register_debugfs(void)

fs/dlm/dlm_internal.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -598,6 +598,7 @@ struct dlm_ls {
598598
struct dentry *ls_debug_locks_dentry; /* debugfs */
599599
struct dentry *ls_debug_all_dentry; /* debugfs */
600600
struct dentry *ls_debug_toss_dentry; /* debugfs */
601+
struct dentry *ls_debug_queued_asts_dentry; /* debugfs */
601602

602603
wait_queue_head_t ls_uevent_wait; /* user part of join/leave */
603604
int ls_uevent_result;

0 commit comments

Comments
 (0)