mtd/fs/jffs2 dir.c,1.77,1.78 file.c,1.88,1.89 gc.c,1.103,1.104 nodelist.h,1.95,1.96 os-linux.h,1.30,1.31 super-v24.c,1.69,1.70 wbuf.c,1.36,1.37 write.c,1.65,1.66

David Woodhouse dwmw2 at infradead.org
Mon Aug 25 07:31:49 EDT 2003


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

Modified Files:
	dir.c file.c gc.c nodelist.h os-linux.h super-v24.c wbuf.c 
	write.c 
Log Message:
Keep track of whether we're writing for GC or not

Index: dir.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs2/dir.c,v
retrieving revision 1.77
retrieving revision 1.78
diff -u -r1.77 -r1.78
--- dir.c	5 Jun 2003 14:42:24 -0000	1.77
+++ dir.c	25 Aug 2003 11:31:46 -0000	1.78
@@ -338,7 +338,7 @@
 	ri->data_crc = cpu_to_je32(crc32(0, target, strlen(target)));
 	ri->node_crc = cpu_to_je32(crc32(0, ri, sizeof(*ri)-8));
 	
-	fn = jffs2_write_dnode(c, f, ri, target, strlen(target), phys_ofs, &writtenlen);
+	fn = jffs2_write_dnode(c, f, ri, target, strlen(target), phys_ofs, &writtenlen, NOT_GC);
 
 	jffs2_free_raw_inode(ri);
 
@@ -396,7 +396,7 @@
 	rd->node_crc = cpu_to_je32(crc32(0, rd, sizeof(*rd)-8));
 	rd->name_crc = cpu_to_je32(crc32(0, dentry->d_name.name, namelen));
 
