]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - usr.sbin/nfsd/nfsv4.4
nfsv4(4): Fix a few issues reported by mandoc
[FreeBSD/FreeBSD.git] / usr.sbin / nfsd / nfsv4.4
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 December 20, 2019
28 .Dt NFSV4 4
29 .Os
30 .Sh NAME
31 .Nm NFSv4
32 .Nd NFS Version 4 Protocol
33 .Sh DESCRIPTION
34 The NFS client and server provides support for the
35 .Tn NFSv4
36 specification; see
37 .%T "Network File System (NFS) Version 4 Protocol RFC 7530" ,
38 .%T "Network File System (NFS) Version 4 Minor Version 1 Protocol RFC 5661" ,
39 .%T "Network File System (NFS) Version 4 Minor Version 2 Protocol RFC 7862" ,
40 .%T "File System Extended Attributes in NFSv4 RFC 8276" and
41 .%T "Parallel NFS (pNFS) Flexible File Layout RFC 8435" .
42 The protocol is somewhat similar to NFS Version 3, but differs in significant
43 ways.
44 It uses a single compound RPC that concatenates operations to-gether.
45 Each of these operations are similar to the RPCs of NFS Version 3.
46 The operations in the compound are performed in order, until one of
47 them fails (returns an error) and then the RPC terminates at that point.
48 .Pp
49 It has
50 integrated locking support, which implies that the server is no longer
51 stateless.
52 As such, the
53 .Nm
54 server remains in recovery mode for a grace period (always greater than the
55 lease duration the server uses) after a reboot.
56 During this grace period, clients may recover state but not perform other
57 open/lock state changing operations.
58 To provide for correct recovery semantics, a small file described by
59 .Xr stablerestart 5
60 is used by the server during the recovery phase.
61 If this file is missing or empty, there is a backup copy maintained by
62 .Xr nfsd 8
63 that will be used.
64 If either file is missing, they will be created by the
65 .Xr nfsd 8 .
66 If both the file and the backup copy are empty,
67 it will result in the server starting without providing a grace period
68 for recovery.
69 Note that recovery only occurs when the server
70 machine is rebooted, not when the
71 .Xr nfsd 8
72 are just restarted.
73 .Pp
74 It provides several optional features not present in NFS Version 3:
75 .sp
76 .Bd -literal -offset indent -compact
77 - NFS Version 4 ACLs
78 - Referrals, which redirect subtrees to other servers
79   (not yet implemented)
80 - Delegations, which allow a client to operate on a file locally
81 - pNFS, where I/O operations are separated from Metadata operations
82 And for NFSv4.2 only
83 - User namespace extended attributes
84 - lseek(SEEK_DATA/SEEK_HOLE)
85 - File copying done locally on the server for copy_file_range(2)
86 - posix_fallocate(2)
87 - posix_fadvise(POSIX_FADV_WILLNEED/POSIX_FADV_DONTNEED)
88 .Ed
89 .Pp
90 The
91 .Nm
92 protocol does not use a separate mount protocol and assumes that the
93 server provides a single file system tree structure, rooted at the point
94 in the local file system tree specified by one or more
95 .sp 1
96 .Bd -literal -offset indent -compact
97 V4: <rootdir> [-sec=secflavors] [host(s) or net]
98 .Ed
99 .sp 1
100 line(s) in the
101 .Xr exports 5
102 file.
103 (See
104 .Xr exports 5
105 for details.)
106 The
107 .Xr nfsd 8
108 allows a limited subset of operations to be performed on non-exported subtrees
109 of the local file system, so that traversal of the tree to the exported
110 subtrees is possible.
111 As such, the ``<rootdir>'' can be in a non-exported file system.
112 The exception is ZFS, which checks exports and, as such, all ZFS file systems
113 below the ``<rootdir>'' must be exported.
114 However,
115 the entire tree that is rooted at that point must be in local file systems
116 that are of types that can be NFS exported.
117 Since the
118 .Nm
119 file system is rooted at ``<rootdir>'', setting this to anything other
120 than ``/'' will result in clients being required to use different mount
121 paths for
122 .Nm
123 than for NFS Version 2 or 3.
124 Unlike NFS Version 2 and 3, Version 4 allows a client mount to span across
125 multiple server file systems, although not all clients are capable of doing
126 this.
127 .Pp
128 .Nm
129 uses strings for users and groups instead of numbers.
130 On the wire, these strings can either have the numbers in the string or
131 take the form:
132 .sp
133 .Bd -literal -offset indent -compact
134 <user>@<dns.domain>
135 .Ed
136 .sp
137 where ``<dns.domain>'' is not the same as the DNS domain used
138 for host name lookups, but is usually set to the same string.
139 Most systems set this ``<dns.domain>''
140 to the domain name part of the machine's
141 .Xr hostname 1
142 by default.
143 However, this can normally be overridden by a command line
144 option or configuration file for the daemon used to do the name<->number
145 mapping.
146 Under FreeBSD, the mapping daemon is called
147 .Xr nfsuserd 8
148 and has a command line option that overrides the domain component of the
149 machine's hostname.
150 For use of this form of string on
151 .Nm ,
152 either client or server, this daemon must be running.
153 .Pp
154 The form where the numbers are in the strings can only be used for AUTH_SYS.
155 To configure your systems this way, the
156 .Xr nfsuserd 8
157 daemon does not need to be running on the server, but the following sysctls need to be
158 set to 1 on the server.
159 .sp
160 .Bd -literal -offset indent -compact
161 vfs.nfs.enable_uidtostring
162 vfs.nfsd.enable_stringtouid
163 .Ed
164 .sp
165 On the client, the sysctl
166 .sp
167 .Bd -literal -offset indent -compact
168 vfs.nfs.enable_uidtostring
169 .Ed
170 .sp
171 must be set to 1 and the
172 .Xr nfsuserd 8
173 daemon does not need to be running.
174 .Pp
175 If these strings are not configured correctly, ``ls -l'' will typically
176 report a lot of ``nobody'' and ``nogroup'' ownerships.
177 .Pp
178 Although uid/gid numbers are no longer used in the
179 .Nm
180 protocol except optionally in the above strings, they will still be in the RPC authentication fields when
181 using AUTH_SYS (sec=sys), which is the default.
182 As such, in this case both the user/group name and number spaces must
183 be consistent between the client and server.
184 .Pp
185 However, if you run
186 .Nm
187 with RPCSEC_GSS (sec=krb5, krb5i, krb5p), only names and KerberosV tickets
188 will go on the wire.
189 .Sh SERVER SETUP
190 To set up the NFS server that supports
191 .Nm ,
192 you will need to set the variables in
193 .Xr rc.conf 5
194 as follows:
195 .sp
196 .Bd -literal -offset indent -compact
197 nfs_server_enable="YES"
198 nfsv4_server_enable="YES"
199 .Ed
200 .sp
201 plus
202 .sp
203 .Bd -literal -offset indent -compact
204 nfsuserd_enable="YES"
205 .Ed
206 .sp
207 if the server is using the ``<user>@<domain>'' form of user/group strings or
208 is using the ``-manage-gids'' option for
209 .Xr nfsuserd 8 .
210 .Pp
211 You will also need to add at least one ``V4:'' line to the
212 .Xr exports 5
213 file for
214 .Nm
215 to work.
216 .Pp
217 If the file systems you are exporting are only being accessed via
218 .Nm
219 there are a couple of
220 .Xr sysctl 8
221 variables that you can change, which might improve performance.
222 .Bl -tag -width Ds
223 .It Cm vfs.nfsd.issue_delegations
224 when set non-zero, allows the server to issue Open Delegations to
225 clients.
226 These delegations permit the client to manipulate the file
227 locally on the client.
228 Unfortunately, at this time, client use of
229 delegations is limited, so performance gains may not be observed.
230 This can only be enabled when the file systems being exported to
231 .Nm
232 clients are not being accessed locally on the server and, if being
233 accessed via NFS Version 2 or 3 clients, these clients cannot be
234 using the NLM.
235 .It Cm vfs.nfsd.enable_locallocks
236 can be set to 0 to disable acquisition of local byte range locks.
237 Disabling local locking can only be done if neither local accesses
238 to the exported file systems nor the NLM is operating on them.
239 .El
240 .sp
241 Note that Samba server access would be considered ``local access'' for the above
242 discussion.
243 .Pp
244 To build a kernel with the NFS server that supports
245 .Nm
246 linked into it, the
247 .sp
248 .Bd -literal -offset indent -compact
249 options NFSD
250 .Ed
251 .sp
252 must be specified in the kernel's
253 .Xr config 5
254 file.
255 .Sh CLIENT MOUNTS
256 To do an
257 .Nm
258 mount, specify the ``nfsv4'' option on the
259 .Xr mount_nfs 8
260 command line.
261 This will force use of the client that supports
262 .Nm
263 plus set ``tcp'' and
264 .Nm .
265 .Pp
266 The
267 .Xr nfsuserd 8
268 must be running if name<->uid/gid mapping is being used, as above.
269 Also, since an
270 .Nm
271 mount uses the host uuid to identify the client uniquely to the server,
272 you cannot safely do an
273 .Nm
274 mount when
275 .sp
276 .Bd -literal -offset indent -compact
277 hostid_enable="NO"
278 .Ed
279 .sp
280 is set in
281 .Xr rc.conf 5 .
282 .sp
283 If the
284 .Nm
285 server that is being mounted on supports delegations, you can start the
286 .Xr nfscbd 8
287 daemon to handle client side callbacks.
288 This will occur if
289 .sp
290 .Bd -literal -offset indent -compact
291 nfsuserd_enable="YES"   <-- If name<->uid/gid mapping is being used.
292 nfscbd_enable="YES"
293 .Ed
294 .sp
295 are set in
296 .Xr rc.conf 5 .
297 .sp
298 Without a functioning callback path, a server will never issue Delegations
299 to a client.
300 .sp
301 For NFSv4.0, by default, the callback address will be set to the IP address acquired via
302 .Fn rtalloc
303 in the kernel and port# 7745.
304 To override the default port#, a command line option for
305 .Xr nfscbd 8
306 can be used.
307 .sp
308 To get callbacks to work when behind a NAT gateway, a port for the callback
309 service will need to be set up on the NAT gateway and then the address
310 of the NAT gateway (host IP plus port#) will need to be set by assigning the
311 .Xr sysctl 8
312 variable vfs.nfs.callback_addr to a string of the form:
313 .sp
314 N.N.N.N.N.N
315 .sp
316 where the first 4 Ns are the host IP address and the last two are the
317 port# in network byte order (all decimal #s in the range 0-255).
318 .Pp
319 For NFSv4.1 and NFSv4.2, the callback path (called a backchannel) uses the same TCP connection as the mount,
320 so none of the above applies and should work through gateways without
321 any issues.
322 .Pp
323 To build a kernel with the client that supports
324 .Nm
325 linked into it, the option
326 .sp
327 .Bd -literal -offset indent -compact
328 options NFSCL
329 .Ed
330 .sp
331 must be specified in the kernel's
332 .Xr config 5
333 file.
334 .Pp
335 Options can be specified for the
336 .Xr nfsuserd 8
337 and
338 .Xr nfscbd 8
339 daemons at boot time via the ``nfsuserd_flags'' and ``nfscbd_flags''
340 .Xr rc.conf 5
341 variables.
342 .Pp
343 NFSv4 mount(s) against exported volume(s) on the same host are not recommended,
344 since this can result in a hung NFS server.
345 It occurs when an nfsd thread tries to do an NFSv4
346 .Fn VOP_RECLAIM
347 / Close RPC as part of acquiring a new vnode.
348 If all other nfsd threads are blocked waiting for lock(s) held by this nfsd
349 thread, then there isn't an nfsd thread to service the Close RPC.
350 .Sh FILES
351 .Bl -tag -width /var/db/nfs-stablerestart.bak -compact
352 .It Pa /var/db/nfs-stablerestart
353 NFS V4 stable restart file
354 .It Pa /var/db/nfs-stablerestart.bak
355 backup copy of the file
356 .El
357 .Sh SEE ALSO
358 .Xr stablerestart 5 ,
359 .Xr mountd 8 ,
360 .Xr nfscbd 8 ,
361 .Xr nfsd 8 ,
362 .Xr nfsdumpstate 8 ,
363 .Xr nfsrevoke 8 ,
364 .Xr nfsuserd 8
365 .Sh BUGS
366 At this time, there is no recall of delegations for local file system
367 operations.
368 As such, delegations should only be enabled for file systems
369 that are being used solely as NFS export volumes and are not being accessed
370 via local system calls nor services such as Samba.