Commit c7f3888a authored by Al Viro's avatar Al Viro

switch iov_iter_get_pages() to passing maximal number of pages

... instead of maximal size.
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 49c7dd28
...@@ -158,7 +158,7 @@ static inline int dio_refill_pages(struct dio *dio, struct dio_submit *sdio) ...@@ -158,7 +158,7 @@ static inline int dio_refill_pages(struct dio *dio, struct dio_submit *sdio)
{ {
ssize_t ret; ssize_t ret;
ret = iov_iter_get_pages(sdio->iter, dio->pages, DIO_PAGES * PAGE_SIZE, ret = iov_iter_get_pages(sdio->iter, dio->pages, DIO_PAGES,
&sdio->from); &sdio->from);
if (ret < 0 && sdio->blocks_available && (dio->rw & WRITE)) { if (ret < 0 && sdio->blocks_available && (dio->rw & WRITE)) {
......
...@@ -1303,10 +1303,10 @@ static int fuse_get_user_pages(struct fuse_req *req, struct iov_iter *ii, ...@@ -1303,10 +1303,10 @@ static int fuse_get_user_pages(struct fuse_req *req, struct iov_iter *ii,
while (nbytes < *nbytesp && req->num_pages < req->max_pages) { while (nbytes < *nbytesp && req->num_pages < req->max_pages) {
unsigned npages; unsigned npages;
size_t start; size_t start;
unsigned n = req->max_pages - req->num_pages;
ssize_t ret = iov_iter_get_pages(ii, ssize_t ret = iov_iter_get_pages(ii,
&req->pages[req->num_pages], &req->pages[req->num_pages],
n * PAGE_SIZE, &start); req->max_pages - req->num_pages,
&start);
if (ret < 0) if (ret < 0)
return ret; return ret;
......
...@@ -84,7 +84,7 @@ unsigned long iov_iter_alignment(const struct iov_iter *i); ...@@ -84,7 +84,7 @@ unsigned long iov_iter_alignment(const struct iov_iter *i);
void iov_iter_init(struct iov_iter *i, int direction, const struct iovec *iov, void iov_iter_init(struct iov_iter *i, int direction, const struct iovec *iov,
unsigned long nr_segs, size_t count); unsigned long nr_segs, size_t count);
ssize_t iov_iter_get_pages(struct iov_iter *i, struct page **pages, ssize_t iov_iter_get_pages(struct iov_iter *i, struct page **pages,
size_t maxsize, size_t *start); unsigned maxpages, size_t *start);
ssize_t iov_iter_get_pages_alloc(struct iov_iter *i, struct page ***pages, ssize_t iov_iter_get_pages_alloc(struct iov_iter *i, struct page ***pages,
size_t maxsize, size_t *start); size_t maxsize, size_t *start);
int iov_iter_npages(const struct iov_iter *i, int maxpages); int iov_iter_npages(const struct iov_iter *i, int maxpages);
......
...@@ -310,7 +310,7 @@ void iov_iter_init(struct iov_iter *i, int direction, ...@@ -310,7 +310,7 @@ void iov_iter_init(struct iov_iter *i, int direction,
EXPORT_SYMBOL(iov_iter_init); EXPORT_SYMBOL(iov_iter_init);
static ssize_t get_pages_iovec(struct iov_iter *i, static ssize_t get_pages_iovec(struct iov_iter *i,
struct page **pages, size_t maxsize, struct page **pages, unsigned maxpages,
size_t *start) size_t *start)
{ {
size_t offset = i->iov_offset; size_t offset = i->iov_offset;
...@@ -323,10 +323,10 @@ static ssize_t get_pages_iovec(struct iov_iter *i, ...@@ -323,10 +323,10 @@ static ssize_t get_pages_iovec(struct iov_iter *i,
len = iov->iov_len - offset; len = iov->iov_len - offset;
if (len > i->count) if (len > i->count)
len = i->count; len = i->count;
if (len > maxsize)
len = maxsize;
addr = (unsigned long)iov->iov_base + offset; addr = (unsigned long)iov->iov_base + offset;
len += *start = addr & (PAGE_SIZE - 1); len += *start = addr & (PAGE_SIZE - 1);
if (len > maxpages * PAGE_SIZE)
len = maxpages * PAGE_SIZE;
addr &= ~(PAGE_SIZE - 1); addr &= ~(PAGE_SIZE - 1);
n = (len + PAGE_SIZE - 1) / PAGE_SIZE; n = (len + PAGE_SIZE - 1) / PAGE_SIZE;
res = get_user_pages_fast(addr, n, (i->type & WRITE) != WRITE, pages); 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,15 +588,14 @@ static unsigned long alignment_bvec(const struct iov_iter *i)
} }
static ssize_t get_pages_bvec(struct iov_iter *i, static ssize_t get_pages_bvec(struct iov_iter *i,
struct page **pages, size_t maxsize, struct page **pages, unsigned maxpages,
size_t *start) size_t *start)
{ {
const struct bio_vec *bvec = i->bvec; const struct bio_vec *bvec = i->bvec;
size_t len = bvec->bv_len - i->iov_offset; size_t len = bvec->bv_len - i->iov_offset;
if (len > i->count) if (len > i->count)
len = i->count; len = i->count;
if (len > maxsize) /* can't be more than PAGE_SIZE */
len = maxsize;
*start = bvec->bv_offset + i->iov_offset; *start = bvec->bv_offset + i->iov_offset;
get_page(*pages = bvec->bv_page); get_page(*pages = bvec->bv_page);
...@@ -712,13 +711,13 @@ unsigned long iov_iter_alignment(const struct iov_iter *i) ...@@ -712,13 +711,13 @@ unsigned long iov_iter_alignment(const struct iov_iter *i)
EXPORT_SYMBOL(iov_iter_alignment); EXPORT_SYMBOL(iov_iter_alignment);
ssize_t iov_iter_get_pages(struct iov_iter *i, ssize_t iov_iter_get_pages(struct iov_iter *i,
struct page **pages, size_t maxsize, struct page **pages, unsigned maxpages,
size_t *start) size_t *start)
{ {
if (i->type & ITER_BVEC) if (i->type & ITER_BVEC)
return get_pages_bvec(i, pages, maxsize, start); return get_pages_bvec(i, pages, maxpages, start);
else else
return get_pages_iovec(i, pages, maxsize, start); return get_pages_iovec(i, pages, maxpages, start);
} }
EXPORT_SYMBOL(iov_iter_get_pages); EXPORT_SYMBOL(iov_iter_get_pages);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment