summaryrefslogtreecommitdiffstats
path: root/sys/rpc
diff options
context:
space:
mode:
authorrwatson <rwatson@FreeBSD.org>2005-09-19 16:51:43 +0000
committerrwatson <rwatson@FreeBSD.org>2005-09-19 16:51:43 +0000
commitc479a90eb8129ad770ff6daba981e9f20af69e6f (patch)
treee3c313c0b77fbcc1f434ec162a95a06a9e05a773 /sys/rpc
parent745da316335f104d267ad6c4b565be45311e5d6e (diff)
downloadFreeBSD-src-c479a90eb8129ad770ff6daba981e9f20af69e6f.zip
FreeBSD-src-c479a90eb8129ad770ff6daba981e9f20af69e6f.tar.gz
Add GIANT_REQUIRED and WITNESS sleep warnings to uprintf() and tprintf(),
as they both interact with the tty code (!MPSAFE) and may sleep if the tty buffer is full (per comment). Modify all consumers of uprintf() and tprintf() to hold Giant around calls into these functions. In most cases, this means adding an acquisition of Giant immediately around the function. In some cases (nfs_timer()), it means acquiring Giant higher up in the callout. With these changes, UFS no longer panics on SMP when either blocks are exhausted or inodes are exhausted under load due to races in the tty code when running without Giant. NB: Some reduction in calls to uprintf() in the svr4 code is probably desirable. NB: In the case of nfs_timer(), calling uprintf() while holding a mutex, or even in a callout at all, is a bad idea, and will generate warnings and potential upset. This needs to be fixed, but was a problem before this change. NB: uprintf()/tprintf() sleeping is generally a bad ideas, as is having non-MPSAFE tty code. MFC after: 1 week
Diffstat (limited to 'sys/rpc')
-rw-r--r--sys/rpc/rpcclnt.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/sys/rpc/rpcclnt.c b/sys/rpc/rpcclnt.c
index 3c32e5c..698c956 100644
--- a/sys/rpc/rpcclnt.c
+++ b/sys/rpc/rpcclnt.c
@@ -1254,9 +1254,12 @@ rpcclnt_request(rpc, mrest, procnum, td, cred, reply)
* If there was a successful reply and a tprintf msg. tprintf a
* response.
*/
- if (!error && (task->r_flags & R_TPRINTFMSG))
+ if (!error && (task->r_flags & R_TPRINTFMSG)) {
+ mtx_lock(&Giant);
rpcclnt_msg(task->r_td, rpc->rc_prog->prog_name,
"is alive again");
+ mtx_unlock(&Giant);
+ }
/* free request header (leaving mrest) */
mheadend->m_next = NULL;
@@ -1390,6 +1393,7 @@ rpcclnt_timer(arg)
#else
s = splnet();
#endif
+ mtx_lock(&Giant); /* rpc_msg -> tprintf */
TAILQ_FOREACH(rep, &rpctask_q, r_chain) {
rpc = rep->r_rpcclnt;
if (rep->r_mrep || (rep->r_flags & R_SOFTTERM))
@@ -1474,6 +1478,7 @@ rpcclnt_timer(arg)
}
}
}
+ mtx_unlock(&Giant); /* rpc_msg -> tprintf */
splx(s);
#ifdef __OpenBSD__
@@ -1775,6 +1780,8 @@ rpcclnt_msg(p, server, msg)
tprintf_close(tpr);
RPC_RETURN(0);
#else
+ GIANT_REQUIRED;
+
tprintf(p ? p->td_proc : NULL, LOG_INFO,
"nfs server %s: %s\n", server, msg);
RPC_RETURN(0);
OpenPOWER on IntegriCloud