From: Ben Slusky One more patch --- this fixes a minor bio handling bug in the filebacked code path. I'd fixed it incidentally in the loop-recycle patch. I don't think you could actually see damage from this bug unless you run device mapper on top of loop devices, but still this is the correct behavior. --- 25-akpm/drivers/block/loop.c | 16 ++++++---------- 1 files changed, 6 insertions(+), 10 deletions(-) diff -puN drivers/block/loop.c~loop-bio-handling-fix drivers/block/loop.c --- 25/drivers/block/loop.c~loop-bio-handling-fix Wed Jan 14 12:49:32 2004 +++ 25-akpm/drivers/block/loop.c Wed Jan 14 12:49:32 2004 @@ -264,12 +264,10 @@ fail: static int lo_send(struct loop_device *lo, struct bio *bio, int bsize, loff_t pos) { - unsigned vecnr; - int ret = 0; - - for (vecnr = 0; vecnr < bio->bi_vcnt; vecnr++) { - struct bio_vec *bvec = &bio->bi_io_vec[vecnr]; + struct bio_vec *bvec; + int i, ret = 0; + bio_for_each_segment(bvec, bio, i) { ret = do_lo_send(lo, bvec, bsize, pos); if (ret < 0) break; @@ -333,12 +331,10 @@ do_lo_receive(struct loop_device *lo, static int lo_receive(struct loop_device *lo, struct bio *bio, int bsize, loff_t pos) { - unsigned vecnr; - int ret = 0; - - for (vecnr = 0; vecnr < bio->bi_vcnt; vecnr++) { - struct bio_vec *bvec = &bio->bi_io_vec[vecnr]; + struct bio_vec *bvec; + int i, ret = 0; + bio_for_each_segment(bvec, bio, i) { ret = do_lo_receive(lo, bvec, bsize, pos); if (ret < 0) break; _