On Mon, Jan 09, 2012 at 12:35:52PM +1100, NeilBrown wrote: > On Sat, 7 Jan 2012 13:53:04 +0100 Michał Mirosław <mirq-linux@xxxxxxxxxxxx> > wrote: > > On Sat, Nov 19, 2011 at 02:41:39PM +0100, Michał Mirosław wrote: > > > I get following BUG_ON tripped while booting, before rootfs is mounted by > > > Debian's initrd. This started to happen for kernels since sometime > > > during 3.1-rcX. > > > > > > [ 6.246170] ------------[ cut here ]------------ > > > [ 6.246246] kernel BUG at /mnt/src-tmp/jaja/git/qmqm/drivers/scsi/scsi_lib.c:1153! [...] > > > [ 6.249414] [<ffffffff8124a9be>] ? sd_prep_fn+0x2cd/0xb72 > > > [ 6.249490] [<ffffffff811a5d67>] ? cfq_dispatch_requests+0x6f2/0x82c > > > [ 6.249567] [<ffffffff8119a168>] ? blk_peek_request+0xc8/0x1bf > > > [ 6.249638] [<ffffffff81243d83>] ? scsi_request_fn+0x64/0x406 > > > [ 6.249708] [<ffffffff8119a526>] ? blk_flush_plug_list+0x186/0x1b7 > > > [ 6.249780] [<ffffffff8119a562>] ? blk_finish_plug+0xb/0x2a > > > [ 6.249849] [<ffffffff812a400f>] ? raid1d+0x91/0xb22 [...] > > I've bisected this to following commit. It's not trivially revertable on v3.2, > > but I'll do some tries with it. > Thanks for doing that - it is a great help. > And you were right - the write-mostly flag is relevant. > Please test this patch - it should fix the problem. > diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c > index cc24f0c..a368db2 100644 > --- a/drivers/md/raid1.c > +++ b/drivers/md/raid1.c > @@ -531,8 +531,17 @@ static int read_balance(struct r1conf *conf, struct r1bio *r1_bio, int *max_sect > if (test_bit(WriteMostly, &rdev->flags)) { > /* Don't balance among write-mostly, just > * use the first as a last resort */ > - if (best_disk < 0) > + if (best_disk < 0) { > + if (is_badblock(rdev, this_sector, sectors, > + &first_bad, &bad_sectors)) { > + if (first_bad < this_sector) > + /* Cannot use this */ > + continue; > + best_good_sectors = first_bad - this_sector; > + } else > + best_good_sectors = sectors; > best_disk = disk; > + } > continue; > } > /* This is a reasonable device to use. It might > Built and booted fine. Thanks! Michał Mirosław -- To unsubscribe from this list: send the line "unsubscribe linux-raid" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html