diff options
Diffstat (limited to 'fs/bio-integrity.c')
-rw-r--r-- | fs/bio-integrity.c | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/fs/bio-integrity.c b/fs/bio-integrity.c index 77ebc3c263d6..549b0144da11 100644 --- a/fs/bio-integrity.c +++ b/fs/bio-integrity.c | |||
@@ -140,7 +140,6 @@ int bio_integrity_add_page(struct bio *bio, struct page *page, | |||
140 | 140 | ||
141 | iv = bip_vec_idx(bip, bip->bip_vcnt); | 141 | iv = bip_vec_idx(bip, bip->bip_vcnt); |
142 | BUG_ON(iv == NULL); | 142 | BUG_ON(iv == NULL); |
143 | BUG_ON(iv->bv_page != NULL); | ||
144 | 143 | ||
145 | iv->bv_page = page; | 144 | iv->bv_page = page; |
146 | iv->bv_len = len; | 145 | iv->bv_len = len; |
@@ -465,7 +464,7 @@ static int bio_integrity_verify(struct bio *bio) | |||
465 | 464 | ||
466 | if (ret) { | 465 | if (ret) { |
467 | kunmap_atomic(kaddr, KM_USER0); | 466 | kunmap_atomic(kaddr, KM_USER0); |
468 | break; | 467 | return ret; |
469 | } | 468 | } |
470 | 469 | ||
471 | sectors = bv->bv_len / bi->sector_size; | 470 | sectors = bv->bv_len / bi->sector_size; |
@@ -493,18 +492,13 @@ static void bio_integrity_verify_fn(struct work_struct *work) | |||
493 | struct bio_integrity_payload *bip = | 492 | struct bio_integrity_payload *bip = |
494 | container_of(work, struct bio_integrity_payload, bip_work); | 493 | container_of(work, struct bio_integrity_payload, bip_work); |
495 | struct bio *bio = bip->bip_bio; | 494 | struct bio *bio = bip->bip_bio; |
496 | int error = bip->bip_error; | 495 | int error; |
497 | 496 | ||
498 | if (bio_integrity_verify(bio)) { | 497 | error = bio_integrity_verify(bio); |
499 | clear_bit(BIO_UPTODATE, &bio->bi_flags); | ||
500 | error = -EIO; | ||
501 | } | ||
502 | 498 | ||
503 | /* Restore original bio completion handler */ | 499 | /* Restore original bio completion handler */ |
504 | bio->bi_end_io = bip->bip_end_io; | 500 | bio->bi_end_io = bip->bip_end_io; |
505 | 501 | bio_endio(bio, error); | |
506 | if (bio->bi_end_io) | ||
507 | bio->bi_end_io(bio, error); | ||
508 | } | 502 | } |
509 | 503 | ||
510 | /** | 504 | /** |
@@ -525,7 +519,17 @@ void bio_integrity_endio(struct bio *bio, int error) | |||
525 | 519 | ||
526 | BUG_ON(bip->bip_bio != bio); | 520 | BUG_ON(bip->bip_bio != bio); |
527 | 521 | ||
528 | bip->bip_error = error; | 522 | /* In case of an I/O error there is no point in verifying the |
523 | * integrity metadata. Restore original bio end_io handler | ||
524 | * and run it. | ||
525 | */ | ||
526 | if (error) { | ||
527 | bio->bi_end_io = bip->bip_end_io; | ||
528 | bio_endio(bio, error); | ||
529 | |||
530 | return; | ||
531 | } | ||
532 | |||
529 | INIT_WORK(&bip->bip_work, bio_integrity_verify_fn); | 533 | INIT_WORK(&bip->bip_work, bio_integrity_verify_fn); |
530 | queue_work(kintegrityd_wq, &bip->bip_work); | 534 | queue_work(kintegrityd_wq, &bip->bip_work); |
531 | } | 535 | } |