Bug 1249478

Summary: Not able to extend Btrfs file system on RHEL 7.1
Product: Red Hat Enterprise Linux 7 Reporter: Awez <awshaikh>
Component: btrfs-progsAssignee: Ric Wheeler <rwheeler>
Status: CLOSED NOTABUG QA Contact: Filesystem QE <fs-qe>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.1CC: bkunal, xuw
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-08-17 14:27:04 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Awez 2015-08-03 06:54:23 UTC
Description of problem: BTRFS filesystem is not re-sizing using the below command.

btrfs filesystem resize +350g /btrfs/

btrfs filesystem resize -350g /btrfs/

ERROR: unable to resize '/btrfs/' - File too large

But it is working as below:

btrfs filesystem resize max /btrfs/


Version-Release number of selected component (if applicable):

Kernel version: 3.10.0-229.4.2.el7.x86_64
BTRFS version: btrfs-progs-3.16.2-1.el7.x86_64


How reproducible:

extend a btrfs filesystem using the command mentioned in the description.


Steps to Reproduce:
1. Create a btrfs filesystem with lvm or without it

mkfs.btrfs /dev/vdc

Btrfs v3.16.2
See http://btrfs.wiki.kernel.org for more information.

Turning ON incompat feature 'extref': increased hardlink limit per file to 65536
fs created label (null) on /dev/vdc
	nodesize 16384 leafsize 16384 sectorsize 4096 size 350.00GiB

2. Checking btrfs filesystem information

[root@srv1-rhel7 ~]# btrfs filesystem show
Label: none  uuid: cbf6d3b8-0dc4-4424-87d2-1df38c2199a4
	Total devices 1 FS bytes used 112.00KiB
	devid    1 size 350.00GiB used 2.04GiB path /dev/vdc

Btrfs v3.16.2

3. mounting btrfs filesystem ie "/dev/vdc" on directory /btrfs/

[root@srv1-rhel7 ~]# mount /dev/vdc /btrfs/

[root@srv1-rhel7 ~]# df -h
Filesystem                        Size  Used Avail Use% Mounted on
/dev/vdc                          350G  512K  348G   1% /btrfs

---create filesystem with just one disk ie /dev/vdc---

---Now adding new disk in the current ie /dev/vdd---

4. Adding new disk to the current btrfs filesystem ie "/dev/vdd"

[root@srv1-rhel7 ~]# btrfs  device add /dev/vdd /btrfs/ 

[root@srv1-rhel7 ~]# btrfs filesystem show
Label: none  uuid: cbf6d3b8-0dc4-4424-87d2-1df38c2199a4
	Total devices 2 FS bytes used 384.00KiB
	devid    1 size 350.00GiB used 2.04GiB path /dev/vdc
	devid    2 size 350.00GiB used 0.00 path /dev/vdd

Btrfs v3.16.2

5. Resizing the filesystem with the new added free space.

[root@srv1-rhel7 ~]# btrfs filesystem resize +350g /btrfs/
Resize '/btrfs/' of '+350g'
ERROR: unable to resize '/btrfs/' - File too large

---without lvm as a base also i was getting the same error, but the below worked.

6. Resizing the filesystem by giving the "max" instead of the value "+350G"

[root@srv1-rhel7 ~]# btrfs filesystem resize max /btrfs/	<<<--- using "max" worked and this also worked using lvm
Resize '/btrfs/' of 'max'


Actual results: 

[root@srv1-rhel7 ~]# btrfs filesystem resize +350g /btrfs/
Resize '/btrfs/' of '+350g'
ERROR: unable to resize '/btrfs/' - File too large



Expected results: As per Red Hat Doc.

# btrfs filesystem resize +350g /btrfs/
Resize '/btrfs/' of '+350G'

Comment 2 XuWang 2015-08-04 08:48:58 UTC
I think that there is some misunderstanding for the "resize" cmd of btrfs.
The resize format is " resize [<devid>:]<size>[gkm]|[<devid>:]max <path>", and if no devid applied, will use the default value '1'.

From the message applied in Comment 0:
[root@srv1-rhel7 ~]# btrfs filesystem show
Label: none  uuid: cbf6d3b8-0dc4-4424-87d2-1df38c2199a4
	Total devices 2 FS bytes used 384.00KiB
	devid    1 size 350.00GiB used 2.04GiB path /dev/vdc
	devid    2 size 350.00GiB used 0.00 path /dev/vdd

device with id 1 already added into btrfs filesystem, and the size btrfs can used is 359GiB.
So when you use this cmd " btrfs filesystem resize +350g /btrfs/", the btrfs will find there is no extra 350GiB space in device 1, so will triger the -EFBIG.

btrfs filesystem resize is used for device enlarge/shrink cases. for example:

[root@hp-dl385pg8-09 ~]# btrfs fi show
Label: none  uuid: c24ca2d0-2d8a-4499-82c0-623484b4e2f2
	Total devices 1 FS bytes used 128.00KiB
	devid    1 size 1.00GiB used 138.38MiB path /dev/loop0

[root@hp-dl385pg8-09 ~]# btrfs fi resize -100M /mnt
Resize '/mnt' of '-100M'
[root@hp-dl385pg8-09 ~]# btrfs fi show
Label: none  uuid: c24ca2d0-2d8a-4499-82c0-623484b4e2f2
	Total devices 1 FS bytes used 128.00KiB
	devid    1 size 924.00MiB used 130.38MiB path /dev/loop0

[root@hp-dl385pg8-09 ~]# btrfs fi resize +100M /mnt
Resize '/mnt' of '+100M'

[root@hp-dl385pg8-09 ~]# btrfs fi show
Label: none  uuid: c24ca2d0-2d8a-4499-82c0-623484b4e2f2
	Total devices 1 FS bytes used 128.00KiB
	devid    1 size 1.00GiB used 130.38MiB path /dev/loop0

Comment 3 Awez 2015-08-17 14:27:04 UTC
As this is not a bug, so closing this and marking as "CLOSED" "NOTABUG".

Please reopen in case issue is again found.

-Regards,
Awez