Module Name:    src
Committed By:   pooka
Date:           Mon Nov 15 20:31:41 UTC 2010

Modified Files:
        src/sys/fs/puffs: puffs_msgif.c

Log Message:
Apply patch from PR kern/44093 by yamt:

Interrupt server wait only on certain signals (same set at nfs -i)
instead of all signals.  According to the PR this helps with
"git clone" run on a puffs file system.


To generate a diff of this commit:
cvs rdiff -u -r1.83 -r1.84 src/sys/fs/puffs/puffs_msgif.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/fs/puffs/puffs_msgif.c
diff -u src/sys/fs/puffs/puffs_msgif.c:1.83 src/sys/fs/puffs/puffs_msgif.c:1.84
--- src/sys/fs/puffs/puffs_msgif.c:1.83	Fri Nov 12 17:46:09 2010
+++ src/sys/fs/puffs/puffs_msgif.c	Mon Nov 15 20:31:41 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: puffs_msgif.c,v 1.83 2010/11/12 17:46:09 pooka Exp $	*/
+/*	$NetBSD: puffs_msgif.c,v 1.84 2010/11/15 20:31:41 pooka Exp $	*/
 
 /*
  * Copyright (c) 2005, 2006, 2007  Antti Kantee.  All Rights Reserved.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: puffs_msgif.c,v 1.83 2010/11/12 17:46:09 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: puffs_msgif.c,v 1.84 2010/11/15 20:31:41 pooka Exp $");
 
 #include <sys/param.h>
 #include <sys/atomic.h>
@@ -378,17 +378,30 @@
 	if (__predict_false((park->park_flags & PARKFLAG_WANTREPLY)
 	   && (park->park_flags & PARKFLAG_CALL) == 0
 	   && (l->l_flag & LW_PENDSIG) != 0 && sigispending(l, 0))) {
-		park->park_flags |= PARKFLAG_HASERROR;
-		preq->preq_rv = EINTR;
-		if (PUFFSOP_OPCLASS(preq->preq_opclass) == PUFFSOP_VN
-		    && (preq->preq_optype == PUFFS_VN_INACTIVE
-		     || preq->preq_optype == PUFFS_VN_RECLAIM)) {
-			park->park_preq->preq_opclass |= PUFFSOPFLAG_FAF;
-			park->park_flags &= ~PARKFLAG_WANTREPLY;
-			DPRINTF(("puffs_msg_enqueue: converted to FAF %p\n",
-			    park));
-		} else {
-			return;
+		sigset_t ss;
+
+		/*
+		 * see the comment about signals in puffs_msg_wait.
+		 */
+		sigpending1(l, &ss);
+		if (sigismember(&ss, SIGINT) ||
+		    sigismember(&ss, SIGTERM) ||
+		    sigismember(&ss, SIGKILL) ||
+		    sigismember(&ss, SIGHUP) ||
+		    sigismember(&ss, SIGQUIT)) {
+			park->park_flags |= PARKFLAG_HASERROR;
+			preq->preq_rv = EINTR;
+			if (PUFFSOP_OPCLASS(preq->preq_opclass) == PUFFSOP_VN
+			    && (preq->preq_optype == PUFFS_VN_INACTIVE
+			     || preq->preq_optype == PUFFS_VN_RECLAIM)) {
+				park->park_preq->preq_opclass |=
+				    PUFFSOPFLAG_FAF;
+				park->park_flags &= ~PARKFLAG_WANTREPLY;
+				DPRINTF(("puffs_msg_enqueue: "
+				    "converted to FAF %p\n", park));
+			} else {
+				return;
+			}
 		}
 	}
 
@@ -426,10 +439,30 @@
 int
 puffs_msg_wait(struct puffs_mount *pmp, struct puffs_msgpark *park)
 {
+	lwp_t *l = curlwp;
+	proc_t *p = l->l_proc;
 	struct puffs_req *preq = park->park_preq; /* XXX: hmmm */
+	sigset_t ss;
+	sigset_t oss;
 	int error = 0;
 	int rv;
 
+	/*
+	 * block unimportant signals.
+	 *
+	 * The set of "important" signals here was chosen to be same as
+	 * nfs interruptible mount.
+	 */
+	sigfillset(&ss);
+	sigdelset(&ss, SIGINT);
+	sigdelset(&ss, SIGTERM);
+	sigdelset(&ss, SIGKILL);
+	sigdelset(&ss, SIGHUP);
+	sigdelset(&ss, SIGQUIT);
+	mutex_enter(p->p_lock);
+	sigprocmask1(l, SIG_BLOCK, &ss, &oss);
+	mutex_exit(p->p_lock);
+
 	mutex_enter(&pmp->pmp_lock);
 	puffs_mp_reference(pmp);
 	mutex_exit(&pmp->pmp_lock);
@@ -503,6 +536,10 @@
 	puffs_mp_release(pmp);
 	mutex_exit(&pmp->pmp_lock);
 
+	mutex_enter(p->p_lock);
+	sigprocmask1(l, SIG_SETMASK, &oss, NULL);
+	mutex_exit(p->p_lock);
+
 	return rv;
 }
 

Reply via email to