From: David Sterba <dsterba@suse.cz>
To: xiaoshoukui <xiaoshoukui@gmail.com>
Cc: josef@toxicpanda.com, dsterba@suse.com, clm@fb.com,
linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org,
xiaoshoukui <xiaoshoukui@ruijie.com.cn>
Subject: Re: [PATCH] btrfs: fix return value when race occur between balance and cancel/pause
Date: Thu, 10 Aug 2023 14:05:01 +0200 [thread overview]
Message-ID: <20230810120501.GA2420@suse.cz> (raw)
In-Reply-To: <20230810034810.23934-1-xiaoshoukui@gmail.com>
On Wed, Aug 09, 2023 at 11:48:10PM -0400, xiaoshoukui wrote:
> Issue a pause or cancel IOCTL request after judging that there is no
> pause or cancel request on the path of __btrfs_balance to return 0,
> which will mislead the user that the pause or cancel requests are
> successful.In fact, the balance request has not been paused or canceled.
>
> On that race condition, a non-zero errno should be returned to the user.
>
> Signed-off-by: xiaoshoukui <xiaoshoukui@ruijie.com.cn>
> ---
> fs/btrfs/fs.h | 6 ++++++
> fs/btrfs/volumes.c | 14 +++++++++-----
> 2 files changed, 15 insertions(+), 5 deletions(-)
>
> diff --git a/fs/btrfs/fs.h b/fs/btrfs/fs.h
> index 203d2a267828..c27def881922 100644
> --- a/fs/btrfs/fs.h
> +++ b/fs/btrfs/fs.h
> @@ -93,6 +93,12 @@ enum {
> */
> BTRFS_FS_BALANCE_RUNNING,
>
> + /* Indicate that balance has been paused. */
> + BTRFS_FS_BALANCE_PAUSED,
> +
> + /* Indicate that balance has been canceled. */
> + BTRFS_FS_BALANCE_CANCELED,
I don't like that the status is tracked in several bits like that, in
addition to the already complicated locking and state transitions of
restarted balance. I think this is a hint that some things can be
simplified or combined together, though it could be difficult
next prev parent reply other threads:[~2023-08-10 12:11 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-10 3:48 [PATCH] btrfs: fix return value when race occur between balance and cancel/pause xiaoshoukui
2023-08-10 12:05 ` David Sterba [this message]
2023-08-11 2:35 ` xiaoshoukui
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=20230810120501.GA2420@suse.cz \
--to=dsterba@suse.cz \
--cc=clm@fb.com \
--cc=dsterba@suse.com \
--cc=josef@toxicpanda.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=xiaoshoukui@gmail.com \
--cc=xiaoshoukui@ruijie.com.cn \
/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).