}
EXPORT_SYMBOL(pipe_unlock);
+static inline void __pipe_lock(struct pipe_inode_info *pipe)
+{
+ mutex_lock_nested(&pipe->mutex, I_MUTEX_PARENT);
+}
+
+static inline void __pipe_unlock(struct pipe_inode_info *pipe)
+{
+ mutex_unlock(&pipe->mutex);
+}
+
void pipe_double_lock(struct pipe_inode_info *pipe1,
struct pipe_inode_info *pipe2)
{
do_wakeup = 0;
ret = 0;
- pipe_lock(pipe);
+ __pipe_lock(pipe);
for (;;) {
int bufs = pipe->nrbufs;
if (bufs) {
}
pipe_wait(pipe);
}
- pipe_unlock(pipe);
+ __pipe_unlock(pipe);
/* Signal writers asynchronously that there is more room. */
if (do_wakeup) {
do_wakeup = 0;
ret = 0;
- pipe_lock(pipe);
+ __pipe_lock(pipe);
if (!pipe->readers) {
send_sig(SIGPIPE, current, 0);
pipe->waiting_writers--;
}
out:
- pipe_unlock(pipe);
+ __pipe_unlock(pipe);
if (do_wakeup) {
wake_up_interruptible_sync_poll(&pipe->wait, POLLIN | POLLRDNORM);
kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
switch (cmd) {
case FIONREAD:
- pipe_lock(pipe);
+ __pipe_lock(pipe);
count = 0;
buf = pipe->curbuf;
nrbufs = pipe->nrbufs;
count += pipe->bufs[buf].len;
buf = (buf+1) & (pipe->buffers - 1);
}
- pipe_unlock(pipe);
+ __pipe_unlock(pipe);
return put_user(count, (int __user *)arg);
default:
struct pipe_inode_info *pipe = inode->i_pipe;
int kill = 0;
- pipe_lock(pipe);
+ __pipe_lock(pipe);
if (file->f_mode & FMODE_READ)
pipe->readers--;
if (file->f_mode & FMODE_WRITE)
kill = 1;
}
spin_unlock(&inode->i_lock);
- pipe_unlock(pipe);
+ __pipe_unlock(pipe);
if (kill)
__free_pipe_info(pipe);
struct pipe_inode_info *pipe = filp->private_data;
int retval = 0;
- pipe_lock(pipe);
+ __pipe_lock(pipe);
if (filp->f_mode & FMODE_READ)
retval = fasync_helper(fd, filp, on, &pipe->fasync_readers);
if ((filp->f_mode & FMODE_WRITE) && retval >= 0) {
/* this can happen only if on == T */
fasync_helper(-1, filp, 0, &pipe->fasync_readers);
}
- pipe_unlock(pipe);
+ __pipe_unlock(pipe);
return retval;
}
filp->private_data = pipe;
/* OK, we have a pipe and it's pinned down */
- pipe_lock(pipe);
+ __pipe_lock(pipe);
/* We can only do regular read/write on fifos */
filp->f_mode &= (FMODE_READ | FMODE_WRITE);
}
/* Ok! */
- pipe_unlock(pipe);
+ __pipe_unlock(pipe);
return 0;
err_rd:
kill = 1;
}
spin_unlock(&inode->i_lock);
- pipe_unlock(pipe);
+ __pipe_unlock(pipe);
if (kill)
__free_pipe_info(pipe);
return ret;
if (!pipe)
return -EBADF;
- pipe_lock(pipe);
+ __pipe_lock(pipe);
switch (cmd) {
case F_SETPIPE_SZ: {
}
out:
- pipe_unlock(pipe);
+ __pipe_unlock(pipe);
return ret;
}