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

AAARGHH. Davids lost mail.



Anything I write to this list that contains the word sub-scribe (without
the -) is snarfed by majordomo as an admin request. This is my third
attempt at reposting the message that David got snarfed since he quoted
the un-sub-scribe line before... gotta change that majordomo rule :) 

--
Grr. That message had words in it last time I saw it. Unfortunately it 
doesn't seem to be in my outgoing folder either.

Note to self: Never use a mail system you don't admin yourself.

The original went something like this...

chayden@xxxxxxx.com said:
> I think this has been a known problem for a while.  

Not known by me, or it would have been fixed sooner.

> The problem is, there is no reference count field in the inode structure,
> so it automatically gets blown away.  It wouldn't be too much coding to add
> the field and make sure it gets checked at every close...

I agree. I haven't had time to check this patch for correctness properly, 
so I haven't committed it to CVS, but it looks right at first glance, and 
definitely stops the test case from oopsing.


Index: include/linux/jffs.h
===================================================================
RCS file: /home/cvs/mtd/include/linux/jffs.h,v
retrieving revision 1.14
diff -u -r1.14 jffs.h
--- include/linux/jffs.h	2000/08/21 10:41:45	1.14
+++ include/linux/jffs.h	2000/11/28 14:34:12
@@ -144,6 +144,7 @@
 	__u8 nsize;   /* Name length.  */
 	__u8 nlink;   /* Number of links.  */
 	__u8 deleted; /* Has this file been deleted?  */
+	int users;    /* Number of times this file is in use */
 	char *name;   /* The name of this file; NULL-terminated.  */
 	__u32 size;   /* The total size of the file's data.  */
 	__u32 highest_version; /* The highest version number of this file.  */
Index: fs/jffs/inode-v22.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs/inode-v22.c,v
retrieving revision 1.52
diff -u -r1.52 inode-v22.c
--- fs/jffs/inode-v22.c	2000/11/15 22:04:12	1.52
+++ fs/jffs/inode-v22.c	2000/11/28 14:34:16
@@ -347,6 +347,7 @@
 	struct super_block *sb;
 	struct inode *inode;
 	struct jffs_control *c;
+	struct jffs_file *f;
 
 	inode = get_empty_inode();
 	if (!inode) {
@@ -373,7 +374,11 @@
 	inode->i_blocks = (inode->i_size + 511) >> 9;
 	inode->i_version = 0;
 	inode->i_flags = sb->s_flags;
-	inode->u.generic_ip = (void *)jffs_find_file(c, raw_inode->ino);
+	
+	f = jffs_find_file(c, raw_inode->ino);
+	if (f)
+		f->users++;
+	inode->u.generic_ip = (void *)f;
 
 	insert_inode_hash(inode);
 
@@ -1026,9 +1031,6 @@
 	dir->i_ctime = dir->i_mtime = CURRENT_TIME;
 	mark_inode_dirty(dir);
 	inode->i_nlink--;
-	if (inode->i_nlink == 0) {
-		inode->u.generic_ip = 0;
-	}
 	inode->i_ctime = dir->i_ctime;
 	mark_inode_dirty(inode);
 
@@ -1847,6 +1849,8 @@
 		jffs_read_data(f, (char *)&rdev, 0, sizeof(kdev_t));
 		inode->i_rdev = kdev_t_to_nr(rdev);
 	}
+	if (inode->u.generic_ip == f)
+		f->users++;
 	D3(printk (KERN_NOTICE "read_inode(): up biglock\n"));
 	up(&c->fmc->biglock);
 }
@@ -1855,6 +1859,7 @@
 void
 jffs_delete_inode(struct inode *inode)
 {
+	struct jffs_file *f = (struct jffs_file *)inode->u.generic_ip;
 	D3(printk("jffs_delete_inode(): inode->i_ino == %lu\n",
 		  inode->i_ino));
 
@@ -1862,6 +1867,10 @@
 	inode->i_size = 0;
 	inode->i_blocks = 0;
 	clear_inode(inode);
+	if (inode->i_nlink == 0) {
+		f->users--;
+		jffs_possibly_delete_file(f);
+	}
 
 	unlock_kernel();
 }
Index: fs/jffs/inode-v23.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs/inode-v23.c,v
retrieving revision 1.49
diff -u -r1.49 inode-v23.c
--- fs/jffs/inode-v23.c	2000/11/21 08:51:00	1.49
+++ fs/jffs/inode-v23.c	2000/11/28 14:34:19
@@ -343,6 +343,7 @@
 	struct super_block * sb;
 	struct inode * inode;
 	struct jffs_control *c;
+	struct jffs_file *f;
 
 	sb = dir->i_sb;
 	inode = new_inode(sb);
@@ -366,8 +367,12 @@
 	inode->i_blksize = PAGE_SIZE;
 	inode->i_blocks = (inode->i_size + 511) >> 9;
 	inode->i_version = 0;
-	inode->u.generic_ip = (void *)jffs_find_file(c, raw_inode->ino);
 
+	f = jffs_find_file(c, raw_inode->ino);
+	if (f)
+		f->users++;
+
+	inode->u.generic_ip = (void *)f;
 	insert_inode_hash(inode);
 
 	return inode;
@@ -1016,9 +1021,6 @@
 	dir->i_ctime = dir->i_mtime = CURRENT_TIME;
 	mark_inode_dirty(dir);
 	inode->i_nlink--;
-	if (inode->i_nlink == 0) {
-		inode->u.generic_ip = 0;
-	}
 	inode->i_ctime = dir->i_ctime;
 	mark_inode_dirty(inode);
 
@@ -1693,6 +1695,8 @@
 		jffs_read_data(f, (char *)&rdev, 0, sizeof(kdev_t));
 		init_special_inode(inode, inode->i_mode, kdev_t_to_nr(rdev));
 	}
+	if (inode->u.generic_ip == f)
+		f->users++;
 	D3(printk (KERN_NOTICE "read_inode(): up biglock\n"));
 	up(&c->fmc->biglock);
 }
@@ -1701,13 +1705,20 @@
 void
 jffs_delete_inode(struct inode *inode)
 {
+	struct jffs_file *f = (struct jffs_file *)inode->u.generic_ip;
 	D3(printk("jffs_delete_inode(): inode->i_ino == %lu\n",
 		  inode->i_ino));
 
 	lock_kernel();
 	inode->i_size = 0;
 	inode->i_blocks = 0;
+	inode->u.generic_ip = 0;
 	clear_inode(inode);
+	if (inode->i_nlink == 0) {
+		f->users--;
+		jffs_possibly_delete_file(f);
+	}
+
 	unlock_kernel();
 }
 
Index: fs/jffs/intrep.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs/intrep.c,v
retrieving revision 1.78
diff -u -r1.78 intrep.c
--- fs/jffs/intrep.c	2000/11/14 18:45:31	1.78
+++ fs/jffs/intrep.c	2000/11/28 14:34:23
@@ -1139,7 +1139,7 @@
 		if (insert_into_tree) {
 			jffs_insert_file_into_tree(f);
 		}
-		if (f->deleted) {
+		if (f->deleted && !f->users) {
 			/* Mark all versions of the node as obsolete.  */
 			jffs_possibly_delete_file(f);
 		}
@@ -1820,7 +1820,7 @@
 		return -1;
 	});
 
-	if (f->deleted) {
+	if (f->deleted && !f->users) {
 		/* First try to remove all older versions.  Commence with
 		   the oldest node.  */
 		for (n = f->version_head; n; n = n->version_next) {



--
dwmw2





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