Skip to content

Commit

Permalink
dm verity: skip verity work if I/O error when system is shutting down
Browse files Browse the repository at this point in the history
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 <hyeongseok@gmail.com>
Reviewed-by: Sami Tolvanen <samitolvanen@google.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
  • Loading branch information
hyeongseok-kim901 authored and snitm committed Dec 21, 2020
1 parent a2b8b2d commit 252bd12
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion drivers/md/dm-verity-target.c
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,15 @@ static int verity_verify_io(struct dm_verity_io *io)
return 0;
}

/*
* Skip verity work in response to I/O error when system is shutting down.
*/
static inline bool verity_is_system_shutting_down(void)
{
return system_state == SYSTEM_HALT || system_state == SYSTEM_POWER_OFF
|| system_state == SYSTEM_RESTART;
}

/*
* End one "io" structure with a given error.
*/
Expand Down Expand Up @@ -564,7 +573,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;
}
Expand Down

0 comments on commit 252bd12

Please sign in to comment.