Mike Christie wrote:
In __end_that_request_first if the bio is partially completed
blk_recalc_rq_segments will reset the segment values. If the bio is
later remapped and resent becuase of an error, we restore bi_idx but the
segment values are left to the partially completed state causing many
fun problems when blk_rq_map_sg is called in SCSI.
The attached patch clears the BIO_SEG_VALID bit, so the segment values
are recalculated when it is resent. It was built and tested against
2.6.4-udm1.
Mike Christie
------------------------------------------------------------------------
--- linux-2.6.4-rc1-udm1.orig/drivers/md/dm-bio-record.h 2004-03-03 19:56:43.000000000 -0800
+++ linux-2.6.4-rc1-udm1/drivers/md/dm-bio-record.h 2004-03-03 20:50:58.645821621 -0800
@@ -37,6 +37,7 @@ static inline void dm_bio_restore(struct
bio->bi_bdev = bd->bi_bdev;
bio->bi_size = bd->bi_size;
bio->bi_idx = bd->bi_idx;
+ bio->bi_flags &= ~(1 << BIO_SEG_VALID);
}
#endif
I don't think this is 100% correct. It gets the correct number of
segments counted so no oops from SCSI, but when we resend it the
bio_vec's bv_offset and bv_len would sitll be in the state
__end_that_request_direst left them.
Would it be ok to just add a curr_bv_offset and curr_bv_len to the bio
that is writeable leaving the bio_vec readonly, or is the correct fix
for DM to do a deep record of the bio?