public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Boris Burkov <boris@bur.io>
To: dsterba@suse.cz, linux-btrfs@vger.kernel.org, kernel-team@fb.com
Subject: Re: [PATCH v3 3/4] btrfs: remove free space items when creating free space tree
Date: Mon, 21 Sep 2020 11:22:20 -0700	[thread overview]
Message-ID: <20200921182220.GB4045720@devvm842.ftw2.facebook.com> (raw)
In-Reply-To: <20200921171304.GM6756@twin.jikos.cz>

On Mon, Sep 21, 2020 at 07:13:04PM +0200, David Sterba wrote:
> On Thu, Sep 17, 2020 at 11:13:40AM -0700, Boris Burkov wrote:
> > --- a/fs/btrfs/disk-io.c
> > +++ b/fs/btrfs/disk-io.c
> > @@ -3333,6 +3333,15 @@ int __cold open_ctree(struct super_block *sb, struct btrfs_fs_devices *fs_device
> >  			close_ctree(fs_info);
> >  			return ret;
> >  		}
> > +		/*
> > +		 * Creating the free space tree creates inode orphan items and
> > +		 * delayed iputs when it deletes the free space inodes. Later in
> > +		 * open_ctree, we run btrfs_orphan_cleanup which tries to clean
> > +		 * up the orphan items. However, the outstanding references on
> > +		 * the inodes from the delayed iputs causes the cleanup to fail.
> > +		 * To fix it, force going through the delayed iputs here.
> > +		 */
> > +		btrfs_run_delayed_iputs(fs_info);
> 
> This is called from open_ctree, so this is mount context and the free
> space tree creation is called before that. That will schedule all free
> space inodes for deletion and waits here. This takes time proportional
> to the filesystem size.
> 
> We've had reports that this takes a lot of time already, so I wonder if
> the delayed iputs can be avoided here.

Good point. The way I see it, deleting the inodes creates legitimate
orphan items, and the delayed_iput doesn't go down until after
open_ctree, I assume for the reason you give. So to delete the free
space inodes without incurring the iput cost during mount, we could:

1. make orphan cleanup smart enough to tell the difference between
orphan items left over from an old mount, vs. orphan items created while
mounting.

2. move orphan cleanup to before free space tree creation/free space
inode deletion in open_ctree.

I'll try to think of a way to do 1. or think of some option 3, as 2.
seems a bit hacky/fragile.

While thinking about a legitimate case for orphans, I realized that
unconditionally failing on free space inode delete errors in
create_free_space_tree without handling ENOENT is almost certainly
wrong, so I will likely need to resend this patch anyway.

  reply	other threads:[~2020-09-21 18:22 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-17 18:13 [PATCH v3 0/4] btrfs: free space tree mounting fixes Boris Burkov
2020-09-17 18:13 ` [PATCH v3 1/4] btrfs: support remount of ro fs with free space tree Boris Burkov
2020-09-21 14:35   ` Josef Bacik
2020-09-24 17:02   ` David Sterba
2020-09-17 18:13 ` [PATCH 2/4] btrfs: use sb state to print space_cache mount option Boris Burkov
2020-09-21 14:50   ` Josef Bacik
2020-09-21 17:04     ` David Sterba
2020-09-21 17:13       ` Boris Burkov
2020-09-24 17:04   ` David Sterba
2020-09-17 18:13 ` [PATCH v3 3/4] btrfs: remove free space items when creating free space tree Boris Burkov
2020-09-21 14:54   ` Josef Bacik
2020-09-21 17:13   ` David Sterba
2020-09-21 18:22     ` Boris Burkov [this message]
2020-09-21 19:01     ` Josef Bacik
2020-09-24 17:07   ` David Sterba
2020-09-17 18:13 ` [PATCH 4/4] btrfs: skip space_cache v1 setup when not using it Boris Burkov
2020-09-21 14:54   ` Josef Bacik
2020-09-18 14:23 ` [PATCH v3 0/4] btrfs: free space tree mounting fixes 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=20200921182220.GB4045720@devvm842.ftw2.facebook.com \
    --to=boris@bur.io \
    --cc=dsterba@suse.cz \
    --cc=kernel-team@fb.com \
    --cc=linux-btrfs@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