* [patch 1/2]raid5: set bio bi_vcnt 0 for discard request
@ 2013-10-19 6:50 Shaohua Li
2013-10-23 8:07 ` Martin K. Petersen
0 siblings, 1 reply; 3+ messages in thread
From: Shaohua Li @ 2013-10-19 6:50 UTC (permalink / raw)
To: NeilBrown, linux-raid; +Cc: Jes.Sorensen
SCSI layer will add new payload for discard request. If two bios are merged
to one, the second bio has bi_vcnt 1 which is set in raid5. This will confuse
SCSI and cause oops.
Suite for backport to 3.7+
Reported-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Shaohua Li <shli@fusionio.com>
---
drivers/md/raid5.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
Index: linux/drivers/md/raid5.c
===================================================================
--- linux.orig/drivers/md/raid5.c 2013-10-19 14:10:22.392044663 +0800
+++ linux/drivers/md/raid5.c 2013-10-19 14:10:22.388044717 +0800
@@ -877,6 +877,12 @@ static void ops_run_io(struct stripe_hea
bi->bi_io_vec[0].bv_len = STRIPE_SIZE;
bi->bi_io_vec[0].bv_offset = 0;
bi->bi_size = STRIPE_SIZE;
+ /*
+ * If this is discard request, set bi_vcnt 0. We don't
+ * want to confuse SCSI because SCSI will replace payload
+ */
+ if (rw & REQ_DISCARD)
+ bi->bi_vcnt = 0;
if (rrdev)
set_bit(R5_DOUBLE_LOCKED, &sh->dev[i].flags);
@@ -915,6 +921,12 @@ static void ops_run_io(struct stripe_hea
rbi->bi_io_vec[0].bv_len = STRIPE_SIZE;
rbi->bi_io_vec[0].bv_offset = 0;
rbi->bi_size = STRIPE_SIZE;
+ /*
+ * If this is discard request, set bi_vcnt 0. We don't
+ * want to confuse SCSI because SCSI will replace payload
+ */
+ if (rw & REQ_DISCARD)
+ rbi->bi_vcnt = 0;
if (conf->mddev->gendisk)
trace_block_bio_remap(bdev_get_queue(rbi->bi_bdev),
rbi, disk_devt(conf->mddev->gendisk),
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [patch 1/2]raid5: set bio bi_vcnt 0 for discard request
2013-10-19 6:50 [patch 1/2]raid5: set bio bi_vcnt 0 for discard request Shaohua Li
@ 2013-10-23 8:07 ` Martin K. Petersen
2013-10-24 1:58 ` NeilBrown
0 siblings, 1 reply; 3+ messages in thread
From: Martin K. Petersen @ 2013-10-23 8:07 UTC (permalink / raw)
To: Shaohua Li; +Cc: NeilBrown, linux-raid, Jes.Sorensen
>>>>> "Shaohua" == Shaohua Li <shli@kernel.org> writes:
Shaohua> SCSI layer will add new payload for discard request. If two
Shaohua> bios are merged to one, the second bio has bi_vcnt 1 which is
Shaohua> set in raid5. This will confuse SCSI and cause oops.
A discard bio does not have a payload prior to the SCSI command being
prepared so vcnt should indeed be 0.
Acked-by: Martin K. Petersen <martin.petersen@oracle.com>
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-10-24 1:58 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-19 6:50 [patch 1/2]raid5: set bio bi_vcnt 0 for discard request Shaohua Li
2013-10-23 8:07 ` Martin K. Petersen
2013-10-24 1:58 ` NeilBrown
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).