-	fd = jffs2_write_dirent(c, dir_f, rd, dentry->d_name.name, namelen, phys_ofs, &writtenlen);
+	fd = jffs2_write_dirent(c, dir_f, rd, dentry->d_name.name, namelen, phys_ofs, &writtenlen, NOT_GC);
 
 	if (IS_ERR(fd)) {
 		/* dirent failed to write. Delete the inode normally 
@@ -475,7 +475,7 @@
 	ri->data_crc = cpu_to_je32(0);
 	ri->node_crc = cpu_to_je32(crc32(0, ri, sizeof(*ri)-8));
 	
-	fn = jffs2_write_dnode(c, f, ri, NULL, 0, phys_ofs, &writtenlen);
+	fn = jffs2_write_dnode(c, f, ri, NULL, 0, phys_ofs, &writtenlen, NOT_GC);
 
 	jffs2_free_raw_inode(ri);
 
@@ -533,7 +533,7 @@
 	rd->node_crc = cpu_to_je32(crc32(0, rd, sizeof(*rd)-8));
 	rd->name_crc = cpu_to_je32(crc32(0, dentry->d_name.name, namelen));
 
-	fd = jffs2_write_dirent(c, dir_f, rd, dentry->d_name.name, namelen, phys_ofs, &writtenlen);
+	fd = jffs2_write_dirent(c, dir_f, rd, dentry->d_name.name, namelen, phys_ofs, &writtenlen, NOT_GC);
 	
 	if (IS_ERR(fd)) {
 		/* dirent failed to write. Delete the inode normally 
@@ -635,7 +635,7 @@
 	ri->data_crc = cpu_to_je32(crc32(0, &dev, devlen));
 	ri->node_crc = cpu_to_je32(crc32(0, ri, sizeof(*ri)-8));
 	
-	fn = jffs2_write_dnode(c, f, ri, (char *)&dev, devlen, phys_ofs, &writtenlen);
+	fn = jffs2_write_dnode(c, f, ri, (char *)&dev, devlen, phys_ofs, &writtenlen, NOT_GC);
 
 	jffs2_free_raw_inode(ri);
 
@@ -696,7 +696,7 @@
 	rd->node_crc = cpu_to_je32(crc32(0, rd, sizeof(*rd)-8));
 	rd->name_crc = cpu_to_je32(crc32(0, dentry->d_name.name, namelen));
 
-	fd = jffs2_write_dirent(c, dir_f, rd, dentry->d_name.name, namelen, phys_ofs, &writtenlen);
+	fd = jffs2_write_dirent(c, dir_f, rd, dentry->d_name.name, namelen, phys_ofs, &writtenlen, NOT_GC);
 	
 	if (IS_ERR(fd)) {
 		/* dirent failed to write. Delete the inode normally 

Index: file.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs2/file.c,v
retrieving revision 1.88
retrieving revision 1.89
diff -u -r1.88 -r1.89
--- file.c	24 Aug 2003 20:34:52 -0000	1.88
+++ file.c	25 Aug 2003 11:31:46 -0000	1.89
@@ -167,7 +167,7 @@
 	else
 		ri->data_crc = cpu_to_je32(0);
 
-	new_metadata = jffs2_write_dnode(c, f, ri, mdata, mdatalen, phys_ofs, NULL);
+	new_metadata = jffs2_write_dnode(c, f, ri, mdata, mdatalen, phys_ofs, NULL, NOT_GC);
 	if (S_ISLNK(inode->i_mode))
 		kfree(mdata);
 	
@@ -308,7 +308,7 @@
 		ri.node_crc = cpu_to_je32(crc32(0, &ri, sizeof(ri)-8));
 		ri.data_crc = cpu_to_je32(0);
 		
-		fn = jffs2_write_dnode(c, f, &ri, NULL, 0, phys_ofs, NULL);
+		fn = jffs2_write_dnode(c, f, &ri, NULL, 0, phys_ofs, NULL, NOT_GC);
 
 		if (IS_ERR(fn)) {
 			ret = PTR_ERR(fn);

Index: gc.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs2/gc.c,v
retrieving revision 1.103
retrieving revision 1.104
diff -u -r1.103 -r1.104
--- gc.c	22 May 2003 18:01:02 -0000	1.103
+++ gc.c	25 Aug 2003 11:31:46 -0000	1.104
@@ -684,7 +684,7 @@
 	ri.node_crc = cpu_to_je32(crc32(0, &ri, sizeof(ri)-8));
 	ri.data_crc = cpu_to_je32(crc32(0, mdata, mdatalen));
 
-	new_fn = jffs2_write_dnode(c, f, &ri, mdata, mdatalen, phys_ofs, NULL);
+	new_fn = jffs2_write_dnode(c, f, &ri, mdata, mdatalen, phys_ofs, NULL, IS_GC);
 
 	if (IS_ERR(new_fn)) {
 		printk(KERN_WARNING "Error writing new dnode: %ld\n", PTR_ERR(new_fn));
@@ -728,7 +728,7 @@
 		       sizeof(rd)+rd.nsize, ret);
 		return ret;
 	}
-	new_fd = jffs2_write_dirent(c, f, &rd, fd->name, rd.nsize, phys_ofs, NULL);
+	new_fd = jffs2_write_dirent(c, f, &rd, fd->name, rd.nsize, phys_ofs, NULL, IS_GC);
 
 	if (IS_ERR(new_fd)) {
 		printk(KERN_WARNING "jffs2_write_dirent in garbage_collect_dirent failed: %ld\n", PTR_ERR(new_fd));
@@ -951,7 +951,7 @@
 		       sizeof(ri), ret);
 		return ret;
 	}
-	new_fn = jffs2_write_dnode(c, f, &ri, NULL, 0, phys_ofs, NULL);
+	new_fn = jffs2_write_dnode(c, f, &ri, NULL, 0, phys_ofs, NULL, IS_GC);
 
 	if (IS_ERR(new_fn)) {
 		printk(KERN_WARNING "Error writing new hole node: %ld\n", PTR_ERR(new_fn));
@@ -1114,7 +1114,7 @@
 		ri.node_crc = cpu_to_je32(crc32(0, &ri, sizeof(ri)-8));
 		ri.data_crc = cpu_to_je32(crc32(0, writebuf, cdatalen));
 	
-		new_fn = jffs2_write_dnode(c, f, &ri, writebuf, cdatalen, phys_ofs, NULL);
+		new_fn = jffs2_write_dnode(c, f, &ri, writebuf, cdatalen, phys_ofs, NULL, IS_GC);
 
 		if (IS_ERR(new_fn)) {
 			printk(KERN_WARNING "Error writing new dnode: %ld\n", PTR_ERR(new_fn));

Index: nodelist.h
===================================================================
RCS file: /home/cvs/mtd/fs/jffs2/nodelist.h,v
retrieving revision 1.95
retrieving revision 1.96
diff -u -r1.95 -r1.96
--- nodelist.h	24 Aug 2003 10:29:09 -0000	1.95
+++ nodelist.h	25 Aug 2003 11:31:46 -0000	1.96
@@ -314,8 +314,11 @@
 
 /* write.c */
 int jffs2_do_new_inode(struct jffs2_sb_info *c, struct jffs2_inode_info *f, uint32_t mode, struct jffs2_raw_inode *ri);
-struct jffs2_full_dnode *jffs2_write_dnode(struct jffs2_sb_info *c, struct jffs2_inode_info *f, struct jffs2_raw_inode *ri, const unsigned char *data, uint32_t datalen, uint32_t flash_ofs,  uint32_t *writelen);
-struct jffs2_full_dirent *jffs2_write_dirent(struct jffs2_sb_info *c, struct jffs2_inode_info *f, struct jffs2_raw_dirent *rd, const unsigned char *name, uint32_t namelen, uint32_t flash_ofs,  uint32_t *writelen);
+
+#define NOT_GC 0
+#define IS_GC 1
+struct jffs2_full_dnode *jffs2_write_dnode(struct jffs2_sb_info *c, struct jffs2_inode_info *f, struct jffs2_raw_inode *ri, const unsigned char *data, uint32_t datalen, uint32_t flash_ofs,  uint32_t *writelen, int is_gc);
+struct jffs2_full_dirent *jffs2_write_dirent(struct jffs2_sb_info *c, struct jffs2_inode_info *f, struct jffs2_raw_dirent *rd, const unsigned char *name, uint32_t namelen, uint32_t flash_ofs,  uint32_t *writelen, int is_gc);
 int jffs2_write_inode_range(struct jffs2_sb_info *c, struct jffs2_inode_info *f,
 			    struct jffs2_raw_inode *ri, unsigned char *buf, 
 			    uint32_t offset, uint32_t writelen, uint32_t *retlen);

Index: os-linux.h
===================================================================
RCS file: /home/cvs/mtd/fs/jffs2/os-linux.h,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -r1.30 -r1.31
--- os-linux.h	24 Aug 2003 20:34:52 -0000	1.30
+++ os-linux.h	25 Aug 2003 11:31:46 -0000	1.31
@@ -71,7 +71,7 @@
 
 /* Hmmm. P'raps generic code should only ever see versions of signal
    functions which do the locking automatically? */
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,40)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,40) && !defined(__rh_config_h__)
 #define current_sig_lock current->sigmask_lock
 #else
 #define current_sig_lock current->sighand->siglock
