aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2014-06-18 20:34:33 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2014-08-07 14:40:11 -0400
commitc7f3888ad7f0932a87fb76e6e4edff2a90cc7920 (patch)
treed108b0518699032b366b78fe461be3fc0fa307d2
parent49c7dd287adffc972e6dd6cf7011d63c7c5c2e10 (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>
-rw-r--r--fs/direct-io.c2
-rw-r--r--fs/fuse/file.c4
-rw-r--r--include/linux/uio.h2
-rw-r--r--mm/iov_iter.c17
4 files changed, 12 insertions, 13 deletions
diff --git a/fs/direct-io.c b/fs/direct-io.c
index 17e39b047de5..c3116404ab49 100644
--- a/fs/direct-io.c
+++ b/fs/direct-io.c
@@ -158,7 +158,7 @@ static inline int dio_refill_pages(struct dio *dio, struct dio_submit *sdio)
158{ 158{
159 ssize_t ret; 159 ssize_t ret;
160 160
161 ret = iov_iter_get_pages(sdio->iter, dio->pages, DIO_PAGES * PAGE_SIZE, 161 ret = iov_iter_get_pages(sdio->iter, dio->pages, DIO_PAGES,
162 &sdio->from); 162 &sdio->from);
163 163
164 if (ret < 0 && sdio->blocks_available && (dio->rw & WRITE)) { 164 if (ret < 0 && sdio->blocks_available && (dio->rw & WRITE)) {
diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index 40ac2628ddcf..912061ac4baf 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -1303,10 +1303,10 @@ static int fuse_get_user_pages(struct fuse_req *req, struct iov_iter *ii,
1303 while (nbytes < *nbytesp && req->num_pages < req->max_pages) { 1303 while (nbytes < *nbytesp && req->num_pages < req->max_pages) {
1304 unsigned npages; 1304 unsigned npages;
1305 size_t start; 1305 size_t start;
1306 unsigned n = req->max_pages - req->num_pages;
1307 ssize_t ret = iov_iter_get_pages(ii, 1306 ssize_t ret = iov_iter_get_pages(ii,
1308 &req->pages[req->num_pages], 1307 &req->pages[req->num_pages],
1309 n * PAGE_SIZE, &start); 1308 req->max_pages - req->num_pages,
1309 &start);
1310 if (ret < 0) 1310 if (ret < 0)
1311 return ret; 1311 return ret;
1312 1312
diff --git a/include/linux/uio.h b/include/linux/uio.h
index 09a7cffc224e..48d64e6ab292 100644
--- a/include/linux/uio.h
+++ b/include/linux/uio.h
@@ -84,7 +84,7 @@ unsigned long iov_iter_alignment(const struct iov_iter *i);
84void iov_iter_init(struct iov_iter *i, int direction, const struct iovec *iov, 84void iov_iter_init(struct iov_iter *i, int direction, const struct iovec *iov,
85 unsigned long nr_segs, size_t count); 85 unsigned long nr_segs, size_t count);
86ssize_t iov_iter_get_pages(struct iov_iter *i, struct page **pages, 86ssize_t iov_iter_get_pages(struct iov_iter *i, struct page **pages,
87 size_t maxsize, size_t *start); 87 unsigned maxpages, size_t *start);
88ssize_t iov_iter_get_pages_alloc(struct iov_iter *i, struct page ***pages, 88ssize_t iov_iter_get_pages_alloc(struct iov_iter *i, struct page ***pages,
89 size_t maxsize, size_t *start); 89 size_t maxsize, size_t *start);
90int iov_iter_npages(const struct iov_iter *i, int maxpages); 90int iov_iter_npages(const struct iov_iter *i, int maxpages);
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,
310EXPORT_SYMBOL(iov_iter_init); 310EXPORT_SYMBOL(iov_iter_init);
311 311
312static ssize_t get_pages_iovec(struct iov_iter *i, 312static 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
590static ssize_t get_pages_bvec(struct iov_iter *i, 590static 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)
712EXPORT_SYMBOL(iov_iter_alignment); 711EXPORT_SYMBOL(iov_iter_alignment);
713 712
714ssize_t iov_iter_get_pages(struct iov_iter *i, 713ssize_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}
723EXPORT_SYMBOL(iov_iter_get_pages); 722EXPORT_SYMBOL(iov_iter_get_pages);
724 723