2 * Copyright (c) 1989, 1991, 1993, 1995
3 * The Regents of the University of California. All rights reserved.
5 * This code is derived from software contributed to Berkeley by
6 * Rick Macklem at The University of Guelph.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 4. Neither the name of the University nor the names of its contributors
17 * may be used to endorse or promote products derived from this software
18 * without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * @(#)nfs_socket.c 8.5 (Berkeley) 3/30/95
35 #include <sys/cdefs.h>
36 __FBSDID("$FreeBSD$");
39 * Socket operations for use by nfs
42 #include "opt_inet6.h"
43 #include "opt_kgssapi.h"
45 #include <sys/param.h>
46 #include <sys/systm.h>
47 #include <sys/kernel.h>
48 #include <sys/limits.h>
50 #include <sys/malloc.h>
52 #include <sys/mount.h>
53 #include <sys/mutex.h>
55 #include <sys/signalvar.h>
56 #include <sys/syscallsubr.h>
57 #include <sys/sysctl.h>
58 #include <sys/syslog.h>
59 #include <sys/vnode.h>
63 #include <nfs/nfsproto.h>
64 #include <nfsclient/nfs.h>
65 #include <nfs/xdr_subs.h>
66 #include <nfsclient/nfsm_subs.h>
67 #include <nfsclient/nfsmount.h>
68 #include <nfsclient/nfsnode.h>
71 #include <sys/dtrace_bsd.h>
73 dtrace_nfsclient_nfs23_start_probe_func_t
74 dtrace_nfsclient_nfs23_start_probe;
76 dtrace_nfsclient_nfs23_done_probe_func_t
77 dtrace_nfsclient_nfs23_done_probe;
80 * Registered probes by RPC type.
82 uint32_t nfsclient_nfs2_start_probes[NFS_NPROCS];
83 uint32_t nfsclient_nfs2_done_probes[NFS_NPROCS];
85 uint32_t nfsclient_nfs3_start_probes[NFS_NPROCS];
86 uint32_t nfsclient_nfs3_done_probes[NFS_NPROCS];
89 static int nfs_bufpackets = 4;
90 static int nfs_reconnects;
91 static int nfs3_jukebox_delay = 10;
92 static int nfs_skip_wcc_data_onerr = 1;
93 static int fake_wchan;
95 SYSCTL_DECL(_vfs_oldnfs);
97 SYSCTL_INT(_vfs_oldnfs, OID_AUTO, bufpackets, CTLFLAG_RW, &nfs_bufpackets, 0,
98 "Buffer reservation size 2 < x < 64");
99 SYSCTL_INT(_vfs_oldnfs, OID_AUTO, reconnects, CTLFLAG_RD, &nfs_reconnects, 0,
100 "Number of times the nfs client has had to reconnect");
101 SYSCTL_INT(_vfs_oldnfs, OID_AUTO, nfs3_jukebox_delay, CTLFLAG_RW,
102 &nfs3_jukebox_delay, 0,
103 "Number of seconds to delay a retry after receiving EJUKEBOX");
104 SYSCTL_INT(_vfs_oldnfs, OID_AUTO, skip_wcc_data_onerr, CTLFLAG_RW,
105 &nfs_skip_wcc_data_onerr, 0,
106 "Disable weak cache consistency checking when server returns an error");
108 static void nfs_down(struct nfsmount *, struct thread *, const char *,
110 static void nfs_up(struct nfsmount *, struct thread *, const char *,
112 static int nfs_msg(struct thread *, const char *, const char *, int);
114 extern int nfsv2_procid[];
116 struct nfs_cached_auth {
117 int ca_refs; /* refcount, including 1 from the cache */
118 uid_t ca_uid; /* uid that corresponds to this auth */
119 AUTH *ca_auth; /* RPC auth handle */
126 static enum nfs_rto_timer_t nfs_proct[NFS_NPROCS] = {
127 NFS_DEFAULT_TIMER, /* NULL */
128 NFS_GETATTR_TIMER, /* GETATTR */
129 NFS_DEFAULT_TIMER, /* SETATTR */
130 NFS_LOOKUP_TIMER, /* LOOKUP */
131 NFS_GETATTR_TIMER, /* ACCESS */
132 NFS_READ_TIMER, /* READLINK */
133 NFS_READ_TIMER, /* READ */
134 NFS_WRITE_TIMER, /* WRITE */
135 NFS_DEFAULT_TIMER, /* CREATE */
136 NFS_DEFAULT_TIMER, /* MKDIR */
137 NFS_DEFAULT_TIMER, /* SYMLINK */
138 NFS_DEFAULT_TIMER, /* MKNOD */
139 NFS_DEFAULT_TIMER, /* REMOVE */
140 NFS_DEFAULT_TIMER, /* RMDIR */
141 NFS_DEFAULT_TIMER, /* RENAME */
142 NFS_DEFAULT_TIMER, /* LINK */
143 NFS_READ_TIMER, /* READDIR */
144 NFS_READ_TIMER, /* READDIRPLUS */
145 NFS_DEFAULT_TIMER, /* FSSTAT */
146 NFS_DEFAULT_TIMER, /* FSINFO */
147 NFS_DEFAULT_TIMER, /* PATHCONF */
148 NFS_DEFAULT_TIMER, /* COMMIT */
149 NFS_DEFAULT_TIMER, /* NOOP */
153 * Choose the correct RTT timer for this NFS procedure.
155 static inline enum nfs_rto_timer_t
156 nfs_rto_timer(u_int32_t procnum)
159 return (nfs_proct[procnum]);
163 * Initialize the RTT estimator state for a new mount point.
166 nfs_init_rtt(struct nfsmount *nmp)
170 for (i = 0; i < NFS_MAX_TIMER; i++) {
171 nmp->nm_timers[i].rt_srtt = hz;
172 nmp->nm_timers[i].rt_deviate = 0;
173 nmp->nm_timers[i].rt_rtxcur = hz;
178 * Initialize sockets and congestion for a new NFS connection.
179 * We do not free the sockaddr if error.
182 nfs_connect(struct nfsmount *nmp)
184 int rcvreserve, sndreserve;
186 struct sockaddr *saddr;
187 struct ucred *origcred;
188 struct thread *td = curthread;
190 struct netconfig *nconf;
192 int one = 1, retries;
196 * We need to establish the socket using the credentials of
197 * the mountpoint. Some parts of this process (such as
198 * sobind() and soconnect()) will use the curent thread's
199 * credential instead of the socket credential. To work
200 * around this, temporarily change the current thread's
201 * credential to that of the mountpoint.
203 * XXX: It would be better to explicitly pass the correct
204 * credential to sobind() and soconnect().
206 origcred = td->td_ucred;
207 td->td_ucred = nmp->nm_mountp->mnt_cred;
211 if (nmp->nm_flag & NFSMNT_NFSV3)
213 else if (nmp->nm_flag & NFSMNT_NFSV4)
215 if (saddr->sa_family == AF_INET)
216 if (nmp->nm_sotype == SOCK_DGRAM)
217 nconf = getnetconfigent("udp");
219 nconf = getnetconfigent("tcp");
221 if (nmp->nm_sotype == SOCK_DGRAM)
222 nconf = getnetconfigent("udp6");
224 nconf = getnetconfigent("tcp6");
227 * Get buffer reservation size from sysctl, but impose reasonable
230 pktscale = nfs_bufpackets;
235 mtx_lock(&nmp->nm_mtx);
236 if (nmp->nm_sotype == SOCK_DGRAM) {
237 sndreserve = (nmp->nm_wsize + NFS_MAXPKTHDR) * pktscale;
238 rcvreserve = (max(nmp->nm_rsize, nmp->nm_readdirsize) +
239 NFS_MAXPKTHDR) * pktscale;
240 } else if (nmp->nm_sotype == SOCK_SEQPACKET) {
241 sndreserve = (nmp->nm_wsize + NFS_MAXPKTHDR) * pktscale;
242 rcvreserve = (max(nmp->nm_rsize, nmp->nm_readdirsize) +
243 NFS_MAXPKTHDR) * pktscale;
245 if (nmp->nm_sotype != SOCK_STREAM)
246 panic("nfscon sotype");
247 sndreserve = (nmp->nm_wsize + NFS_MAXPKTHDR +
248 sizeof (u_int32_t)) * pktscale;
249 rcvreserve = (nmp->nm_rsize + NFS_MAXPKTHDR +
250 sizeof (u_int32_t)) * pktscale;
252 mtx_unlock(&nmp->nm_mtx);
254 client = clnt_reconnect_create(nconf, saddr, NFS_PROG, vers,
255 sndreserve, rcvreserve);
256 CLNT_CONTROL(client, CLSET_WAITCHAN, "nfsreq");
257 if (nmp->nm_flag & NFSMNT_INT)
258 CLNT_CONTROL(client, CLSET_INTERRUPTIBLE, &one);
259 if (nmp->nm_flag & NFSMNT_RESVPORT)
260 CLNT_CONTROL(client, CLSET_PRIVPORT, &one);
261 if ((nmp->nm_flag & NFSMNT_SOFT) != 0) {
262 if (nmp->nm_sotype == SOCK_DGRAM)
264 * For UDP, the large timeout for a reconnect will
265 * be set to "nm_retry * nm_timeo / 2", so we only
266 * want to do 2 reconnect timeout retries.
270 retries = nmp->nm_retry;
273 CLNT_CONTROL(client, CLSET_RETRIES, &retries);
276 * For UDP, there are 2 timeouts:
277 * - CLSET_RETRY_TIMEOUT sets the initial timeout for the timer
278 * that does a retransmit of an RPC request using the same socket
279 * and xid. This is what you normally want to do, since NFS
280 * servers depend on "same xid" for their Duplicate Request Cache.
281 * - timeout specified in CLNT_CALL_MBUF(), which specifies when
282 * retransmits on the same socket should fail and a fresh socket
283 * created. Each of these timeouts counts as one CLSET_RETRIES,
285 * Set the initial retransmit timeout for UDP. This timeout doesn't
286 * exist for TCP and the following call just fails, which is ok.
288 timo.tv_sec = nmp->nm_timeo / NFS_HZ;
289 timo.tv_usec = (nmp->nm_timeo % NFS_HZ) * 1000000 / NFS_HZ;
290 CLNT_CONTROL(client, CLSET_RETRY_TIMEOUT, &timo);
292 mtx_lock(&nmp->nm_mtx);
293 if (nmp->nm_client) {
295 * Someone else already connected.
297 CLNT_RELEASE(client);
299 nmp->nm_client = client;
302 * Protocols that do not require connections may be optionally left
303 * unconnected for servers that reply from a port other than NFS_PORT.
305 if (!(nmp->nm_flag & NFSMNT_NOCONN)) {
306 mtx_unlock(&nmp->nm_mtx);
307 CLNT_CONTROL(client, CLSET_CONNECT, &one);
309 mtx_unlock(&nmp->nm_mtx);
311 /* Restore current thread's credentials. */
312 td->td_ucred = origcred;
314 mtx_lock(&nmp->nm_mtx);
315 /* Initialize other non-zero congestion variables. */
317 mtx_unlock(&nmp->nm_mtx);
322 * NFS disconnect. Clean up and unlink.
325 nfs_disconnect(struct nfsmount *nmp)
329 mtx_lock(&nmp->nm_mtx);
330 if (nmp->nm_client) {
331 client = nmp->nm_client;
332 nmp->nm_client = NULL;
333 mtx_unlock(&nmp->nm_mtx);
334 rpc_gss_secpurge_call(client);
336 CLNT_RELEASE(client);
338 mtx_unlock(&nmp->nm_mtx);
342 nfs_safedisconnect(struct nfsmount *nmp)
349 nfs_getauth(struct nfsmount *nmp, struct ucred *cred)
351 rpc_gss_service_t svc;
354 switch (nmp->nm_secflavor) {
355 case RPCSEC_GSS_KRB5:
356 case RPCSEC_GSS_KRB5I:
357 case RPCSEC_GSS_KRB5P:
358 if (!nmp->nm_mech_oid)
359 if (!rpc_gss_mech_to_oid_call("kerberosv5",
362 if (nmp->nm_secflavor == RPCSEC_GSS_KRB5)
363 svc = rpc_gss_svc_none;
364 else if (nmp->nm_secflavor == RPCSEC_GSS_KRB5I)
365 svc = rpc_gss_svc_integrity;
367 svc = rpc_gss_svc_privacy;
368 auth = rpc_gss_secfind_call(nmp->nm_client, cred,
369 nmp->nm_principal, nmp->nm_mech_oid, svc);
375 return (authunix_create(cred));
381 * Callback from the RPC code to generate up/down notifications.
384 struct nfs_feedback_arg {
385 struct nfsmount *nf_mount;
386 int nf_lastmsg; /* last tprintf */
388 struct thread *nf_td;
392 nfs_feedback(int type, int proc, void *arg)
394 struct nfs_feedback_arg *nf = (struct nfs_feedback_arg *) arg;
395 struct nfsmount *nmp = nf->nf_mount;
399 case FEEDBACK_REXMIT2:
400 case FEEDBACK_RECONNECT:
402 if (nf->nf_lastmsg + nmp->nm_tprintf_delay < now) {
403 nfs_down(nmp, nf->nf_td,
404 "not responding", 0, NFSSTA_TIMEO);
405 nf->nf_tprintfmsg = TRUE;
406 nf->nf_lastmsg = now;
411 nfs_up(nf->nf_mount, nf->nf_td,
412 "is alive again", NFSSTA_TIMEO, nf->nf_tprintfmsg);
418 * nfs_request - goes something like this
419 * - fill in request struct
420 * - links it into list
421 * - calls nfs_send() for first transmit
422 * - calls nfs_receive() to get reply
423 * - break down rpc header and return with nfs reply pointed to
425 * nb: always frees up mreq mbuf list
428 nfs_request(struct vnode *vp, struct mbuf *mreq, int procnum,
429 struct thread *td, struct ucred *cred, struct mbuf **mrp,
430 struct mbuf **mdp, caddr_t *dposp)
434 struct nfsmount *nmp;
438 int error = 0, timeo;
440 enum nfs_rto_timer_t timer;
441 struct nfs_feedback_arg nf;
442 struct rpc_callextra ext;
446 /* Reject requests while attempting a forced unmount. */
447 if (vp->v_mount->mnt_kern_flag & MNTK_UNMOUNTF) {
451 nmp = VFSTONFS(vp->v_mount);
452 bzero(&nf, sizeof(struct nfs_feedback_arg));
455 nf.nf_lastmsg = time_uptime -
456 ((nmp->nm_tprintf_delay) - (nmp->nm_tprintf_initial_delay));
459 * XXX if not already connected call nfs_connect now. Longer
460 * term, change nfs_mount to call nfs_connect unconditionally
461 * and let clnt_reconnect_create handle reconnects.
466 auth = nfs_getauth(nmp, cred);
471 bzero(&ext, sizeof(ext));
474 ext.rc_feedback = nfs_feedback;
475 ext.rc_feedback_arg = &nf;
478 * Use a conservative timeout for RPCs other than getattr,
479 * lookup, read or write. The justification for doing "other"
480 * this way is that these RPCs happen so infrequently that
481 * timer est. would probably be stale. Also, since many of
482 * these RPCs are non-idempotent, a conservative timeout is
485 timer = nfs_rto_timer(procnum);
486 if (timer != NFS_DEFAULT_TIMER)
487 ext.rc_timers = &nmp->nm_timers[timer - 1];
489 ext.rc_timers = NULL;
492 if (dtrace_nfsclient_nfs23_start_probe != NULL) {
496 if (nmp->nm_flag & NFSMNT_NFSV3) {
497 probe_id = nfsclient_nfs3_start_probes[procnum];
498 probe_procnum = procnum;
500 probe_id = nfsclient_nfs2_start_probes[procnum];
501 probe_procnum = nfsv2_procid[procnum];
504 (dtrace_nfsclient_nfs23_start_probe)(probe_id, vp,
505 mreq, cred, probe_procnum);
509 nfsstats.rpcrequests++;
512 * This timeout specifies when a new socket should be created,
513 * along with new xid values. For UDP, this should be done
514 * infrequently, since retransmits of RPC requests should normally
517 if (nmp->nm_sotype == SOCK_DGRAM) {
518 if ((nmp->nm_flag & NFSMNT_SOFT) != 0) {
520 * CLSET_RETRIES is set to 2, so this should be half
521 * of the total timeout required.
523 timeo = nmp->nm_retry * nmp->nm_timeo / 2;
526 timo.tv_sec = timeo / NFS_HZ;
527 timo.tv_usec = (timeo % NFS_HZ) * 1000000 / NFS_HZ;
529 /* For UDP hard mounts, use a large value. */
530 timo.tv_sec = NFS_MAXTIMEO / NFS_HZ;
534 timo.tv_sec = nmp->nm_timeo / NFS_HZ;
535 timo.tv_usec = (nmp->nm_timeo % NFS_HZ) * 1000000 / NFS_HZ;
538 stat = CLNT_CALL_MBUF(nmp->nm_client, &ext,
539 (nmp->nm_flag & NFSMNT_NFSV3) ? procnum : nfsv2_procid[procnum],
543 * If there was a successful reply and a tprintf msg.
544 * tprintf a response.
546 if (stat == RPC_SUCCESS)
548 else if (stat == RPC_TIMEDOUT) {
549 nfsstats.rpctimeouts++;
551 } else if (stat == RPC_VERSMISMATCH) {
552 nfsstats.rpcinvalid++;
554 } else if (stat == RPC_PROGVERSMISMATCH) {
555 nfsstats.rpcinvalid++;
556 error = EPROTONOSUPPORT;
557 } else if (stat == RPC_INTR) {
560 nfsstats.rpcinvalid++;
566 KASSERT(mrep != NULL, ("mrep shouldn't be NULL if no error\n"));
569 * Search for any mbufs that are not a multiple of 4 bytes long
570 * or with m_data not longword aligned.
571 * These could cause pointer alignment problems, so copy them to
572 * well aligned mbufs.
574 error = nfs_realign(&mrep, M_NOWAIT);
575 if (error == ENOMEM) {
578 nfsstats.rpcinvalid++;
583 dpos = mtod(mrep, caddr_t);
584 tl = nfsm_dissect(u_int32_t *, NFSX_UNSIGNED);
586 error = fxdr_unsigned(int, *tl);
587 if ((nmp->nm_flag & NFSMNT_NFSV3) &&
588 error == NFSERR_TRYLATER) {
591 waituntil = time_second + nfs3_jukebox_delay;
592 while (time_second < waituntil)
593 (void)tsleep(&fake_wchan, PSOCK, "nqnfstry",
598 * Make sure NFSERR_RETERR isn't bogusly set by a server
599 * such as amd. (No actual NFS error has bit 31 set.)
601 error &= ~NFSERR_RETERR;
604 * If the File Handle was stale, invalidate the lookup
605 * cache, just in case.
610 * Skip wcc data on non-ENOENT NFS errors for now.
611 * NetApp filers return corrupt postop attrs in the
612 * wcc data for NFS err EROFS. Not sure if they could
613 * return corrupt postop attrs for others errors.
614 * Blocking ENOENT post-op attributes breaks negative
615 * name caching, so always allow it through.
617 if ((nmp->nm_flag & NFSMNT_NFSV3) &&
618 (!nfs_skip_wcc_data_onerr || error == ENOENT)) {
622 error |= NFSERR_RETERR;
629 if (dtrace_nfsclient_nfs23_done_probe != NULL) {
633 if (nmp->nm_flag & NFSMNT_NFSV3) {
634 probe_id = nfsclient_nfs3_done_probes[procnum];
635 probe_procnum = procnum;
637 probe_id = nfsclient_nfs2_done_probes[procnum];
638 probe_procnum = (nmp->nm_flag & NFSMNT_NFSV3) ?
639 procnum : nfsv2_procid[procnum];
642 (dtrace_nfsclient_nfs23_done_probe)(probe_id, vp,
643 mreq, cred, probe_procnum, 0);
655 if (dtrace_nfsclient_nfs23_done_probe != NULL) {
659 if (nmp->nm_flag & NFSMNT_NFSV3) {
660 probe_id = nfsclient_nfs3_done_probes[procnum];
661 probe_procnum = procnum;
663 probe_id = nfsclient_nfs2_done_probes[procnum];
664 probe_procnum = (nmp->nm_flag & NFSMNT_NFSV3) ?
665 procnum : nfsv2_procid[procnum];
668 (dtrace_nfsclient_nfs23_done_probe)(probe_id, vp,
669 mreq, cred, probe_procnum, error);
679 * Mark all of an nfs mount's outstanding requests with R_SOFTTERM and
680 * wait for all requests to complete. This is used by forced unmounts
681 * to terminate any outstanding RPCs.
684 nfs_nmcancelreqs(struct nfsmount *nmp)
688 CLNT_CLOSE(nmp->nm_client);
693 * Any signal that can interrupt an NFS operation in an intr mount
694 * should be added to this set. SIGSTOP and SIGKILL cannot be masked.
696 int nfs_sig_set[] = {
705 * Check to see if one of the signals in our subset is pending on
706 * the process (in an intr mount).
709 nfs_sig_pending(sigset_t set)
713 for (i = 0 ; i < sizeof(nfs_sig_set)/sizeof(int) ; i++)
714 if (SIGISMEMBER(set, nfs_sig_set[i]))
720 * The set/restore sigmask functions are used to (temporarily) overwrite
721 * the thread td_sigmask during an RPC call (for example). These are also
722 * used in other places in the NFS client that might tsleep().
725 nfs_set_sigmask(struct thread *td, sigset_t *oldset)
733 td = curthread; /* XXX */
735 /* Remove the NFS set of signals from newset. */
737 mtx_lock(&p->p_sigacts->ps_mtx);
738 for (i = 0 ; i < sizeof(nfs_sig_set)/sizeof(int) ; i++) {
740 * But make sure we leave the ones already masked
741 * by the process, i.e. remove the signal from the
742 * temporary signalmask only if it wasn't already
745 if (!SIGISMEMBER(td->td_sigmask, nfs_sig_set[i]) &&
746 !SIGISMEMBER(p->p_sigacts->ps_sigignore, nfs_sig_set[i]))
747 SIGDELSET(newset, nfs_sig_set[i]);
749 mtx_unlock(&p->p_sigacts->ps_mtx);
750 kern_sigprocmask(td, SIG_SETMASK, &newset, oldset,
751 SIGPROCMASK_PROC_LOCKED);
756 nfs_restore_sigmask(struct thread *td, sigset_t *set)
759 td = curthread; /* XXX */
760 kern_sigprocmask(td, SIG_SETMASK, set, NULL, 0);
764 * NFS wrapper to msleep(), that shoves a new p_sigmask and restores the
765 * old one after msleep() returns.
768 nfs_msleep(struct thread *td, void *ident, struct mtx *mtx, int priority,
769 char *wmesg, int timo)
775 if ((priority & PCATCH) == 0)
776 return msleep(ident, mtx, priority, wmesg, timo);
778 td = curthread; /* XXX */
779 nfs_set_sigmask(td, &oldset);
780 error = msleep(ident, mtx, priority, wmesg, timo);
781 nfs_restore_sigmask(td, &oldset);
787 * Test for a termination condition pending on the process.
788 * This is used for NFSMNT_INT mounts.
791 nfs_sigintr(struct nfsmount *nmp, struct thread *td)
796 /* Terminate all requests while attempting a forced unmount. */
797 if (nmp->nm_mountp->mnt_kern_flag & MNTK_UNMOUNTF)
799 if (!(nmp->nm_flag & NFSMNT_INT))
805 tmpset = p->p_siglist;
806 SIGSETOR(tmpset, td->td_siglist);
807 SIGSETNAND(tmpset, td->td_sigmask);
808 mtx_lock(&p->p_sigacts->ps_mtx);
809 SIGSETNAND(tmpset, p->p_sigacts->ps_sigignore);
810 mtx_unlock(&p->p_sigacts->ps_mtx);
811 if ((SIGNOTEMPTY(p->p_siglist) || SIGNOTEMPTY(td->td_siglist))
812 && nfs_sig_pending(tmpset)) {
821 nfs_msg(struct thread *td, const char *server, const char *msg, int error)
825 p = td ? td->td_proc : NULL;
827 tprintf(p, LOG_INFO, "nfs server %s: %s, error %d\n", server,
830 tprintf(p, LOG_INFO, "nfs server %s: %s\n", server, msg);
835 nfs_down(struct nfsmount *nmp, struct thread *td, const char *msg,
836 int error, int flags)
840 mtx_lock(&nmp->nm_mtx);
841 if ((flags & NFSSTA_TIMEO) && !(nmp->nm_state & NFSSTA_TIMEO)) {
842 nmp->nm_state |= NFSSTA_TIMEO;
843 mtx_unlock(&nmp->nm_mtx);
844 vfs_event_signal(&nmp->nm_mountp->mnt_stat.f_fsid,
847 mtx_unlock(&nmp->nm_mtx);
848 mtx_lock(&nmp->nm_mtx);
849 if ((flags & NFSSTA_LOCKTIMEO) &&
850 !(nmp->nm_state & NFSSTA_LOCKTIMEO)) {
851 nmp->nm_state |= NFSSTA_LOCKTIMEO;
852 mtx_unlock(&nmp->nm_mtx);
853 vfs_event_signal(&nmp->nm_mountp->mnt_stat.f_fsid,
856 mtx_unlock(&nmp->nm_mtx);
857 nfs_msg(td, nmp->nm_mountp->mnt_stat.f_mntfromname, msg, error);
861 nfs_up(struct nfsmount *nmp, struct thread *td, const char *msg,
862 int flags, int tprintfmsg)
867 nfs_msg(td, nmp->nm_mountp->mnt_stat.f_mntfromname, msg, 0);
869 mtx_lock(&nmp->nm_mtx);
870 if ((flags & NFSSTA_TIMEO) && (nmp->nm_state & NFSSTA_TIMEO)) {
871 nmp->nm_state &= ~NFSSTA_TIMEO;
872 mtx_unlock(&nmp->nm_mtx);
873 vfs_event_signal(&nmp->nm_mountp->mnt_stat.f_fsid,
876 mtx_unlock(&nmp->nm_mtx);
878 mtx_lock(&nmp->nm_mtx);
879 if ((flags & NFSSTA_LOCKTIMEO) &&
880 (nmp->nm_state & NFSSTA_LOCKTIMEO)) {
881 nmp->nm_state &= ~NFSSTA_LOCKTIMEO;
882 mtx_unlock(&nmp->nm_mtx);
883 vfs_event_signal(&nmp->nm_mountp->mnt_stat.f_fsid,
886 mtx_unlock(&nmp->nm_mtx);