Re: Longstanding bug in tty_write/swap/nfs_readpage interaction

Olaf Kirch (okir@monad.swb.de)
Fri, 13 Dec 1996 17:08:11 +0100


On Fri, 13 Dec 1996 15:17:47 +0200, Linus Torvalds wrote:
> Personally I
> think this is a NFS problem - the page-read function shouldn't care about
> process state details like TASK_RUNNING because reading a page isn't
> really a "process" thing at all.

Alright, the guru hath spoken :-) Below I'm appending a patch against
2.1.14 that should do the right thing for all calls to schedule() within
the nfs code. In fact more than one place is affected by this misunder-
standing; including code that has been in the kernel since the very
first nfs implementation... Just scary.

Cheers
Olaf

-- 
Olaf Kirch         |  --- o --- Nous sommes du soleil we love when we play
okir@monad.swb.de  |    / | \   sol.dhoop.naytheet.ah kin.ir.samse.qurax
             For my PGP public key, finger okir@brewhq.swb.de.
------------------------------------------------------------------
diff -ur nfs.orig/bio.c nfs/bio.c
--- nfs.orig/bio.c	Wed Nov 27 09:47:53 1996
+++ nfs/bio.c	Fri Dec 13 16:58:42 1996
@@ -144,8 +144,10 @@
 	if (result == -EAGAIN && req->rq_retries--) {
 		dprintk("BIO: retransmitting request.\n");
 		memset(&req->rq_rpcreq, 0, sizeof(struct rpc_ioreq));
-		while (rpc_reserve(server->rsock, &req->rq_rpcreq, 1) < 0)
+		while (rpc_reserve(server->rsock, &req->rq_rpcreq, 1) < 0) {
+			current->state = TASK_RUNNING;
 			schedule();
+		}
 		current->fsuid = req->rq_fsuid;
 		current->fsgid = req->rq_fsgid;
 		for (i = 0; i < NGROUPS; i++)
diff -ur nfs.orig/nfsiod.c nfs/nfsiod.c
--- nfs.orig/nfsiod.c	Mon Oct  7 14:49:25 1996
+++ nfs/nfsiod.c	Fri Dec 13 16:58:52 1996
@@ -77,6 +77,7 @@
 {
 	dprintk("BIO: enqueuing request %p\n", &req->rq_rpcreq);
 	wake_up(&req->rq_wait);
+	current->state = TASK_RUNNING;
 	schedule();
 }
 
diff -ur nfs.orig/proc.c nfs/proc.c
--- nfs.orig/proc.c	Wed Nov 27 09:49:31 1996
+++ nfs/proc.c	Fri Dec 13 16:59:04 1996
@@ -81,6 +81,7 @@
 	int *i;
 
 	while (!(i = (int *)kmalloc(size+NFS_SLACK_SPACE,GFP_NFS))) {
+		current->state = TASK_RUNNING;
 		schedule();
 	}
 	return i;
diff -ur nfs.orig/symlink.c nfs/symlink.c
--- nfs.orig/symlink.c	Wed Nov 27 09:47:54 1996
+++ nfs/symlink.c	Fri Dec 13 16:59:40 1996
@@ -80,6 +80,7 @@
 		return error;
 	}
 	while ((res2 = (char *) kmalloc(NFS_MAXPATHLEN + 1, GFP_NFS)) == NULL) {
+		current->state = TASK_RUNNING;
 		schedule();
 	}
 	memcpy(res2, res, len);