mtd/fs/jffs2 gc.c,1.125,1.126

David Woodhouse dwmw2 at infradead.org
Mon Nov 3 09:46:15 EST 2003


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

Modified Files:
	gc.c 
Log Message:
Fix inocache_lock handling

Index: gc.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs2/gc.c,v
retrieving revision 1.125
retrieving revision 1.126
diff -u -r1.125 -r1.126
--- gc.c	3 Nov 2003 13:30:29 -0000	1.125
+++ gc.c	3 Nov 2003 14:46:12 -0000	1.126
@@ -330,12 +330,17 @@
 		spin_unlock(&c->inocache_lock);
 
 		ret = jffs2_garbage_collect_pristine(c, ic, raw);
-		jffs2_set_inocache_state(c, ic, INO_STATE_CHECKEDABSENT);
 
-		if (ret != -EBADFD)
+		spin_lock(&c->inocache_lock);
+		ic->state = INO_STATE_CHECKEDABSENT;
+		wake_up(&c->inocache_wq);
+
+		if (ret != -EBADFD) {
+			spin_unlock(&c->inocache_lock);
 			goto release_sem;
+		}
 
-		/* Fall through if it wanted us to */
+		/* Fall through if it wanted us to, with inocache_lock held */
 	}
 
 	/* FIXME: We still have the inocache_lock held. This is ugly.
@@ -403,10 +408,11 @@
 			D1(printk(KERN_DEBUG "ilookup() failed for ino #%u; inode is probably deleted.\n",
 				  inum));
 
-			spin_lock(c->inocache_lock);
+			spin_lock(&c->inocache_lock);
 			ic = jffs2_get_ino_cache(c, inum);
 			if (!ic) {
 				D1(printk(KERN_DEBUG "Inode cache for ino #%u is gone.\n", inum));
+				spin_unlock(&c->inocache_lock);
 				return 0;
 			}
 			if (ic->state != INO_STATE_CHECKEDABSENT) {
@@ -414,9 +420,10 @@
 				D1(printk(KERN_DEBUG "Waiting for ino #%u in state %d\n",
 					  ic->ino, ic->state));
 				sleep_on_spinunlock(&c->inocache_wq, &c->inocache_lock);
-				D1(printk(KERN_DEBUG "Waited for ino #%u. State now %d\n",
-					  ic->ino, ic->state));
+			} else {
+				spin_unlock(&c->inocache_lock);
 			}
+
 			return 0;
 		}
 	} else {




More information about the linux-mtd-cvs mailing list