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