From 6ecdc8490675831993e857040340dbec3e1d61e1 Mon Sep 17 00:00:00 2001 From: Hyeongseok Kim Date: Tue, 8 Dec 2020 22:46:49 +0530 Subject: [PATCH] dm verity: skip verity work on I/O errors when system is shutting down If emergency system shutdown is called, like by thermal shutdown, dm device could be alive when the block device couldn't process I/O requests anymore. In this status, the handling of I/O errors by new dm I/O requests or by those already in-flight can lead to a verity corruption state, which is misjudgment. So, skip verity work for I/O error when system is shutting down. Change-Id: I7b2e79283bb5810cefe688bf43b9ae97030ce917 Reviewed-by: Sami Tolvanen Signed-off-by: Hyeongseok Kim Patch-mainline: dm-devel @ 12/03/20, 00:46 Signed-off-by: Ravi Kumar Siddojigari --- drivers/md/dm-verity-target.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/md/dm-verity-target.c b/drivers/md/dm-verity-target.c index 99cee512273f..f8030c289f4e 100644 --- a/drivers/md/dm-verity-target.c +++ b/drivers/md/dm-verity-target.c @@ -62,6 +62,14 @@ struct dm_verity_prefetch_work { struct buffer_aux { int hash_verified; }; +/* + * While system shutdown, skip verity work for I/O error. + */ +static inline bool verity_is_system_shutting_down(void) +{ + return system_state == SYSTEM_HALT || system_state == SYSTEM_POWER_OFF + || system_state == SYSTEM_RESTART; +} /* * Initialize struct buffer_aux for a freshly created buffer. @@ -564,7 +572,8 @@ static void verity_end_io(struct bio *bio) { struct dm_verity_io *io = bio->bi_private; - if (bio->bi_status && !verity_fec_is_enabled(io->v)) { + if (bio->bi_status && + (!verity_fec_is_enabled(io->v) || verity_is_system_shutting_down())) { verity_finish_io(io, bio->bi_status); return; }