From: majianpeng <majianpeng@gmail.com>
To: koverstreet <koverstreet@google.com>, NeilBrown <neilb@suse.de>
Cc: axboe <axboe@kernel.dk>, linux-raid <linux-raid@vger.kernel.org>
Subject: [PATCH] raid5: After bio_reset, it must set some parameter of struct bio.
Date: Fri, 17 May 2013 15:29:36 +0800 [thread overview]
Message-ID: <201305171529317358582@gmail.com> (raw)
In commit 2f6db2a7073452b1, raid5 used bio_reset.But Kent Overstreet
leak some fields of bio to set.So it will cause bugs:
[ 355.746233] md/raid:md0: raid level 5 active with 3 out of 4 devices, algorithm 2
[ 355.783651] ------------[ cut here ]------------
[ 355.783707] kernel BUG at drivers/scsi/scsi_lib.c:1196!
[ 355.783756] invalid opcode: 0000 [#1] SMP
[ 355.783846] Modules linked in: raid456 async_raid6_recov async_memcpy async_pq async_xor async_tx netconsole configfs e1000e btrfs xor raid6_pq
[ 355.784208] CPU: 0 PID: 0 Comm: swapper/0 Not tainted 3.10.0-rc1+ #158
[ 355.784261] Hardware name: To Be Filled By O.E.M. To Be Filled By O.E.M./To be filled by O.E.M., BIOS 080015 11/09/2011
[ 355.784336] task: ffffffff81c10440 ti: ffffffff81c00000 task.ti: ffffffff81c00000
[ 355.784386] RIP: 0010:[<ffffffff81428fd2>] [<ffffffff81428fd2>] scsi_setup_fs_cmnd+0x92/0xa0
[ 355.784469] RSP: 0018:ffff8800bd203c48 EFLAGS: 00010046
[ 355.784517] RAX: 0000000000000000 RBX: ffff880036e1a000 RCX: 0000000000000002
[ 355.784571] RDX: ffffffff812afab0 RSI: ffff8800b5d75178 RDI: ffff880036e1a000
[ 355.784593] RBP: ffff8800bd203c58 R08: ffff8800b5d74738 R09: 0000000000000001
[ 355.784593] R10: 0000000000000000 R11: 0000000000012a00 R12: ffff8800b5d75178
[ 355.784593] R13: ffff880036e1a000 R14: ffff8800b583a800 R15: 0000000000040000
[ 355.784593] FS: 0000000000000000(0000) GS:ffff8800bd200000(0000) knlGS:0000000000000000
[ 355.784593] CS: 0010 DS: 0000 ES: 0000 CR0: 000000008005003b
[ 355.784593] CR2: 0000000001dfa008 CR3: 00000000b6d11000 CR4: 00000000000407f0
[ 355.784593] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
[ 355.784593] DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
[ 355.784593] Stack:
[ 355.784593] ffff8800b5d75178 ffff8800b58f0000 ffff8800bd203ca8 ffffffff81439453
[ 355.784593] ffffffff821f2100 000000010000d993 ffff880000080000 ffff8800b58f0000
[ 355.784593] ffff8800b5d75178 ffffffff81c01fd8 ffffffff81c01fd8 ffff880036e1a000
[ 355.784593] Call Trace:
[ 355.784593] <IRQ>
[ 355.784593] [<ffffffff81439453>] sd_prep_fn+0xf3/0x810
[ 355.784593] [<ffffffff8129e186>] blk_peek_request+0x126/0x230
[ 355.784593] [<ffffffff814297ce>] scsi_request_fn+0x4e/0x4e0
[ 355.784593] [<ffffffff8129cce4>] ? blk_run_queue+0x24/0x50
[ 355.784593] [<ffffffff8129c773>] __blk_run_queue+0x33/0x40
[ 355.784593] [<ffffffff8129ccef>] blk_run_queue+0x2f/0x50
[ 355.784593] [<ffffffff81429361>] scsi_run_queue+0x151/0x2f0
[ 355.784593] [<ffffffff81409d97>] ? put_device+0x17/0x20
[ 355.784593] [<ffffffff814228c4>] ? __scsi_put_command+0x64/0xa0
[ 355.784593] [<ffffffff8142a852>] scsi_next_command+0x42/0x60
[ 355.784593] [<ffffffff8142a9a2>] scsi_io_completion+0xd2/0x6e0
[ 355.784593] [<ffffffff8109e6ed>] ? trace_hardirqs_on+0xd/0x10
[ 355.784593] [<ffffffff81421dcc>] scsi_finish_command+0xac/0xf0
[ 355.784593] [<ffffffff8142a753>] scsi_softirq_done+0xa3/0x140
[ 355.784593] [<ffffffff812a3aeb>] blk_done_softirq+0x7b/0x90
[ 355.784593] [<ffffffff81046970>] __do_softirq+0x100/0x280
[ 355.784593] [<ffffffff81046c95>] irq_exit+0xb5/0xc0
[ 355.784593] [<ffffffff81696443>] do_IRQ+0x63/0xe0
[ 355.784593] [<ffffffff8168c4af>] common_interrupt+0x6f/0x6f
[ 355.784593] <EOI>
[ 355.784593] [<ffffffff8100a576>] ? default_idle+0x26/0x100
[ 355.784593] [<ffffffff8100ae56>] arch_cpu_idle+0x26/0x30
[ 355.784593] [<ffffffff8108ffae>] cpu_startup_entry+0x8e/0x270
[ 355.784593] [<ffffffff8166ba03>] rest_init+0xd3/0xe0
[ 355.784593] [<ffffffff8166b935>] ? rest_init+0x5/0xe0
[ 355.784593] [<ffffffff81ecbe1b>] start_kernel+0x3b5/0x3c2
[ 355.784593] [<ffffffff81ecb86e>] ? repair_env_string+0x5e/0x5e
[ 355.784593] [<ffffffff81ecb5a3>] x86_64_start_reservations+0x2a/0x2c
[ 355.784593] [<ffffffff81ecb671>] x86_64_start_kernel+0xcc/0xcf
[ 355.784593] Code: c3 48 8b 00 48 85 c0 74 b7 48 8b 40 48 48 85 c0 74 ae 4c 89 e6 48 89 df ff d0 85 c0 74 a2 eb dc b8 02 00 00 00 0f 1f 40 00 eb d1 <0f> 0b 66 66 66 2e 0f 1f 84 00 00 00 00 00 66 66 66 66 90 55 48
[ 355.784593] RIP [<ffffffff81428fd2>] scsi_setup_fs_cmnd+0x92/0xa0
[ 355.784593] RSP <ffff8800bd203c48>
Signed-off-by: Jianpeng Ma <majianpeng@gmail.com>
---
drivers/md/raid5.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 9359828..66314b5 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -642,8 +642,10 @@ static void ops_run_io(struct stripe_head *sh, struct stripe_head_state *s)
md_sync_acct(rdev->bdev, STRIPE_SECTORS);
set_bit(STRIPE_IO_STARTED, &sh->state);
-
bio_reset(bi);
+
+ bi->bi_vcnt = bi->bi_max_vecs = 1;
+ bi->bi_io_vec = &(sh->dev[i].vec);
bi->bi_bdev = rdev->bdev;
bi->bi_rw = rw;
bi->bi_end_io = (rw & WRITE)
@@ -663,7 +665,6 @@ static void ops_run_io(struct stripe_head *sh, struct stripe_head_state *s)
+ rdev->data_offset);
if (test_bit(R5_ReadNoMerge, &sh->dev[i].flags))
bi->bi_rw |= REQ_FLUSH;
-
bi->bi_io_vec[0].bv_len = STRIPE_SIZE;
bi->bi_io_vec[0].bv_offset = 0;
bi->bi_size = STRIPE_SIZE;
@@ -684,6 +685,9 @@ static void ops_run_io(struct stripe_head *sh, struct stripe_head_state *s)
set_bit(STRIPE_IO_STARTED, &sh->state);
bio_reset(rbi);
+
+ rbi->bi_vcnt = rbi->bi_max_vecs = 1;
+ rbi->bi_io_vec = &(sh->dev[i].rvec);
rbi->bi_bdev = rrdev->bdev;
rbi->bi_rw = rw;
BUG_ON(!(rw & WRITE));
--
1.8.3.rc1.44.gb387c77
--------------------------------------------------------------------------------
majianpeng
reply other threads:[~2013-05-17 7:29 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=201305171529317358582@gmail.com \
--to=majianpeng@gmail.com \
--cc=axboe@kernel.dk \
--cc=koverstreet@google.com \
--cc=linux-raid@vger.kernel.org \
--cc=neilb@suse.de \
/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;
as well as URLs for NNTP newsgroup(s).