@@ -118,7 +118,7 @@
 #define jffs2_nand_flash_setup(c) (0)
 #define jffs2_nand_flash_cleanup(c) do {} while(0)
 #define jffs2_wbuf_dirty(c) (0)
-#define jffs2_flash_writev jffs2_flash_direct_writev
+#define jffs2_flash_writev(a,b,c,d,e) jffs2_flash_direct_writev(a,b,c,d,e,0)
 #define jffs2_wbuf_timeout NULL
 #define jffs2_wbuf_process NULL
 
@@ -133,7 +133,7 @@
 struct kstatfs;
 
 /* wbuf.c */
-int jffs2_flash_writev(struct jffs2_sb_info *c, const struct iovec *vecs, unsigned long count, loff_t to, size_t *retlen);
+int jffs2_flash_writev(struct jffs2_sb_info *c, const struct iovec *vecs, unsigned long count, loff_t to, size_t *retlen, uint32_t ino);
 int jffs2_flash_write(struct jffs2_sb_info *c, loff_t ofs, size_t len, size_t *retlen, const u_char *buf);
 int jffs2_flash_read(struct jffs2_sb_info *c, loff_t ofs, size_t len, size_t *retlen, u_char *buf);
 int jffs2_check_oob_empty(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb,int mode);

Index: super-v24.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs2/super-v24.c,v
retrieving revision 1.69
retrieving revision 1.70
diff -u -r1.69 -r1.70
--- super-v24.c	24 Aug 2003 20:34:53 -0000	1.69
+++ super-v24.c	25 Aug 2003 11:31:47 -0000	1.70
@@ -104,6 +104,7 @@
 {
 	struct jffs2_sb_info *c = JFFS2_SB_INFO(sb);
 
+	D1(printk(KERN_DEBUG "jffs2_sync_fs() called\n"));
 	/* Flush with GC is OK -- it leaves a partially-written node
 	   but only a GC node, so no data are lost if it's not 
 	   complete and we immediately power off */

Index: wbuf.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs2/wbuf.c,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -r1.36 -r1.37
--- wbuf.c	24 Aug 2003 20:34:53 -0000	1.36
+++ wbuf.c	25 Aug 2003 11:31:47 -0000	1.37
@@ -227,6 +227,8 @@
 	uint32_t old_wbuf_len;
 	int ret = 0;
 
+	D1(printk(KERN_DEBUG "jffs2_flush_wbuf_gc() called...\n"));
+
 	down(&c->alloc_sem);
 	old_wbuf_ofs = c->wbuf_ofs;
 	old_wbuf_len = c->wbuf_len;
@@ -236,6 +238,8 @@
 
 		up(&c->alloc_sem);
 
+		D1(printk(KERN_DEBUG "jffs2_flush_wbuf_gc() calls gc pass\n"));
+
 		ret = jffs2_garbage_collect_pass(c);
 		if (ret) {
 			/* GC failed. Flush it with padding instead */
@@ -246,6 +250,8 @@
 		down(&c->alloc_sem);
 	}
 
+	D1(printk(KERN_DEBUG "jffs2_flush_wbuf_gc() ends...\n"));
+
 	up(&c->alloc_sem);
 	return ret;
 }
