[PATCH 1/2] dm-integrity: skip the superblock reread in recovery mode
From: Genjian
Date: Mon Nov 23 2026 - 07:43:23 EST
From: Genjian Zhang <zhanggenjian@xxxxxxxxxx>
When the on-disk superblock identifier is invalid, the recovery-mode
constructor rebuilds the superblock in memory without writing it to
disk. On first activation, resume rereads the on-disk superblock and
compares it with the reconstructed copy. The identifiers differ, so
the driver marks the target failed and recovery reads fail, even though
the disk contents have not changed since construction.
Skip the superblock reread in recovery mode so recovery reads use the
block layout established by the constructor.
Fixes: fc79aeb86a2c ("dm-integrity: validate the superblock on resume")
Signed-off-by: Genjian Zhang <zhanggenjian@xxxxxxxxxx>
---
drivers/md/dm-integrity.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/md/dm-integrity.c b/drivers/md/dm-integrity.c
index 6968e38888db..b17bb9da9195 100644
--- a/drivers/md/dm-integrity.c
+++ b/drivers/md/dm-integrity.c
@@ -3865,8 +3865,8 @@ static void dm_integrity_postsuspend(struct dm_target *ti)
}
/*
- * The superblock is re-read from the device on every resume, so that we pick
- * up the flags and the recalculate position. The geometry described by the
+ * Outside recovery mode, resume re-reads the superblock to pick up the
+ * flags and the recalculate position. The geometry described by the
* superblock must not change though - the in-memory structures (and the
* journal in particular) were sized according to the superblock that was
* validated in the constructor. Reject a superblock that was modified behind
@@ -3922,6 +3922,9 @@ static void dm_integrity_resume(struct dm_target *ti)
ic->wrote_to_journal = false;
+ if (ic->mode == 'R')
+ goto skip_writes;
+
flags = ic->sb->flags & cpu_to_le32(SB_FLAG_RECALCULATING);
if (ic->discard_keyed)
flags |= cpu_to_le32(SB_FLAG_DISCARD_KEYED);
@@ -3941,9 +3944,6 @@ static void dm_integrity_resume(struct dm_target *ti)
goto skip_writes;
}
- if (ic->mode == 'R')
- goto skip_writes;
-
if ((ic->sb->flags & flags) != flags) {
ic->sb->flags |= flags;
r = sync_rw_sb(ic, REQ_OP_WRITE | REQ_FUA);
--
2.25.1