From: David Sterba <dsterba@suse.cz>
To: xiaoshoukui <xiaoshoukui@gmail.com>
Cc: clm@fb.com, josef@toxicpanda.com, dsterba@suse.com,
linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org,
xiaoshoukui <xiaoshoukui@ruijie.com.cn>
Subject: Re: [PATCH] btrfs: fix balance_ctl not free properly in btrfs_balance
Date: Fri, 14 Jul 2023 12:01:44 +0200 [thread overview]
Message-ID: <20230714100143.GE20457@suse.cz> (raw)
In-Reply-To: <20230714071548.45825-1-xiaoshoukui@gmail.com>
On Fri, Jul 14, 2023 at 03:15:48AM -0400, xiaoshoukui wrote:
> Signed-off-by: xiaoshoukui <xiaoshoukui@ruijie.com.cn>
> ---
> fs/btrfs/volumes.c | 10 +---------
> 1 file changed, 1 insertion(+), 9 deletions(-)
>
> diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
> index 7823168c08a6..c1ab94d8694c 100644
> --- a/fs/btrfs/volumes.c
> +++ b/fs/btrfs/volumes.c
> @@ -4055,14 +4055,6 @@ static int alloc_profile_is_valid(u64 flags, int extended)
> return has_single_bit_set(flags);
> }
>
> -static inline int balance_need_close(struct btrfs_fs_info *fs_info)
> -{
> - /* cancel requested || normal exit path */
> - return atomic_read(&fs_info->balance_cancel_req) ||
> - (atomic_read(&fs_info->balance_pause_req) == 0 &&
> - atomic_read(&fs_info->balance_cancel_req) == 0);
> -}
> -
> /*
> * Validate target profile against allowed profiles and return true if it's OK.
> * Otherwise print the error message and return false.
> @@ -4411,7 +4403,7 @@ int btrfs_balance(struct btrfs_fs_info *fs_info,
> }
>
> if ((ret && ret != -ECANCELED && ret != -ENOSPC) ||
> - balance_need_close(fs_info)) {
> + ret == -ECANCELED || ret == 0) {
> reset_balance_state(fs_info);
> btrfs_exclop_finish(fs_info);
This is a similar patch to what Josef sent but not exactly the same,
https://lore.kernel.org/linux-btrfs/9cdf58c2f045863e98a52d7f9d5102ba12b87f07.1687496547.git.josef@toxicpanda.com/
Both remove balance_need_close but your version does not track the
paused state. I haven't analyzed it closer, but it looks like you're
missing some case. Josef's fix simplifies the error handling so we don't
have te enumerate the errors.
As you have a reproducer, can you please try it with this patch instead?
It's possible that there are still some unhandled states so it would be
good to check. Thanks.
next prev parent reply other threads:[~2023-07-14 10:08 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-14 7:15 [PATCH] btrfs: fix balance_ctl not free properly in btrfs_balance xiaoshoukui
2023-07-14 10:01 ` David Sterba [this message]
2023-07-26 3:06 ` 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=20230714100143.GE20457@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).