From: Jaegeuk Kim <jaegeuk@kernel.org>
To: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org
Cc: Jaegeuk Kim <jaegeuk@kernel.org>
Subject: [PATCH] vfs: do not try to evict inode when super is frozen
Date: Thu, 3 Mar 2022 18:21:04 -0800 [thread overview]
Message-ID: <20220304022104.2525009-1-jaegeuk@kernel.org> (raw)
Otherwise, we will get a deadlock.
[freeze test] shrinkder
freeze_super
- pwercpu_down_write(SB_FREEZE_FS)
- super_cache_scan
- down_read(&sb->s_umount)
- prune_icache_sb
- dispose_list
- evict
- f2fs_evict_inode
thaw_super
- down_write(&sb->s_umount);
- __percpu_down_read(SB_FREEZE_FS)
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
fs/super.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/fs/super.c b/fs/super.c
index 7af820ba5ad5..f7303d91f874 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -79,6 +79,12 @@ static unsigned long super_cache_scan(struct shrinker *shrink,
if (!trylock_super(sb))
return SHRINK_STOP;
+ /* This prevents inode eviction that requires SB_FREEZE_FS. */
+ if (sb->s_writers.frozen == SB_FREEZE_FS) {
+ up_read(&sb->s_umount);
+ return SHRINK_STOP;
+ }
+
if (sb->s_op->nr_cached_objects)
fs_objects = sb->s_op->nr_cached_objects(sb, sc);
--
2.35.1.616.g0bdcbb4464-goog
next reply other threads:[~2022-03-04 2:21 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-04 2:21 Jaegeuk Kim [this message]
2022-03-04 2:48 ` [PATCH] vfs: do not try to evict inode when super is frozen Dave Chinner
2022-03-04 5:14 ` Jaegeuk Kim
2022-03-04 18:04 ` Jaegeuk Kim
2022-03-04 22:18 ` Dave Chinner
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=20220304022104.2525009-1-jaegeuk@kernel.org \
--to=jaegeuk@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).