From: Josef Bacik <josef@toxicpanda.com>
To: Julian Sun <sunjunchao2870@gmail.com>
Cc: linux-btrfs@vger.kernel.org, clm@fb.com, dsterba@suse.com,
syzbot+67ba3c42bcbb4665d3ad@syzkaller.appspotmail.com,
stable@vger.kernel.org
Subject: Re: [PATCH] btrfs: fix the race between umount and btrfs-cleaner
Date: Wed, 21 Aug 2024 14:08:04 -0400 [thread overview]
Message-ID: <20240821180804.GF1998418@perftesting> (raw)
In-Reply-To: <20240821114628.645455-1-sunjunchao2870@gmail.com>
On Wed, Aug 21, 2024 at 07:46:28PM +0800, Julian Sun wrote:
> There is a race condition generic_shutdown_super() and
> __btrfs_run_defrag_inode().
> Consider the following scenario:
>
> umount thread: btrfs-cleaner thread:
> btrfs_run_delayed_iputs()
> ->run_delayed_iput_locked()
> ->iput(inode)
> // Here the inode (ie ino 261) will be cleared and freed
> btrfs_kill_super()
> ->generic_shutdown_super()
> btrfs_run_defrag_inodes()
> ->__btrfs_run_defrag_inode()
> ->btrfs_iget(ino)
> // The inode 261 was recreated with i_count=1
> // and added to the sb list
> ->evict_inodes(sb) // After some work
> // inode 261 was added ->iput(inode)
> // to the dispose list ->iput_funal()
> ->evict(inode) ->evict(inode)
This is wrong though, evict_inodes() isn't supposed to isolate if i_count == 1,
and iput_final sets I_FREEING, so we won't get the evict() from evict_inodes.
Something else is happening here. Thanks,
Josef
next prev parent reply other threads:[~2024-08-21 18:08 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-21 11:46 [PATCH] btrfs: fix the race between umount and btrfs-cleaner Julian Sun
2024-08-21 18:08 ` Josef Bacik [this message]
2024-08-22 11:41 ` Julian Sun
2024-08-22 11:51 ` Julian Sun
2024-08-22 12:45 ` Julian Sun
2024-08-26 15:39 ` David Sterba
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=20240821180804.GF1998418@perftesting \
--to=josef@toxicpanda.com \
--cc=clm@fb.com \
--cc=dsterba@suse.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=sunjunchao2870@gmail.com \
--cc=syzbot+67ba3c42bcbb4665d3ad@syzkaller.appspotmail.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;
as well as URLs for NNTP newsgroup(s).