zfsonlinux/zfs — Issue #570: Share NFS without working default options
Author: FransUrbo
Created: 2012-02-13 09:10:15+00:00
State: open

Trying to share a volume with NFS fails because it (zfs set sharenfs=on tank/dir) does not set default values:

server:~# zfs set sharenfs=on tank/dir
server:~# tail -n0 -f /var/log/syslog | egrep -v 'dnsmasq|sensord|slapd|smbd|CRON|nmbd|postfix'
Feb 13 09:42:55 Server mountd[13932]: authenticated mount request from 192.168.69.3:913 for /tank/dir (/tank/dir)
client:~# mount -t nfs server:/tank/dir /shares/tank
mount.nfs: access denied by server while mounting server:/tank/dir

Testing with /etc/exports instead, shows:

server:~# tail -n1 /etc/exports:
/tank/dir *(rw,root_squash)
server:~# exportfs -a
exportfs: /etc/exports [2]: Neither 'subtree_check' or 'no_subtree_check' specified for export "*:/tank/dir".
Assuming default behaviour ('no_subtree_check').
NOTE: this default has changed since nfs-utils version 1.0.x

exportfs: Warning: /tank/dir requires fsid= for NFS export
server:~# showmount -e
Export list for server:
/tank/dir *

Strange that it allowed the export considering the missing fsid '(_requires_ fsid). And adding these two, allows export without any warnings.

Testing to set this on sharenfs shows:
server:~# zfs set sharenfs="rw root_squash no_subtree_check fsid=100" tank/dir
cannot set property for 'tank/dir': 'sharenfs' cannot be set to invalid options
server:~# zfs set sharenfs="rw,root_squash,no_subtree_check,fsid=100" tank/dir
cannot set property for 'tank/dir': 'sharenfs' cannot be set to invalid options
server:~# zfs set sharenfs="rw" tank/dir
server:~# zfs set sharenfs="rw fsid=100" tank/dir
cannot set property for 'tank/dir': 'sharenfs' cannot be set to invalid options
server:~# zfs set sharenfs="rw root_squash" tank/dir
cannot set property for 'tank/dir': 'sharenfs' cannot be set to invalid options
server:~# zfs set sharenfs="rw,root_squash" tank/dir
server:~# zfs set sharenfs="rw,root_squash,no_subtree_check" tank/dir
server:~# zfs set sharenfs="rw,root_squash,no_subtree_check,fsid=100" tank/dir
cannot set property for 'tank/dir': 'sharenfs' cannot be set to invalid options

So it seems that it's the fsid option that isn't allowed. Checking the code, adding (allowing) this option to lib/libshare/nfs.c:get_linux_shareopts_cb() should hopfully work.