Commit 98f0bc99 authored by Al Viro's avatar Al Viro

bio_map_user_iov(): move alignment check into the main loop

Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent e2e115d1
...@@ -1344,11 +1344,6 @@ struct bio *bio_map_user_iov(struct request_queue *q, ...@@ -1344,11 +1344,6 @@ struct bio *bio_map_user_iov(struct request_queue *q,
return ERR_PTR(-EINVAL); return ERR_PTR(-EINVAL);
nr_pages += end - start; nr_pages += end - start;
/*
* buffer must be aligned to at least logical block size for now
*/
if (uaddr & queue_dma_alignment(q))
return ERR_PTR(-EINVAL);
} }
if (!nr_pages) if (!nr_pages)
...@@ -1373,29 +1368,34 @@ struct bio *bio_map_user_iov(struct request_queue *q, ...@@ -1373,29 +1368,34 @@ struct bio *bio_map_user_iov(struct request_queue *q,
npages = DIV_ROUND_UP(offs + bytes, PAGE_SIZE); npages = DIV_ROUND_UP(offs + bytes, PAGE_SIZE);
for (j = 0; j < npages; j++) { if (unlikely(offs & queue_dma_alignment(q))) {
unsigned int n = PAGE_SIZE - offs; ret = -EINVAL;
unsigned short prev_bi_vcnt = bio->bi_vcnt; j = 0;
} else {
if (n > bytes) for (j = 0; j < npages; j++) {
n = bytes; struct page *page = pages[j];
unsigned int n = PAGE_SIZE - offs;
if (!bio_add_pc_page(q, bio, pages[j], n, offs)) unsigned short prev_bi_vcnt = bio->bi_vcnt;
break;
if (n > bytes)
/* n = bytes;
* check if vector was merged with previous
* drop page reference if needed if (!bio_add_pc_page(q, bio, page, n, offs))
*/ break;
if (bio->bi_vcnt == prev_bi_vcnt)
put_page(pages[j]); /*
* check if vector was merged with previous
added += n; * drop page reference if needed
bytes -= n; */
offs = 0; if (bio->bi_vcnt == prev_bi_vcnt)
put_page(page);
added += n;
bytes -= n;
offs = 0;
}
iov_iter_advance(&i, added);
} }
iov_iter_advance(&i, added);
/* /*
* release the pages we didn't map into the bio, if any * release the pages we didn't map into the bio, if any
*/ */
......
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