Bug 271692 - zfs inherit always behaves as if the -S flag was given
Summary: zfs inherit always behaves as if the -S flag was given
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 12.4-RELEASE
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-fs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-05-28 10:57 UTC by Martin Birgmeier
Modified: 2023-07-29 03:20 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Birgmeier 2023-05-28 10:57:09 UTC
Scenario:
- FreeBSD 12.4 latest patches
- The following commands have been issued:

[0]# zfs get canmount coconut.3/12/usr/local.OLD
NAME                        PROPERTY  VALUE     SOURCE
coconut.3/12/usr/local.OLD  canmount  off       local
[0]# zfs get mountpoint coconut.3/12/usr/local.OLD
NAME                        PROPERTY    VALUE           SOURCE
coconut.3/12/usr/local.OLD  mountpoint  /usr/local.OLD  local
[0]# zfs inherit mountpoint coconut.3/12/usr/local.OLD
[0]# zfs get mountpoint coconut.3/12/usr/local.OLD    
NAME                        PROPERTY    VALUE       SOURCE
coconut.3/12/usr/local.OLD  mountpoint  /usr/local  received
[0]# zfs inherit mountpoint coconut.3/12/usr/local.OLD
[0]# zfs get mountpoint coconut.3/12/usr/local.OLD    
NAME                        PROPERTY    VALUE       SOURCE
coconut.3/12/usr/local.OLD  mountpoint  /usr/local  received
[0]# zfs set mountpoint=/usr/local.OLD coconut.3/12/usr/local.OLD
[0]# zfs get mountpoint coconut.3/12/usr/local.OLD               
NAME                        PROPERTY    VALUE           SOURCE
coconut.3/12/usr/local.OLD  mountpoint  /usr/local.OLD  local
[0]# zfs inherit mountpoint coconut.3/12/usr/local.OLD           
[0]# zfs get mountpoint coconut.3/12/usr/local.OLD    
NAME                        PROPERTY    VALUE       SOURCE
coconut.3/12/usr/local.OLD  mountpoint  /usr/local  received
[0]# zfs inherit -S mountpoint coconut.3/12/usr/local.OLD
[0]# zfs get mountpoint coconut.3/12/usr/local.OLD       
NAME                        PROPERTY    VALUE       SOURCE
coconut.3/12/usr/local.OLD  mountpoint  /usr/local  received
[0]# zfs set mountpoint=/usr/local.OLD coconut.3/12/usr/local.OLD
[0]# zfs get mountpoint coconut.3/12/usr/local.OLD               
NAME                        PROPERTY    VALUE           SOURCE
coconut.3/12/usr/local.OLD  mountpoint  /usr/local.OLD  local
[0]# zfs get mountpoint coconut.3/12/usr          
NAME              PROPERTY    VALUE       SOURCE
coconut.3/12/usr  mountpoint  /usr        inherited from coconut.3/12
[0]# 

Result (see the scenario above):
- The mountpoint of coconut.3/12/usr/local.OLD is never set to its inherited default of /usr/local.OLD, even if no -S flag is given to the "zfs inherit" command. In fact, "zfs inherit" behaves as if the -S flag is always specified.

Expected result:
- After "zfs inherit mountpoint coconut.3/12/usr/local.OLD", the mountpoint should be set to the parent's mountpoint plus the filesystem name, in this case to /usr/local.OLD.

See also https://forums.freebsd.org/threads/zfs-inherit-mountpoint-after-zfs-rename-not-working.59965/ where the second post describes exactly the same issue.

-- Martin
Comment 1 Martin Birgmeier 2023-05-29 08:24:01 UTC
One more observation: Before I reproduced the commands shown in this PR, I had already tried various combinations of "zfs inherit mountpoint", "zfs set mountpoint", and also "zfs rename". On one such occasion after a "zfs rename" and "zfs set mountpoint", the mountpoint shown after "zfs inherit mountpoint" reverted back to the value it should have had before the "zfs rename" had been issued. Then, after another back-to-back "zfs inherit", it reverted back to the "received" value as shown in the PR.

It "feels" as if some string handling is buggy.

-- Martin