Linux Btrfs filesystem development
 help / color / mirror / Atom feed
From: Boris Burkov <boris@bur.io>
To: Mark Harmstone <mark@harmstone.com>
Cc: linux-btrfs@vger.kernel.org
Subject: Re: [PATCH v2 09/16] btrfs: release BG lock before calling btrfs_link_bg_list()
Date: Fri, 15 Aug 2025 17:32:33 -0700	[thread overview]
Message-ID: <20250816003233.GF3042054@zen.localdomain> (raw)
In-Reply-To: <20250813143509.31073-10-mark@harmstone.com>

On Wed, Aug 13, 2025 at 03:34:51PM +0100, Mark Harmstone wrote:
> Release block_group->lock before calling btrfs_link_bg_list() in
> btrfs_delete_unused_bgs(), as this was causing lockdep issues.
> 
> This lock isn't held in any other place that we call btrfs_link_bg_list(), as
> the block group lists are manipulated while holding fs_info->unused_bgs_lock.
> 

Please include the offending lockdep output you are fixing.

Is this a generic fix unrelated to your other changes? I think a
separate patch from the series is clearer in that case. And it would
need a Fixes: tag (probably my patch that added btrfs_link_bg_list, haha)

Thanks.

> Signed-off-by: Mark Harmstone <mark@harmstone.com>
> ---
>  fs/btrfs/block-group.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/btrfs/block-group.c b/fs/btrfs/block-group.c
> index bed9c58b6cbc..8c28f829547e 100644
> --- a/fs/btrfs/block-group.c
> +++ b/fs/btrfs/block-group.c
> @@ -1620,6 +1620,8 @@ void btrfs_delete_unused_bgs(struct btrfs_fs_info *fs_info)
>  		if ((space_info->total_bytes - block_group->length < used &&
>  		     block_group->zone_unusable < block_group->length) ||
>  		    has_unwritten_metadata(block_group)) {
> +			spin_unlock(&block_group->lock);
> +
>  			/*
>  			 * Add a reference for the list, compensate for the ref
>  			 * drop under the "next" label for the
> @@ -1628,7 +1630,6 @@ void btrfs_delete_unused_bgs(struct btrfs_fs_info *fs_info)
>  			btrfs_link_bg_list(block_group, &retry_list);
>  
>  			trace_btrfs_skip_unused_block_group(block_group);
> -			spin_unlock(&block_group->lock);
>  			spin_unlock(&space_info->lock);
>  			up_write(&space_info->groups_sem);
>  			goto next;
> -- 
> 2.49.1
> 

  reply	other threads:[~2025-08-16  0:31 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-13 14:34 [PATCH v2 00/16] btrfs: remap tree Mark Harmstone
2025-08-13 14:34 ` [PATCH v2 01/16] btrfs: add definitions and constants for remap-tree Mark Harmstone
2025-08-15 23:51   ` Boris Burkov
2025-08-18 17:21     ` Mark Harmstone
2025-08-18 17:33       ` Boris Burkov
2025-08-16  0:01   ` Qu Wenruo
2025-08-16  0:17     ` Qu Wenruo
2025-08-18 17:23       ` Mark Harmstone
2025-08-13 14:34 ` [PATCH v2 02/16] btrfs: add REMAP chunk type Mark Harmstone
2025-08-13 14:34 ` [PATCH v2 03/16] btrfs: allow remapped chunks to have zero stripes Mark Harmstone
2025-08-16  0:03   ` Boris Burkov
2025-08-22 17:01     ` Mark Harmstone
2025-08-19  1:05   ` kernel test robot
2025-08-22 17:07     ` Mark Harmstone
2025-08-13 14:34 ` [PATCH v2 04/16] btrfs: remove remapped block groups from the free-space tree Mark Harmstone
2025-08-13 14:34 ` [PATCH v2 05/16] btrfs: don't add metadata items for the remap tree to the extent tree Mark Harmstone
2025-08-16  0:06   ` Boris Burkov
2025-08-13 14:34 ` [PATCH v2 06/16] btrfs: add extended version of struct block_group_item Mark Harmstone
2025-08-16  0:08   ` Boris Burkov
2025-08-13 14:34 ` [PATCH v2 07/16] btrfs: allow mounting filesystems with remap-tree incompat flag Mark Harmstone
2025-08-22 19:14   ` Boris Burkov
2025-08-13 14:34 ` [PATCH v2 08/16] btrfs: redirect I/O for remapped block groups Mark Harmstone
2025-08-22 19:42   ` Boris Burkov
2025-08-27 14:08     ` Mark Harmstone
2025-08-13 14:34 ` [PATCH v2 09/16] btrfs: release BG lock before calling btrfs_link_bg_list() Mark Harmstone
2025-08-16  0:32   ` Boris Burkov [this message]
2025-08-27 15:35     ` Mark Harmstone
2025-08-27 15:48       ` Filipe Manana
2025-08-27 15:52         ` Mark Harmstone
2025-08-13 14:34 ` [PATCH v2 10/16] btrfs: handle deletions from remapped block group Mark Harmstone
2025-08-16  0:28   ` Boris Burkov
2025-08-27 17:11     ` Mark Harmstone
2025-08-13 14:34 ` [PATCH v2 11/16] btrfs: handle setting up relocation of block group with remap-tree Mark Harmstone
2025-08-13 14:34 ` [PATCH v2 12/16] btrfs: move existing remaps before relocating block group Mark Harmstone
2025-08-13 14:34 ` [PATCH v2 13/16] btrfs: replace identity maps with actual remaps when doing relocations Mark Harmstone
2025-08-13 14:34 ` [PATCH v2 14/16] btrfs: add do_remap param to btrfs_discard_extent() Mark Harmstone
2025-08-13 14:34 ` [PATCH v2 15/16] btrfs: add fully_remapped_bgs list Mark Harmstone
2025-08-16  0:56   ` Boris Burkov
2025-08-27 18:51     ` Mark Harmstone
2025-08-13 14:34 ` [PATCH v2 16/16] btrfs: allow balancing remap tree Mark Harmstone
2025-08-16  1:02   ` Boris Burkov
2025-09-02 14:58     ` Mark Harmstone
2025-09-02 15:21     ` Mark Harmstone

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=20250816003233.GF3042054@zen.localdomain \
    --to=boris@bur.io \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=mark@harmstone.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