NFSv4 - how to set up at FreeBSD 8.1 ?

Rick Macklem rmacklem at uoguelph.ca
Wed Jan 5 14:56:03 UTC 2011


> Yes, to access the file volumes via any version of NFS, they need to
> be exported. (I don't think it would make sense to allow access to all
> of the server's data without limitations for NFSv4?)
> 
> What is different (and makes it confusing for folks familiar with
> NFSv2,3)
> is the fact that it is a single "mount tree" for NFSv4 that has to be
> rooted
> somewhere.
> Solaris10 - always roots it at "/" but somehow works around the ZFS
> case,
> so any exported share can be mounted with the same path used
> by NFSv2,3.
> Linux - Last I looked (which was a couple of years ago), it exported a
> single volume for NFSv4 and the rest of the server's volumes
> could only be accessed via NFSv2,3. (I don't know if they've
> changed this yet?)
> 
> So, I chose to allow a little more flexibility than Solaris10 and
> allow
> /etc/exports to set the location of the "mount root". I didn't
> anticipate
> the "glitch" that ZFS introduced (where all ZFS volumes in the mount
> path
> must be exported for mount to work) because it does its own exporting.
> (Obviously, the glitch/inconsistency needs to be resolved at some
> point.)
> 
Perhaps it would help to show what goes on the wire when a mount is done.
# mount -t nfs -o nfsv4 server:/usr/home /mnt

For NFSv2,3 there will be a Mount RPC with /usr/home as the argument. This
goes directly to mountd and then mountd decides if it is ok and replies with
the file handle (FH) for /usr/home if it is.

For NFSv4, the client will do a compound RPC that looks something like this:
(The exact structure is up to the client implementor.)

PutRooFH  <-- set the position to the "root mount location" as specified by the V4: line
Lookup usr
Lookup home
GetFH     <-- return the file handle at this location

As such, there can only be one "root mount location" and at least Lookup
operations must work for all elements of the path from there to the client's
mount point. (For non-ZFS, it currently allows Lookup plus a couple of others that
some clients use during mounting to work for non-exported file systems, so that
setting "root mount location" == "/" works without exporting the entire file
server's tree.)

For all other operations, the file system must be exported just like for NFSv2,3.

Hope this helps, rick


More information about the freebsd-stable mailing list