diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2014-06-18 20:34:33 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2014-08-07 14:40:11 -0400 |
commit | c7f3888ad7f0932a87fb76e6e4edff2a90cc7920 (patch) | |
tree | d108b0518699032b366b78fe461be3fc0fa307d2 /mm | |
parent | 49c7dd287adffc972e6dd6cf7011d63c7c5c2e10 (diff) |
switch iov_iter_get_pages() to passing maximal number of pages
... instead of maximal size.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'mm')
-rw-r--r-- | mm/iov_iter.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/mm/iov_iter.c b/mm/iov_iter.c index 7b5dbd1517b5..ab88dc0ea1d3 100644 --- a/mm/iov_iter.c +++ b/mm/iov_iter.c | |||
@@ -310,7 +310,7 @@ void iov_iter_init(struct iov_iter *i, int direction, | |||
310 | EXPORT_SYMBOL(iov_iter_init); | 310 | EXPORT_SYMBOL(iov_iter_init); |
311 | 311 | ||
312 | static ssize_t get_pages_iovec(struct iov_iter *i, | 312 | static ssize_t get_pages_iovec(struct iov_iter *i, |
313 | struct page **pages, size_t maxsize, | 313 | struct page **pages, unsigned maxpages, |
314 | size_t *start) | 314 | size_t *start) |
315 | { | 315 | { |
316 | size_t offset = i->iov_offset; | 316 | size_t offset = i->iov_offset; |
@@ -323,10 +323,10 @@ static ssize_t get_pages_iovec(struct iov_iter *i, | |||
323 | len = iov->iov_len - offset; | 323 | len = iov->iov_len - offset; |
324 | if (len > i->count) | 324 | if (len > i->count) |
325 | len = i->count; | 325 | len = i->count; |
326 | if (len > maxsize) | ||
327 | len = maxsize; | ||
328 | addr = (unsigned long)iov->iov_base + offset; | 326 | addr = (unsigned long)iov->iov_base + offset; |
329 | len += *start = addr & (PAGE_SIZE - 1); | 327 | len += *start = addr & (PAGE_SIZE - 1); |
328 | if (len > maxpages * PAGE_SIZE) | ||
329 | len = maxpages * PAGE_SIZE; | ||
330 | addr &= ~(PAGE_SIZE - 1); | 330 | addr &= ~(PAGE_SIZE - 1); |
331 | n = (len + PAGE_SIZE - 1) / PAGE_SIZE; | 331 | n = (len + PAGE_SIZE - 1) / PAGE_SIZE; |
332 | res = get_user_pages_fast(addr, n, (i->type & WRITE) != WRITE, pages); | 332 | res = get_user_pages_fast(addr, n, (i->type & WRITE) != WRITE, pages); |
@@ -588,15 +588,14 @@ static unsigned long alignment_bvec(const struct iov_iter *i) | |||
588 | } | 588 | } |
589 | 589 | ||
590 | static ssize_t get_pages_bvec(struct iov_iter *i, | 590 | static ssize_t get_pages_bvec(struct iov_iter *i, |
591 | struct page **pages, size_t maxsize, | 591 | struct page **pages, unsigned maxpages, |
592 | size_t *start) | 592 | size_t *start) |
593 | { | 593 | { |
594 | const struct bio_vec *bvec = i->bvec; | 594 | const struct bio_vec *bvec = i->bvec; |
595 | size_t len = bvec->bv_len - i->iov_offset; | 595 | size_t len = bvec->bv_len - i->iov_offset; |
596 | if (len > i->count) | 596 | if (len > i->count) |
597 | len = i->count; | 597 | len = i->count; |
598 | if (len > maxsize) | 598 | /* can't be more than PAGE_SIZE */ |
599 | len = maxsize; | ||
600 | *start = bvec->bv_offset + i->iov_offset; | 599 | *start = bvec->bv_offset + i->iov_offset; |
601 | 600 | ||
602 | get_page(*pages = bvec->bv_page); | 601 | get_page(*pages = bvec->bv_page); |
@@ -712,13 +711,13 @@ unsigned long iov_iter_alignment(const struct iov_iter *i) | |||
712 | EXPORT_SYMBOL(iov_iter_alignment); | 711 | EXPORT_SYMBOL(iov_iter_alignment); |
713 | 712 | ||
714 | ssize_t iov_iter_get_pages(struct iov_iter *i, | 713 | ssize_t iov_iter_get_pages(struct iov_iter *i, |
715 | struct page **pages, size_t maxsize, | 714 | struct page **pages, unsigned maxpages, |
716 | size_t *start) | 715 | size_t *start) |
717 | { | 716 | { |
718 | if (i->type & ITER_BVEC) | 717 | if (i->type & ITER_BVEC) |
719 | return get_pages_bvec(i, pages, maxsize, start); | 718 | return get_pages_bvec(i, pages, maxpages, start); |
720 | else | 719 | else |
721 | return get_pages_iovec(i, pages, maxsize, start); | 720 | return get_pages_iovec(i, pages, maxpages, start); |
722 | } | 721 | } |
723 | EXPORT_SYMBOL(iov_iter_get_pages); | 722 | EXPORT_SYMBOL(iov_iter_get_pages); |
724 | 723 | ||