[Bug 237392] growfs : operation not permitted

From: <bugzilla-noreply_at_freebsd.org>
Date: Sat, 20 Aug 2022 23:52:14 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=237392

tofig@freebsd.az changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |tofig@freebsd.az

--- Comment #2 from tofig@freebsd.az ---
This issue is still present on RELEASE-13.1 with the following uname -a output:

FreeBSD parent 13.1-RELEASE FreeBSD 13.1-RELEASE
releng/13.1-n250148-fc952ac2212 GENERIC arm64


I've done some bug triaging and hopefully it helps to fix it.

Growfs calls dev_to_statfs() to find out the mountpoint on which the device is
currently mounted. This is the listing for dev_to_statfs:

https://github.com/freebsd/freebsd-src/blob/main/sbin/growfs/growfs.c#L1437

Inside dev_to_statfs(), getmntinfo() returns the list of all active mounts
along with the information for each of them. /dev/vtbd0p4 is likely not in the
list of mounted devices; instead /dev/gpt/rootfs is. Therefore dev_to_statfs()
is not able to find the mountpoint under which /dev/vtbd0p4 is mounted, and
hence returns NULL.

Later on, there is a check for the return value from dev_to_statfs():

https://github.com/freebsd/freebsd-src/blob/main/sbin/growfs/growfs.c#L1576

This check is to differentiate for 2 separate cases: 1) device is mounted and
2) device is not mounted. In your case, though the device is mounted (but under
a different name) the second case is taken and we attempt to open the device
directly:

fso = open(device, O_WRONLY);

This operation fails with the error that you were seeing in your test.

If getmntinfo() was able to detect that your device /dev/vtbd0p4 was mounted
under a different name (likely / ?), then the ufs-suspend mechanism would be
used and that would possibly work just fine. 

I am not quite sure how dev_to_statfs() is supposed to derive the information
about /dev/vtbd0p4 being mounted using a different device name like
/dev/gpt/rootfs.

-- 
You are receiving this mail because:
You are the assignee for the bug.