[PATCH 1/3] block: loop: use kmap(page) instead of page_address(page)
From: Ming Lei
Date: Sun Mar 22 2015 - 04:16:26 EST
The raw page allocated in lo_send() can be a highmem page,
so kmap(page) should be used for read/write on the page.
Also the patch removes kmap()/kunmap() in lo_send() because
it isn't needed at all.
Signed-off-by: Ming Lei <ming.lei@xxxxxxxxxxxxx>
---
drivers/block/loop.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index d1f168b..965f117 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -275,10 +275,13 @@ static int do_lo_send_write(struct loop_device *lo, struct bio_vec *bvec,
{
int ret = lo_do_transfer(lo, WRITE, page, 0, bvec->bv_page,
bvec->bv_offset, bvec->bv_len, pos >> 9);
- if (likely(!ret))
- return __do_lo_send_write(lo->lo_backing_file,
- page_address(page), bvec->bv_len,
+ if (likely(!ret)) {
+ ret = __do_lo_send_write(lo->lo_backing_file,
+ kmap(page), bvec->bv_len,
pos);
+ kunmap(page);
+ return ret;
+ }
printk_ratelimited(KERN_ERR "loop: Transfer error at byte offset %llu, "
"length %i.\n", (unsigned long long)pos, bvec->bv_len);
if (ret > 0)
@@ -299,7 +302,6 @@ static int lo_send(struct loop_device *lo, struct request *rq, loff_t pos)
page = alloc_page(GFP_NOIO | __GFP_HIGHMEM);
if (unlikely(!page))
goto fail;
- kmap(page);
do_lo_send = do_lo_send_write;
} else {
do_lo_send = do_lo_send_direct_write;
@@ -312,7 +314,6 @@ static int lo_send(struct loop_device *lo, struct request *rq, loff_t pos)
pos += bvec.bv_len;
}
if (page) {
- kunmap(page);
__free_page(page);
}
out:
--
1.7.9.5
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/