Skip to contentSkip to conversation

mtip32xx: Correctly handle bio->bi_idx != 0 conditions

PATCH In review Sam Bradshaw 2 participants 2 messages May 14, 2013 – May 15, 2013 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mtip32xx: Correctly handle bio->bi_idx != 0 conditions

Stacking drivers may append bvecs to existing bio's, resulting in non-zero bi_idx conditions. This patch counts the loops of bio_for_each_segment() rather than inheriting the bi_idx value to pass as a segment count to the hardware submission routine.

---

(quoted diff) +0 -0

b/drivers/block/mtip32xx/mtip32xx.c
index 847107e..7c77ae1 100644

drivers/block/mtip32xx/mtip32xx.c +0 -0
@@ -3863,7 +3863,7 @@ static void mtip_make_request(struct request_queue

*queue, struct bio *bio)
struct driver_data *dd = queue->queuedata; struct scatterlist *sg;
struct bio_vec *bvec;
- int nents = 0;
+ int i, nents = 0;
int tag = 0, unaligned = 0;

if (unlikely(dd->dd_flag & MTIP_DDF_STOP_IO)) {
@@ -3921,11 +3921,12 @@ static void mtip_make_request(struct request_queue *queue, struct bio *bio)
}

/* Create the scatter list for this bio. */
- bio_for_each_segment(bvec, bio, nents) {
+ bio_for_each_segment(bvec, bio, i) {
sg_set_page(&sg[nents],
bvec->bv_page, bvec->bv_len, bvec->bv_offset);
+ nents++;
}

/* Issue the read/write. */

maintainer
#1 lore raw
Quoted 5 lines · Sam Bradshaw

Stacking drivers may append bvecs to existing bio's, resulting in non-zero bi_idx conditions. This patch counts the loops of bio_for_each_segment() rather than inheriting the bi_idx value to pass as a segment count to the hardware submission routine.

Yup, that's a plain bug. Iteration always starts at current index and forward, so nents wont necessarily start at 0. Applied.

Signature · 1 line
Jens Axboe