Linux Btrfs filesystem development
 help / color / mirror / Atom feed
From: Boris Burkov <boris@bur.io>
To: Josef Bacik <josef@toxicpanda.com>
Cc: linux-btrfs@vger.kernel.org, kernel-team@fb.com
Subject: Re: [PATCH] btrfs: reset RO counter on block group if we fail to relocate
Date: Mon, 25 Jul 2022 14:55:00 -0700	[thread overview]
Message-ID: <Yt8RNCQ8o7f2IQt7@zen> (raw)
In-Reply-To: <ca31fa4152849cee02f16c49f7ef818b89995a25.1658768686.git.josef@toxicpanda.com>

On Mon, Jul 25, 2022 at 01:05:05PM -0400, Josef Bacik wrote:
> With the automatic block group reclaim code we will preemptively try to
> mark the block group RO before we start the relocation.  We do this to
> make sure we should actually try to relocate the block group.
> 
> However if we hit an error during the actual relocation we won't clean
> up our RO counter and the block group will remain RO.  This was observed
> internally with file systems reporting less space available from df when
> we had failed background relocations.
> 
> Fix this by doing the dec_ro in the error case.
> 
> Fixes: 18bb8bbf13c1 ("btrfs: zoned: automatically reclaim zones")
> Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: Boris Burkov <boris@bur.io>
> ---
>  fs/btrfs/block-group.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/btrfs/block-group.c b/fs/btrfs/block-group.c
> index c3aecfb0a71d..993aca2f1e18 100644
> --- a/fs/btrfs/block-group.c
> +++ b/fs/btrfs/block-group.c
> @@ -1640,9 +1640,11 @@ void btrfs_reclaim_bgs_work(struct work_struct *work)
>  				div64_u64(zone_unusable * 100, bg->length));
>  		trace_btrfs_reclaim_block_group(bg);
>  		ret = btrfs_relocate_chunk(fs_info, bg->start);
> -		if (ret)
> +		if (ret) {
> +			btrfs_dec_block_group_ro(bg);
>  			btrfs_err(fs_info, "error relocating chunk %llu",
>  				  bg->start);
> +		}
>  
>  next:
>  		btrfs_put_block_group(bg);
> -- 
> 2.26.3
> 

  reply	other threads:[~2022-07-25 21:53 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-25 17:05 [PATCH] btrfs: reset RO counter on block group if we fail to relocate Josef Bacik
2022-07-25 21:55 ` Boris Burkov [this message]
2022-07-27 19:24 ` 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=Yt8RNCQ8o7f2IQt7@zen \
    --to=boris@bur.io \
    --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