diff options
| author | Ming-Hung Tsai <mtsai@redhat.com> | 2024-12-05 14:41:52 +0300 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2025-01-17 15:36:10 +0300 |
| commit | 14f0e64c2f1179d16012216ffd9e6ca4640df8a9 (patch) | |
| tree | fd9fefec49953ae17d4cd2d0db609dca1af8517a /drivers/md/persistent-data/dm-array.c | |
| parent | 6002bec5354f86d1a2df21468f68e3ec03ede9da (diff) | |
| download | linux-14f0e64c2f1179d16012216ffd9e6ca4640df8a9.tar.xz | |
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>
Diffstat (limited to 'drivers/md/persistent-data/dm-array.c')
| -rw-r--r-- | drivers/md/persistent-data/dm-array.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/md/persistent-data/dm-array.c b/drivers/md/persistent-data/dm-array.c index de303ba33857..788a31cae187 100644 --- a/drivers/md/persistent-data/dm-array.c +++ b/drivers/md/persistent-data/dm-array.c @@ -960,10 +960,10 @@ 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); - } + + dm_btree_cursor_end(&c->cursor); } EXPORT_SYMBOL_GPL(dm_array_cursor_end); |
