From: Chris Mason <clm@fb.com>
To: David Sterba <dsterba@suse.cz>
Cc: Omar Sandoval <osandov@osandov.com>,
"linux-btrfs@vger.kernel.org" <linux-btrfs@vger.kernel.org>,
Kernel Team <Kernel-team@fb.com>,
"Nikolay Borisov" <nborisov@suse.com>
Subject: Re: [PATCH v2] Btrfs: fix missing delayed iputs on unmount
Date: Thu, 1 Nov 2018 13:31:18 +0000 [thread overview]
Message-ID: <2DCF4F92-0B05-420C-ADEB-3A7A69F6DB37@fb.com> (raw)
In-Reply-To: <20181101101532.GL9136@twin.jikos.cz>
On 1 Nov 2018, at 6:15, David Sterba wrote:
> On Wed, Oct 31, 2018 at 10:06:08AM -0700, Omar Sandoval wrote:
>> From: Omar Sandoval <osandov@fb.com>
>>
>> There's a race between close_ctree() and cleaner_kthread().
>> close_ctree() sets btrfs_fs_closing(), and the cleaner stops when it
>> sees it set, but this is racy; the cleaner might have already checked
>> the bit and could be cleaning stuff. In particular, if it deletes
>> unused
>> block groups, it will create delayed iputs for the free space cache
>> inodes. As of "btrfs: don't run delayed_iputs in commit", we're no
>> longer running delayed iputs after a commit. Therefore, if the
>> cleaner
>> creates more delayed iputs after delayed iputs are run in
>> btrfs_commit_super(), we will leak inodes on unmount and get a busy
>> inode crash from the VFS.
>>
>> Fix it by parking the cleaner
>
> Ouch, that's IMO wrong way to fix it. The bug is on a higher level,
> we're missing a commit or clean up data structures. Messing with state
> of a thread would be the last thing I'd try after proving that it's
> not
> possible to fix in the logic of btrfs itself.
>
> The shutdown sequence in close_tree is quite tricky and we've had bugs
> there. The interdependencies of thread and data structures and other
> subsystems cannot have loops that could not find an ordering that will
> not leak something.
>
> It's not a big problem if some step is done more than once, like
> committing or cleaning up some other structures if we know that
> it could create new.
The problem is the cleaner thread needs to be told to stop doing new
work, and we need to wait for the work it's already doing to be
finished. We're getting "stop doing new work" already because the
cleaner thread checks to see if the FS is closing, but we don't have a
way today to wait for him to finish what he's already doing.
kthread_park() is basically the same as adding another mutex or
synchronization point. I'm not sure how we could change close_tree() or
the final commit to pick this up more effectively?
-chris
next prev parent reply other threads:[~2018-11-01 13:31 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-31 17:06 [PATCH v2] Btrfs: fix missing delayed iputs on unmount Omar Sandoval
2018-11-01 10:15 ` David Sterba
2018-11-01 13:31 ` Chris Mason [this message]
2018-11-01 15:08 ` David Sterba
2018-11-01 15:22 ` David Sterba
2018-11-01 15:24 ` Omar Sandoval
2018-11-01 15:28 ` Omar Sandoval
2018-11-01 15:29 ` David Sterba
2018-11-01 16:00 ` Omar Sandoval
2018-11-01 16:44 ` David Sterba
2018-11-01 16:50 ` Nikolay Borisov
2018-11-01 17:15 ` David Sterba
2018-11-01 17:36 ` Chris Mason
2018-11-01 15:23 ` Omar Sandoval
2018-11-01 15:28 ` David Sterba
2018-11-01 14:35 ` Nikolay Borisov
2018-11-01 15:10 ` Nikolay Borisov
2018-11-07 16:01 ` David Sterba
2018-11-10 4:07 ` Omar Sandoval
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=2DCF4F92-0B05-420C-ADEB-3A7A69F6DB37@fb.com \
--to=clm@fb.com \
--cc=Kernel-team@fb.com \
--cc=dsterba@suse.cz \
--cc=linux-btrfs@vger.kernel.org \
--cc=nborisov@suse.com \
--cc=osandov@osandov.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).