From: David Sterba <dsterba@suse.cz>
To: Filipe Manana <fdmanana@kernel.org>
Cc: Nikolay Borisov <nborisov@suse.com>,
linux-btrfs <linux-btrfs@vger.kernel.org>
Subject: Re: [PATCH v3 1/2] btrfs: fix deadlock between chunk allocation and chunk btree modifications
Date: Mon, 18 Oct 2021 18:22:01 +0200 [thread overview]
Message-ID: <20211018162201.GO30611@twin.jikos.cz> (raw)
In-Reply-To: <CAL3q7H62eWcTZWCkN8ZMDEOjgjJBXYgESSdhcdWHxzfVzUBUqA@mail.gmail.com>
On Wed, Oct 13, 2021 at 03:21:47PM +0100, Filipe Manana wrote:
> > > @@ -3724,19 +3718,13 @@ void check_system_chunk(struct btrfs_trans_handle *trans, u64 type)
> > > left = info->total_bytes - btrfs_space_info_used(info, true);
> > > spin_unlock(&info->lock);
> > >
> > > - num_devs = get_profile_num_devs(fs_info, type);
> > > -
> > > - /* num_devs device items to update and 1 chunk item to add or remove */
> > > - thresh = btrfs_calc_metadata_size(fs_info, num_devs) +
> > > - btrfs_calc_insert_metadata_size(fs_info, 1);
> > > -
> > > - if (left < thresh && btrfs_test_opt(fs_info, ENOSPC_DEBUG)) {
> > > + if (left < bytes && btrfs_test_opt(fs_info, ENOSPC_DEBUG)) {
> > > btrfs_info(fs_info, "left=%llu, need=%llu, flags=%llu",
> > > - left, thresh, type);
> > > + left, bytes, type);
> > > btrfs_dump_space_info(fs_info, info, 0, 0);
> > > }
> >
> > This can be simplified to if (btrfs_test_opt(fs_info, ENOSPC_DEBUG))
> > and nested inside the next if (left < bytes). I checked
> > and even with the extra nesting the code doesn't break the 76 char limit.
>
> This is a bug fix only, I'm not reformatting code blocks I'm not
> really changing.
I tend to agree to keep the fix minimal and do unrelated cleanups if it
happens in the scope of the fix. Backporing such patches is easier but I
understand the comment that sometimes it's worth to do the collateral
cleanups. No hard rules here.
> > > +/*
> > > + * Reserve space in the system space for allocating or removing a chunk.
> > > + * The caller must be holding fs_info->chunk_mutex.
> >
> > Better to use lockdep_assert_held.
>
> reserve_chunk_space() does that, that's why I didn't add it here again.
I'm not sure what's the overhead of lockdep_assert_held but it could be
potentially a perf hit, where we would care even for a debugging build.
If the call chain is not spread over many functions/files I'd say it's
ok to do lockdep_assert only on the entry function and not each in the
call sub tree.
next prev parent reply other threads:[~2021-10-18 16:22 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-07 11:03 [PATCH 0/2] btrfs: fix a deadlock between chunk allocation and chunk tree modifications fdmanana
2021-10-07 11:03 ` [PATCH 1/2] btrfs: fix deadlock between chunk allocation and chunk btree modifications fdmanana
2021-10-07 11:04 ` [PATCH 2/2] btrfs: update comments for chunk allocation -ENOSPC cases fdmanana
2021-10-08 15:10 ` [PATCH v2 0/2] btrfs: fix a deadlock between chunk allocation and chunk tree modifications fdmanana
2021-10-08 15:10 ` [PATCH v2 1/2] btrfs: fix deadlock between chunk allocation and chunk btree modifications fdmanana
2021-10-11 16:05 ` Josef Bacik
2021-10-11 17:31 ` Filipe Manana
2021-10-11 17:42 ` Josef Bacik
2021-10-11 18:22 ` Filipe Manana
2021-10-11 18:31 ` Josef Bacik
2021-10-11 19:09 ` Filipe Manana
2021-10-12 21:34 ` Josef Bacik
2021-10-13 9:19 ` Filipe Manana
2021-10-08 15:10 ` [PATCH v2 2/2] btrfs: update comments for chunk allocation -ENOSPC cases fdmanana
2021-10-13 9:12 ` [PATCH v3 0/2] btrfs: fix a deadlock between chunk allocation and chunk tree modifications fdmanana
2021-10-13 9:12 ` [PATCH v3 1/2] btrfs: fix deadlock between chunk allocation and chunk btree modifications fdmanana
2021-10-13 14:09 ` Nikolay Borisov
2021-10-13 14:21 ` Filipe Manana
2021-10-18 16:22 ` David Sterba [this message]
2021-10-14 15:20 ` Josef Bacik
2021-10-13 9:12 ` [PATCH v3 2/2] btrfs: update comments for chunk allocation -ENOSPC cases fdmanana
2021-10-14 15:21 ` Josef Bacik
2021-10-18 16:33 ` [PATCH v3 0/2] btrfs: fix a deadlock between chunk allocation and chunk tree modifications 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=20211018162201.GO30611@twin.jikos.cz \
--to=dsterba@suse.cz \
--cc=fdmanana@kernel.org \
--cc=linux-btrfs@vger.kernel.org \
--cc=nborisov@suse.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;
as well as URLs for NNTP newsgroup(s).