Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 58559
b: refs/heads/master
c: 9dd592d
h: refs/heads/master
i:
  58557: 5bc46b4
  58555: ae6609d
  58551: 4642743
  58543: 6ce8796
  58527: 73baccc
  58495: fa21fd3
v: v3
  • Loading branch information
David Teigland authored and Steven Whitehouse committed Jul 9, 2007
1 parent fb9fae2 commit 89c71c7
Show file tree
Hide file tree
Showing 3 changed files with 164 additions and 3 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 8b4021fa436f7c76a2299e6d85d4d4a619724e9a
refs/heads/master: 9dd592d70be0db6fa8e4e19d7642cfaa424b200e
164 changes: 162 additions & 2 deletions trunk/fs/dlm/debug_fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ static struct dentry *dlm_root;

struct rsb_iter {
int entry;
int master;
int header;
struct dlm_ls *ls;
struct list_head *next;
struct dlm_rsb *rsb;
Expand Down Expand Up @@ -86,6 +88,8 @@ static int print_resource(struct dlm_rsb *res, struct seq_file *s)
struct dlm_lkb *lkb;
int i, lvblen = res->res_ls->ls_lvblen, recover_list, root_list;

lock_rsb(res);

seq_printf(s, "\nResource %p Name (len=%d) \"", res, res->res_length);
for (i = 0; i < res->res_length; i++) {
if (isprint(res->res_name[i]))
Expand Down Expand Up @@ -152,6 +156,59 @@ static int print_resource(struct dlm_rsb *res, struct seq_file *s)
seq_printf(s, "\n");
}
out:
unlock_rsb(res);
return 0;
}

static void print_master_lock(struct seq_file *s, struct dlm_lkb *lkb,
struct dlm_rsb *r)
{
struct dlm_user_args *ua;
unsigned int waiting = 0;
uint64_t xid = 0;

if (lkb->lkb_flags & DLM_IFL_USER) {
ua = (struct dlm_user_args *) lkb->lkb_astparam;
if (ua)
xid = ua->xid;
}

if (lkb->lkb_timestamp)
waiting = jiffies_to_msecs(jiffies - lkb->lkb_timestamp);

/* id nodeid remid pid xid flags sts grmode rqmode time_ms len name */

seq_printf(s, "%x %d %x %u %llu %x %d %d %d %u %d \"%s\"\n",
lkb->lkb_id,
lkb->lkb_nodeid,
lkb->lkb_remid,
lkb->lkb_ownpid,
(unsigned long long)xid,
lkb->lkb_exflags,
lkb->lkb_status,
lkb->lkb_grmode,
lkb->lkb_rqmode,
waiting,
r->res_length,
r->res_name);
}

static int print_master_resource(struct dlm_rsb *r, struct seq_file *s)
{
struct dlm_lkb *lkb;

lock_rsb(r);

list_for_each_entry(lkb, &r->res_grantqueue, lkb_statequeue)
print_master_lock(s, lkb, r);

list_for_each_entry(lkb, &r->res_convertqueue, lkb_statequeue)
print_master_lock(s, lkb, r);

list_for_each_entry(lkb, &r->res_waitqueue, lkb_statequeue)
print_master_lock(s, lkb, r);

unlock_rsb(r);
return 0;
}

Expand Down Expand Up @@ -209,7 +266,7 @@ static struct rsb_iter *rsb_iter_init(struct dlm_ls *ls)
{
struct rsb_iter *ri;

ri = kmalloc(sizeof *ri, GFP_KERNEL);
ri = kzalloc(sizeof *ri, GFP_KERNEL);
if (!ri)
return NULL;

Expand Down Expand Up @@ -267,7 +324,17 @@ static int rsb_seq_show(struct seq_file *file, void *iter_ptr)
{
struct rsb_iter *ri = iter_ptr;

print_resource(ri->rsb, file);
if (ri->master) {
if (ri->header) {
seq_printf(file, "id nodeid remid pid xid flags sts "
"grmode rqmode time_ms len name\n");
ri->header = 0;
}
if (is_master(ri->rsb))
print_master_resource(ri->rsb, file);
} else {
print_resource(ri->rsb, file);
}

return 0;
}
Expand Down Expand Up @@ -302,6 +369,83 @@ static const struct file_operations rsb_fops = {
.release = seq_release
};

/*
* Dump master lock state
*/

static struct rsb_iter *master_iter_init(struct dlm_ls *ls, loff_t *pos)
{
struct rsb_iter *ri;

ri = kzalloc(sizeof *ri, GFP_KERNEL);
if (!ri)
return NULL;

ri->ls = ls;
ri->entry = 0;
ri->next = NULL;
ri->master = 1;

if (*pos == 0)
ri->header = 1;

if (rsb_iter_next(ri)) {
rsb_iter_free(ri);
return NULL;
}

return ri;
}

static void *master_seq_start(struct seq_file *file, loff_t *pos)
{
struct rsb_iter *ri;
loff_t n = *pos;

ri = master_iter_init(file->private, pos);
if (!ri)
return NULL;

while (n--) {
if (rsb_iter_next(ri)) {
rsb_iter_free(ri);
return NULL;
}
}

return ri;
}

static struct seq_operations master_seq_ops = {
.start = master_seq_start,
.next = rsb_seq_next,
.stop = rsb_seq_stop,
.show = rsb_seq_show,
};

static int master_open(struct inode *inode, struct file *file)
{
struct seq_file *seq;
int ret;

ret = seq_open(file, &master_seq_ops);
if (ret)
return ret;

seq = file->private_data;
seq->private = inode->i_private;

return 0;
}

static const struct file_operations master_fops = {
.owner = THIS_MODULE,
.open = master_open,
.read = seq_read,
.llseek = seq_lseek,
.release = seq_release
};

/*
* dump lkb's on the ls_waiters list
*/
Expand Down Expand Up @@ -369,6 +513,20 @@ int dlm_create_debug_file(struct dlm_ls *ls)
return -ENOMEM;
}

memset(name, 0, sizeof(name));
snprintf(name, DLM_LOCKSPACE_LEN+8, "%s_master", ls->ls_name);

ls->ls_debug_master_dentry = debugfs_create_file(name,
S_IFREG | S_IRUGO,
dlm_root,
ls,
&master_fops);
if (!ls->ls_debug_master_dentry) {
debugfs_remove(ls->ls_debug_waiters_dentry);
debugfs_remove(ls->ls_debug_rsb_dentry);
return -ENOMEM;
}

return 0;
}

Expand All @@ -378,6 +536,8 @@ void dlm_delete_debug_file(struct dlm_ls *ls)
debugfs_remove(ls->ls_debug_rsb_dentry);
if (ls->ls_debug_waiters_dentry)
debugfs_remove(ls->ls_debug_waiters_dentry);
if (ls->ls_debug_master_dentry)
debugfs_remove(ls->ls_debug_master_dentry);
}

int dlm_register_debugfs(void)
Expand Down
1 change: 1 addition & 0 deletions trunk/fs/dlm/dlm_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,7 @@ struct dlm_ls {

struct dentry *ls_debug_rsb_dentry; /* debugfs */
struct dentry *ls_debug_waiters_dentry; /* debugfs */
struct dentry *ls_debug_master_dentry; /* debugfs */

wait_queue_head_t ls_uevent_wait; /* user part of join/leave */
int ls_uevent_result;
Expand Down

0 comments on commit 89c71c7

Please sign in to comment.