From 0b720f02b9390ed95d9cd4740ea88451ac2e34ac Mon Sep 17 00:00:00 2001 From: green <green> Date: Sun, 12 Aug 2007 00:46:58 +0000 Subject: [PATCH] b=13276 r=shadow,wangdi check return value of ll_node_from_inode in ll_file_read and ll_file_sendfile, do not try to access uninitialised locks tree on error exit from ll_file_write --- lustre/ChangeLog | 6 ++++++ lustre/llite/file.c | 12 ++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/lustre/ChangeLog b/lustre/ChangeLog index 8476a298ca..7331230d70 100644 --- a/lustre/ChangeLog +++ b/lustre/ChangeLog @@ -78,6 +78,12 @@ Details : Flock locks might destroy just granted lock if it could be merged so teach ldlm_cli_enquque_fini that this is a valid case for flock locks. +Severity : minor +Bugzilla : 13276 +Frequency : rare +Description: Oops in read and write path when failing to allocate lock. +Details : Check if lock allocation failed and return error back. + -------------------------------------------------------------------------------- 2007-08-10 Cluster File Systems, Inc. <info@clusterfs.com> diff --git a/lustre/llite/file.c b/lustre/llite/file.c index 2f75521fd9..98b42e7ff0 100644 --- a/lustre/llite/file.c +++ b/lustre/llite/file.c @@ -1362,6 +1362,10 @@ repeat: } node = ll_node_from_inode(inode, *ppos, end, LCK_PR); + if (IS_ERR(node)){ + GOTO(out, rc = PTR_ERR(node)); + } + tree.lt_fd = LUSTRE_FPRIVATE(file); rc = ll_tree_lock(&tree, node, buf, count, file->f_flags & O_NONBLOCK ? LDLM_FL_BLOCK_NOWAIT :0); @@ -1536,7 +1540,7 @@ repeat: if (*ppos >= maxbytes) { send_sig(SIGXFSZ, current, 0); - GOTO(out, retval = -EFBIG); + GOTO(out_unlock, retval = -EFBIG); } if (*ppos + count > maxbytes) count = maxbytes - *ppos; @@ -1548,9 +1552,10 @@ repeat: retval = generic_file_write(file, buf, chunk, ppos); ll_rw_stats_tally(ll_i2sbi(inode), current->pid, file, count, 1); -out: +out_unlock: ll_tree_unlock(&tree); +out: if (retval > 0) { buf += retval; count -= retval; @@ -1602,6 +1607,9 @@ static ssize_t ll_file_sendfile(struct file *in_file, loff_t *ppos,size_t count, RETURN(generic_file_sendfile(in_file, ppos, count, actor, target)); node = ll_node_from_inode(inode, *ppos, *ppos + count - 1, LCK_PR); + if (IS_ERR(node)) + RETURN(PTR_ERR(node)); + tree.lt_fd = LUSTRE_FPRIVATE(in_file); rc = ll_tree_lock(&tree, node, NULL, count, in_file->f_flags & O_NONBLOCK?LDLM_FL_BLOCK_NOWAIT:0); -- GitLab