mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-01-07 13:53:24 +00:00
iov_iter: lift dealing with maxpages out of first_{iovec,bvec}_segment()
caller can do that just as easily Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
parent
7392ed1734
commit
599a0bdd72
@ -1295,7 +1295,7 @@ static ssize_t iter_xarray_get_pages(struct iov_iter *i,
|
||||
/* must be done on non-empty ITER_IOVEC one */
|
||||
static unsigned long first_iovec_segment(const struct iov_iter *i,
|
||||
size_t *size, size_t *start,
|
||||
size_t maxsize, unsigned maxpages)
|
||||
size_t maxsize)
|
||||
{
|
||||
size_t skip;
|
||||
long k;
|
||||
@ -1309,8 +1309,6 @@ static unsigned long first_iovec_segment(const struct iov_iter *i,
|
||||
if (len > maxsize)
|
||||
len = maxsize;
|
||||
len += (*start = addr % PAGE_SIZE);
|
||||
if (len > maxpages * PAGE_SIZE)
|
||||
len = maxpages * PAGE_SIZE;
|
||||
*size = len;
|
||||
return addr & PAGE_MASK;
|
||||
}
|
||||
@ -1320,7 +1318,7 @@ static unsigned long first_iovec_segment(const struct iov_iter *i,
|
||||
/* must be done on non-empty ITER_BVEC one */
|
||||
static struct page *first_bvec_segment(const struct iov_iter *i,
|
||||
size_t *size, size_t *start,
|
||||
size_t maxsize, unsigned maxpages)
|
||||
size_t maxsize)
|
||||
{
|
||||
struct page *page;
|
||||
size_t skip = i->iov_offset, len;
|
||||
@ -1331,8 +1329,6 @@ static struct page *first_bvec_segment(const struct iov_iter *i,
|
||||
skip += i->bvec->bv_offset;
|
||||
page = i->bvec->bv_page + skip / PAGE_SIZE;
|
||||
len += (*start = skip % PAGE_SIZE);
|
||||
if (len > maxpages * PAGE_SIZE)
|
||||
len = maxpages * PAGE_SIZE;
|
||||
*size = len;
|
||||
return page;
|
||||
}
|
||||
@ -1360,7 +1356,9 @@ ssize_t iov_iter_get_pages(struct iov_iter *i,
|
||||
if (i->nofault)
|
||||
gup_flags |= FOLL_NOFAULT;
|
||||
|
||||
addr = first_iovec_segment(i, &len, start, maxsize, maxpages);
|
||||
addr = first_iovec_segment(i, &len, start, maxsize);
|
||||
if (len > maxpages * PAGE_SIZE)
|
||||
len = maxpages * PAGE_SIZE;
|
||||
n = DIV_ROUND_UP(len, PAGE_SIZE);
|
||||
res = get_user_pages_fast(addr, n, gup_flags, pages);
|
||||
if (unlikely(res <= 0))
|
||||
@ -1370,7 +1368,9 @@ ssize_t iov_iter_get_pages(struct iov_iter *i,
|
||||
if (iov_iter_is_bvec(i)) {
|
||||
struct page *page;
|
||||
|
||||
page = first_bvec_segment(i, &len, start, maxsize, maxpages);
|
||||
page = first_bvec_segment(i, &len, start, maxsize);
|
||||
if (len > maxpages * PAGE_SIZE)
|
||||
len = maxpages * PAGE_SIZE;
|
||||
n = DIV_ROUND_UP(len, PAGE_SIZE);
|
||||
while (n--)
|
||||
get_page(*pages++ = page++);
|
||||
@ -1488,7 +1488,7 @@ ssize_t iov_iter_get_pages_alloc(struct iov_iter *i,
|
||||
if (i->nofault)
|
||||
gup_flags |= FOLL_NOFAULT;
|
||||
|
||||
addr = first_iovec_segment(i, &len, start, maxsize, ~0U);
|
||||
addr = first_iovec_segment(i, &len, start, maxsize);
|
||||
n = DIV_ROUND_UP(len, PAGE_SIZE);
|
||||
p = get_pages_array(n);
|
||||
if (!p)
|
||||
@ -1505,7 +1505,7 @@ ssize_t iov_iter_get_pages_alloc(struct iov_iter *i,
|
||||
if (iov_iter_is_bvec(i)) {
|
||||
struct page *page;
|
||||
|
||||
page = first_bvec_segment(i, &len, start, maxsize, ~0U);
|
||||
page = first_bvec_segment(i, &len, start, maxsize);
|
||||
n = DIV_ROUND_UP(len, PAGE_SIZE);
|
||||
*pages = p = get_pages_array(n);
|
||||
if (!p)
|
||||
|
Loading…
Reference in New Issue
Block a user