Heinrich Rebehn
2010-Aug-25 07:47 UTC
zfs sharenfs with multiple hosts/networks and options
Hi list, with traditional /etc/exports i can do /export/linux/root -ro xxx.xxx.xxx.0/24 /export/linux/root -maproot=0 xxx.xxx.xxx.1 How can i do this using zfs's sharenfs option? When i try zfs set sharenfs="-ro -network xxx.xxx.xxx.0/24,-maproot=0 xxx.xxx.xxx.1" data/linux/root /var/log/messages shows "network/host conflict" and "bad exports list line. The general problem seems to be that with each "zfs set sharenfs" command, the corresponding in /etc/zfs/exports gets overwritten. Is there a workaround for this besides ignoring sharenfs and using hand edited /etc/exports? Thanks for any help, Heinrich Rebehn University of Bremen Physics / Electrical and Electronics Engineering - Department of Telecommunications - Phone : +49/421/218-62394 Fax : -3341
On Wed, Aug 25, 2010 at 09:47:13AM +0200, Heinrich Rebehn wrote:> Hi list, > > with traditional /etc/exports i can do > > /export/linux/root -ro xxx.xxx.xxx.0/24 > /export/linux/root -maproot=0 xxx.xxx.xxx.1 > > How can i do this using zfs's sharenfs option? > > When i try > > zfs set sharenfs="-ro -network xxx.xxx.xxx.0/24,-maproot=0 xxx.xxx.xxx.1" data/linux/root > > /var/log/messages shows "network/host conflict" and "bad exports list line. > > The general problem seems to be that with each "zfs set sharenfs" command, the corresponding in /etc/zfs/exports gets overwritten. > > Is there a workaround for this besides ignoring sharenfs and using hand edited /etc/exports? > > Thanks for any help,In december '09 I started a thread about it in freebsd-fs@. Subject: zfs sharenfs to multiple subnets - found a dirty looking hack I found a dirty hack to do what you need there. Not sure there is a more elegant way to do it already, would be nice. Marco -- Now watch me snatch defeat from the jaws of victory - "Rigoletto" during a game on www.dailygammon.com
On 08/25/2010 03:47, Heinrich Rebehn wrote:> Hi list, > > with traditional /etc/exports i can do > > /export/linux/root -ro xxx.xxx.xxx.0/24 > /export/linux/root -maproot=0 xxx.xxx.xxx.1 > > How can i do this using zfs's sharenfs option? > > When i try > > zfs set sharenfs="-ro -network xxx.xxx.xxx.0/24,-maproot=0 xxx.xxx.xxx.1" data/linux/root > > /var/log/messages shows "network/host conflict" and "bad exports list line. > > The general problem seems to be that with each "zfs set sharenfs" command, the corresponding in /etc/zfs/exports gets overwritten. > > Is there a workaround for this besides ignoring sharenfs and using hand edited /etc/exports? > > Thanks for any help, >Hi Heinrich, All the sharenfs property is actually doing and maybe not exactly in this order is modifying /etc/zfs/exports with the interpreted contents of the sharenfs property and using a syntax that the native mountd(8) understands or at least tries to in a very simple way. After this is all done, mountd(8) recieves a HUP signal to inform if to reread /etc/exports & /etc/zfs/exports. So traditionally everything is happening the way it always has been except for the fact your now using the zfs(1M) Sun command with our own patch on top of that to make it look like its doing what you see in *Solaris or at least the interpreted version. Currently we do not have a/the share(1M) command implemented. My suggestion would be to write a script either in Python or Perl or maybe even in C to parse your own command line arguments and adjust /etc/exports or /etc/zfs/exports accordingly depending on the type of filesystem your arguments point to and then send signal HUP to mountd(8). This will at least be a little more under your control without having to modify sources and deal with conflicts later. I would recommend that you disable using the sharenfs property at all if you choose to go this route as you may start to find inconsistencies among your shares. The reference code where this is all happening is: cddl/compat/opensolaris/misc/fsshare.c Disable handling of the sharenfs property (ZFS_PROP_SHARENFS): cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c Personally I would love to see our version of the sharenfs version translated into something that is local to FreeBSD only like the org.freebsd:swap local property that we use to enable swap on zvol's. My theorized version of this would look a little like the following. zfs set \ org.freebsd:nfs='ro=@192.168.1.0/24,root=0; rw=@192.168.2.1,root=514' org.freebsd:nfs4='V4: ......' Where options are separated by commas and shares to different hosts or networks are separated by semicolons. But if you don't want to go through all this then you could always designate /etc/zfs/exports as a permanent share for users that are allowed to write and administered by the sharenfs property. And use /etc/exports as your extraneous read-only shares. Just a thought. Anyway! enough said. Good luck on your mission. Regards, -- jhell,v