Skip to content

Commit 63eab2b

Browse files
Alexander Aringteigland
authored andcommitted
fs: dlm: add lkb waiters debugfs functionality
This patch adds functionality to put a lkb to the waiters state. It can be useful to combine this feature with the "rawmsg" debugfs functionality. It will bring the DLM lkb into a state that a message will be parsed by the kernel. Signed-off-by: Alexander Aring <aahringo@redhat.com> Signed-off-by: David Teigland <teigland@redhat.com>
1 parent 5054e79 commit 63eab2b

File tree

3 files changed

+43
-1
lines changed

3 files changed

+43
-1
lines changed

fs/dlm/debug_fs.c

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -754,10 +754,35 @@ static ssize_t waiters_read(struct file *file, char __user *userbuf,
754754
return rv;
755755
}
756756

757+
static ssize_t waiters_write(struct file *file, const char __user *user_buf,
758+
size_t count, loff_t *ppos)
759+
{
760+
struct dlm_ls *ls = file->private_data;
761+
int mstype, to_nodeid;
762+
char buf[128] = {};
763+
uint32_t lkb_id;
764+
int n, error;
765+
766+
if (copy_from_user(buf, user_buf,
767+
min_t(size_t, sizeof(buf) - 1, count)))
768+
return -EFAULT;
769+
770+
n = sscanf(buf, "%x %d %d", &lkb_id, &mstype, &to_nodeid);
771+
if (n != 3)
772+
return -EINVAL;
773+
774+
error = dlm_debug_add_lkb_to_waiters(ls, lkb_id, mstype, to_nodeid);
775+
if (error)
776+
return error;
777+
778+
return count;
779+
}
780+
757781
static const struct file_operations waiters_fops = {
758782
.owner = THIS_MODULE,
759783
.open = simple_open,
760784
.read = waiters_read,
785+
.write = waiters_write,
761786
.llseek = default_llseek,
762787
};
763788

@@ -907,7 +932,7 @@ void dlm_create_debug_file(struct dlm_ls *ls)
907932
snprintf(name, DLM_LOCKSPACE_LEN + 8, "%s_waiters", ls->ls_name);
908933

909934
ls->ls_debug_waiters_dentry = debugfs_create_file(name,
910-
S_IFREG | S_IRUGO,
935+
0644,
911936
dlm_root,
912937
ls,
913938
&waiters_fops);

fs/dlm/lock.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6363,3 +6363,18 @@ int dlm_debug_add_lkb(struct dlm_ls *ls, uint32_t lkb_id, char *name, int len,
63636363
return 0;
63646364
}
63656365

6366+
int dlm_debug_add_lkb_to_waiters(struct dlm_ls *ls, uint32_t lkb_id,
6367+
int mstype, int to_nodeid)
6368+
{
6369+
struct dlm_lkb *lkb;
6370+
int error;
6371+
6372+
error = find_lkb(ls, lkb_id, &lkb);
6373+
if (error)
6374+
return error;
6375+
6376+
error = add_to_waiters(lkb, mstype, to_nodeid);
6377+
dlm_put_lkb(lkb);
6378+
return error;
6379+
}
6380+

fs/dlm/lock.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ int dlm_user_deadlock(struct dlm_ls *ls, uint32_t flags, uint32_t lkid);
6060
void dlm_clear_proc_locks(struct dlm_ls *ls, struct dlm_user_proc *proc);
6161
int dlm_debug_add_lkb(struct dlm_ls *ls, uint32_t lkb_id, char *name, int len,
6262
int lkb_nodeid, unsigned int lkb_flags, int lkb_status);
63+
int dlm_debug_add_lkb_to_waiters(struct dlm_ls *ls, uint32_t lkb_id,
64+
int mstype, int to_nodeid);
6365

6466
static inline int is_master(struct dlm_rsb *r)
6567
{

0 commit comments

Comments
 (0)