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