diff options
author | Miklos Szeredi <miklos@szeredi.hu> | 2009-04-14 13:48:37 -0400 |
---|---|---|
committer | Jens Axboe <jens.axboe@oracle.com> | 2009-04-15 06:10:11 -0400 |
commit | 2933970b960223076d6affcf7a77e2bc546b8102 (patch) | |
tree | 1658b9692948b5118fc5fea29b83be4329c56b6e | |
parent | b3c2d2ddd63944ef2a1e4a43077b602288107e01 (diff) |
splice: remove i_mutex locking in splice_from_pipe()
splice_from_pipe() is only called from two places:
- generic_splice_sendpage()
- splice_write_null()
Neither of these require i_mutex to be taken on the destination inode.
Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
-rw-r--r-- | fs/splice.c | 18 |
1 files changed, 2 insertions, 16 deletions
diff --git a/fs/splice.c b/fs/splice.c index fd6b278d447b..349576b2c75a 100644 --- a/fs/splice.c +++ b/fs/splice.c | |||
@@ -784,7 +784,7 @@ EXPORT_SYMBOL(__splice_from_pipe); | |||
784 | * @actor: handler that splices the data | 784 | * @actor: handler that splices the data |
785 | * | 785 | * |
786 | * Description: | 786 | * Description: |
787 | * See __splice_from_pipe. This function locks the input and output inodes, | 787 | * See __splice_from_pipe. This function locks the pipe inode, |
788 | * otherwise it's identical to __splice_from_pipe(). | 788 | * otherwise it's identical to __splice_from_pipe(). |
789 | * | 789 | * |
790 | */ | 790 | */ |
@@ -793,7 +793,6 @@ ssize_t splice_from_pipe(struct pipe_inode_info *pipe, struct file *out, | |||
793 | splice_actor *actor) | 793 | splice_actor *actor) |
794 | { | 794 | { |
795 | ssize_t ret; | 795 | ssize_t ret; |
796 | struct inode *inode = out->f_mapping->host; | ||
797 | struct splice_desc sd = { | 796 | struct splice_desc sd = { |
798 | .total_len = len, | 797 | .total_len = len, |
799 | .flags = flags, | 798 | .flags = flags, |
@@ -801,24 +800,11 @@ ssize_t splice_from_pipe(struct pipe_inode_info *pipe, struct file *out, | |||
801 | .u.file = out, | 800 | .u.file = out, |
802 | }; | 801 | }; |
803 | 802 | ||
804 | /* | ||
805 | * The actor worker might be calling ->write_begin and | ||
806 | * ->write_end. Most of the time, these expect i_mutex to | ||
807 | * be held. Since this may result in an ABBA deadlock with | ||
808 | * pipe->inode, we have to order lock acquiry here. | ||
809 | * | ||
810 | * Outer lock must be inode->i_mutex, as pipe_wait() will | ||
811 | * release and reacquire pipe->inode->i_mutex, AND inode must | ||
812 | * never be a pipe. | ||
813 | */ | ||
814 | WARN_ON(S_ISFIFO(inode->i_mode)); | ||
815 | mutex_lock_nested(&inode->i_mutex, I_MUTEX_PARENT); | ||
816 | if (pipe->inode) | 803 | if (pipe->inode) |
817 | mutex_lock_nested(&pipe->inode->i_mutex, I_MUTEX_CHILD); | 804 | mutex_lock(&pipe->inode->i_mutex); |
818 | ret = __splice_from_pipe(pipe, &sd, actor); | 805 | ret = __splice_from_pipe(pipe, &sd, actor); |
819 | if (pipe->inode) | 806 | if (pipe->inode) |
820 | mutex_unlock(&pipe->inode->i_mutex); | 807 | mutex_unlock(&pipe->inode->i_mutex); |
821 | mutex_unlock(&inode->i_mutex); | ||
822 | 808 | ||
823 | return ret; | 809 | return ret; |
824 | } | 810 | } |