From: Anand Jain <anand.jain@oracle.com>
To: Nikolay Borisov <nborisov@suse.com>, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH v2 1/3] btrfs: introduce BTRFS_EXCLOP_BALANCE_PAUSED exclusive state
Date: Wed, 10 Nov 2021 16:56:41 +0800 [thread overview]
Message-ID: <6b09a082-fe67-a6da-7322-1822425e14c0@oracle.com> (raw)
In-Reply-To: <e6b4d90e-5e5a-37be-24a8-f493451a889b@suse.com>
On 9/11/21 11:33 pm, Nikolay Borisov wrote:
> <snip>
>
>>
>>> +void btrfs_exclop_pause_balance(struct btrfs_fs_info *fs_info)
>>> +{
>>> + spin_lock(&fs_info->super_lock);
>>> + ASSERT(fs_info->exclusive_operation == BTRFS_EXCLOP_BALANCE ||
>>> + fs_info->exclusive_operation == BTRFS_EXCLOP_DEV_ADD);
>>> + fs_info->exclusive_operation = BTRFS_EXCLOP_BALANCE_PAUSED;
>>> + spin_unlock(&fs_info->super_lock);
>>> +}
>>> +
>>
>> This function can be more generic and replace its open coded version
>> in a few places.
>>
>> btrfs_exclop_balance(fs_info, exclop)
>> {
>> ::
>> switch(exclop)
>> {
>> case BTRFS_EXCLOP_BALANCE_PAUSED:
>> ASSERT(fs_info->exclusive_operation ==
>> BTRFS_EXCLOP_BALANCE ||
>> fs_info->exclusive_operation ==
>> BTRFS_EXCLOP_DEV_ADD);
>> break;
>> case BTRFS_EXCLOP_BALANCE:
>> ASSERT(fs_info->exclusive_operation ==
>> BTRFS_EXCLOP_BALANCE_PAUSED);
>> break;
>> }
>> ::
>> }
>>
>>
>>> static int btrfs_ioctl_getversion(struct file *file, int __user *arg)
>>> {
>>> struct inode *inode = file_inode(file);
>>> @@ -4020,6 +4029,10 @@ static long btrfs_ioctl_balance(struct file
>>> *file, void __user *arg)
>>> if (fs_info->balance_ctl &&
>>> !test_bit(BTRFS_FS_BALANCE_RUNNING, &fs_info->flags)) {
>>
>>
>>> /* this is (3) */
>>> + spin_lock(&fs_info->super_lock);
>>> + ASSERT(fs_info->exclusive_operation ==
>>> BTRFS_EXCLOP_BALANCE_PAUSED);
>>> + fs_info->exclusive_operation = BTRFS_EXCLOP_BALANCE;
>>
>> Here you set the status to BALANCE running. Why do we do it so early
>> without even checking if the user cmd is a resume? Like a few lines
>> below?
>>
>> 4064 if (bargs->flags & BTRFS_BALANCE_RESUME) {
>>
>> I guess it is because of the legacy balance ioctl.
>>
>> 4927 case BTRFS_IOC_BALANCE:
>> 4928 return btrfs_ioctl_balance(file, NULL);
>>
>> Could you confirm?
>
>
> Actually no, I thought that just because we are in (3) (based on the
> comments) the right thing would be done. However, that's clearly not the
> case...
>
> I wonder whether putting the code under the & BALANCE_RESUME branch is
> sufficient because as you pointed out the v1 ioctl doesn't handle args
> at all. If I'm reading the code correctly balance ioctl v1 can't really
> resume balance because it will always return with :
>
> 20 if (fs_info->balance_ctl) {
>
> 19 ret = -EINPROGRESS;
>
> 18 goto out_bargs;
>
> 17 }
>
> OTOH if I put the code right before we call btrfs_balance then there's
> no way to distinguish we are starting from paused state
>
> <snip>
Yeah looks like the legacy code did not resume the balance, it supported
the pause though or may be the trick was to remount to resume the
balance?
As this part of the code is very confusing I think it is better to split
the balance v1 and v2 codes into separate functions.
next prev parent reply other threads:[~2021-11-10 8:56 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-08 14:28 [PATCH v2 0/3] x Balance vs device add fixes Nikolay Borisov
2021-11-08 14:28 ` [PATCH v2 1/3] btrfs: introduce BTRFS_EXCLOP_BALANCE_PAUSED exclusive state Nikolay Borisov
2021-11-08 14:57 ` Josef Bacik
2021-11-08 14:58 ` Nikolay Borisov
2021-11-09 11:35 ` Anand Jain
2021-11-09 15:33 ` Nikolay Borisov
2021-11-10 8:56 ` Anand Jain [this message]
2021-11-10 9:31 ` Nikolay Borisov
2021-11-11 15:00 ` David Sterba
2021-11-11 14:48 ` David Sterba
2021-11-08 14:28 ` [PATCH v2 2/3] btrfs: make device add compatible with paused balance in btrfs_exclop_start_try_lock Nikolay Borisov
2021-11-08 14:57 ` Josef Bacik
2021-11-08 14:28 ` [PATCH v2 3/3] btrfs: allow device add if balance is paused Nikolay Borisov
2021-11-08 14:58 ` Josef Bacik
2021-11-11 15:05 ` [PATCH v2 0/3] x Balance vs device add fixes 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=6b09a082-fe67-a6da-7322-1822425e14c0@oracle.com \
--to=anand.jain@oracle.com \
--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