diff options
| author | Ingo Molnar <mingo@elte.hu> | 2009-05-11 12:59:32 +0200 | 
|---|---|---|
| committer | Ingo Molnar <mingo@elte.hu> | 2009-05-11 12:59:37 +0200 | 
| commit | 7961386fe9596e6bf03d09948a73c5df9653325b (patch) | |
| tree | 60fa2586a0d340ef8f7473956eef17430d8250c7 /fs/pipe.c | |
| parent | aa47b7e0f89b9998dad4d1667447e8cb7703ff4e (diff) | |
| parent | 091bf7624d1c90cec9e578a18529f615213ff847 (diff) | |
| download | olio-linux-3.10-7961386fe9596e6bf03d09948a73c5df9653325b.tar.xz olio-linux-3.10-7961386fe9596e6bf03d09948a73c5df9653325b.zip  | |
Merge commit 'v2.6.30-rc5' into sched/core
Merge reason: sched/core was on .30-rc1 before, update to latest fixes
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'fs/pipe.c')
| -rw-r--r-- | fs/pipe.c | 42 | 
1 files changed, 38 insertions, 4 deletions
diff --git a/fs/pipe.c b/fs/pipe.c index 4af7aa52181..13414ec45b8 100644 --- a/fs/pipe.c +++ b/fs/pipe.c @@ -37,6 +37,42 @@   * -- Manfred Spraul <manfred@colorfullife.com> 2002-05-09   */ +static void pipe_lock_nested(struct pipe_inode_info *pipe, int subclass) +{ +	if (pipe->inode) +		mutex_lock_nested(&pipe->inode->i_mutex, subclass); +} + +void pipe_lock(struct pipe_inode_info *pipe) +{ +	/* +	 * pipe_lock() nests non-pipe inode locks (for writing to a file) +	 */ +	pipe_lock_nested(pipe, I_MUTEX_PARENT); +} +EXPORT_SYMBOL(pipe_lock); + +void pipe_unlock(struct pipe_inode_info *pipe) +{ +	if (pipe->inode) +		mutex_unlock(&pipe->inode->i_mutex); +} +EXPORT_SYMBOL(pipe_unlock); + +void pipe_double_lock(struct pipe_inode_info *pipe1, +		      struct pipe_inode_info *pipe2) +{ +	BUG_ON(pipe1 == pipe2); + +	if (pipe1 < pipe2) { +		pipe_lock_nested(pipe1, I_MUTEX_PARENT); +		pipe_lock_nested(pipe2, I_MUTEX_CHILD); +	} else { +		pipe_lock_nested(pipe2, I_MUTEX_CHILD); +		pipe_lock_nested(pipe1, I_MUTEX_PARENT); +	} +} +  /* Drop the inode semaphore and wait for a pipe event, atomically */  void pipe_wait(struct pipe_inode_info *pipe)  { @@ -47,12 +83,10 @@ void pipe_wait(struct pipe_inode_info *pipe)  	 * is considered a noninteractive wait:  	 */  	prepare_to_wait(&pipe->wait, &wait, TASK_INTERRUPTIBLE); -	if (pipe->inode) -		mutex_unlock(&pipe->inode->i_mutex); +	pipe_unlock(pipe);  	schedule();  	finish_wait(&pipe->wait, &wait); -	if (pipe->inode) -		mutex_lock(&pipe->inode->i_mutex); +	pipe_lock(pipe);  }  static int  |