All of lore.kernel.org
 help / color / mirror / Atom feed
From: Qu Wenruo <quwenruo.btrfs@gmx.com>
To: Anand Jain <anand.jain@oracle.com>, Qu Wenruo <wqu@suse.com>,
	linux-btrfs@vger.kernel.org
Cc: Nathan Dehnel <ncdehnel@gmail.com>
Subject: Re: [PATCH] btrfs: resize: Allow user to shrink missing device
Date: Mon, 18 Nov 2019 20:02:37 +0800	[thread overview]
Message-ID: <a7dedb8c-f80c-8abb-8332-cbbc681e7a49@gmx.com> (raw)
In-Reply-To: <18e6af7c-a9b0-9a9d-f91b-ade078c6b2c1@oracle.com>


[-- Attachment #1.1: Type: text/plain, Size: 4228 bytes --]



On 2019/11/18 下午7:38, Anand Jain wrote:
> On 18/11/19 3:05 PM, Qu Wenruo wrote:
>> One user reported an use case where one device can't be replaced due to
>> tiny device size difference.
>>
>> Since it's a RAID10 fs, if we go regular "remove missing" it can take a
>> long time and even not be possible due to lack of space.
>>
>> So here we work around this situation by allowing user to shrink missing
>> device.
>> Then user can go shrink the device first, then replace it.
> 
> 
>  Why not introduce --resize option in the replace command.
>  Which shall allow replace command to resize the source-device
>  to the size of the replace target-device.

Nope, it won't work for degraded mount.

That's the root problem the patch is going to solve.

Thanks,
Qu

> 
> Thanks, Anand
> 
>> Reported-by: Nathan Dehnel <ncdehnel@gmail.com>
>> Signed-off-by: Qu Wenruo <wqu@suse.com>
>> ---
>>   fs/btrfs/ioctl.c | 29 +++++++++++++++++++++++++----
>>   1 file changed, 25 insertions(+), 4 deletions(-)
>>
>> diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
>> index de730e56d3f5..ebd2f40aca6f 100644
>> --- a/fs/btrfs/ioctl.c
>> +++ b/fs/btrfs/ioctl.c
>> @@ -1604,6 +1604,7 @@ static noinline int btrfs_ioctl_resize(struct
>> file *file,
>>       char *sizestr;
>>       char *retptr;
>>       char *devstr = NULL;
>> +    bool missing;
>>       int ret = 0;
>>       int mod = 0;
>>   @@ -1651,7 +1652,10 @@ static noinline int btrfs_ioctl_resize(struct
>> file *file,
>>           goto out_free;
>>       }
>>   -    if (!test_bit(BTRFS_DEV_STATE_WRITEABLE, &device->dev_state)) {
>> +
>> +    missing = test_bit(BTRFS_DEV_STATE_MISSING, &device->dev_state);
>> +    if (!test_bit(BTRFS_DEV_STATE_WRITEABLE, &device->dev_state) &&
>> +        !missing) {
>>           btrfs_info(fs_info,
>>                  "resizer unable to apply on readonly device %llu",
>>                  devid);
>> @@ -1659,13 +1663,24 @@ static noinline int btrfs_ioctl_resize(struct
>> file *file,
>>           goto out_free;
>>       }
>>   -    if (!strcmp(sizestr, "max"))
>> +    if (!strcmp(sizestr, "max")) {
>> +        if (missing) {
>> +            btrfs_info(fs_info,
>> +                "'max' can't be used for missing device %llu",
>> +                   devid);
>> +            ret = -EPERM;
>> +            goto out_free;
>> +        }
>>           new_size = device->bdev->bd_inode->i_size;
>> -    else {
>> +    } else {
>>           if (sizestr[0] == '-') {
>>               mod = -1;
>>               sizestr++;
>>           } else if (sizestr[0] == '+') {
>> +            if (missing)
>> +                btrfs_info(fs_info,
>> +                "'+size' can't be used for missing device %llu",
>> +                       devid);
>>               mod = 1;
>>               sizestr++;
>>           }
>> @@ -1694,6 +1709,12 @@ static noinline int btrfs_ioctl_resize(struct
>> file *file,
>>               ret = -ERANGE;
>>               goto out_free;
>>           }
>> +        if (missing) {
>> +            ret = -EINVAL;
>> +            btrfs_info(fs_info,
>> +            "can not increase device size for missing device %llu",
>> +                   devid);
>> +        }
>>           new_size = old_size + new_size;
>>       }
>>   @@ -1701,7 +1722,7 @@ static noinline int btrfs_ioctl_resize(struct
>> file *file,
>>           ret = -EINVAL;
>>           goto out_free;
>>       }
>> -    if (new_size > device->bdev->bd_inode->i_size) {
>> +    if (!missing && new_size > device->bdev->bd_inode->i_size) {
>>           ret = -EFBIG;
>>           goto out_free;
>>       }
>>
> 


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  reply	other threads:[~2019-11-18 12:04 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-18  7:05 [PATCH] btrfs: resize: Allow user to shrink missing device Qu Wenruo
2019-11-18 11:38 ` Anand Jain
2019-11-18 12:02   ` Qu Wenruo [this message]
2019-11-19  7:40     ` Anand Jain
2019-11-19  7:54       ` Qu Wenruo
2019-11-19  8:03         ` Qu Wenruo
2019-11-19 14:34       ` David Sterba
2019-11-20  5:52         ` Anand Jain

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=a7dedb8c-f80c-8abb-8332-cbbc681e7a49@gmx.com \
    --to=quwenruo.btrfs@gmx.com \
    --cc=anand.jain@oracle.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=ncdehnel@gmail.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.