diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2022-06-10 20:53:17 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2022-07-06 16:43:19 -0400 |
commit | 599a0bdd72f0a7ed5f55faef0ecdcd36cb1bc287 (patch) | |
tree | a2ab26be169af3db67eab18d985a1aae8219e81d /lib/iov_iter.c | |
parent | 7392ed1734c319150b5ddec3f192a6405728e8d0 (diff) |
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>
Diffstat (limited to 'lib/iov_iter.c')
-rw-r--r-- | lib/iov_iter.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/lib/iov_iter.c b/lib/iov_iter.c index 225b968ed8c5..1b5e96ddddf3 100644 --- a/lib/iov_iter.c +++ b/lib/iov_iter.c @@ -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) |