diff options
Diffstat (limited to 'fs/splice.c')
-rw-r--r-- | fs/splice.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/fs/splice.c b/fs/splice.c index c521090a0469..f2400ce7d528 100644 --- a/fs/splice.c +++ b/fs/splice.c @@ -1195,8 +1195,15 @@ static long do_splice(struct file *in, loff_t __user *off_in, pipe_lock(opipe); ret = wait_for_space(opipe, flags); - if (!ret) + if (!ret) { + unsigned int p_space; + + /* Don't try to read more the pipe has space for. */ + p_space = opipe->max_usage - pipe_occupancy(opipe->head, opipe->tail); + len = min_t(size_t, len, p_space << PAGE_SHIFT); + ret = do_splice_to(in, &offset, opipe, len, flags); + } pipe_unlock(opipe); if (ret > 0) wakeup_pipe_readers(opipe); |