btrfs-progs icon indicating copy to clipboard operation
btrfs-progs copied to clipboard

"btrfs fi resize max" fails when devid 1 is missing

Open kdave opened this issue 3 years ago • 3 comments

Clone of bug https://bugzilla.kernel.org/show_bug.cgi?id=83621

When issuing "btrfs filesystem resize max /" I get an error "error: unable to resize '/' - no such device" if the devid for the underlying partition is 2.

Fix: mention the exact devid in the command, which in my case implies changing the command to "btrfs filesystem resize 2:max /"

I assume I would not get this error on a clean situation (filesystem on one partition with devid of 1).

Reproducer steps:

$ mkfs.btrfs /dev/sda /sdb
$ mount /dev/sdb mnt
$ btrfs device delete 1 mnt
$ btrfs fi resize 2:-1G mnt
$ btrfs fi resize max mnt
ERROR: cannot find devid: 1
ERROR: unable to resize 'mnt': No such device

kdave avatar May 20 '22 14:05 kdave

Some how I think this might be related to something I was experiencing with a failed filesystem, but was due to user input and not BTRFS it self. My kernel log was showing David 1 was missing but BTRFS filesystem show was not showing david1 missing.

fixapc avatar May 21 '22 00:05 fixapc

I had the same error on a filesystem that no longer has a device with devid=1. The command always fails to resize without a devid.

btrfs filesystem resize 4:max /mnt/btrfs-raid1/
Resize device id 4 (/dev/sdd1) from 500.00GiB to max

btrfs filesystem show /mnt/btrfs-raid1/
Label: none  uuid: xx
        Total devices 3 FS bytes used 209.64GiB
        devid    3 size 500.00GiB used 192.03GiB path /dev/sdc1
        devid    4 size 12.73TiB used 195.03GiB path /dev/sdd1
        devid    5 size 14.55TiB used 39.00GiB path /dev/sde1

btrfs filesystem resize max /mnt/btrfs-raid1/
ERROR: cannot find devid: 1
ERROR: unable to resize '/mnt/btrfs-raid1/': No such device

Elfe avatar Jun 28 '22 20:06 Elfe

In manual, using resize command, if you don't provide devid, it use 1 by default.

If max is passed, the filesystem will occupy all available space on the device respecting devid (remember, devid 1 by default).

In code, it cannot pass checking resize args in userspace check_resize_args(). also same as in kernel space.

realwakka avatar Aug 03 '22 05:08 realwakka

Now implemented in devel, if the devid 1 does not exist in the filesystem and the resize string does not specify the number, then the lowest devid is used (and a warning printed). This is a slight change in behaviour and it's possible that something depends on the failure but that would be a strange case, the fallback is for user convenience.

kdave avatar Oct 25 '23 21:10 kdave