]> git.decadent.org.uk Git - nfs-utils.git/blob - utils/statd/statd.man
ffc5e950990c5f7f0b7c1c0b9d06199aed030a41
[nfs-utils.git] / utils / statd / statd.man
1 .\"@(#)rpc.statd.8"
2 .\"
3 .\" Copyright (C) 1999 Olaf Kirch <okir@monad.swb.de>
4 .\" Modified by Jeffrey A. Uphoff, 1999, 2002, 2005.
5 .\" Modified by Lon Hohberger, 2000.
6 .\" Modified by Paul Clements, 2004.
7 .\"
8 .\" Rewritten by Chuck Lever <chuck.lever@oracle.com>, 2009.
9 .\" Copyright 2009 Oracle.  All rights reserved.
10 .\"
11 .TH RPC.STATD 8 "1 November 2009
12 .SH NAME
13 rpc.statd \- NSM service daemon
14 .SH SYNOPSIS
15 .BI "rpc.statd [-dh?FLNvVw] [-H " prog "] [-n " my-name "] [-o " outgoing-port "] [-p " listener-port "] [-P " path " ]
16 .SH DESCRIPTION
17 File locks are not part of persistent file system state.
18 Lock state is thus lost when a host reboots.
19 .PP
20 Network file systems must also detect when lock state is lost
21 because a remote host has rebooted.
22 After an NFS client reboots, an NFS server must release all file locks
23 held by applications that were running on that client.
24 After a server reboots, a client must remind the
25 server of file locks held by applications running on that client.
26 .PP
27 For NFS version 2 [RFC1094] and NFS version 3 [RFC1813], the
28 .I Network Status Monitor
29 protocol (or NSM for short)
30 is used to notify NFS peers of reboots.
31 On Linux, two separate user-space components constitute the NSM service:
32 .TP
33 .B rpc.statd
34 A daemon that listens for reboot notifications from other hosts, and
35 manages the list of hosts to be notified when the local system reboots
36 .TP
37 .B sm-notify
38 A helper program that notifies NFS peers after the local system reboots
39 .PP
40 The local NFS lock manager alerts its local
41 .B rpc.statd
42 of each remote peer that should be monitored.
43 When the local system reboots, the
44 .B sm-notify
45 command notifies the NSM service on monitored peers of the reboot.
46 When a remote reboots, that peer notifies the local
47 .BR rpc.statd ,
48 which in turn passes the reboot notification
49 back to the local NFS lock manager.
50 .SH NSM OPERATION IN DETAIL
51 The first file locking interaction between an NFS client and server causes
52 the NFS lock managers on both peers to contact their local NSM service to
53 store information about the opposite peer.
54 On Linux, the local lock manager contacts
55 .BR rpc.statd .
56 .PP
57 .B rpc.statd
58 records information about each monitored NFS peer on persistent storage.
59 This information describes how to contact a remote peer
60 in case the local system reboots,
61 how to recognize which monitored peer is reporting a reboot,
62 and how to notify the local lock manager when a monitored peer
63 indicates it has rebooted.
64 .PP
65 An NFS client sends a hostname, known as the client's
66 .IR caller_name ,
67 in each file lock request.
68 An NFS server can use this hostname to send asynchronous GRANT
69 calls to a client, or to notify the client it has rebooted.
70 .PP
71 The Linux NFS server can provide the client's
72 .I caller_name
73 or the client's network address to
74 .BR rpc.statd .
75 For the purposes of the NSM protocol,
76 this name or address is known as the monitored peer's
77 .IR mon_name .
78 In addition, the local lock manager tells
79 .B rpc.statd
80 what it thinks its own hostname is.
81 For the purposes of the NSM protocol,
82 this hostname is known as
83 .IR my_name .
84 .PP
85 There is no equivalent interaction between an NFS server and a client
86 to inform the client of the server's
87 .IR caller_name .
88 Therefore NFS clients do not actually know what
89 .I mon_name
90 an NFS server might use in an SM_NOTIFY request.
91 The Linux NFS client uses the server hostname from the mount command
92 to identify rebooting NFS servers.
93 .SS Reboot notification
94 When the local system reboots, the
95 .B sm-notify
96 command reads the list of monitored peers from persistent storage and
97 sends an SM_NOTIFY request to the NSM service on each listed remote peer.
98 It uses the
99 .I mon_name
100 string as the destination.
101 To identify which host has rebooted, the
102 .B sm-notify
103 command normally sends the results of
104 .BR gethostname (3)
105 as the
106 .I my_name
107 string.
108 The remote
109 .B rpc.statd
110 matches incoming SM_NOTIFY requests using this string,
111 or the caller's network address,
112 to one or more peers on its own monitor list.
113 .PP
114 If
115 .B rpc.statd
116 does not find a peer on its monitor list that matches
117 an incoming SM_NOTIFY request,
118 the notification is not forwarded to the local lock manager.
119 In addition, each peer has its own
120 .IR "NSM state number" ,
121 a 32-bit integer that is bumped after each reboot by the
122 .B sm-notify
123 command.
124 .B rpc.statd
125 uses this number to distinguish between actual reboots
126 and replayed notifications.
127 .PP
128 Part of NFS lock recovery is rediscovering
129 which peers need to be monitored again.
130 The
131 .B sm-notify
132 command clears the monitor list on persistent storage after each reboot.
133 .SH OPTIONS
134 .TP
135 .BR -d , " --no-syslog
136 Causes
137 .B rpc.statd
138 to write log messages on
139 .I stderr
140 instead of to the system log,
141 if the
142 .B -F
143 option was also specified.
144 .TP
145 .BR -F , " --foreground
146 Keeps
147 .B rpc.statd
148 attached to its controlling terminal so that NSM
149 operation can be monitored directly or run under a debugger.
150 If this option is not specified,
151 .B rpc.statd
152 backgrounds itself soon after it starts.
153 .TP
154 .BR -h , " -?" , " --help
155 Causes
156 .B rpc.statd
157 to display usage information on
158 .I stderr
159 and then exit.
160 .TP
161 .BI "\-H," "" " \-\-ha-callout " prog
162 Specifies a high availability callout program.
163 If this option is not specified, no callouts are performed.
164 See the
165 .B High-availability callouts
166 section below for details.
167 .TP
168 .BR -L , " --no-notify
169 Prevents
170 .B rpc.statd
171 from running the
172 .B sm-notify
173 command when it starts up,
174 preserving the existing NSM state number and monitor list.
175 .IP
176 Note: the
177 .B sm-notify
178 command contains a check to ensure it runs only once after each system reboot.
179 This prevents spurious reboot notification if
180 .B rpc.statd
181 restarts without the
182 .B -L
183 option.
184 .TP
185 .BI "\-n, " "" "\-\-name " ipaddr " | " hostname
186 Specifies the bind address used for RPC listener sockets.
187 The
188 .I ipaddr
189 form can be expressed as either an IPv4 or an IPv6 presentation address.
190 If this option is not specified,
191 .B rpc.statd
192 uses a wildcard address as the transport bind address.
193 .IP
194 This string is also passed to the
195 .B sm-notify
196 command to be used as the source address from which
197 to send reboot notification requests.
198 See
199 .BR sm-notify (8)
200 for details.
201 .TP
202 .BR -N
203 Causes
204 .B rpc.statd
205 to run the
206 .B sm-notify
207 command, and then exit.
208 Since the
209 .B sm-notify
210 command can also be run directly, this option is deprecated.
211 .TP
212 .BI "\-o," "" " \-\-outgoing\-port "  port
213 Specifies the source port number the
214 .B sm-notify
215 command should use when sending reboot notifications.
216 See
217 .BR sm-notify (8)
218 for details.
219 .TP
220 .BI "\-p," "" " \-\-port " port
221 Specifies the port number used for RPC listener sockets.
222 If this option is not specified,
223 .B rpc.statd
224 chooses a random ephemeral port for each listener socket.
225 .IP
226 This option can be used to fix the port value of its listeners when
227 SM_NOTIFY requests must traverse a firewall between clients and servers.
228 .TP
229 .BI "\-P, " "" \-\-state\-directory\-path " pathname
230 Specifies the pathname of the parent directory
231 where NSM state information resides.
232 If this option is not specified,
233 .B rpc.statd
234 uses
235 .I /var/lib/nfs
236 by default.
237 .IP
238 After starting,
239 .B rpc.statd
240 attempts to set its effective UID and GID to the owner
241 and group of this directory.
242 .TP
243 .BR -v ", " -V ", " --version
244 Causes
245 .B rpc.statd
246 to display version information on
247 .I stderr
248 and then exit.
249 .SH SECURITY
250 The
251 .B rpc.statd
252 daemon must be started as root to acquire privileges needed
253 to create sockets with privileged source ports, and to access the
254 state information database.
255 Because
256 .B rpc.statd
257 maintains a long-running network service, however, it drops root privileges
258 as soon as it starts up to reduce the risk of a privilege escalation attack.
259 .PP
260 During normal operation,
261 the effective user ID it chooses is the owner of the state directory.
262 This allows it to continue to access files in that directory after it
263 has dropped its root privileges.
264 To control which user ID
265 .B rpc.statd
266 chooses, simply use
267 .BR chown (1)
268 to set the owner of
269 the state directory.
270 .PP
271 You can also protect your
272 .B rpc.statd
273 listeners using the
274 .B tcp_wrapper
275 library or
276 .BR iptables (8).
277 To use the
278 .B tcp_wrapper
279 library, add the hostnames of peers that should be allowed access to
280 .IR /etc/hosts.allow .
281 Use the daemon name
282 .B statd
283 even if the
284 .B rpc.statd
285 binary has a different filename.
286 .P
287 For further information see the
288 .BR tcpd (8)
289 and
290 .BR hosts_access (5)
291 man pages.
292 .SH ADDITIONAL NOTES
293 Lock recovery after a reboot is critical to maintaining data integrity
294 and preventing unnecessary application hangs.
295 .PP
296 To help
297 .B rpc.statd
298 match SM_NOTIFY requests to NLM requests, a number of best practices
299 should be observed, including:
300 .IP
301 The UTS nodename of your systems should match the DNS names that NFS
302 peers use to contact them
303 .IP
304 The UTS nodenames of your systems should always be fully qualified domain names
305 .IP
306 The forward and reverse DNS mapping of the UTS nodenames should be
307 consistent
308 .IP
309 The hostname the client uses to mount the server should match the server's
310 .I mon_name
311 in SM_NOTIFY requests it sends
312 .IP
313 The use of network addresses as a
314 .I mon_name
315 or a
316 .I my_name
317 string should be avoided when
318 interoperating with non-Linux NFS implementations.
319 .PP
320 Unmounting an NFS file system does not necessarily stop
321 either the NFS client or server from monitoring each other.
322 Both may continue monitoring each other for a time in case subsequent
323 NFS traffic between the two results in fresh mounts and additional
324 file locking.
325 .PP
326 On Linux, if the
327 .B lockd
328 kernel module is unloaded during normal operation,
329 all remote NFS peers are unmonitored.
330 This can happen on an NFS client, for example,
331 if an automounter removes all NFS mount
332 points due to inactivity.
333 .SS High-availability callouts
334 .B rpc.statd
335 can exec a special callout program during processing of
336 successful SM_MON, SM_UNMON, and SM_UNMON_ALL requests.
337 Such a program may be used in High Availability NFS (HA-NFS)
338 environments to track lock state that may need to be migrated after
339 a system reboot.
340 .PP
341 The name of the callout program is specified with the
342 .B -H
343 option.
344 The program is run with 3 arguments:
345 The first is either
346 .B add-client
347 or
348 .B del-client
349 depending on the reason for the callout.
350 The second is the
351 .I mon_name
352 of the monitored peer.
353 The third is the
354 .I caller_name
355 of the requesting lock manager.
356 .SS IPv6 and TI-RPC support
357 TI-RPC is a pre-requisite for supporting NFS on IPv6.
358 If TI-RPC support is built into
359 .BR rpc.statd ,
360 it attempts to start listeners on network transports marked
361 'visible' in
362 .IR /etc/netconfig .
363 As long as at least one network transport listener starts successfully,
364 .B rpc.statd
365 will operate.
366 .SH FILES
367 .TP 2.5i
368 .I /var/lib/nfs/sm
369 directory containing monitor list
370 .TP 2.5i
371 .I /var/lib/nfs/sm.bak
372 directory containing notify list
373 .TP 2.5i
374 .I /var/lib/nfs/state
375 NSM state number for this host
376 .TP 2.5i
377 .I /var/run/run.statd.pid
378 pid file
379 .TP 2.5i
380 .I /etc/netconfig
381 network transport capability database
382 .SH SEE ALSO
383 .BR sm-notify (8),
384 .BR nfs (5),
385 .BR rpc.nfsd (8),
386 .BR rpcbind (8),
387 .BR tcpd (8),
388 .BR hosts_access (5),
389 .BR iptables (8),
390 .BR netconfig (5)
391 .sp
392 RFC 1094 - "NFS: Network File System Protocol Specification"
393 .br
394 RFC 1813 - "NFS Version 3 Protocol Specification"
395 .br
396 OpenGroup Protocols for Interworking: XNFS, Version 3W - Chapter 11
397 .SH AUTHORS
398 Jeff Uphoff <juphoff@users.sourceforge.net>
399 .br
400 Olaf Kirch <okir@monad.swb.de>
401 .br
402 H.J. Lu <hjl@gnu.org>
403 .br
404 Lon Hohberger <hohberger@missioncriticallinux.com>
405 .br
406 Paul Clements <paul.clements@steeleye.com>
407 .br
408 Chuck Lever <chuck.lever@oracle.com>