LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] block: bio: stop to pin pages if bio can't hold more
@ 2015-01-25 10:57 Ming Lei
  0 siblings, 0 replies; only message in thread
From: Ming Lei @ 2015-01-25 10:57 UTC (permalink / raw)
  To: Jens Axboe, linux-kernel; +Cc: Ming Lei

It doesn't make sense to continue to pin user pages when
bio can't hold more pages.

Also this patch fixes possible double page release issue
when get_user_pages_fast() failure happens just after some
of pages in last round weren't added in the bio.

Signed-off-by: Ming Lei <ming.lei@canonical.com>
---
 block/bio.c |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/block/bio.c b/block/bio.c
index 471d738..fcf0b15 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -1365,9 +1365,13 @@ static struct bio *__bio_map_user_iov(struct request_queue *q,
 		cur_page = j;
 		/*
 		 * release the pages we didn't map into the bio, if any
+		 * and stop to pin pages if page can't be added.
 		 */
-		while (j < page_limit)
-			page_cache_release(pages[j++]);
+		if (j < page_limit) {
+			while (j < page_limit)
+				page_cache_release(pages[j++]);
+			break;
+		}
 	}
 
 	kfree(pages);
-- 
1.7.9.5


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2015-01-25 10:58 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-25 10:57 [PATCH] block: bio: stop to pin pages if bio can't hold more Ming Lei

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).