Bug 118111 - Resizing BTRFS Volumes smaller than 256MB is not possible
Summary: Resizing BTRFS Volumes smaller than 256MB is not possible
Status: NEW
Alias: None
Product: File System
Classification: Unclassified
Component: btrfs (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: Josef Bacik
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-05-12 08:38 UTC by Kai Wagner
Modified: 2017-08-04 06:48 UTC (History)
5 users (show)

See Also:
Kernel Version: 4.6
Subsystem:
Regression: No
Bisected commit-id:


Attachments

Description Kai Wagner 2016-05-12 08:38:50 UTC
At the moment its not possible to resize a btrfs volume smaler than 256M.

Example:

Create a 100MB Volume and try to resize that volume to 200MB. Its not possible and you get the following useless error output: 

"ERROR: unable to resize '/media/test/' - Invalid argument"

The 256MB limit is hardcoded in the ioctl.c file in line 1584.

Option 1: Change this hardcoded limit 

My code fix idear:

OLD:

1584        if (new_size < SZ_256M) {
1585               ret = -EINVAL;
1586               goto out_free;
1587        }

NEW:

1584        if (new_size < old_size) {
1585               ret = -EINVAL;
1586               goto out_free;
1587        }


Option 2: Change the error message to something usefull like (Can't resize this volume because your volume is to small - minimum 256MB)
Comment 1 Cengiz Can 2016-05-22 22:13:10 UTC
Hello Kai,

Thank you for reporting this.

This has been brought to discussion in 2012 and 2014

http://comments.gmane.org/gmane.comp.file-systems.btrfs/36077
http://www.linuxquestions.org/questions/linux-general-1/minimum-partition-size-946423

I'm not 100% sure why there's a hardcoded limit but that error message needs an improvement as you stated.

I'll work on this.
Comment 2 Cengiz Can 2016-11-27 22:51:59 UTC
Hello again Kai, 

I'm quouting #btrfs on FreeNode:

"Since btrfs allocates space for data/metadata in quite large blocks (1GB is typical), these can be smaller on a small fs, but on a really small fs it involves hacks that would be tedious to undo when expanding the filesystem to an usable size, there's an assumption that a filesystem that tiny is used for a test or some other special purpose rather than for real data"

Thus, I think there're no plans to support btrfs volumes < 256MBs right now.
Comment 3 Cengiz Can 2016-11-27 22:58:28 UTC
I think we can mark this as WONTFIX
Comment 4 lakshmipathi 2017-01-08 20:55:35 UTC
(In reply to Cengiz Can from comment #3)
> I think we can mark this as WONTFIX

Cengiz Can, imo, this can be marked as 'fixed' instead of wontfix. assuming the error message is verbose now instead of "ERROR: unable to resize '/media/test/' - Invalid argument"
Comment 5 Melissa Betts 2017-04-26 08:09:28 UTC
As a first step, the virtual disk needs to be increased on the hypervisor side. Please refer to the vendor documentation for this particular task. The parted -l output above also provides the information whether a MSDOS or GPT partition label was used. fdisk -l (an example is provided in the section Resizing the partition online using fdisk) will show this information.
Once this has been accomplished, rescan the local disk:

    btrfs:~ # echo 1 > /sys/block/sda/device/rescan/ http://bagario.net
    btrfs:~ # parted -l
    Model: VMware Virtual disk (scsi)
    Disk /dev/sda: 42.9GB
    Sector size (logical/physical): 512B/512B
    Partition Table: msdos
    Disk Flags:

    Number  Start   End     Size    Type     File system     Flags
    1      1049kB  4302MB  4301MB  primary  linux-swap(v1)  type=82
    2      4302MB  21.5GB  17.2GB  primary  btrfs           boot, type=83
    btrfs:~ #
Comment 6 Cengiz Can 2017-04-26 11:31:53 UTC
(In reply to lakshmipathi from comment #4)
> (In reply to Cengiz Can from comment #3)
> > I think we can mark this as WONTFIX
> 
> Cengiz Can, imo, this can be marked as 'fixed' instead of wontfix. assuming
> the error message is verbose now instead of "ERROR: unable to resize
> '/media/test/' - Invalid argument"

Hello!

Can you point me to the new error message in source? 

http://lxr.free-electrons.com/source/fs/btrfs/ioctl.c#L1594 (4.10) seems to be still returning `-EINVAL`
Comment 7 lakshmipathi 2017-04-26 11:46:04 UTC
(In reply to Cengiz Can from comment #6)
> (In reply to lakshmipathi from comment #4)
> > (In reply to Cengiz Can from comment #3)
> > > I think we can mark this as WONTFIX
> > 
> > Cengiz Can, imo, this can be marked as 'fixed' instead of wontfix. assuming
> > the error message is verbose now instead of "ERROR: unable to resize
> > '/media/test/' - Invalid argument"
> 
> Hello!
> 
> Can you point me to the new error message in source? 
> 
> http://lxr.free-electrons.com/source/fs/btrfs/ioctl.c#L1594 (4.10) seems to
> be still returning `-EINVAL`

As I previously commented, this bug can marked as fixed (instead of marking it as wontfix) if(assuming) the error message is verbose like 'Can't resize this volume because your volume is to small - minimum 256MB' instead of "ERROR: unable to resize '/media/test/' - Invalid argument"
Comment 8 Tomasz Pala 2017-08-04 06:48:58 UTC
Or, if WONTFIX here, this (hint message) could be handled by btrfs-tools. Additionally mkfs.btrfs should tell the user creating such a small fs that it won't be expandable.

Note You need to log in before you can comment on or make changes to this bug.