[1637] in SIPB_Linux_Development

home help back first fref pref prev next nref lref last post

Re: (fwd) Linux patch to fs/inode.c, mark #3

daemon@ATHENA.MIT.EDU (Theodore Y. Ts'o)
Mon Mar 31 15:34:50 1997

Date: Mon, 31 Mar 1997 15:34:32 -0500
From: "Theodore Y. Ts'o" <tytso@MIT.EDU>
To: Derek Atkins <warlord@MIT.EDU>
Cc: linux-dev@MIT.EDU
In-Reply-To: Derek Atkins's message of 31 Mar 1997 14:34:07 -0500,
	<sjmd8sfq2j4.fsf@bobbi-harlow.MIT.EDU>

   From: Derek Atkins <warlord@MIT.EDU>
   Date: 31 Mar 1997 14:34:07 -0500

   I spent a while with Ted today trying to track down the Linux-AFS
   cache corruption..  We went through the AFS cache code, and he seemed
   to think that there wasn't much of a problem.  Under a system that is
   heavily loaded, he thinks that there is a race condition in the Linux
   kernel where it is possible for two opened files to get the same inode
   structure.

Try this patch instead.  I've refined the patch a bit more since my
meeting with Derek this morning....  As before, it's against 2.0.29

						- Ted

--- fs/inode.c	1997/03/31 17:05:03	1.1
+++ fs/inode.c	1997/03/31 20:02:49
@@ -147,7 +147,8 @@
 
 static inline void lock_inode(struct inode * inode)
 {
-	wait_on_inode(inode);
+	while (inode->i_lock)
+		wait_on_inode(inode);
 	inode->i_lock = 1;
 }
 
@@ -173,8 +174,8 @@
 {
 	struct wait_queue * wait;
 
+	lock_inode(inode);
 	truncate_inode_pages(inode, 0);
-	wait_on_inode(inode);
 	if (IS_WRITABLE(inode)) {
 		if (inode->i_sb && inode->i_sb->dq_op)
 			inode->i_sb->dq_op->drop(inode);
@@ -186,6 +187,7 @@
 		nr_free_inodes++;
 	memset(inode,0,sizeof(*inode));
 	((volatile struct inode *) inode)->i_wait = wait;
+	wake_up(&inode->i_wait);
 	insert_inode_free(inode);
 }
 
@@ -512,6 +514,7 @@
 		sleep_on(&inode_wait);
 		goto repeat;
 	}
+found_good:
 	if (best->i_lock) {
 		wait_on_inode(best);
 		goto repeat;
@@ -522,7 +525,7 @@
 	}
 	if (best->i_count)
 		goto repeat;
-found_good:
+	
 	clear_inode(best);
 	best->i_count = 1;
 	best->i_nlink = 1;

home help back first fref pref prev next nref lref last post