From: Nicholas Bellinger Date: Wed, 22 Jan 2014 04:32:05 +0000 (-0800) Subject: bio-integrity: Fix bio_integrity_verify segment start bug X-Git-Tag: firefly_0821_release~176^2~4519^2~4 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=5837c80e870bc3b12ac6a98cdc9ce7a9522a8fb6;p=firefly-linux-kernel-4.4.55.git bio-integrity: Fix bio_integrity_verify segment start bug This patch addresses a bug in bio_integrity_verify() code that has been causing DIF READ verify operations to be silently skipped. The issue is that bio->bi_idx will have been incremented within bio_advance() code in the normal blk_update_request() -> req_bio_endio() completion path, and bio_integrity_verify() is using bio_for_each_segment() which starts the bio segment walk at the current bio->bi_idx. So instead use bio_for_each_segment_all() to always start the bio segment walk from zero, regardless of the current bio->bi_idx value after bio_advance() has been called. Cc: Martin K. Petersen Cc: Jens Axboe Cc: Christoph Hellwig Signed-off-by: Nicholas Bellinger Cc: stable@kernel.dk # >= v3.10 Signed-off-by: Jens Axboe --- diff --git a/fs/bio-integrity.c b/fs/bio-integrity.c index 80d972d739e5..0bad24ddc2e7 100644 --- a/fs/bio-integrity.c +++ b/fs/bio-integrity.c @@ -447,20 +447,21 @@ static int bio_integrity_verify(struct bio *bio) { struct blk_integrity *bi = bdev_get_integrity(bio->bi_bdev); struct blk_integrity_exchg bix; - struct bio_vec bv; - struct bvec_iter iter; + struct bio_vec *bv; sector_t sector = bio->bi_integrity->bip_iter.bi_sector; unsigned int sectors, total, ret; void *prot_buf = bio->bi_integrity->bip_buf; + int i; ret = total = 0; bix.disk_name = bio->bi_bdev->bd_disk->disk_name; bix.sector_size = bi->sector_size; - bio_for_each_segment(bv, bio, iter) { - void *kaddr = kmap_atomic(bv.bv_page); - bix.data_buf = kaddr + bv.bv_offset; - bix.data_size = bv.bv_len; + bio_for_each_segment_all(bv, bio, i) { + void *kaddr = kmap_atomic(bv->bv_page); + + bix.data_buf = kaddr + bv->bv_offset; + bix.data_size = bv->bv_len; bix.prot_buf = prot_buf; bix.sector = sector; @@ -471,7 +472,7 @@ static int bio_integrity_verify(struct bio *bio) return ret; } - sectors = bv.bv_len / bi->sector_size; + sectors = bv->bv_len / bi->sector_size; sector += sectors; prot_buf += sectors * bi->tuple_size; total += sectors * bi->tuple_size;