From: Zhan Xusheng <zhanxusheng1024@gmail.com>
To: Gao Xiang <xiang@kernel.org>
Cc: Gao Xiang <hsiangkao@linux.alibaba.com>,
linux-erofs@lists.ozlabs.org, linux-kernel@vger.kernel.org,
Zhan Xusheng <zhanxusheng@xiaomi.com>
Subject: [PATCH] [PATCH v2] erofs: fix missing folio_unlock causing lock imbalance
Date: Tue, 31 Mar 2026 11:46:31 +0800 [thread overview]
Message-ID: <20260331034631.21945-1-zhanxusheng@xiaomi.com> (raw)
In-Reply-To: <20260331033300.21366-1-zhanxusheng@xiaomi.com>
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>
---
fs/erofs/zdata.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/fs/erofs/zdata.c b/fs/erofs/zdata.c
index fe8121df9ef2..b566996a0d1a 100644
--- a/fs/erofs/zdata.c
+++ b/fs/erofs/zdata.c
@@ -605,8 +605,7 @@ static int erofs_try_to_free_all_cached_folios(struct erofs_sb_info *sbi,
if (!folio_trylock(folio))
return -EBUSY;
- if (!erofs_folio_is_managed(sbi, folio))
- continue;
+ DBG_BUGON(!erofs_folio_is_managed(sbi, folio));
pcl->compressed_bvecs[i].page = NULL;
folio_detach_private(folio);
folio_unlock(folio);
--
2.43.0
next parent reply other threads:[~2026-03-31 3:46 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20260331033300.21366-1-zhanxusheng@xiaomi.com>
2026-03-31 3:46 ` Zhan Xusheng [this message]
2026-03-31 3:55 ` Gao Xiang
2026-03-31 5:02 ` [PATCH] [PATCH v3] erofs: ensure all folios are managed in erofs_try_to_free_all_cached_folios() Zhan Xusheng
2026-03-31 5:28 ` Gao Xiang
2026-04-02 6:46 ` Chunhai Guo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260331034631.21945-1-zhanxusheng@xiaomi.com \
--to=zhanxusheng1024@gmail.com \
--cc=hsiangkao@linux.alibaba.com \
--cc=linux-erofs@lists.ozlabs.org \
--cc=linux-kernel@vger.kernel.org \
--cc=xiang@kernel.org \
--cc=zhanxusheng@xiaomi.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®