Skip to content

Commit 7b24fc4

Browse files
martinkpetersenJens Axboe
authored andcommitted
block: Don't verify integrity metadata on read error
If we get an I/O error on a read request there is no point in doing a verify pass on the integrity buffer. Adjust the completion path accordingly. Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com> Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
1 parent f2257b7 commit 7b24fc4

2 files changed

Lines changed: 15 additions & 11 deletions

File tree

‎fs/bio-integrity.c‎

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ static int bio_integrity_verify(struct bio *bio)
465465

466466
if (ret) {
467467
kunmap_atomic(kaddr, KM_USER0);
468-
break;
468+
return ret;
469469
}
470470

471471
sectors = bv->bv_len / bi->sector_size;
@@ -493,18 +493,13 @@ static void bio_integrity_verify_fn(struct work_struct *work)
493493
struct bio_integrity_payload *bip =
494494
container_of(work, struct bio_integrity_payload, bip_work);
495495
struct bio *bio = bip->bip_bio;
496-
int error = bip->bip_error;
496+
int error;
497497

498-
if (bio_integrity_verify(bio)) {
499-
clear_bit(BIO_UPTODATE, &bio->bi_flags);
500-
error = -EIO;
501-
}
498+
error = bio_integrity_verify(bio);
502499

503500
/* Restore original bio completion handler */
504501
bio->bi_end_io = bip->bip_end_io;
505-
506-
if (bio->bi_end_io)
507-
bio->bi_end_io(bio, error);
502+
bio_endio(bio, error);
508503
}
509504

510505
/**
@@ -525,7 +520,17 @@ void bio_integrity_endio(struct bio *bio, int error)
525520

526521
BUG_ON(bip->bip_bio != bio);
527522

528-
bip->bip_error = error;
523+
/* In case of an I/O error there is no point in verifying the
524+
* integrity metadata. Restore original bio end_io handler
525+
* and run it.
526+
*/
527+
if (error) {
528+
bio->bi_end_io = bip->bip_end_io;
529+
bio_endio(bio, error);
530+
531+
return;
532+
}
533+
529534
INIT_WORK(&bip->bip_work, bio_integrity_verify_fn);
530535
queue_work(kintegrityd_wq, &bip->bip_work);
531536
}

‎include/linux/bio.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,6 @@ struct bio_integrity_payload {
312312
void *bip_buf; /* generated integrity data */
313313
bio_end_io_t *bip_end_io; /* saved I/O completion fn */
314314

315-
int bip_error; /* saved I/O error */
316315
unsigned int bip_size;
317316

318317
unsigned short bip_pool; /* pool the ivec came from */

0 commit comments

Comments
 (0)