1 .\" Copyright (c) 2009 Rick Macklem, University of Guelph
2 .\" All rights reserved.
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
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.
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
32 .Nd NFS Version 4 Protocol
34 The NFS client and server provides support for the
37 .%T "Network File System (NFS) Version 4 Protocol RFC 7530" and
38 .%T "Network File System (NFS) Version 4 Minor Version 1 Protocol RFC 5661" .
39 The protocol is somewhat similar to NFS Version 3, but differs in significant
41 It uses a single compound RPC that concatenates operations to-gether.
42 Each of these operations are similar to the RPCs of NFS Version 3.
43 The operations in the compound are performed in order, until one of
44 them fails (returns an error) and then the RPC terminates at that point.
47 integrated locking support, which implies that the server is no longer
51 server remains in recovery mode for a grace period (always greater than the
52 lease duration the server uses) after a reboot.
53 During this grace period, clients may recover state but not perform other
54 open/lock state changing operations.
55 To provide for correct recovery semantics, a small file described by
57 is used by the server during the recovery phase.
58 If this file is missing or empty, there is a backup copy maintained by
60 that will be used. If either file is missing, they will be
63 If both the file and the backup copy are empty,
64 it will result in the server starting without providing a grace period
66 Note that recovery only occurs when the server
67 machine is rebooted, not when the
71 It provides several optional features not present in NFS Version 3:
73 .Bd -literal -offset indent -compact
75 - Referrals, which redirect subtrees to other servers
77 - Delegations, which allow a client to operate on a file locally
78 - pNFS, where I/O operations are separated from Metadata operations
83 protocol does not use a separate mount protocol and assumes that the
84 server provides a single file system tree structure, rooted at the point
85 in the local file system tree specified by one or more
87 .Bd -literal -offset indent -compact
88 V4: <rootdir> [-sec=secflavors] [host(s) or net]
99 allows a limited subset of operations to be performed on non-exported subtrees
100 of the local file system, so that traversal of the tree to the exported
101 subtrees is possible.
102 As such, the ``<rootdir>'' can be in a non-exported file system.
103 The exception is ZFS, which checks exports and, as such, all ZFS file systems
104 below the ``<rootdir>'' must be exported.
106 the entire tree that is rooted at that point must be in local file systems
107 that are of types that can be NFS exported.
110 file system is rooted at ``<rootdir>'', setting this to anything other
111 than ``/'' will result in clients being required to use different mount
114 than for NFS Version 2 or 3.
115 Unlike NFS Version 2 and 3, Version 4 allows a client mount to span across
116 multiple server file systems, although not all clients are capable of doing
120 uses strings for users and groups instead of numbers.
121 On the wire, these strings can either have the numbers in the string or
124 .Bd -literal -offset indent -compact
128 where ``<dns.domain>'' is not the same as the DNS domain used
129 for host name lookups, but is usually set to the same string.
130 Most systems set this ``<dns.domain>''
131 to the domain name part of the machine's
134 However, this can normally be overridden by a command line
135 option or configuration file for the daemon used to do the name<->number
137 Under FreeBSD, the mapping daemon is called
139 and has a command line option that overrides the domain component of the
141 For use of this form of string on
143 either client or server, this daemon must be running.
145 The form where the numbers are in the strings can only be used for AUTH_SYS.
146 To configure your systems this way, the
148 daemon does not need to be running on the server, but the following sysctls need to be
149 set to 1 on the server.
151 .Bd -literal -offset indent -compact
152 vfs.nfs.enable_uidtostring
153 vfs.nfsd.enable_stringtouid
156 On the client, the sysctl
158 .Bd -literal -offset indent -compact
159 vfs.nfs.enable_uidtostring
162 must be set to 1 and the
164 daemon does not need to be running.
166 If these strings are not configured correctly, ``ls -l'' will typically
167 report a lot of ``nobody'' and ``nogroup'' ownerships.
169 Although uid/gid numbers are no longer used in the
171 protocol except optionally in the above strings, they will still be in the RPC authentication fields when
172 using AUTH_SYS (sec=sys), which is the default.
173 As such, in this case both the user/group name and number spaces must
174 be consistent between the client and server.
178 with RPCSEC_GSS (sec=krb5, krb5i, krb5p), only names and KerberosV tickets
181 To set up the NFS server that supports
183 you will need to set the variables in
187 .Bd -literal -offset indent -compact
188 nfs_server_enable="YES"
189 nfsv4_server_enable="YES"
194 .Bd -literal -offset indent -compact
195 nfsuserd_enable="YES"
198 if the server is using the ``<user>@<domain>'' form of user/group strings or
199 is using the ``-manage-gids'' option for
202 You will also need to add at least one ``V4:'' line to the
208 If the file systems you are exporting are only being accessed via
210 there are a couple of
212 variables that you can change, which might improve performance.
214 .It Cm vfs.nfsd.issue_delegations
215 when set non-zero, allows the server to issue Open Delegations to
217 These delegations permit the client to manipulate the file
218 locally on the client.
219 Unfortunately, at this time, client use of
220 delegations is limited, so performance gains may not be observed.
221 This can only be enabled when the file systems being exported to
223 clients are not being accessed locally on the server and, if being
224 accessed via NFS Version 2 or 3 clients, these clients cannot be
226 .It Cm vfs.nfsd.enable_locallocks
227 can be set to 0 to disable acquisition of local byte range locks.
228 Disabling local locking can only be done if neither local accesses
229 to the exported file systems nor the NLM is operating on them.
232 Note that Samba server access would be considered ``local access'' for the above
235 To build a kernel with the NFS server that supports
239 .Bd -literal -offset indent -compact
243 must be specified in the kernel's
249 mount, specify the ``nfsv4'' option on the
252 This will force use of the client that supports
259 must be running if name<->uid/gid mapping is being used, as above.
262 mount uses the host uuid to identify the client uniquely to the server,
263 you cannot safely do an
267 .Bd -literal -offset indent -compact
276 server that is being mounted on supports delegations, you can start the
278 daemon to handle client side callbacks.
281 .Bd -literal -offset indent -compact
282 nfsuserd_enable="YES" <-- If name<->uid/gid mapping is being used.
289 Without a functioning callback path, a server will never issue Delegations
292 For NFSv4.0, by default, the callback address will be set to the IP address acquired via
293 rtalloc() in the kernel and port# 7745.
294 To override the default port#, a command line option for
298 To get callbacks to work when behind a NAT gateway, a port for the callback
299 service will need to be set up on the NAT gateway and then the address
300 of the NAT gateway (host IP plus port#) will need to be set by assigning the
302 variable vfs.nfs.callback_addr to a string of the form:
306 where the first 4 Ns are the host IP address and the last two are the
307 port# in network byte order (all decimal #s in the range 0-255).
309 For NFSv4.1, the callback path (called a backchannel) uses the same TCP connection as the mount,
310 so none of the above applies and should work through gateways without
313 To build a kernel with the client that supports
315 linked into it, the option
317 .Bd -literal -offset indent -compact
321 must be specified in the kernel's
325 Options can be specified for the
329 daemons at boot time via the ``nfsuserd_flags'' and ``nfscbd_flags''
333 NFSv4 mount(s) against exported volume(s) on the same host are not recommended,
334 since this can result in a hung NFS server.
335 It occurs when an nfsd thread tries to do an NFSv4 VOP_RECLAIM()/Close RPC
336 as part of acquiring a new vnode.
337 If all other nfsd threads are blocked waiting for lock(s) held by this nfsd
338 thread, then there isn't an nfsd thread to service the Close RPC.
340 .Bl -tag -width /var/db/nfs-stablerestart.bak -compact
341 .It Pa /var/db/nfs-stablerestart
342 NFS V4 stable restart file
343 .It Pa /var/db/nfs-stablerestart.bak
344 backup copy of the file
347 .Xr stablerestart 5 ,
355 At this time, there is no recall of delegations for local file system
357 As such, delegations should only be enabled for file systems
358 that are being used solely as NFS export volumes and are not being accessed
359 via local system calls nor services such as Samba.