Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

erofs: ensure all folios are managed in erofs_try_to_free_all_cached_folios()

folio_trylock() in erofs_try_to_free_all_cached_folios() may
successfully acquire the folio lock, but the subsequent check
for erofs_folio_is_managed() can skip unlocking when the folio
is not managed by EROFS.

As Gao Xiang pointed out, this condition should not happen in
practice because compressed_bvecs[] only holds valid cached folios
at this point — any non-managed folio would have already been
detached by z_erofs_cache_release_folio() under folio lock.

Fix this by adding DBG_BUGON() to catch unexpected folios
and ensure folio_unlock() is always called.

Suggested-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Signed-off-by: Zhan Xusheng <zhanxusheng@xiaomi.com>
Reviewed-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Reviewed-by: Chunhai Guo <guochunhai@vivo.com>
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>

authored by

Zhan Xusheng and committed by
Gao Xiang
5de6951f 307210c2

+1 -2
+1 -2
fs/erofs/zdata.c
··· 605 605 if (!folio_trylock(folio)) 606 606 return -EBUSY; 607 607 608 - if (!erofs_folio_is_managed(sbi, folio)) 609 - continue; 608 + DBG_BUGON(!erofs_folio_is_managed(sbi, folio)); 610 609 pcl->compressed_bvecs[i].page = NULL; 611 610 folio_detach_private(folio); 612 611 folio_unlock(folio);