]> git.baikalelectronics.ru Git - kernel.git/commitdiff
dm integrity: set journal entry unused when shrinking device
authorMikulas Patocka <mpatocka@redhat.com>
Sat, 26 Mar 2022 14:24:56 +0000 (10:24 -0400)
committerMike Snitzer <snitzer@kernel.org>
Fri, 1 Apr 2022 14:31:23 +0000 (10:31 -0400)
Commit 90273765fd27 ("dm integrity: don't replay journal data past the
end of the device") skips journal replay if the target sector points
beyond the end of the device. Unfortunatelly, it doesn't set the
journal entry unused, which resulted in this BUG being triggered:
BUG_ON(!journal_entry_is_unused(je))

Fix this by calling journal_entry_set_unused() for this case.

Fixes: 90273765fd27 ("dm integrity: don't replay journal data past the end of the device")
Cc: stable@vger.kernel.org # v5.7+
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Tested-by: Milan Broz <gmazyland@gmail.com>
[snitzer: revised header]
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
drivers/md/dm-integrity.c

index c58a5111cb575fe8dc9f24dd900f049bafe99ca0..ad2d5faa2ebbb4e4371f9f532e3558d551967465 100644 (file)
@@ -2472,9 +2472,11 @@ static void do_journal_write(struct dm_integrity_c *ic, unsigned write_start,
                                        dm_integrity_io_error(ic, "invalid sector in journal", -EIO);
                                        sec &= ~(sector_t)(ic->sectors_per_block - 1);
                                }
+                               if (unlikely(sec >= ic->provided_data_sectors)) {
+                                       journal_entry_set_unused(je);
+                                       continue;
+                               }
                        }
-                       if (unlikely(sec >= ic->provided_data_sectors))
-                               continue;
                        get_area_and_offset(ic, sec, &area, &offset);
                        restore_last_bytes(ic, access_journal_data(ic, i, j), je);
                        for (k = j + 1; k < ic->journal_section_entries; k++) {