1.\" Copyright (c) 2009 Rick Macklem, University of Guelph 2.\" All rights reserved. 3.\" 4.\" Redistribution and use in source and binary forms, with or without 5.\" modification, are permitted provided that the following conditions 6.\" are met: 7.\" 1. Redistributions of source code must retain the above copyright 8.\" notice, this list of conditions and the following disclaimer. 9.\" 2. Redistributions in binary form must reproduce the above copyright 10.\" notice, this list of conditions and the following disclaimer in the 11.\" documentation and/or other materials provided with the distribution. 12.\" 13.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 14.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 16.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 19.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23.\" SUCH DAMAGE. 24.\" 25.\" $FreeBSD$ 26.\" 27.Dd April 10, 2011 28.Dt NFSV4 4 29.Os 30.Sh NAME 31.Nm NFSv4 32.Nd NFS Version 4 Protocol 33.Sh DESCRIPTION 34The experimental NFS client and server provides support for the 35.Tn NFSv4 36specification; see 37.%T "Network File System (NFS) Version 4 Protocol RFC 3530" . 38The protocol is somewhat similar to NFS Version 3, but differs in significant 39ways. 40It uses a single compound RPC that concatenates operations to-gether. 41Each of these operations are similar to the RPCs of NFS Version 3. 42The operations in the compound are performed in order, until one of 43them fails (returns an error) and then the RPC terminates at that point. 44.Pp 45It has 46integrated locking support, which implies that the server is no longer 47stateless. 48As such, the 49.Nm 50server remains in recovery mode for a grace period (always greater than the 51lease duration the server uses) after a reboot. 52During this grace period, clients may recover state but not perform other 53open/lock state changing operations. 54To provide for correct recovery semantics, a small file described by 55.Xr stablerestart 5 56is used by the server during the recovery phase. 57If this file is missing or empty, there is a backup copy maintained by 58.Xr nfsd 8 59that will be used. If either file is missing, they will be 60created by the 61.Xr nfsd 8 . 62If both the file and the backup copy are empty, 63it will result in the server starting without providing a grace period 64for recovery. 65Note that recovery only occurs when the server 66machine is rebooted, not when the 67.Xr nfsd 8 68are just restarted. 69.Pp 70It provides several optional features not present in NFS Version 3: 71.sp 72.Bd -literal -offset indent -compact 73- NFS Version 4 ACLs 74- Referrals, which redirect subtrees to other servers 75 (not yet implemented) 76- Delegations, which allow a client to operate on a file locally 77.Ed 78.Pp 79The 80.Nm 81protocol does not use a separate mount protocol and assumes that the 82server provides a single file system tree structure, rooted at the point 83in the local file system tree specified by one or more 84.sp 1 85.Bd -literal -offset indent -compact 86V4: <rootdir> [-sec=secflavors] [host(s) or net] 87.Ed 88.sp 1 89line(s) in the 90.Xr exports 5 91file. 92(See 93.Xr exports 5 94for details.) 95The 96.Xr nfsd 8 97allows a limited subset of operations to be performed on non-exported subtrees 98of the local file system, so that traversal of the tree to the exported 99subtrees is possible. 100As such, the ``<rootdir>'' can be in a non-exported file system. 101However, 102the entire tree that is rooted at that point must be in local file systems 103that are of types that can be NFS exported. 104Since the 105.Nm 106file system is rooted at ``<rootdir>'', setting this to anything other 107than ``/'' will result in clients being required to use different mount 108paths for 109.Nm 110than for NFS Version 2 or 3. 111Unlike NFS Version 2 and 3, Version 4 allows a client mount to span across 112multiple server file systems, although not all clients are capable of doing 113this. 114.Pp 115.Nm 116uses names for users and groups instead of numbers. 117On the wire, they 118take the form: 119.sp 120.Bd -literal -offset indent -compact 121<user>@<dns.domain> 122.Ed 123.sp 124where ``<dns.domain>'' is not the same as the DNS domain used 125for host name lookups, but is usually set to the same string. 126Most systems set this ``<dns.domain>'' 127to the domain name part of the machine's 128.Xr hostname 1 129by default. 130However, this can normally be overridden by a command line 131option or configuration file for the daemon used to do the name<->number 132mapping. 133Under FreeBSD, the mapping daemon is called 134.Xr nfsuserd 8 135and has a command line option that overrides the domain component of the 136machine's hostname. 137For use of 138.Nm , 139either client or server, this daemon must be running. 140If this ``<dns.domain>'' is not set correctly or the daemon is not running, ``ls -l'' will typically 141report a lot of ``nobody'' and ``nogroup'' ownerships. 142.Pp 143Although uid/gid numbers are no longer used in the 144.Nm 145protocol, they will still be in the RPC authentication fields when 146using AUTH_SYS (sec=sys), which is the default. 147As such, in this case both the user/group name and number spaces must 148be consistent between the client and server. 149.Pp 150However, if you run 151.Nm 152with RPCSEC_GSS (sec=krb5, krb5i, krb5p), only names and KerberosV tickets 153will go on the wire. 154.Sh SERVER SETUP 155.Pp 156To set up the experimental NFS server that supports 157.Nm , 158you will need to either build a kernel with: 159.sp 160.Bd -literal -offset indent -compact 161options NFSD 162.Ed 163and not 164.Bd -literal -offset indent -compact 165options NFSSERVER 166.Ed 167.sp 168or start 169.Xr mountd 8 170and 171.Xr nfsd 8 172with the ``-e'' option to force use of the experimental server. 173The 174.Xr nfsuserd 8 175daemon must also be running. 176This will occur if 177.sp 178.Bd -literal -offset indent -compact 179nfs_server_enable="YES" 180nfsv4_server_enable="YES" 181nfsuserd_enable="YES" 182.Ed 183.sp 184are set in 185.Xr rc.conf 5 . 186.Pp 187You will also need to add at least one ``V4:'' line to the 188.Xr exports 5 189file for 190.Nm 191to work. 192.Pp 193If the file systems you are exporting are only being accessed via 194.Nm 195there are a couple of 196.Xr sysctl 8 197variables that you can change, which might improve performance. 198.Bl -tag -width Ds 199.It Cm vfs.newnfs.issue_delegations 200when set non-zero, allows the server to issue Open Delegations to 201clients. 202These delegations permit the client to manipulate the file 203locally on the client. 204Unfortunately, at this time, client use of 205delegations is limited, so performance gains may not be observed. 206This can only be enabled when the file systems being exported to 207.Nm 208clients are not being accessed locally on the server and, if being 209accessed via NFS Version 2 or 3 clients, these clients cannot be 210using the NLM. 211.It Cm vfs.newnfs.enable_locallocks 212can be set to 0 to disable acquisition of local byte range locks. 213Disabling local locking can only be done if neither local accesses 214to the exported file systems nor the NLM is operating on them. 215.El 216.sp 217Note that Samba server access would be considered ``local access'' for the above 218discussion. 219.Pp 220To build a kernel with the experimental 221.Nm 222linked into it, the 223.sp 224.Bd -literal -offset indent -compact 225options NFSD 226.Ed 227.sp 228must be specified in the kernel's 229.Xr config 5 230file. 231.Sh CLIENT MOUNTS 232.Pp 233To do an 234.Nm 235mount, specify the ``nfsv4'' option on the 236.Xr mount_nfs 8 237command line. 238This will force use of the experimental client plus set ``tcp'' and 239.Nm . 240.Pp 241The 242.Xr nfsuserd 8 243must be running, as above. 244If the 245.Nm 246server that is being mounted on supports delegations, you can start the 247.Xr nfscbd 8 248daemon to handle client side callbacks. 249This will occur if 250.sp 251.Bd -literal -offset indent -compact 252nfsuserd_enable="YES" 253nfscbd_enable="YES" 254.Ed 255.sp 256are set in 257.Xr rc.conf 5 . 258.sp 259Without a functioning callback path, a server will never issue Delegations 260to a client. 261.sp 262By default, the callback address will be set to the IP address acquired via 263rtalloc() in the kernel and port# 7745. 264To override the default port#, a command line option for 265.Xr nfscbd 8 266can be used. 267.sp 268To get callbacks to work when behind a NAT gateway, a port for the callback 269service will need to be set up on the NAT gateway and then the address 270of the NAT gateway (host IP plus port#) will need to be set by assigning the 271.Xr sysctl 8 272variable vfs.newnfs.callback_addr to a string of the form: 273.sp 274N.N.N.N.N.N 275.sp 276where the first 4 Ns are the host IP address and the last two are the 277port# in network byte order (all decimal #s in the range 0-255). 278.Pp 279To build a kernel with the experimental 280.Nm 281client linked into it, the option 282.sp 283.Bd -literal -offset indent -compact 284options NFSCL 285.Ed 286.sp 287must be specified in the kernel's 288.Xr config 5 289file. 290.Pp 291Options can be specified for the 292.Xr nfsuserd 8 293and 294.Xr nfscbd 8 295daemons at boot time via the ``nfsuserd_flags'' and ``nfscbd_flags'' 296.Xr rc.conf 5 297variables. 298.Sh FILES 299.Bl -tag -width /var/db/nfs-stablerestart.bak -compact 300.It Pa /var/db/nfs-stablerestart 301NFS V4 stable restart file 302.It Pa /var/db/nfs-stablerestart.bak 303backup copy of the file 304.El 305.Sh SEE ALSO 306.Xr stablerestart 5 , 307.Xr mountd 8 , 308.Xr nfscbd 8 , 309.Xr nfsd 8 , 310.Xr nfsdumpstate 8 , 311.Xr nfsrevoke 8 , 312.Xr nfsuserd 8 , 313.Sh BUGS 314At this time, there is no recall of delegations for local file system 315operations. 316As such, delegations should only be enabled for file systems 317that are being used solely as NFS export volumes and are not being accessed 318via local system calls nor services such as Samba. 319