@@ -259,7 +265,7 @@
 
 #define PAGE_DIV(x) ( (x) & (~(c->wbuf_pagesize - 1)) )
 #define PAGE_MOD(x) ( (x) & (c->wbuf_pagesize - 1) )
-int jffs2_flash_writev(struct jffs2_sb_info *c, const struct iovec *invecs, unsigned long count, loff_t to, size_t *retlen)
+int jffs2_flash_writev(struct jffs2_sb_info *c, const struct iovec *invecs, unsigned long count, loff_t to, size_t *retlen, uint32_t ino)
 {
 	struct iovec outvecs[3];
 	uint32_t totlen = 0;
@@ -476,7 +482,7 @@
 
 	vecs[0].iov_base = (unsigned char *) buf;
 	vecs[0].iov_len = len;
-	return jffs2_flash_writev(c, vecs, 1, ofs, retlen);
+	return jffs2_flash_writev(c, vecs, 1, ofs, retlen, NOT_GC);
 }
 
 /*

Index: write.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs2/write.c,v
retrieving revision 1.65
retrieving revision 1.66
diff -u -r1.65 -r1.66
--- write.c	21 Jan 2003 18:11:29 -0000	1.65
+++ write.c	25 Aug 2003 11:31:47 -0000	1.66
@@ -86,7 +86,7 @@
 /* jffs2_write_dnode - given a raw_inode, allocate a full_dnode for it, 
    write it to the flash, link it into the existing inode/fragment list */
 
