mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ming Lei <ming.lei@canonical.com>
To: Jens Axboe <axboe@fb.com>, linux-kernel@vger.kernel.org
Cc: Christoph Hellwig <hch@lst.de>, Al Viro <viro@zeniv.linux.org.uk>,
	Maxim Patlasov <mpatlasov@parallels.com>,
	Ming Lei <ming.lei@canonical.com>
Subject: [PATCH 1/3] block: loop: use kmap(page) instead of page_address(page)
Date: Sun, 22 Mar 2015 16:14:52 +0800	[thread overview]
Message-ID: <1427012095-4095-2-git-send-email-ming.lei@canonical.com> (raw)
In-Reply-To: <1427012095-4095-1-git-send-email-ming.lei@canonical.com>

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@canonical.com>
---
 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


  reply	other threads:[~2015-03-22  8:16 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-22  8:14 [PATCH 0/3] block: loop: switch to VFS ITER_BVEC Ming Lei
2015-03-22  8:14 ` Ming Lei [this message]
2015-03-24 10:29   ` [PATCH 1/3] block: loop: use kmap(page) instead of page_address(page) Christoph Hellwig
2015-03-24 10:49     ` Ming Lei
2015-03-24 11:09       ` Christoph Hellwig
2015-03-24 11:24         ` Ming Lei
2015-03-22  8:14 ` [PATCH 2/3] block: loop: unify interface type of lo_send and lo_receive Ming Lei
2015-03-24 10:30   ` Christoph Hellwig
2015-03-24 10:55     ` Ming Lei
2015-03-22  8:14 ` [PATCH 3/3] block: loop: use vfs ITER_BVEC to read/write backing file Ming Lei
2015-03-24 10:31   ` Christoph Hellwig
2015-03-24 11:01     ` Ming Lei
2015-03-24 10:32 ` [PATCH 0/3] block: loop: switch to VFS ITER_BVEC Christoph Hellwig
2015-03-24 10:53   ` Ming Lei
2015-03-24 18:01     ` Christoph Hellwig
2015-03-25  7:23       ` Ming Lei
2015-03-25 15:27         ` Christoph Hellwig
2015-03-31 22:22           ` Al Viro
2015-04-04  5:20           ` Al Viro
2015-04-07 16:23             ` Christoph Hellwig

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1427012095-4095-2-git-send-email-ming.lei@canonical.com \
    --to=ming.lei@canonical.com \
    --cc=axboe@fb.com \
    --cc=hch@lst.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mpatlasov@parallels.com \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®