]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
dm verity: skip verity work if I/O error when system is shutting down
authorHyeongseok Kim <hyeongseok@gmail.com>
Thu, 3 Dec 2020 00:46:59 +0000 (09:46 +0900)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 6 Jan 2021 13:45:01 +0000 (14:45 +0100)
[ Upstream commit 252bd1256396cebc6fc3526127fdb0b317601318 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/md/dm-verity-target.c

index e3599b43f9eb984ccb52e8484ec5e7b6c3a8cd54..599be2d2b0ae9864d7c4c0e566e9206dc765abc4 100644 (file)
@@ -533,6 +533,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.
  */
@@ -560,7 +569,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;
        }