Commit 626f128e authored by Ming-Hung Tsai's avatar Ming-Hung Tsai Committed by Mike Snitzer
Browse files

dm array: fix unreleased btree blocks on closing a faulty array cursor



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: default avatarMing-Hung Tsai <mtsai@redhat.com>
Fixes: fdd1315a ("dm array: introduce cursor api")
Reviewed-by: default avatarJoe Thornber <thornber@redhat.com>
Signed-off-by: default avatarMike Snitzer <snitzer@kernel.org>
parent f2893c08
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -960,11 +960,11 @@ EXPORT_SYMBOL_GPL(dm_array_cursor_begin);

void dm_array_cursor_end(struct dm_array_cursor *c)
{
	if (c->block) {
	if (c->block)
		unlock_ablock(c->info, c->block);

	dm_btree_cursor_end(&c->cursor);
}
}
EXPORT_SYMBOL_GPL(dm_array_cursor_end);

int dm_array_cursor_next(struct dm_array_cursor *c)