public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] block: fix bounce_end_io
@ 2015-09-17 16:06 Ming Lei
  2015-09-17 16:07 ` Jens Axboe
  0 siblings, 1 reply; 2+ messages in thread
From: Ming Lei @ 2015-09-17 16:06 UTC (permalink / raw)
  To: Jens Axboe, linux-kernel
  Cc: Josh Boyer, Adam Williamson, Ming Lei, Ming Lin, Mike Snitzer

When bio bounce is involved, one new bio and its biovecs are
cloned from the comming bio, which can be one fast-cloned bio
from upper layer(such as dm).

So it is obviously wrong to assume the start index of the coming(
original) bio's io vector is zero, which can be any value between
0 and (bi_max_vecs - 1), especially in case of bio split.

This patch fixes Fedora's booting oops on i386, often with the
following kernel log together:

> [    9.026738] systemd[1]: Switching root.
> [    9.036467] systemd-journald[149]: Received SIGTERM from PID 1
> (systemd).
> [    9.082262] BUG: Bad page state in process kworker/u5:1  pfn:372ac
> [    9.083989] page:f3d32ae0 count:0 mapcount:0 mapping:f2252178
> index:0x16a
> [    9.085755] flags: 0x40020021(locked|lru|mappedtodisk)
> [    9.087284] page dumped because: page still charged to cgroup
> [    9.088772] bad because of flags:
> [    9.089731] flags: 0x21(locked|lru)
> [    9.090818] page->mem_cgroup:f2c3e400

Reported-by: Josh Boyer <jwboyer@fedoraproject.org>
Tested-by: Adam Williamson <awilliam@redhat.com>
Cc: Ming Lin <mlin@kernel.org>
Cc: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Ming Lei <ming.lei@canonical.com>
---
 block/bounce.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/block/bounce.c b/block/bounce.c
index 0611aea..1cb5dd3 100644
--- a/block/bounce.c
+++ b/block/bounce.c
@@ -128,12 +128,14 @@ static void bounce_end_io(struct bio *bio, mempool_t *pool)
 	struct bio *bio_orig = bio->bi_private;
 	struct bio_vec *bvec, *org_vec;
 	int i;
+	int start = bio_orig->bi_iter.bi_idx;
 
 	/*
 	 * free up bounce indirect pages used
 	 */
 	bio_for_each_segment_all(bvec, bio, i) {
-		org_vec = bio_orig->bi_io_vec + i;
+		org_vec = bio_orig->bi_io_vec + i + start;
+
 		if (bvec->bv_page == org_vec->bv_page)
 			continue;
 
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] block: fix bounce_end_io
  2015-09-17 16:06 [PATCH] block: fix bounce_end_io Ming Lei
@ 2015-09-17 16:07 ` Jens Axboe
  0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2015-09-17 16:07 UTC (permalink / raw)
  To: Ming Lei, linux-kernel
  Cc: Josh Boyer, Adam Williamson, Ming Lin, Mike Snitzer

On 09/17/2015 10:06 AM, Ming Lei wrote:
> When bio bounce is involved, one new bio and its biovecs are
> cloned from the comming bio, which can be one fast-cloned bio
> from upper layer(such as dm).
>
> So it is obviously wrong to assume the start index of the coming(
> original) bio's io vector is zero, which can be any value between
> 0 and (bi_max_vecs - 1), especially in case of bio split.
>
> This patch fixes Fedora's booting oops on i386, often with the
> following kernel log together:
>
>> [    9.026738] systemd[1]: Switching root.
>> [    9.036467] systemd-journald[149]: Received SIGTERM from PID 1
>> (systemd).
>> [    9.082262] BUG: Bad page state in process kworker/u5:1  pfn:372ac
>> [    9.083989] page:f3d32ae0 count:0 mapcount:0 mapping:f2252178
>> index:0x16a
>> [    9.085755] flags: 0x40020021(locked|lru|mappedtodisk)
>> [    9.087284] page dumped because: page still charged to cgroup
>> [    9.088772] bad because of flags:
>> [    9.089731] flags: 0x21(locked|lru)
>> [    9.090818] page->mem_cgroup:f2c3e400

Applied, thanks Ming - and thanks Adam for testing it.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-09-17 16:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-17 16:06 [PATCH] block: fix bounce_end_io Ming Lei
2015-09-17 16:07 ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox