Skip to content

Commit 626f128

Browse files
mingnusMike Snitzer
authored andcommitted
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: Ming-Hung Tsai <mtsai@redhat.com> Fixes: fdd1315 ("dm array: introduce cursor api") Reviewed-by: Joe Thornber <thornber@redhat.com> Signed-off-by: Mike Snitzer <snitzer@kernel.org>
1 parent f2893c0 commit 626f128

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

drivers/md/persistent-data/dm-array.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -960,10 +960,10 @@ EXPORT_SYMBOL_GPL(dm_array_cursor_begin);
960960

961961
void dm_array_cursor_end(struct dm_array_cursor *c)
962962
{
963-
if (c->block) {
963+
if (c->block)
964964
unlock_ablock(c->info, c->block);
965-
dm_btree_cursor_end(&c->cursor);
966-
}
965+
966+
dm_btree_cursor_end(&c->cursor);
967967
}
968968
EXPORT_SYMBOL_GPL(dm_array_cursor_end);
969969

0 commit comments

Comments
 (0)