dm integrity: only allocate recalculate buffer when needed
authorMikulas Patocka <mpatocka@redhat.com>
Mon, 26 Jun 2023 14:46:00 +0000 (16:46 +0200)
committerMike Snitzer <snitzer@kernel.org>
Tue, 27 Jun 2023 20:02:18 +0000 (16:02 -0400)
commitda8b4fc1f63a01a0eca9338ae338b804c437b51f
treed4b671cee1d6c6e28a52a760d6757d9deaa1319c
parent6d50eb4725934fd22f5eeccb401000687c790fd0
dm integrity: only allocate recalculate buffer when needed

dm-integrity preallocated 8MiB buffer for recalculating in the
constructor and freed it in the destructor. This wastes memory when
the user has many dm-integrity devices.

Fix dm-integrity so that the buffer is only allocated when
recalculation is in progress; allocate the buffer at the beginning of
integrity_recalc() and free it at the end.

Note that integrity_recalc() doesn't hold any locks when allocating
the buffer, so it shouldn't cause low-memory deadlock.

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
drivers/md/dm-integrity.c