Linux Btrfs filesystem development
 help / color / mirror / Atom feed
From: Boris Burkov <boris@bur.io>
To: Leo Martins <loemra.dev@gmail.com>
Cc: linux-btrfs@vger.kernel.org, kernel-team@fb.com, fstests@vger.kernel.org
Subject: Re: [PATCH v2 1/3] btrfs: remove ffe RAID loop
Date: Tue, 14 Oct 2025 20:29:35 -0700	[thread overview]
Message-ID: <20251015032935.GB1702774@zen.localdomain> (raw)
In-Reply-To: <a46aa0e4fb936ab73748fc9fd92a9404380769b1.1759532729.git.loemra.dev@gmail.com>

On Fri, Oct 03, 2025 at 04:41:57PM -0700, Leo Martins wrote:
> This patch removes the RAID loop from find_free_extent since it
> is impossible to allocate from a block group with a different
> RAID profile.
> 
> Historically, we've been able to fulfill allocation requests
> from mismatched RAID block groups assuming they provided the
> required duplcation. For example, a request for RAID0 could be
> fulfilled by a RAID1 block group.
> 
> 2a28468e525f ("btrfs: extent-tree: Make sure we only allocate extents from block groups with the same type")
> changed this behavior to skip block groups with different flags
> than the request. This makes the duplication compatiblity check
> redundant since we're going to keep searching regardless.
> 
> Signed-off-by: Leo Martins <loemra.dev@gmail.com>

Reviewed-by: Boris Burkov <boris@bur.io>

> ---
>  fs/btrfs/extent-tree.c | 32 +-------------------------------
>  1 file changed, 1 insertion(+), 31 deletions(-)
> 
> diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
> index a4416c451b25..28b442660014 100644
> --- a/fs/btrfs/extent-tree.c
> +++ b/fs/btrfs/extent-tree.c
> @@ -4171,13 +4171,8 @@ static int find_free_extent_update_loop(struct btrfs_fs_info *fs_info,
>  	if (ffe_ctl->loop >= LOOP_CACHING_WAIT && ffe_ctl->have_caching_bg)
>  		return 1;
>  
> -	ffe_ctl->index++;
> -	if (ffe_ctl->index < BTRFS_NR_RAID_TYPES)
> -		return 1;
> -
>  	/* See the comments for btrfs_loop_type for an explanation of the phases. */
>  	if (ffe_ctl->loop < LOOP_NO_EMPTY_SIZE) {
> -		ffe_ctl->index = 0;
>  		/*
>  		 * We want to skip the LOOP_CACHING_WAIT step if we don't have
>  		 * any uncached bgs and we've already done a full search
> @@ -4477,9 +4472,7 @@ static noinline int find_free_extent(struct btrfs_root *root,
>  search:
>  	trace_btrfs_find_free_extent_search_loop(root, ffe_ctl);
>  	ffe_ctl->have_caching_bg = false;
> -	if (ffe_ctl->index == btrfs_bg_flags_to_raid_index(ffe_ctl->flags) ||
> -	    ffe_ctl->index == 0)
> -		full_search = true;
> +	full_search = true;
>  	down_read(&space_info->groups_sem);
>  	list_for_each_entry(block_group,
>  			    &space_info->block_groups[ffe_ctl->index], list) {
> @@ -4498,30 +4491,7 @@ static noinline int find_free_extent(struct btrfs_root *root,
>  		btrfs_grab_block_group(block_group, ffe_ctl->delalloc);
>  		ffe_ctl->search_start = block_group->start;
>  
> -		/*
> -		 * this can happen if we end up cycling through all the
> -		 * raid types, but we want to make sure we only allocate
> -		 * for the proper type.
> -		 */
>  		if (!block_group_bits(block_group, ffe_ctl->flags)) {
> -			u64 extra = BTRFS_BLOCK_GROUP_DUP |
> -				BTRFS_BLOCK_GROUP_RAID1_MASK |
> -				BTRFS_BLOCK_GROUP_RAID56_MASK |
> -				BTRFS_BLOCK_GROUP_RAID10;
> -
> -			/*
> -			 * if they asked for extra copies and this block group
> -			 * doesn't provide them, bail.  This does allow us to
> -			 * fill raid0 from raid1.
> -			 */
> -			if ((ffe_ctl->flags & extra) && !(block_group->flags & extra))
> -				goto loop;
> -
> -			/*
> -			 * This block group has different flags than we want.
> -			 * It's possible that we have MIXED_GROUP flag but no
> -			 * block group is mixed.  Just skip such block group.
> -			 */
>  			btrfs_release_block_group(block_group, ffe_ctl->delalloc);
>  			continue;
>  		}
> -- 
> 2.47.3
> 

  reply	other threads:[~2025-10-15  3:29 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-03 23:41 [PATCH v2 0/3] btrfs: find_free_extent cleanups Leo Martins
2025-10-03 23:41 ` [PATCH v2 1/3] btrfs: remove ffe RAID loop Leo Martins
2025-10-15  3:29   ` Boris Burkov [this message]
2025-10-03 23:41 ` [PATCH v2 2/3] btrfs: add tracing for find_free_extent skip conditions Leo Martins
2025-10-15  3:28   ` Boris Burkov
2025-10-03 23:41 ` [PATCH v2 3/3] fstests: btrfs: test RAID conversions under stress Leo Martins
2025-10-04  1:54   ` Qu Wenruo
2025-10-06 17:37     ` Leo Martins
2025-10-06 18:16       ` David Sterba
2025-10-15  3:31   ` Boris Burkov

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=20251015032935.GB1702774@zen.localdomain \
    --to=boris@bur.io \
    --cc=fstests@vger.kernel.org \
    --cc=kernel-team@fb.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=loemra.dev@gmail.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