Skip to content

Commit 5de6951

Browse files
Zhan Xushenghsiangkao
authored andcommitted
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>
1 parent 307210c commit 5de6951

1 file changed

Lines changed: 1 addition & 2 deletions

File tree

fs/erofs/zdata.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -605,8 +605,7 @@ static int erofs_try_to_free_all_cached_folios(struct erofs_sb_info *sbi,
605605
if (!folio_trylock(folio))
606606
return -EBUSY;
607607

608-
if (!erofs_folio_is_managed(sbi, folio))
609-
continue;
608+
DBG_BUGON(!erofs_folio_is_managed(sbi, folio));
610609
pcl->compressed_bvecs[i].page = NULL;
611610
folio_detach_private(folio);
612611
folio_unlock(folio);

0 commit comments

Comments
 (0)