[PATCH] erofs: fix deadlock when shrink erofs slab
Chao Yu
chao at kernel.org
Fri Nov 19 12:32:48 AEDT 2021
On 2021/11/18 21:58, Huang Jianan via Linux-erofs wrote:
> We observed the following deadlock in the stress test under low
> memory scenario:
>
> Thread A Thread B
> - erofs_shrink_scan
> - erofs_try_to_release_workgroup
> - erofs_workgroup_try_to_freeze -- A
> - z_erofs_do_read_page
> - z_erofs_collection_begin
> - z_erofs_register_collection
> - erofs_insert_workgroup
> - xa_lock(&sbi->managed_pslots) -- B
> - erofs_workgroup_get
> - erofs_wait_on_workgroup_freezed -- A
> - xa_erase
> - xa_lock(&sbi->managed_pslots) -- B
>
> To fix this, it need to hold the xa lock before freeze the workgroup
> beacuse we will operate xarry. So let's hold the lock before access
> each workgroup, just like when we using the radix tree before.
>
> Fixes: 64094a04414f ("erofs: convert workstn to XArray")
> Signed-off-by: Huang Jianan <huangjianan at oppo.com>
Reviewed-by: Chao Yu <chao at kernel.org>
Thanks,
More information about the Linux-erofs
mailing list