From: David Sterba <dsterba@suse.cz>
To: Josef Bacik <josef@toxicpanda.com>
Cc: Nikolay Borisov <nborisov@suse.com>,
kernel-team@fb.com, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH 1/3] btrfs: rename the btrfs_calc_*_metadata_size helpers
Date: Tue, 20 Aug 2019 19:40:08 +0200 [thread overview]
Message-ID: <20190820174008.GU24086@twin.jikos.cz> (raw)
In-Reply-To: <20190819124727.t5xhqyntq72cagav@MacBook-Pro-91.local>
On Mon, Aug 19, 2019 at 08:47:28AM -0400, Josef Bacik wrote:
> > > +static inline u64 btrfs_calc_insert_metadata_size(struct btrfs_fs_info *fs_info,
> > > + unsigned num_items)
> > > {
> > > return (u64)fs_info->nodesize * BTRFS_MAX_LEVEL * 2 * num_items;
> > > }
> >
> > Isn't assuming that we are going to split on every level of the cow
> > rather pessimistic, bordering on impossible. Isn't it realistically
> > possible that we will only ever split up until root->level.
This is a natural idea, I had it as well long time ago, and your
argument why this does not work is that the level can increase between
the time of reservatino and time of commit. So this would lead to ENOSPC
where not expected and then abort.
> I had this discussion with Chris when I messed with this. We do pass in the
> root we intend on messing with so we could very well do this, but it sort of
> scares me because maybe we've been using more of our worst case reservations
> than I expected.
>
> My plan is to get these last corners worked out, get a few more months of
> production testing, and then start experimenting with using the root->level + 1
> for the maximum level and see how that goes. The ramp up from 1 level to 3
> level roots happens pretty fast, so I suspect there'll be weird corner cases
> going from empty->not empty, but I _think_ we should be fine to make this change
> further down the road?
I had a patch for that and tried to do worst case calculations for each
level, ie. what's the number minimum number of items that would require
splitting and increasing the level.
Starting with level 4, the +1 should be safe, for 5+ safe unless eg. the
commit period is so long that the number of dirty metadata is out of
scale (the period affected by commit=, so not a typical usecase).
So the whole idea should work. The formula I used was
level = max(4, root->level + 1)
instead of BTRFS_MAX_LEVEL.
For start, setting the minimum to 5 would be IMHO safe enough, the
savings in the over-reservations would be 3*nodesize in most cases, or
~38%. This could help to avoid early ENOSPC.
next prev parent reply other threads:[~2019-08-20 17:39 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-16 15:05 [PATCH 0/3] Rework the worst case calculations for space reservation Josef Bacik
2019-08-16 15:05 ` [PATCH 1/3] btrfs: rename the btrfs_calc_*_metadata_size helpers Josef Bacik
2019-08-19 8:30 ` Nikolay Borisov
2019-08-19 12:47 ` Josef Bacik
2019-08-20 17:40 ` David Sterba [this message]
2019-08-16 15:05 ` [PATCH 2/3] btrfs: only reserve metadata_size for inodes Josef Bacik
2019-08-19 9:17 ` Nikolay Borisov
2019-08-19 12:49 ` Josef Bacik
2019-08-16 15:06 ` [PATCH 3/3] btrfs: global reserve fallback should use metadata_size Josef Bacik
2019-08-16 15:35 ` Filipe Manana
2019-08-16 16:51 ` Josef Bacik
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=20190820174008.GU24086@twin.jikos.cz \
--to=dsterba@suse.cz \
--cc=josef@toxicpanda.com \
--cc=kernel-team@fb.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=nborisov@suse.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