Re: [PATCH v2] MD: raid, fix BUG caused by flags handling

Previous thread: [PATCH v2] BLOCK: fix bio.bi_rw handling by Jiri Slaby on Thursday, August 12, 2010 - 5:31 am. (5 messages)

Next thread: [PATCH 10/11] fs, block: propagate REQ_FLUSH/FUA interface to upper layers by Tejun Heo on Thursday, August 12, 2010 - 5:41 am. (5 messages)
From: Jiri Slaby
Date: Thursday, August 12, 2010 - 5:31 am

Commit 74450be1 (block: unify flags for struct bio and struct request)
added direct test of flags in the & form:
  const bool do_sync = (bio->bi_rw & REQ_SYNC);
But this doesn't fit into bool with my compiler (gcc 4.5). So change
the type to ulong to avoid the bug.

The BUG looks like:
EXT3-fs (md1): using internal journal
------------[ cut here ]------------
kernel BUG at drivers/scsi/scsi_lib.c:1113!
...
Pid: 879, comm: md3_raid1 Tainted: G        W   2.6.35-rc5-mm1_64+ #1265
RIP: 0010:[<ffffffff813312d6>]  [<ffffffff813312d6>] scsi_setup_fs_cmnd+0x96/0xd0
Process md3_raid1 (pid: 879, threadinfo ffff8801c4716000, task ffff8801cbd5a6a0)
...
Call Trace:
 [<ffffffff81339a78>] sd_prep_fn+0xa8/0x800
 [<ffffffff812252e9>] ? cfq_dispatch_request+0x49/0xb0
 [<ffffffff8121a24a>] blk_peek_request+0xca/0x1a0
 [<ffffffff81330a56>] scsi_request_fn+0x56/0x400
 [<ffffffff81219dad>] __generic_unplug_device+0x2d/0x40
 [<ffffffff8121a059>] generic_unplug_device+0x29/0x40
 [<ffffffff81217682>] blk_unplug+0x12/0x20
 [<ffffffff813f14c8>] unplug_slaves+0x78/0xc0
 [<ffffffff813f3ecb>] raid1d+0x37b/0x420
 [<ffffffff813fb6e3>] md_thread+0x53/0x120
...
Code: e8 d0 fe ff ff 5b 41 5c c9 c3 0f 1f 00 4c 89 e7 be 20 00 00 00 e8 db 9f ff ff 48 89 c7 48 85 c0 74 35 48 89 83 c8 00 00 00 eb a3 <0f> 0b 48 8b 00 48 85 c0 74 83 48 8b 40 48 48 85 c0 0f 84 76 ff
RIP  [<ffffffff813312d6>] scsi_setup_fs_cmnd+0x96/0xd0

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Neil Brown <neilb@suse.de>
---
 drivers/md/raid1.c  |   10 ++++++----
 drivers/md/raid10.c |    5 +++--
 2 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index 73cc74f..4bfebce 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -787,8 +787,8 @@ static int make_request(mddev_t *mddev, struct bio * bio)
 	struct bio_list bl;
 	struct page **behind_pages = NULL;
 	const int rw = bio_data_dir(bio);
-	const bool do_sync = (bio->bi_rw & ...
From: Jeff Moyer
Date: Thursday, August 12, 2010 - 6:26 am

At first I wondered why you didn't use the !! trick, but after looking
at the code, I see that the result is |'d into bi_rw.

Looks good.  Sounds like it might have been a real bear to track down.

Reviewed-by: Jeff Moyer <jmoyer@redhat.com>
--

From: Christoph Hellwig
Date: Thursday, August 12, 2010 - 9:05 am

Thanks for sending this again.  It's been sent at least twice before,
but we really need to get it into the block tree, and now that it's been
merged to mainline there, too.


Reviewed-by: Christoph Hellwig <hch@lst.de>

--

Previous thread: [PATCH v2] BLOCK: fix bio.bi_rw handling by Jiri Slaby on Thursday, August 12, 2010 - 5:31 am. (5 messages)

Next thread: [PATCH 10/11] fs, block: propagate REQ_FLUSH/FUA interface to upper layers by Tejun Heo on Thursday, August 12, 2010 - 5:41 am. (5 messages)