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_kdtrace.h"
44 #include "opt_kgssapi.h"
46 #include <sys/param.h>
47 #include <sys/systm.h>
48 #include <sys/kernel.h>
49 #include <sys/limits.h>
51 #include <sys/malloc.h>
53 #include <sys/mount.h>
54 #include <sys/mutex.h>
56 #include <sys/signalvar.h>
57 #include <sys/syscallsubr.h>
58 #include <sys/sysctl.h>
59 #include <sys/syslog.h>
60 #include <sys/vnode.h>
64 #include <nfs/nfsproto.h>
65 #include <nfsclient/nfs.h>
66 #include <nfs/xdr_subs.h>
67 #include <nfsclient/nfsm_subs.h>
68 #include <nfsclient/nfsmount.h>
69 #include <nfsclient/nfsnode.h>
72 #include <sys/dtrace_bsd.h>
74 dtrace_nfsclient_nfs23_start_probe_func_t
75 dtrace_nfsclient_nfs23_start_probe;
77 dtrace_nfsclient_nfs23_done_probe_func_t
78 dtrace_nfsclient_nfs23_done_probe;
81 * Registered probes by RPC type.
83 uint32_t nfsclient_nfs2_start_probes[NFS_NPROCS];
84 uint32_t nfsclient_nfs2_done_probes[NFS_NPROCS];
86 uint32_t nfsclient_nfs3_start_probes[NFS_NPROCS];
87 uint32_t nfsclient_nfs3_done_probes[NFS_NPROCS];
90 static int nfs_realign_test;
91 static int nfs_realign_count;
92 static int nfs_bufpackets = 4;
93 static int nfs_reconnects;
94 static int nfs3_jukebox_delay = 10;
95 static int nfs_skip_wcc_data_onerr = 1;
96 static int fake_wchan;
98 SYSCTL_DECL(_vfs_nfs);
100 SYSCTL_INT(_vfs_nfs, OID_AUTO, realign_test, CTLFLAG_RW, &nfs_realign_test, 0,
101 "Number of realign tests done");
102 SYSCTL_INT(_vfs_nfs, OID_AUTO, realign_count, CTLFLAG_RW, &nfs_realign_count, 0,
103 "Number of mbuf realignments done");
104 SYSCTL_INT(_vfs_nfs, OID_AUTO, bufpackets, CTLFLAG_RW, &nfs_bufpackets, 0,
105 "Buffer reservation size 2 < x < 64");
106 SYSCTL_INT(_vfs_nfs, OID_AUTO, reconnects, CTLFLAG_RD, &nfs_reconnects, 0,
107 "Number of times the nfs client has had to reconnect");
108 SYSCTL_INT(_vfs_nfs, OID_AUTO, nfs3_jukebox_delay, CTLFLAG_RW, &nfs3_jukebox_delay, 0,
109 "Number of seconds to delay a retry after receiving EJUKEBOX");
110 SYSCTL_INT(_vfs_nfs, OID_AUTO, skip_wcc_data_onerr, CTLFLAG_RW, &nfs_skip_wcc_data_onerr, 0,
111 "Disable weak cache consistency checking when server returns an error");
113 static void nfs_down(struct nfsmount *, struct thread *, const char *,
115 static void nfs_up(struct nfsmount *, struct thread *, const char *,
117 static int nfs_msg(struct thread *, const char *, const char *, int);
119 extern int nfsv2_procid[];
121 struct nfs_cached_auth {
122 int ca_refs; /* refcount, including 1 from the cache */
123 uid_t ca_uid; /* uid that corresponds to this auth */
124 AUTH *ca_auth; /* RPC auth handle */
131 static enum nfs_rto_timer_t nfs_proct[NFS_NPROCS] = {
132 NFS_DEFAULT_TIMER, /* NULL */
133 NFS_GETATTR_TIMER, /* GETATTR */
134 NFS_DEFAULT_TIMER, /* SETATTR */
135 NFS_LOOKUP_TIMER, /* LOOKUP */
136 NFS_GETATTR_TIMER, /* ACCESS */
137 NFS_READ_TIMER, /* READLINK */
138 NFS_READ_TIMER, /* READ */
139 NFS_WRITE_TIMER, /* WRITE */
140 NFS_DEFAULT_TIMER, /* CREATE */
141 NFS_DEFAULT_TIMER, /* MKDIR */
142 NFS_DEFAULT_TIMER, /* SYMLINK */
143 NFS_DEFAULT_TIMER, /* MKNOD */
144 NFS_DEFAULT_TIMER, /* REMOVE */
145 NFS_DEFAULT_TIMER, /* RMDIR */
146 NFS_DEFAULT_TIMER, /* RENAME */
147 NFS_DEFAULT_TIMER, /* LINK */
148 NFS_READ_TIMER, /* READDIR */
149 NFS_READ_TIMER, /* READDIRPLUS */
150 NFS_DEFAULT_TIMER, /* FSSTAT */
151 NFS_DEFAULT_TIMER, /* FSINFO */
152 NFS_DEFAULT_TIMER, /* PATHCONF */
153 NFS_DEFAULT_TIMER, /* COMMIT */
154 NFS_DEFAULT_TIMER, /* NOOP */
158 * Choose the correct RTT timer for this NFS procedure.
160 static inline enum nfs_rto_timer_t
161 nfs_rto_timer(u_int32_t procnum)
163 return nfs_proct[procnum];
167 * Initialize the RTT estimator state for a new mount point.
170 nfs_init_rtt(struct nfsmount *nmp)
174 for (i = 0; i < NFS_MAX_TIMER; i++) {
175 nmp->nm_timers[i].rt_srtt = hz;
176 nmp->nm_timers[i].rt_deviate = 0;
177 nmp->nm_timers[i].rt_rtxcur = hz;
182 * Initialize sockets and congestion for a new NFS connection.
183 * We do not free the sockaddr if error.
186 nfs_connect(struct nfsmount *nmp)
188 int rcvreserve, sndreserve;
190 struct sockaddr *saddr;
191 struct ucred *origcred;
192 struct thread *td = curthread;
194 struct netconfig *nconf;
196 int one = 1, retries;
199 * We need to establish the socket using the credentials of
200 * the mountpoint. Some parts of this process (such as
201 * sobind() and soconnect()) will use the curent thread's
202 * credential instead of the socket credential. To work
203 * around this, temporarily change the current thread's
204 * credential to that of the mountpoint.
206 * XXX: It would be better to explicitly pass the correct
207 * credential to sobind() and soconnect().
209 origcred = td->td_ucred;
210 td->td_ucred = nmp->nm_mountp->mnt_cred;
214 if (nmp->nm_flag & NFSMNT_NFSV3)
216 else if (nmp->nm_flag & NFSMNT_NFSV4)
218 if (saddr->sa_family == AF_INET)
219 if (nmp->nm_sotype == SOCK_DGRAM)
220 nconf = getnetconfigent("udp");
222 nconf = getnetconfigent("tcp");
224 if (nmp->nm_sotype == SOCK_DGRAM)
225 nconf = getnetconfigent("udp6");
227 nconf = getnetconfigent("tcp6");
230 * Get buffer reservation size from sysctl, but impose reasonable
233 pktscale = nfs_bufpackets;
238 mtx_lock(&nmp->nm_mtx);
239 if (nmp->nm_sotype == SOCK_DGRAM) {
240 sndreserve = (nmp->nm_wsize + NFS_MAXPKTHDR) * pktscale;
241 rcvreserve = (max(nmp->nm_rsize, nmp->nm_readdirsize) +
242 NFS_MAXPKTHDR) * pktscale;
243 } else if (nmp->nm_sotype == SOCK_SEQPACKET) {
244 sndreserve = (nmp->nm_wsize + NFS_MAXPKTHDR) * pktscale;
245 rcvreserve = (max(nmp->nm_rsize, nmp->nm_readdirsize) +
246 NFS_MAXPKTHDR) * pktscale;
248 if (nmp->nm_sotype != SOCK_STREAM)
249 panic("nfscon sotype");
250 sndreserve = (nmp->nm_wsize + NFS_MAXPKTHDR +
251 sizeof (u_int32_t)) * pktscale;
252 rcvreserve = (nmp->nm_rsize + NFS_MAXPKTHDR +
253 sizeof (u_int32_t)) * pktscale;
255 mtx_unlock(&nmp->nm_mtx);
257 client = clnt_reconnect_create(nconf, saddr, NFS_PROG, vers,
258 sndreserve, rcvreserve);
259 CLNT_CONTROL(client, CLSET_WAITCHAN, "nfsreq");
260 if (nmp->nm_flag & NFSMNT_INT)
261 CLNT_CONTROL(client, CLSET_INTERRUPTIBLE, &one);
262 if (nmp->nm_flag & NFSMNT_RESVPORT)
263 CLNT_CONTROL(client, CLSET_PRIVPORT, &one);
264 if (nmp->nm_flag & NFSMNT_SOFT)
265 retries = nmp->nm_retry;
268 CLNT_CONTROL(client, CLSET_RETRIES, &retries);
270 mtx_lock(&nmp->nm_mtx);
271 if (nmp->nm_client) {
273 * Someone else already connected.
275 CLNT_RELEASE(client);
277 nmp->nm_client = client;
281 * Protocols that do not require connections may be optionally left
282 * unconnected for servers that reply from a port other than NFS_PORT.
284 if (!(nmp->nm_flag & NFSMNT_NOCONN)) {
285 mtx_unlock(&nmp->nm_mtx);
286 CLNT_CONTROL(client, CLSET_CONNECT, &one);
288 mtx_unlock(&nmp->nm_mtx);
291 /* Restore current thread's credentials. */
292 td->td_ucred = origcred;
294 mtx_lock(&nmp->nm_mtx);
295 /* Initialize other non-zero congestion variables */
297 mtx_unlock(&nmp->nm_mtx);
302 * NFS disconnect. Clean up and unlink.
305 nfs_disconnect(struct nfsmount *nmp)
309 mtx_lock(&nmp->nm_mtx);
310 if (nmp->nm_client) {
311 client = nmp->nm_client;
312 nmp->nm_client = NULL;
313 mtx_unlock(&nmp->nm_mtx);
315 rpc_gss_secpurge(client);
318 CLNT_RELEASE(client);
320 mtx_unlock(&nmp->nm_mtx);
325 nfs_safedisconnect(struct nfsmount *nmp)
332 nfs_getauth(struct nfsmount *nmp, struct ucred *cred)
335 rpc_gss_service_t svc;
339 switch (nmp->nm_secflavor) {
341 case RPCSEC_GSS_KRB5:
342 case RPCSEC_GSS_KRB5I:
343 case RPCSEC_GSS_KRB5P:
344 if (!nmp->nm_mech_oid) {
345 if (!rpc_gss_mech_to_oid("kerberosv5",
349 if (nmp->nm_secflavor == RPCSEC_GSS_KRB5)
350 svc = rpc_gss_svc_none;
351 else if (nmp->nm_secflavor == RPCSEC_GSS_KRB5I)
352 svc = rpc_gss_svc_integrity;
354 svc = rpc_gss_svc_privacy;
355 auth = rpc_gss_secfind(nmp->nm_client, cred,
356 nmp->nm_principal, nmp->nm_mech_oid, svc);
363 return (authunix_create(cred));
369 * Callback from the RPC code to generate up/down notifications.
372 struct nfs_feedback_arg {
373 struct nfsmount *nf_mount;
374 int nf_lastmsg; /* last tprintf */
376 struct thread *nf_td;
380 nfs_feedback(int type, int proc, void *arg)
382 struct nfs_feedback_arg *nf = (struct nfs_feedback_arg *) arg;
383 struct nfsmount *nmp = nf->nf_mount;
386 getmicrouptime(&now);
389 case FEEDBACK_REXMIT2:
390 case FEEDBACK_RECONNECT:
391 if (nf->nf_lastmsg + nmp->nm_tprintf_delay < now.tv_sec) {
392 nfs_down(nmp, nf->nf_td,
393 "not responding", 0, NFSSTA_TIMEO);
394 nf->nf_tprintfmsg = TRUE;
395 nf->nf_lastmsg = now.tv_sec;
400 nfs_up(nf->nf_mount, nf->nf_td,
401 "is alive again", NFSSTA_TIMEO, nf->nf_tprintfmsg);
409 * Check for badly aligned mbuf data and realign by copying the unaligned
410 * portion of the data into a new mbuf chain and freeing the portions
411 * of the old chain that were replaced.
413 * We cannot simply realign the data within the existing mbuf chain
414 * because the underlying buffers may contain other rpc commands and
415 * we cannot afford to overwrite them.
417 * We would prefer to avoid this situation entirely. The situation does
418 * not occur with NFS/UDP and is supposed to only occassionally occur
419 * with TCP. Use vfs.nfs.realign_count and realign_test to check this.
423 nfs_realign(struct mbuf **pm, int hsiz)
429 while ((m = *pm) != NULL) {
430 if ((m->m_len & 0x3) || (mtod(m, intptr_t) & 0x3)) {
432 * NB: we can't depend on m_pkthdr.len to help us
433 * decide what to do here. May not be worth doing
434 * the m_length calculation as m_copyback will
435 * expand the mbuf chain below as needed.
437 space = m_length(m, NULL);
438 if (space >= MINCLSIZE) {
439 /* NB: m_copyback handles space > MCLBYTES */
440 n = m_getcl(M_DONTWAIT, MT_DATA, 0);
442 n = m_get(M_DONTWAIT, MT_DATA);
446 * Align the remainder of the mbuf chain.
451 m_copyback(n, off, m->m_len, mtod(m, caddr_t));
466 * nfs_request - goes something like this
467 * - fill in request struct
468 * - links it into list
469 * - calls nfs_send() for first transmit
470 * - calls nfs_receive() to get reply
471 * - break down rpc header and return with nfs reply pointed to
473 * nb: always frees up mreq mbuf list
476 nfs_request(struct vnode *vp, struct mbuf *mreq, int procnum,
477 struct thread *td, struct ucred *cred, struct mbuf **mrp,
478 struct mbuf **mdp, caddr_t *dposp)
482 struct nfsmount *nmp;
489 enum nfs_rto_timer_t timer;
490 struct nfs_feedback_arg nf;
491 struct rpc_callextra ext;
495 /* Reject requests while attempting a forced unmount. */
496 if (vp->v_mount->mnt_kern_flag & MNTK_UNMOUNTF) {
500 nmp = VFSTONFS(vp->v_mount);
501 bzero(&nf, sizeof(struct nfs_feedback_arg));
504 getmicrouptime(&now);
505 nf.nf_lastmsg = now.tv_sec -
506 ((nmp->nm_tprintf_delay) - (nmp->nm_tprintf_initial_delay));
509 * XXX if not already connected call nfs_connect now. Longer
510 * term, change nfs_mount to call nfs_connect unconditionally
511 * and let clnt_reconnect_create handle reconnects.
516 auth = nfs_getauth(nmp, cred);
521 bzero(&ext, sizeof(ext));
524 ext.rc_feedback = nfs_feedback;
525 ext.rc_feedback_arg = &nf;
528 * Use a conservative timeout for RPCs other than getattr,
529 * lookup, read or write. The justification for doing "other"
530 * this way is that these RPCs happen so infrequently that
531 * timer est. would probably be stale. Also, since many of
532 * these RPCs are non-idempotent, a conservative timeout is
535 timer = nfs_rto_timer(procnum);
536 if (timer != NFS_DEFAULT_TIMER) {
537 ext.rc_timers = &nmp->nm_timers[timer - 1];
539 ext.rc_timers = NULL;
543 if (dtrace_nfsclient_nfs23_start_probe != NULL) {
547 if (nmp->nm_flag & NFSMNT_NFSV3) {
548 probe_id = nfsclient_nfs3_start_probes[procnum];
549 probe_procnum = procnum;
551 probe_id = nfsclient_nfs2_start_probes[procnum];
552 probe_procnum = nfsv2_procid[procnum];
555 (dtrace_nfsclient_nfs23_start_probe)(probe_id, vp,
556 mreq, cred, probe_procnum);
560 nfsstats.rpcrequests++;
562 timo.tv_sec = nmp->nm_timeo / NFS_HZ;
563 timo.tv_usec = (nmp->nm_timeo * 1000000) / NFS_HZ;
565 stat = CLNT_CALL_MBUF(nmp->nm_client, &ext,
566 (nmp->nm_flag & NFSMNT_NFSV3) ? procnum : nfsv2_procid[procnum],
570 * If there was a successful reply and a tprintf msg.
571 * tprintf a response.
573 if (stat == RPC_SUCCESS) {
575 } else if (stat == RPC_TIMEDOUT) {
577 } else if (stat == RPC_VERSMISMATCH) {
579 } else if (stat == RPC_PROGVERSMISMATCH) {
580 error = EPROTONOSUPPORT;
587 KASSERT(mrep != NULL, ("mrep shouldn't be NULL if no error\n"));
590 * Search for any mbufs that are not a multiple of 4 bytes long
591 * or with m_data not longword aligned.
592 * These could cause pointer alignment problems, so copy them to
593 * well aligned mbufs.
595 error = nfs_realign(&mrep, 2 * NFSX_UNSIGNED);
596 if (error == ENOMEM) {
603 dpos = mtod(mrep, caddr_t);
604 tl = nfsm_dissect(u_int32_t *, NFSX_UNSIGNED);
606 error = fxdr_unsigned(int, *tl);
607 if ((nmp->nm_flag & NFSMNT_NFSV3) &&
608 error == NFSERR_TRYLATER) {
611 waituntil = time_second + nfs3_jukebox_delay;
612 while (time_second < waituntil) {
613 (void) tsleep(&fake_wchan, PSOCK, "nqnfstry", hz);
619 * If the File Handle was stale, invalidate the lookup
620 * cache, just in case.
625 * Skip wcc data on NFS errors for now. NetApp filers
626 * return corrupt postop attrs in the wcc data for NFS
627 * err EROFS. Not sure if they could return corrupt
628 * postop attrs for others errors.
630 if ((nmp->nm_flag & NFSMNT_NFSV3) && !nfs_skip_wcc_data_onerr) {
634 error |= NFSERR_RETERR;
641 if (dtrace_nfsclient_nfs23_done_probe != NULL) {
645 if (nmp->nm_flag & NFSMNT_NFSV3) {
646 probe_id = nfsclient_nfs3_done_probes[procnum];
647 probe_procnum = procnum;
649 probe_id = nfsclient_nfs2_done_probes[procnum];
650 probe_procnum = (nmp->nm_flag & NFSMNT_NFSV3) ?
651 procnum : nfsv2_procid[procnum];
654 (dtrace_nfsclient_nfs23_done_probe)(probe_id, vp,
655 mreq, cred, probe_procnum, 0);
667 if (dtrace_nfsclient_nfs23_done_probe != NULL) {
671 if (nmp->nm_flag & NFSMNT_NFSV3) {
672 probe_id = nfsclient_nfs3_done_probes[procnum];
673 probe_procnum = procnum;
675 probe_id = nfsclient_nfs2_done_probes[procnum];
676 probe_procnum = (nmp->nm_flag & NFSMNT_NFSV3) ?
677 procnum : nfsv2_procid[procnum];
680 (dtrace_nfsclient_nfs23_done_probe)(probe_id, vp,
681 mreq, cred, probe_procnum, error);
691 * Mark all of an nfs mount's outstanding requests with R_SOFTTERM and
692 * wait for all requests to complete. This is used by forced unmounts
693 * to terminate any outstanding RPCs.
696 nfs_nmcancelreqs(struct nfsmount *nmp)
700 CLNT_CLOSE(nmp->nm_client);
705 * Any signal that can interrupt an NFS operation in an intr mount
706 * should be added to this set. SIGSTOP and SIGKILL cannot be masked.
708 int nfs_sig_set[] = {
718 * Check to see if one of the signals in our subset is pending on
719 * the process (in an intr mount).
722 nfs_sig_pending(sigset_t set)
726 for (i = 0 ; i < sizeof(nfs_sig_set)/sizeof(int) ; i++)
727 if (SIGISMEMBER(set, nfs_sig_set[i]))
733 * The set/restore sigmask functions are used to (temporarily) overwrite
734 * the process p_sigmask during an RPC call (for example). These are also
735 * used in other places in the NFS client that might tsleep().
738 nfs_set_sigmask(struct thread *td, sigset_t *oldset)
746 td = curthread; /* XXX */
748 /* Remove the NFS set of signals from newset */
750 mtx_lock(&p->p_sigacts->ps_mtx);
751 for (i = 0 ; i < sizeof(nfs_sig_set)/sizeof(int) ; i++) {
753 * But make sure we leave the ones already masked
754 * by the process, ie. remove the signal from the
755 * temporary signalmask only if it wasn't already
758 if (!SIGISMEMBER(td->td_sigmask, nfs_sig_set[i]) &&
759 !SIGISMEMBER(p->p_sigacts->ps_sigignore, nfs_sig_set[i]))
760 SIGDELSET(newset, nfs_sig_set[i]);
762 mtx_unlock(&p->p_sigacts->ps_mtx);
764 kern_sigprocmask(td, SIG_SETMASK, &newset, oldset, 0);
768 nfs_restore_sigmask(struct thread *td, sigset_t *set)
771 td = curthread; /* XXX */
772 kern_sigprocmask(td, SIG_SETMASK, set, NULL, 0);
776 * NFS wrapper to msleep(), that shoves a new p_sigmask and restores the
777 * old one after msleep() returns.
780 nfs_msleep(struct thread *td, void *ident, struct mtx *mtx, int priority, char *wmesg, int timo)
786 if ((priority & PCATCH) == 0)
787 return msleep(ident, mtx, priority, wmesg, timo);
789 td = curthread; /* XXX */
790 nfs_set_sigmask(td, &oldset);
791 error = msleep(ident, mtx, priority, wmesg, timo);
792 nfs_restore_sigmask(td, &oldset);
798 * Test for a termination condition pending on the process.
799 * This is used for NFSMNT_INT mounts.
802 nfs_sigintr(struct nfsmount *nmp, struct thread *td)
807 /* Terminate all requests while attempting a forced unmount. */
808 if (nmp->nm_mountp->mnt_kern_flag & MNTK_UNMOUNTF)
810 if (!(nmp->nm_flag & NFSMNT_INT))
816 tmpset = p->p_siglist;
817 SIGSETOR(tmpset, td->td_siglist);
818 SIGSETNAND(tmpset, td->td_sigmask);
819 mtx_lock(&p->p_sigacts->ps_mtx);
820 SIGSETNAND(tmpset, p->p_sigacts->ps_sigignore);
821 mtx_unlock(&p->p_sigacts->ps_mtx);
822 if ((SIGNOTEMPTY(p->p_siglist) || SIGNOTEMPTY(td->td_siglist))
823 && nfs_sig_pending(tmpset)) {
832 nfs_msg(struct thread *td, const char *server, const char *msg, int error)
836 p = td ? td->td_proc : NULL;
838 tprintf(p, LOG_INFO, "nfs server %s: %s, error %d\n", server,
841 tprintf(p, LOG_INFO, "nfs server %s: %s\n", server, msg);
847 nfs_down(struct nfsmount *nmp, struct thread *td, const char *msg,
848 int error, int flags)
852 mtx_lock(&nmp->nm_mtx);
853 if ((flags & NFSSTA_TIMEO) && !(nmp->nm_state & NFSSTA_TIMEO)) {
854 nmp->nm_state |= NFSSTA_TIMEO;
855 mtx_unlock(&nmp->nm_mtx);
856 vfs_event_signal(&nmp->nm_mountp->mnt_stat.f_fsid,
859 mtx_unlock(&nmp->nm_mtx);
860 mtx_lock(&nmp->nm_mtx);
861 if ((flags & NFSSTA_LOCKTIMEO) && !(nmp->nm_state & NFSSTA_LOCKTIMEO)) {
862 nmp->nm_state |= NFSSTA_LOCKTIMEO;
863 mtx_unlock(&nmp->nm_mtx);
864 vfs_event_signal(&nmp->nm_mountp->mnt_stat.f_fsid,
867 mtx_unlock(&nmp->nm_mtx);
868 nfs_msg(td, nmp->nm_mountp->mnt_stat.f_mntfromname, msg, error);
872 nfs_up(struct nfsmount *nmp, struct thread *td, const char *msg,
873 int flags, int tprintfmsg)
878 nfs_msg(td, nmp->nm_mountp->mnt_stat.f_mntfromname, msg, 0);
881 mtx_lock(&nmp->nm_mtx);
882 if ((flags & NFSSTA_TIMEO) && (nmp->nm_state & NFSSTA_TIMEO)) {
883 nmp->nm_state &= ~NFSSTA_TIMEO;
884 mtx_unlock(&nmp->nm_mtx);
885 vfs_event_signal(&nmp->nm_mountp->mnt_stat.f_fsid,
888 mtx_unlock(&nmp->nm_mtx);
890 mtx_lock(&nmp->nm_mtx);
891 if ((flags & NFSSTA_LOCKTIMEO) && (nmp->nm_state & NFSSTA_LOCKTIMEO)) {
892 nmp->nm_state &= ~NFSSTA_LOCKTIMEO;
893 mtx_unlock(&nmp->nm_mtx);
894 vfs_event_signal(&nmp->nm_mountp->mnt_stat.f_fsid,
897 mtx_unlock(&nmp->nm_mtx);