[DLM] break from snprintf loop
When the debug buffer has filled up, break from the loop and return the correct number of bytes that have been written. Signed-off-by: David Teigland <teigland@redhat.com> Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
This commit is contained in:
parent
f6db1b8e72
commit
06442440bc
1 changed files with 7 additions and 4 deletions
|
@ -310,16 +310,19 @@ static ssize_t waiters_read(struct file *file, char __user *userbuf,
|
||||||
{
|
{
|
||||||
struct dlm_ls *ls = file->private_data;
|
struct dlm_ls *ls = file->private_data;
|
||||||
struct dlm_lkb *lkb;
|
struct dlm_lkb *lkb;
|
||||||
size_t len = DLM_DEBUG_BUF_LEN, pos = 0, rv;
|
size_t len = DLM_DEBUG_BUF_LEN, pos = 0, ret, rv;
|
||||||
|
|
||||||
mutex_lock(&debug_buf_lock);
|
mutex_lock(&debug_buf_lock);
|
||||||
mutex_lock(&ls->ls_waiters_mutex);
|
mutex_lock(&ls->ls_waiters_mutex);
|
||||||
memset(debug_buf, 0, sizeof(debug_buf));
|
memset(debug_buf, 0, sizeof(debug_buf));
|
||||||
|
|
||||||
list_for_each_entry(lkb, &ls->ls_waiters, lkb_wait_reply) {
|
list_for_each_entry(lkb, &ls->ls_waiters, lkb_wait_reply) {
|
||||||
pos += snprintf(debug_buf + pos, len - pos, "%x %d %d %s\n",
|
ret = snprintf(debug_buf + pos, len - pos, "%x %d %d %s\n",
|
||||||
lkb->lkb_id, lkb->lkb_wait_type,
|
lkb->lkb_id, lkb->lkb_wait_type,
|
||||||
lkb->lkb_nodeid, lkb->lkb_resource->res_name);
|
lkb->lkb_nodeid, lkb->lkb_resource->res_name);
|
||||||
|
if (ret >= len - pos)
|
||||||
|
break;
|
||||||
|
pos += ret;
|
||||||
}
|
}
|
||||||
mutex_unlock(&ls->ls_waiters_mutex);
|
mutex_unlock(&ls->ls_waiters_mutex);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue