[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Freeing unlinked inodes in JFFS2

RTeli@xxxxxxx.com said:
> It seems like JFFS2 doesn't free inode_cache & raws for inodes having
> nlink == 0, while mounting. Although it marks all raw nodes belonging
> to that inode as obsolete. I am not able to figure out the reason
> behind keeping these inodes in inocache_list / in core all the time.
> These may be deleted files. They need not be in inocache_list.

> If anyone has any idea about why JFFS2 is doing so pls let me know. 

I can remember (or see) no reason for doing this. Looking at the
commented-out code to remove the ic from the hash table and free it, I
suspect that I just did it the stupid way and got bitten by slab poisoning
when the for_each_inode loop followed the ->next pointer in the freed ic,
'temporarily' commented out the actual freeing of the ic and promptly forgot
about it.

Try this:

Index: build.c
RCS file: /home/cvs/mtd/fs/jffs2/build.c,v
retrieving revision 1.16
diff -u -r1.16 build.c
--- build.c	2001/03/15 15:38:23	1.16
+++ build.c	2001/12/28 14:46:12
@@ -45,6 +45,7 @@
 #define for_each_inode(i, c, ic) for (i=0; i<INOCACHE_HASHSIZE; i++) for (ic=c->inocache_list[i]; ic; ic=ic->next) 
+#define for_each_inode_safe(i, c, ic, tmp) for (i=0; i<INOCACHE_HASHSIZE; i++) for (tmp=ic=c->inocache_list[i]; ic; ic=tmp, tmp=ic->next) 
 /* Scan plan:
  - Scan physical nodes. Build map of inodes/dirents. Allocate inocaches as we go
@@ -82,9 +83,11 @@
 	   a fairly uncommon occurrence, it's not so evil to do it this
 	   way. Recursion bad. */
 	do { 
+		struct jffs2_inode_cache *ic_next;
 		D1(printk(KERN_DEBUG "Pass 2 (re)starting\n"));
 		ret = 0;
-		for_each_inode(i, c, ic) {
+		for_each_inode_safe(i, c, ic, ic_next) {
 			D1(printk(KERN_DEBUG "Pass 2: ino #%u, nlink %d, ic %p, nodes %p\n", ic->ino, ic->nlink, ic, ic->nodes));
 			if (ic->nlink)
@@ -251,7 +254,7 @@
 	ic->scan = NULL;
-	//	jffs2_del_ino_cache(c, ic);
-	//	jffs2_free_inode_cache(ic);
+	jffs2_del_ino_cache(c, ic);
+	jffs2_free_inode_cache(ic);
 	return ret;


To unsubscribe from this list: send the line "unsubscribe jffs-dev" in
the body of a message to majordomo@xxxxxxx.com