Skip to content

Commit 252bd12

Browse files
hyeongseok-kim901snitm
authored andcommitted
dm verity: skip verity work if I/O error when system is shutting down
If emergency system shutdown is called, like by thermal shutdown, a dm device could be alive when the block device couldn't process I/O requests anymore. In this state, 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 a misjudgment. So, skip verity work in response to I/O error when system is shutting down. Signed-off-by: Hyeongseok Kim <[email protected]> Reviewed-by: Sami Tolvanen <[email protected]> Signed-off-by: Mike Snitzer <[email protected]>
1 parent a2b8b2d commit 252bd12

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

drivers/md/dm-verity-target.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,15 @@ static int verity_verify_io(struct dm_verity_io *io)
537537
return 0;
538538
}
539539

540+
/*
541+
* Skip verity work in response to I/O error when system is shutting down.
542+
*/
543+
static inline bool verity_is_system_shutting_down(void)
544+
{
545+
return system_state == SYSTEM_HALT || system_state == SYSTEM_POWER_OFF
546+
|| system_state == SYSTEM_RESTART;
547+
}
548+
540549
/*
541550
* End one "io" structure with a given error.
542551
*/
@@ -564,7 +573,8 @@ static void verity_end_io(struct bio *bio)
564573
{
565574
struct dm_verity_io *io = bio->bi_private;
566575

567-
if (bio->bi_status && !verity_fec_is_enabled(io->v)) {
576+
if (bio->bi_status &&
577+
(!verity_fec_is_enabled(io->v) || verity_is_system_shutting_down())) {
568578
verity_finish_io(io, bio->bi_status);
569579
return;
570580
}

0 commit comments

Comments
 (0)