Skip to content

Commit

Permalink
make nr_pages calculation in default_file_splice_read() a bit less ugly
Browse files Browse the repository at this point in the history
It's an artifact of lousy calling conventions of iov_iter_get_pages_alloc().
Hopefully, we'll get something saner come next cycle; for now that'll
do.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
  • Loading branch information
Al Viro committed Dec 27, 2016
1 parent 3d6ea29 commit 13c0f52
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions fs/splice.c
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ static ssize_t default_file_splice_read(struct file *in, loff_t *ppos,
struct iov_iter to;
struct page **pages;
unsigned int nr_pages;
size_t offset, dummy, copied = 0;
size_t offset, base, copied = 0;
ssize_t res;
int i;

Expand All @@ -400,12 +400,11 @@ static ssize_t default_file_splice_read(struct file *in, loff_t *ppos,

iov_iter_pipe(&to, ITER_PIPE | READ, pipe, len + offset);

res = iov_iter_get_pages_alloc(&to, &pages, len + offset, &dummy);
res = iov_iter_get_pages_alloc(&to, &pages, len + offset, &base);
if (res <= 0)
return -ENOMEM;

BUG_ON(dummy);
nr_pages = DIV_ROUND_UP(res, PAGE_SIZE);
nr_pages = DIV_ROUND_UP(res + base, PAGE_SIZE);

vec = __vec;
if (nr_pages > PIPE_DEF_BUFFERS) {
Expand Down

0 comments on commit 13c0f52

Please sign in to comment.