mirror of https://gitee.com/openkylin/linux.git
bio_map_user_iov(): move alignment check into the main loop
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
parent
e2e115d18b
commit
98f0bc9905
16
block/bio.c
16
block/bio.c
|
@ -1344,11 +1344,6 @@ struct bio *bio_map_user_iov(struct request_queue *q,
|
|||
return ERR_PTR(-EINVAL);
|
||||
|
||||
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)
|
||||
|
@ -1373,14 +1368,19 @@ struct bio *bio_map_user_iov(struct request_queue *q,
|
|||
|
||||
npages = DIV_ROUND_UP(offs + bytes, PAGE_SIZE);
|
||||
|
||||
if (unlikely(offs & queue_dma_alignment(q))) {
|
||||
ret = -EINVAL;
|
||||
j = 0;
|
||||
} else {
|
||||
for (j = 0; j < npages; j++) {
|
||||
struct page *page = pages[j];
|
||||
unsigned int n = PAGE_SIZE - offs;
|
||||
unsigned short prev_bi_vcnt = bio->bi_vcnt;
|
||||
|
||||
if (n > bytes)
|
||||
n = bytes;
|
||||
|
||||
if (!bio_add_pc_page(q, bio, pages[j], n, offs))
|
||||
if (!bio_add_pc_page(q, bio, page, n, offs))
|
||||
break;
|
||||
|
||||
/*
|
||||
|
@ -1388,14 +1388,14 @@ struct bio *bio_map_user_iov(struct request_queue *q,
|
|||
* drop page reference if needed
|
||||
*/
|
||||
if (bio->bi_vcnt == prev_bi_vcnt)
|
||||
put_page(pages[j]);
|
||||
put_page(page);
|
||||
|
||||
added += n;
|
||||
bytes -= n;
|
||||
offs = 0;
|
||||
}
|
||||
iov_iter_advance(&i, added);
|
||||
|
||||
}
|
||||
/*
|
||||
* release the pages we didn't map into the bio, if any
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue