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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 8 Apr 2022 12:22:57 +0000 (14:22 +0200)
commit12ea1f73690b140221f61308f709bce4803ef276
tree21d2dcc72660d318499d23670fcf27a7b84b230f
parent737d5e25e28d4b06b30bb5f42c1125c0877c4c94
dm integrity: set journal entry unused when shrinking device

commit cc09e8a9dec4f0e8299e80a7a2a8e6f54164a10b upstream.

Commit f6f72f32c22c ("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: f6f72f32c22c ("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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/md/dm-integrity.c