Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 142645
b: refs/heads/master
c: 7bfac9e
h: refs/heads/master
i:
  142643: c1d2604
v: v3
  • Loading branch information
Miklos Szeredi authored and Linus Torvalds committed Apr 7, 2009
1 parent 22f9dd2 commit 443f801
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 8 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: 612392307cb09e49051225092cbbd7049bd8db93
refs/heads/master: 7bfac9ecf0585962fe13584f5cf526d8c8e76f17
8 changes: 6 additions & 2 deletions trunk/fs/ocfs2/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -1926,7 +1926,7 @@ static ssize_t ocfs2_file_splice_write(struct pipe_inode_info *pipe,
out->f_path.dentry->d_name.len,
out->f_path.dentry->d_name.name);

inode_double_lock(inode, pipe->inode);
mutex_lock_nested(&inode->i_mutex, I_MUTEX_PARENT);

ret = ocfs2_rw_lock(inode, 1);
if (ret < 0) {
Expand All @@ -1941,12 +1941,16 @@ static ssize_t ocfs2_file_splice_write(struct pipe_inode_info *pipe,
goto out_unlock;
}

if (pipe->inode)
mutex_lock_nested(&pipe->inode->i_mutex, I_MUTEX_CHILD);
ret = generic_file_splice_write_nolock(pipe, out, ppos, len, flags);
if (pipe->inode)
mutex_unlock(&pipe->inode->i_mutex);

out_unlock:
ocfs2_rw_unlock(inode, 1);
out:
inode_double_unlock(inode, pipe->inode);
mutex_unlock(&inode->i_mutex);

mlog_exit(ret);
return ret;
Expand Down
25 changes: 20 additions & 5 deletions trunk/fs/splice.c
Original file line number Diff line number Diff line change
Expand Up @@ -737,10 +737,19 @@ ssize_t splice_from_pipe(struct pipe_inode_info *pipe, struct file *out,
* ->write_end. Most of the time, these expect i_mutex to
* be held. Since this may result in an ABBA deadlock with
* pipe->inode, we have to order lock acquiry here.
*
* Outer lock must be inode->i_mutex, as pipe_wait() will
* release and reacquire pipe->inode->i_mutex, AND inode must
* never be a pipe.
*/
inode_double_lock(inode, pipe->inode);
WARN_ON(S_ISFIFO(inode->i_mode));
mutex_lock_nested(&inode->i_mutex, I_MUTEX_PARENT);
if (pipe->inode)
mutex_lock_nested(&pipe->inode->i_mutex, I_MUTEX_CHILD);
ret = __splice_from_pipe(pipe, &sd, actor);
inode_double_unlock(inode, pipe->inode);
if (pipe->inode)
mutex_unlock(&pipe->inode->i_mutex);
mutex_unlock(&inode->i_mutex);

return ret;
}
Expand Down Expand Up @@ -831,11 +840,17 @@ generic_file_splice_write(struct pipe_inode_info *pipe, struct file *out,
};
ssize_t ret;

inode_double_lock(inode, pipe->inode);
WARN_ON(S_ISFIFO(inode->i_mode));
mutex_lock_nested(&inode->i_mutex, I_MUTEX_PARENT);
ret = file_remove_suid(out);
if (likely(!ret))
if (likely(!ret)) {
if (pipe->inode)
mutex_lock_nested(&pipe->inode->i_mutex, I_MUTEX_CHILD);
ret = __splice_from_pipe(pipe, &sd, pipe_to_file);
inode_double_unlock(inode, pipe->inode);
if (pipe->inode)
mutex_unlock(&pipe->inode->i_mutex);
}
mutex_unlock(&inode->i_mutex);
if (ret > 0) {
unsigned long nr_pages;

Expand Down

0 comments on commit 443f801

Please sign in to comment.