linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nikolay Borisov <nborisov@suse.com>
To: Josef Bacik <josef@toxicpanda.com>,
	kernel-team@fb.com, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH 1/5] btrfs: change the minimum global reserve size
Date: Tue, 20 Aug 2019 16:45:15 +0300	[thread overview]
Message-ID: <761ca884-2f9a-dc44-65db-d9a4db61bf78@suse.com> (raw)
In-Reply-To: <20190816152019.1962-2-josef@toxicpanda.com>



On 16.08.19 г. 18:20 ч., Josef Bacik wrote:
> It made sense to have the global reserve set at 16M in the past, but
> since it is used less nowadays set the minimum size to the number of
> items we'll need to update the main trees we update during a transaction
> commit, plus some slop area so we can do unlinks if we need to.
> 
> In practice this doesn't affect normal file systems, but for xfstests
> where we do things like fill up a fs and then rm * it can fall over in
> weird ways.  This enables us for more sane behavior at extremely small
> file system sizes.
> 
> Signed-off-by: Josef Bacik <josef@toxicpanda.com>
> ---
>  fs/btrfs/block-rsv.c | 22 +++++++++++++++++++++-
>  1 file changed, 21 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/btrfs/block-rsv.c b/fs/btrfs/block-rsv.c
> index c64b460a4301..657675eef443 100644
> --- a/fs/btrfs/block-rsv.c
> +++ b/fs/btrfs/block-rsv.c
> @@ -258,6 +258,7 @@ void btrfs_update_global_block_rsv(struct btrfs_fs_info *fs_info)
>  	struct btrfs_block_rsv *block_rsv = &fs_info->global_block_rsv;
>  	struct btrfs_space_info *sinfo = block_rsv->space_info;
>  	u64 num_bytes;
> +	unsigned min_items;
>  
>  	/*
>  	 * The global block rsv is based on the size of the extent tree, the
> @@ -267,7 +268,26 @@ void btrfs_update_global_block_rsv(struct btrfs_fs_info *fs_info)
>  	num_bytes = btrfs_root_used(&fs_info->extent_root->root_item) +
>  		btrfs_root_used(&fs_info->csum_root->root_item) +
>  		btrfs_root_used(&fs_info->tree_root->root_item);
> -	num_bytes = max_t(u64, num_bytes, SZ_16M);
> +
> +	/*
> +	 * We at a minimum are going to modify the csum root, the tree root, and
> +	 * the extent root.
> +	 */
> +	min_items = 3;
> +
> +	/*
> +	 * But we also want to reserve enough space so we can do the fallback
> +	 * global reserve for an unlink, which is an additional 5 items (see the
> +	 * comment in __unlink_start_trans for what we're modifying.)
> +	 *
> +	 * But we also need space for the delayed ref updates from the unlink,
> +	 * so its 10, 5 for the actual operation, and 5 for the delayed ref
> +	 * updates.
> +	 */
> +	min_items += 10;
> +
> +	num_bytes = max_t(u64, num_bytes,
> +			  btrfs_calc_insert_metadata_size(fs_info, min_items));

For ordinary, 16k nodesize filesystem, btrfs_calc_insert_metadata_size
will really return 3.4m -> 16 * 8 * 2 * 13 * 1024 = 3407872 bytes . In
those cases I expect that the code will always be doing num_bytes =
num_bytes.

>  
>  	spin_lock(&sinfo->lock);
>  	spin_lock(&block_rsv->lock);
> 

  reply	other threads:[~2019-08-20 13:45 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-16 15:20 [PATCH 0/5] Fix global reserve size and can overcommit Josef Bacik
2019-08-16 15:20 ` [PATCH 1/5] btrfs: change the minimum global reserve size Josef Bacik
2019-08-20 13:45   ` Nikolay Borisov [this message]
2019-08-20 19:12     ` Josef Bacik
2019-08-16 15:20 ` [PATCH 2/5] btrfs: always reserve our entire size for the global reserve Josef Bacik
2019-08-20 14:23   ` Nikolay Borisov
2019-08-20 19:13     ` Josef Bacik
2019-08-16 15:20 ` [PATCH 3/5] btrfs: use add_old_bytes when updating " Josef Bacik
2019-08-20 15:33   ` Nikolay Borisov
2019-08-16 15:20 ` [PATCH 4/5] btrfs: do not account global reserve in can_overcommit Josef Bacik
2019-08-21  6:51   ` Nikolay Borisov
2019-08-21 15:30   ` Vladimir Panteleev
2019-08-16 15:20 ` [PATCH 5/5] btrfs: add enospc debug messages for ticket failure Josef Bacik
2019-08-21  6:39   ` Nikolay Borisov
2019-08-22 19:18 [PATCH 0/5][v2] Fix global reserve size and can overcommit Josef Bacik
2019-08-22 19:19 ` [PATCH 1/5] btrfs: change the minimum global reserve size 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=761ca884-2f9a-dc44-65db-d9a4db61bf78@suse.com \
    --to=nborisov@suse.com \
    --cc=josef@toxicpanda.com \
    --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;
as well as URLs for NNTP newsgroup(s).