mirror of https://gitee.com/openkylin/linux.git
splice: add wakeup_pipe_readers()
Add and use wakeup_pipe_readers() to consolidate duplicated codes. Signed-off-by: Namhyung Kim <namhyung@gmail.com> Cc: Jens Axboe <axboe@kernel.dk> Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
This commit is contained in:
parent
61c4f2c81c
commit
825cdcb1a5
33
fs/splice.c
33
fs/splice.c
|
@ -162,6 +162,14 @@ static const struct pipe_buf_operations user_page_pipe_buf_ops = {
|
||||||
.get = generic_pipe_buf_get,
|
.get = generic_pipe_buf_get,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static void wakeup_pipe_readers(struct pipe_inode_info *pipe)
|
||||||
|
{
|
||||||
|
smp_mb();
|
||||||
|
if (waitqueue_active(&pipe->wait))
|
||||||
|
wake_up_interruptible(&pipe->wait);
|
||||||
|
kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* splice_to_pipe - fill passed data into a pipe
|
* splice_to_pipe - fill passed data into a pipe
|
||||||
* @pipe: pipe to fill
|
* @pipe: pipe to fill
|
||||||
|
@ -247,12 +255,8 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
|
||||||
|
|
||||||
pipe_unlock(pipe);
|
pipe_unlock(pipe);
|
||||||
|
|
||||||
if (do_wakeup) {
|
if (do_wakeup)
|
||||||
smp_mb();
|
wakeup_pipe_readers(pipe);
|
||||||
if (waitqueue_active(&pipe->wait))
|
|
||||||
wake_up_interruptible(&pipe->wait);
|
|
||||||
kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
|
|
||||||
}
|
|
||||||
|
|
||||||
while (page_nr < spd_pages)
|
while (page_nr < spd_pages)
|
||||||
spd->spd_release(spd, page_nr++);
|
spd->spd_release(spd, page_nr++);
|
||||||
|
@ -1892,12 +1896,9 @@ static int splice_pipe_to_pipe(struct pipe_inode_info *ipipe,
|
||||||
/*
|
/*
|
||||||
* If we put data in the output pipe, wakeup any potential readers.
|
* If we put data in the output pipe, wakeup any potential readers.
|
||||||
*/
|
*/
|
||||||
if (ret > 0) {
|
if (ret > 0)
|
||||||
smp_mb();
|
wakeup_pipe_readers(opipe);
|
||||||
if (waitqueue_active(&opipe->wait))
|
|
||||||
wake_up_interruptible(&opipe->wait);
|
|
||||||
kill_fasync(&opipe->fasync_readers, SIGIO, POLL_IN);
|
|
||||||
}
|
|
||||||
if (input_wakeup)
|
if (input_wakeup)
|
||||||
wakeup_pipe_writers(ipipe);
|
wakeup_pipe_writers(ipipe);
|
||||||
|
|
||||||
|
@ -1976,12 +1977,8 @@ static int link_pipe(struct pipe_inode_info *ipipe,
|
||||||
/*
|
/*
|
||||||
* If we put data in the output pipe, wakeup any potential readers.
|
* If we put data in the output pipe, wakeup any potential readers.
|
||||||
*/
|
*/
|
||||||
if (ret > 0) {
|
if (ret > 0)
|
||||||
smp_mb();
|
wakeup_pipe_readers(opipe);
|
||||||
if (waitqueue_active(&opipe->wait))
|
|
||||||
wake_up_interruptible(&opipe->wait);
|
|
||||||
kill_fasync(&opipe->fasync_readers, SIGIO, POLL_IN);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue