public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
From: ZhengYuan Huang <gality369@gmail.com>
To: dsterba@suse.cz
Cc: dsterba@suse.com, clm@fb.com, idryomov@gmail.com,
	 linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org,
	 baijiaju1990@gmail.com, r33s3n6@gmail.com, zzzccc427@gmail.com
Subject: Re: [PATCH v2 3/3] btrfs: fix check_chunk_block_group_mappings() to actually iterate all chunks
Date: Tue, 24 Mar 2026 10:57:47 +0800	[thread overview]
Message-ID: <CAOmEq9WK-uA=mGcoeHOy_11acWgzrqfj5fXfSmzQY-E=nUTWmQ@mail.gmail.com> (raw)
In-Reply-To: <20260323175212.GO5735@twin.jikos.cz>

On Tue, Mar 24, 2026 at 1:52 AM David Sterba <dsterba@suse.cz> wrote:
> This is called during mount indirectly from open_ctree() and this is
> single threaded (partially), so the lock may not be needed. It would be
> needed if there's eg. caching thread possibly accessing the same
> structures, I haven't looked closely.
>
> > +     for (node = rb_first_cached(&fs_info->mapping_tree); node;
> > +          node = rb_next(node)) {
> >               struct btrfs_chunk_map *map;
> >               struct btrfs_block_group *bg;
> >
> > -             /*
> > -              * btrfs_find_chunk_map() will return the first chunk map
> > -              * intersecting the range, so setting @length to 1 is enough to
> > -              * get the first chunk.
> > -              */
> > -             map = btrfs_find_chunk_map(fs_info, start, 1);
> > -             if (!map)
> > -                     break;
> > -
> > +             map = rb_entry(node, struct btrfs_chunk_map, rb_node);
> >               bg = btrfs_lookup_block_group(fs_info, map->start);
>
> What concerns me is this lookup. Previously the references avoided
> taking the big lock. The time the lock is held may add up significanly
> for all block groups but as said before it might not be necessary due to
> the mount context.

Thanks for the suggestion, I’ll take a closer look at the locking here.
If the lock turns out to be unnecessary in this context, I’ll drop it
and include the change in v3.

Thanks,
ZhengYuan Huang

  reply	other threads:[~2026-03-24  2:58 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-14 12:37 [PATCH v2 0/3] btrfs: fix balance NULL derefs and chunk/bg mapping verification ZhengYuan Huang
2026-03-14 12:37 ` [PATCH v2 1/3] btrfs: balance: fix null-ptr-deref in chunk_usage_filter ZhengYuan Huang
2026-03-23 17:40   ` David Sterba
2026-03-24  2:56     ` ZhengYuan Huang
2026-03-14 12:37 ` [PATCH v2 2/3] btrfs: balance: fix null-ptr-deref in chunk_usage_range_filter ZhengYuan Huang
2026-03-14 12:37 ` [PATCH v2 3/3] btrfs: fix check_chunk_block_group_mappings() to actually iterate all chunks ZhengYuan Huang
2026-03-23 17:52   ` David Sterba
2026-03-24  2:57     ` ZhengYuan Huang [this message]
2026-03-23 17:33 ` [PATCH v2 0/3] btrfs: fix balance NULL derefs and chunk/bg mapping verification David Sterba
2026-03-24  2:53   ` ZhengYuan Huang

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='CAOmEq9WK-uA=mGcoeHOy_11acWgzrqfj5fXfSmzQY-E=nUTWmQ@mail.gmail.com' \
    --to=gality369@gmail.com \
    --cc=baijiaju1990@gmail.com \
    --cc=clm@fb.com \
    --cc=dsterba@suse.com \
    --cc=dsterba@suse.cz \
    --cc=idryomov@gmail.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=r33s3n6@gmail.com \
    --cc=zzzccc427@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