]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
dm array: fix unreleased btree blocks on closing a faulty array cursor
authorMing-Hung Tsai <mtsai@redhat.com>
Thu, 5 Dec 2024 11:41:52 +0000 (19:41 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 17 Jan 2025 12:34:37 +0000 (13:34 +0100)
commit956a74b22d8492d65beef74dd1f919e2bc5c186f
tree428265f7af811d34dfdb38460956479e5b54e70c
parente477021d252c007f0c6d45b5d13d341efed03979
dm array: fix unreleased btree blocks on closing a faulty array cursor

[ Upstream commit 626f128ee9c4133b1cfce4be2b34a1508949370e ]

The cached block pointer in dm_array_cursor might be NULL if it reaches
an unreadable array block, or the array is empty. Therefore,
dm_array_cursor_end() should call dm_btree_cursor_end() unconditionally,
to prevent leaving unreleased btree blocks.

This fix can be verified using the "array_cursor/iterate/empty" test
in dm-unit:
  dm-unit run /pdata/array_cursor/iterate/empty --kernel-dir <KERNEL_DIR>

Signed-off-by: Ming-Hung Tsai <mtsai@redhat.com>
Fixes: fdd1315aa5f0 ("dm array: introduce cursor api")
Reviewed-by: Joe Thornber <thornber@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/md/persistent-data/dm-array.c