summaryrefslogtreecommitdiffstats
path: root/sys/nfsclient
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/nfsclient
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/nfsclient')
-rw-r--r--sys/nfsclient/nfs_socket.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/sys/nfsclient/nfs_socket.c b/sys/nfsclient/nfs_socket.c
index a796c4c..6683497 100644
--- a/sys/nfsclient/nfs_socket.c
+++ b/sys/nfsclient/nfs_socket.c
@@ -1060,8 +1060,11 @@ tryagain:
* If there was a successful reply and a tprintf msg.
* tprintf a response.
*/
- if (!error)
+ if (!error) {
+ mtx_lock(&Giant);
nfs_up(rep, nmp, rep->r_td, "is alive again", NFSSTA_TIMEO);
+ mtx_unlock(&Giant);
+ }
mrep = rep->r_mrep;
md = rep->r_md;
dpos = rep->r_dpos;
@@ -1182,6 +1185,7 @@ nfs_timer(void *arg)
getmicrouptime(&now);
s = splnet();
+ mtx_lock(&Giant); /* nfs_down -> tprintf */
mtx_lock(&nfs_reqq_mtx);
TAILQ_FOREACH(rep, &nfs_reqq, r_chain) {
nmp = rep->r_nmp;
@@ -1294,6 +1298,7 @@ nfs_timer(void *arg)
}
}
mtx_unlock(&nfs_reqq_mtx);
+ mtx_unlock(&Giant); /* nfs_down -> tprintf */
splx(s);
callout_reset(&nfs_callout, nfs_ticks, nfs_timer, NULL);
}
@@ -1625,6 +1630,8 @@ nfs_msg(struct thread *td, const char *server, const char *msg, int error)
{
struct proc *p;
+ GIANT_REQUIRED; /* tprintf */
+
p = td ? td->td_proc : NULL;
if (error) {
tprintf(p, LOG_INFO, "nfs server %s: %s, error %d\n", server,
@@ -1644,6 +1651,8 @@ nfs_down(rep, nmp, td, msg, error, flags)
int error, flags;
{
+ GIANT_REQUIRED; /* nfs_msg */
+
if (nmp == NULL)
return;
if ((flags & NFSSTA_TIMEO) && !(nmp->nm_state & NFSSTA_TIMEO)) {
@@ -1671,6 +1680,9 @@ nfs_up(rep, nmp, td, msg, flags)
const char *msg;
int flags;
{
+
+ GIANT_REQUIRED; /* nfs_msg */
+
if (nmp == NULL)
return;
if ((rep == NULL) || (rep->r_flags & R_TPRINTFMSG) != 0)
OpenPOWER on IntegriCloud