public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
From: David Sterba <dsterba@suse.cz>
To: Qu Wenruo <wqu@suse.com>
Cc: linux-btrfs@vger.kernel.org
Subject: Re: [PATCH v4 3/5] btrfs: introduce BTRFS_QGROUP_RUNTIME_FLAG_CANCEL_RESCAN
Date: Mon, 5 Sep 2022 19:43:22 +0200	[thread overview]
Message-ID: <20220905174322.GL13489@twin.jikos.cz> (raw)
In-Reply-To: <511e5eec2f5c3797b0981899b57cc4afa8d1102e.1661302005.git.wqu@suse.com>

On Wed, Aug 24, 2022 at 09:14:07AM +0800, Qu Wenruo wrote:
> Here we introduce a new runtime flag,
> BTRFS_QGROUP_RUNTIME_FLAG_CANCEL_RESCAN, which will inform qgroup rescan
> to cancel its work asynchronously.
> 
> This is to address the window when an operation makes qgroup numbers
> inconsistent (like qgroup inheriting) while a qgroup rescan is running.
> 
> In that case, qgroup inconsistent flag will be cleared when qgroup
> rescan finishes.
> But we changed the ownership of some extents, which means the rescan is
> already meaningless, and the qgroup inconsistent flag should not be
> cleared.
> 
> With the new flag, each time we set INCONSISTENT flag, we also set this
> new flag to inform any running qgroup rescan to exit immediately, and
> leaving the INCONSISTENT flag there.
> 
> The new runtime flag can only be cleared when a new rescan is started.
> 
> Signed-off-by: Qu Wenruo <wqu@suse.com>
> ---
>  fs/btrfs/qgroup.c | 46 +++++++++++++++++++++++++++++-----------------
>  fs/btrfs/qgroup.h |  2 ++
>  2 files changed, 31 insertions(+), 17 deletions(-)
> 
> diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c
> index fc2ed19ced9b..1b416ac9c3ad 100644
> --- a/fs/btrfs/qgroup.c
> +++ b/fs/btrfs/qgroup.c
> @@ -333,6 +333,14 @@ int btrfs_verify_qgroup_counts(struct btrfs_fs_info *fs_info, u64 qgroupid,
>  }
>  #endif
>  
> +static void qgroup_mark_inconsistent(struct btrfs_fs_info *fs_info)
> +{
> +	BUILD_BUG_ON(BTRFS_QGROUP_RUNTIME_FLAG_CANCEL_RESCAN &
> +		     BTRFS_QGROUP_STATUS_FLAGS_MASK);

Please use static_assert instead of BUILD_BUG_ON

> +	fs_info->qgroup_flags |= (BTRFS_QGROUP_STATUS_FLAG_INCONSISTENT |
> +				  BTRFS_QGROUP_RUNTIME_FLAG_CANCEL_RESCAN);

There should be either a helper to drop the inconsistent flag again or
qgroup_mark_inconsistent can take a parameter to do so, there are
several instances where unsetting is open coded by the "&= ~" operation.

  reply	other threads:[~2022-09-05 17:48 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-24  1:14 [PATCH v4 0/5] btrfs: qgroup: address the performance penalty for subvolume dropping Qu Wenruo
2022-08-24  1:14 ` [PATCH v4 1/5] btrfs: sysfs: introduce qgroup global attribute groups Qu Wenruo
2022-08-24  1:14 ` [PATCH v4 2/5] btrfs: introduce BTRFS_QGROUP_STATUS_FLAGS_MASK for later expansion Qu Wenruo
2022-08-24  1:14 ` [PATCH v4 3/5] btrfs: introduce BTRFS_QGROUP_RUNTIME_FLAG_CANCEL_RESCAN Qu Wenruo
2022-09-05 17:43   ` David Sterba [this message]
2022-08-24  1:14 ` [PATCH v4 4/5] btrfs: introduce BTRFS_QGROUP_RUNTIME_FLAG_NO_ACCOUNTING to skip qgroup accounting Qu Wenruo
2022-08-24  1:14 ` [PATCH v4 5/5] btrfs: skip subtree scan if it's too high to avoid low stall in btrfs_commit_transaction() Qu Wenruo
2022-09-08 20:45 ` [PATCH v4 0/5] btrfs: qgroup: address the performance penalty for subvolume dropping 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=20220905174322.GL13489@twin.jikos.cz \
    --to=dsterba@suse.cz \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=wqu@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