Description
System information
Type | Version/Name |
---|---|
Distribution Name | Buildroot |
Distribution Version | 2023.02.5 |
Kernel Version | 6.1 |
Architecture | amd64 |
OpenZFS Version | 2.2.0 |
Describe the problem you're observing
Using zpool create ... -O sharesmb=off -O sharenfs=off ...
fails now with 2.2.0 with an error saying:
'sharesmb' cannot be set while dataset 'zoned' property is set
despite not having even set zoned
in my zpool create
command. I don't have a complicated setup -- I'm not using zones, namespaces, or even multiple datasets, just a single "global" zfs.
After some digging into what causes this error message, it seems zfs thinks I'm trying to create a filesystem in a non-global zone (even when trying again and explicitly passing -O zoned=off
to my zpool create
).
I then found in the original PR that added this zone support that it's implicitly requiring CONFIG_USER_NS
to be enabled in the kernel. If it's not enabled, then getzoneid()
will return 0
. When the callers of this function then compare the result to the GLOBAL_ZONEID
, which is a non-zero value, it will always assume we're not dealing with the global zone, which then causes the aforementioned error.
It seems like the easy fix (although perhaps not robust as I'm not familiar with namespaces) would be to check if /proc/self/ns/user
exists and if it doesn't, just return GLOBAL_ZONEID
. Perhaps it may be enough to tweak the existing code such that if readlink() < 0
, check for errno == ENOENT
and in that case return GLOBAL_ZONEID
.
Describe how to reproduce the problem
Try to create a zpool with -O sharesmb=off -O sharenfs=off
with zfs 2.2.0.