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 2/5] btrfs: always reserve our entire size for the global reserve
Date: Tue, 20 Aug 2019 17:23:29 +0300	[thread overview]
Message-ID: <c0657408-7291-fb4c-ac20-90d5fd913e61@suse.com> (raw)
In-Reply-To: <20190816152019.1962-3-josef@toxicpanda.com>



On 16.08.19 г. 18:20 ч., Josef Bacik wrote:
> While messing with the overcommit logic I noticed that sometimes we'd
> ENOSPC out when really we should have run out of space much earlier.  It
> turns out it's because we'll only reserve up to the free amount left in
> the space info for the global reserve, but that doesn't make sense with
> overcommit because we could be well above our actual size.  This results
> in the global reserve not carving out it's entire reservation, and thus
> not putting enough pressure on the rest of the infrastructure to do the
> right thing and ENOSPC out at a convenient time.  Fix this by always
> taking our full reservation amount for the global reserve.
> 
> Signed-off-by: Josef Bacik <josef@toxicpanda.com>


In effect you could possibly overcommit by increasing bytes_may_use you
potentially cause callers of reserve_metadata_bytes to get ENOSPC, am I
right? In any case the code itself looks ok:

Reviewed-by: Nikolay Borisov <nborisov@suse.com>

> ---
>  fs/btrfs/block-rsv.c | 13 ++++---------
>  1 file changed, 4 insertions(+), 9 deletions(-)
> 
> diff --git a/fs/btrfs/block-rsv.c b/fs/btrfs/block-rsv.c
> index 657675eef443..18a0af20ee5a 100644
> --- a/fs/btrfs/block-rsv.c
> +++ b/fs/btrfs/block-rsv.c
> @@ -295,15 +295,10 @@ void btrfs_update_global_block_rsv(struct btrfs_fs_info *fs_info)
>  	block_rsv->size = min_t(u64, num_bytes, SZ_512M);
>  
>  	if (block_rsv->reserved < block_rsv->size) {
> -		num_bytes = btrfs_space_info_used(sinfo, true);
> -		if (sinfo->total_bytes > num_bytes) {
> -			num_bytes = sinfo->total_bytes - num_bytes;
> -			num_bytes = min(num_bytes,
> -					block_rsv->size - block_rsv->reserved);
> -			block_rsv->reserved += num_bytes;
> -			btrfs_space_info_update_bytes_may_use(fs_info, sinfo,
> -							      num_bytes);
> -		}
> +		num_bytes = block_rsv->size - block_rsv->reserved;
> +		block_rsv->reserved += num_bytes;
> +		btrfs_space_info_update_bytes_may_use(fs_info, sinfo,
> +						      num_bytes);
>  	} else if (block_rsv->reserved > block_rsv->size) {
>  		num_bytes = block_rsv->reserved - block_rsv->size;
>  		btrfs_space_info_update_bytes_may_use(fs_info, sinfo,
> 

  reply	other threads:[~2019-08-20 14:23 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
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 [this message]
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 2/5] btrfs: always reserve our entire size for the global reserve 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=c0657408-7291-fb4c-ac20-90d5fd913e61@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).