-struct jffs2_full_dnode *jffs2_write_dnode(struct jffs2_sb_info *c, struct jffs2_inode_info *f, struct jffs2_raw_inode *ri, const unsigned char *data, uint32_t datalen, uint32_t flash_ofs,  uint32_t *writelen)
+struct jffs2_full_dnode *jffs2_write_dnode(struct jffs2_sb_info *c, struct jffs2_inode_info *f, struct jffs2_raw_inode *ri, const unsigned char *data, uint32_t datalen, uint32_t flash_ofs,  uint32_t *writelen, int is_gc)
 
 {
 	struct jffs2_raw_node_ref *raw;
@@ -133,7 +133,7 @@
 	if (!datalen || !data)
 		cnt = 1;
 
-	ret = jffs2_flash_writev(c, vecs, cnt, flash_ofs, &retlen);
+	ret = jffs2_flash_writev(c, vecs, cnt, flash_ofs, &retlen, is_gc?0:f->inocache->ino);
 		
 	if (ret || (retlen != sizeof(*ri) + datalen)) {
 		printk(KERN_NOTICE "Write of %zd bytes at 0x%08x failed. returned %d, retlen %zd\n", 
@@ -191,7 +191,7 @@
 	return fn;
 }
 
-struct jffs2_full_dirent *jffs2_write_dirent(struct jffs2_sb_info *c, struct jffs2_inode_info *f, struct jffs2_raw_dirent *rd, const unsigned char *name, uint32_t namelen, uint32_t flash_ofs,  uint32_t *writelen)
+struct jffs2_full_dirent *jffs2_write_dirent(struct jffs2_sb_info *c, struct jffs2_inode_info *f, struct jffs2_raw_dirent *rd, const unsigned char *name, uint32_t namelen, uint32_t flash_ofs,  uint32_t *writelen, int is_gc)
 {
 	struct jffs2_raw_node_ref *raw;
 	struct jffs2_full_dirent *fd;
@@ -239,7 +239,7 @@
 	fd->name[namelen]=0;
 	fd->raw = raw;
 
-	ret = jffs2_flash_writev(c, vecs, 2, flash_ofs, &retlen);
+	ret = jffs2_flash_writev(c, vecs, 2, flash_ofs, &retlen, is_gc?0:fd->ino);
 	if (ret || (retlen != sizeof(*rd) + namelen)) {
 		printk(KERN_NOTICE "Write of %zd bytes at 0x%08x failed. returned %d, retlen %zd\n", 
 			       sizeof(*rd)+namelen, flash_ofs, ret, retlen);
@@ -331,7 +331,7 @@
 		ri->node_crc = cpu_to_je32(crc32(0, ri, sizeof(*ri)-8));
 		ri->data_crc = cpu_to_je32(crc32(0, comprbuf, cdatalen));
 
-		fn = jffs2_write_dnode(c, f, ri, comprbuf, cdatalen, phys_ofs, NULL);
+		fn = jffs2_write_dnode(c, f, ri, comprbuf, cdatalen, phys_ofs, NULL, NOT_GC);
 
 		if (comprtype != JFFS2_COMPR_NONE)
 			kfree(comprbuf);
@@ -397,7 +397,7 @@
 	ri->data_crc = cpu_to_je32(0);
 	ri->node_crc = cpu_to_je32(crc32(0, ri, sizeof(*ri)-8));
 
-	fn = jffs2_write_dnode(c, f, ri, NULL, 0, phys_ofs, &writtenlen);
+	fn = jffs2_write_dnode(c, f, ri, NULL, 0, phys_ofs, &writtenlen, NOT_GC);
 
 	D1(printk(KERN_DEBUG "jffs2_do_create created file with mode 0x%x\n",
 		  jemode_to_cpu(ri->mode)));
@@ -455,7 +455,7 @@
 	rd->node_crc = cpu_to_je32(crc32(0, rd, sizeof(*rd)-8));
 	rd->name_crc = cpu_to_je32(crc32(0, name, namelen));
 
-	fd = jffs2_write_dirent(c, dir_f, rd, name, namelen, phys_ofs, &writtenlen);
+	fd = jffs2_write_dirent(c, dir_f, rd, name, namelen, phys_ofs, &writtenlen, NOT_GC);
 
 	jffs2_free_raw_dirent(rd);
 	
@@ -513,7 +513,7 @@
 	rd->node_crc = cpu_to_je32(crc32(0, rd, sizeof(*rd)-8));
 	rd->name_crc = cpu_to_je32(crc32(0, name, namelen));
 
-	fd = jffs2_write_dirent(c, dir_f, rd, name, namelen, phys_ofs, NULL);
+	fd = jffs2_write_dirent(c, dir_f, rd, name, namelen, phys_ofs, NULL, NOT_GC);
 	
 	jffs2_free_raw_dirent(rd);
 
@@ -598,7 +598,7 @@
 	rd->node_crc = cpu_to_je32(crc32(0, rd, sizeof(*rd)-8));
 	rd->name_crc = cpu_to_je32(crc32(0, name, namelen));
 
-	fd = jffs2_write_dirent(c, dir_f, rd, name, namelen, phys_ofs, NULL);
+	fd = jffs2_write_dirent(c, dir_f, rd, name, namelen, phys_ofs, NULL, NOT_GC);
 	
 	jffs2_free_raw_dirent(rd);
 




More information about the linux-mtd-cvs mailing list