mtd/fs/jffs2 gc.c,1.119,1.120

David Woodhouse dwmw2 at infradead.org
Fri Oct 31 09:55:05 EST 2003


Update of /home/cvs/mtd/fs/jffs2
In directory phoenix.infradead.org:/tmp/cvs-serv18739

Modified Files:
	gc.c 
Log Message:
Better race workaround. Don't attempt to read an inode with nlink zero

Index: gc.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs2/gc.c,v
retrieving revision 1.119
retrieving revision 1.120
diff -u -r1.119 -r1.120
--- gc.c	30 Oct 2003 15:21:58 -0000	1.119
+++ gc.c	31 Oct 2003 14:55:02 -0000	1.120
@@ -186,7 +186,7 @@
 		ic->state = INO_STATE_CHECKING;
 		spin_unlock(&c->inocache_lock);
 
-		D1(printk(KERN_DEBUG "jffs2_garbage_collect_pass() triggering inode scan of ino#%d\n", ic->ino));
+		D1(printk(KERN_DEBUG "jffs2_garbage_collect_pass() triggering inode scan of ino#%u\n", ic->ino));
 
 		ret = jffs2_do_crccheck_inode(c, ic);
 		if (ret)
@@ -273,9 +273,13 @@
 		   we're at it, so we set the state accordingly */
 		if (ref_flags(raw) == REF_PRISTINE)
 			ic->state = INO_STATE_GC;
-		else {
+		else if (ic->nlink) {
 			D1(printk(KERN_DEBUG "Ino #%u is absent but node not REF_PRISTINE. Reading.\n", 
 				  inum));
+		} else {
+			D1(printk(KERN_WARNING "Waiting for currently-being-deleted ino #%u to go away.\n",
+				  inum));
+			goto wait;
 		}
 		break;
 
@@ -303,7 +307,7 @@
 		   to do the GC. However, sometimes read_inode() needs to get
 		   the alloc_sem() (for marking nodes invalid) so we must
 		   drop the alloc_sem before sleeping. */
-
+	wait:
 		up(&c->alloc_sem);
 		D1(printk(KERN_DEBUG "jffs2_garbage_collect_pass() waiting for ino #%u in state %d\n",
 			  inum, ic->state));
@@ -375,13 +379,9 @@
 	int ret = 0;
 
 	inode = iget(OFNI_BS_2SFFJ(c), ic->ino);
+	if (!inode)
+		return -ENOMEM;
 	if (is_bad_inode(inode)) {
-		if (!ic->nlink && ic->state == INO_STATE_PRESENT) {
-			/* It _did_ exist but doesn't any more -- it was being deleted
-			   while we tried to iget() it. */
-			D1(printk(KERN_NOTICE "Ino #%u was present but iget() failed. VFS race blamed; retrying...\n", ic->ino));
-			goto put_out;
-		}
 		printk(KERN_NOTICE "Eep. read_inode() failed for ino #%u. nlink %d, state %d\n", ic->ino, ic->nlink, ic->state);
 		/* NB. This will happen again. We need to do something appropriate here. */
 		ret = -EIO;




More information about the linux-mtd-cvs mailing list