Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9b88f473 authored by Estelle Hammache's avatar Estelle Hammache Committed by Thomas Gleixner
Browse files

[JFFS2] Code cleanup



Code beautification and block filing correction for optimization.

Signed-off-by: default avatarEstelle Hammache <estelle.hammache@st.com>
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
parent 6170b434
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -7,7 +7,7 @@
 *
 * For licensing information, see the file 'LICENCE' in this directory.
 *
 * $Id: nodemgmt.c,v 1.116 2005/01/24 21:30:22 hammache Exp $
 * $Id: nodemgmt.c,v 1.117 2005/01/25 20:11:11 hammache Exp $
 *
 */

@@ -311,7 +311,7 @@ int jffs2_add_physical_node_ref(struct jffs2_sb_info *c, struct jffs2_raw_node_r
	/* we could get some obsolete nodes after nextblock was refiled
	   in wbuf.c */
	if ((c->nextblock || !ref_obsolete(new))
	    &&(jeb != c->nextblock || (ref_offset(new)) != jeb->offset + (c->sector_size - jeb->free_size))) {
	    &&(jeb != c->nextblock || ref_offset(new) != jeb->offset + (c->sector_size - jeb->free_size))) {
		printk(KERN_WARNING "argh. node added in wrong place\n");
		jffs2_free_raw_node_ref(new);
		return -EINVAL;
@@ -335,7 +335,7 @@ int jffs2_add_physical_node_ref(struct jffs2_sb_info *c, struct jffs2_raw_node_r
		c->used_size += len;
	}

	if (!jeb->free_size && !jeb->dirty_size && !jeb->wasted_size) {
	if (!jeb->free_size && !jeb->dirty_size && !ISDIRTY(jeb->wasted_size)) {
		/* If it lives on the dirty_list, jffs2_reserve_space will put it there */
		D1(printk(KERN_DEBUG "Adding full erase block at 0x%08x to clean_list (free 0x%08x, dirty 0x%08x, used 0x%08x\n",
			  jeb->offset, jeb->free_size, jeb->dirty_size, jeb->used_size));
+8 −15
Original line number Diff line number Diff line
@@ -9,7 +9,7 @@
 *
 * For licensing information, see the file 'LICENCE' in this directory.
 *
 * $Id: wbuf.c,v 1.83 2005/01/24 21:24:15 hammache Exp $
 * $Id: wbuf.c,v 1.84 2005/01/25 20:11:11 hammache Exp $
 *
 */

@@ -147,8 +147,7 @@ static void jffs2_block_refile(struct jffs2_sb_info *c, struct jffs2_eraseblock
		D1(printk("Refiling block at %08x to bad_used_list\n", jeb->offset));
		list_add(&jeb->list, &c->bad_used_list);
	} else {
		if (allow_empty == REFILE_NOTEMPTY)
			BUG();
		BUG_ON(allow_empty == REFILE_NOTEMPTY);
		/* It has to have had some nodes or we couldn't be here */
		D1(printk("Refiling block at %08x to erase_pending_list\n", jeb->offset));
		list_add(&jeb->list, &c->erase_pending_list);
@@ -268,7 +267,6 @@ static void jffs2_wbuf_recover(struct jffs2_sb_info *c)
	ret = jffs2_reserve_space_gc(c, end-start, &ofs, &len);
	if (ret) {
		printk(KERN_WARNING "Failed to allocate space for wbuf recovery. Data loss ensues.\n");
		if (buf)
		kfree(buf);
		return;
	}
@@ -303,7 +301,6 @@ static void jffs2_wbuf_recover(struct jffs2_sb_info *c)
		if (ret || retlen != towrite) {
			/* Argh. We tried. Really we did. */
			printk(KERN_CRIT "Recovery of wbuf failed due to a second write error\n");
			if (buf)
			kfree(buf);

			if (retlen) {
@@ -555,9 +552,7 @@ int jffs2_flush_wbuf_gc(struct jffs2_sb_info *c, uint32_t ino)
		/* retry flushing wbuf in case jffs2_wbuf_recover
		   left some data in the wbuf */
		if (ret)
		{
			ret = __jffs2_flush_wbuf(c, PAD_ACCOUNTING);
		}
		up_write(&c->wbuf_sem);
	} else while (old_wbuf_len &&
		      old_wbuf_ofs == c->wbuf_ofs) {
@@ -575,9 +570,7 @@ int jffs2_flush_wbuf_gc(struct jffs2_sb_info *c, uint32_t ino)
			/* retry flushing wbuf in case jffs2_wbuf_recover
			   left some data in the wbuf */
			if (ret)
			{
				ret = __jffs2_flush_wbuf(c, PAD_ACCOUNTING);
			}
			up_write(&c->wbuf_sem);
			break;
		}
+16 −28
Original line number Diff line number Diff line
@@ -7,7 +7,7 @@
 *
 * For licensing information, see the file 'LICENCE' in this directory.
 *
 * $Id: write.c,v 1.88 2005/01/24 21:13:39 hammache Exp $
 * $Id: write.c,v 1.90 2005/01/28 18:53:01 hammache Exp $
 *
 */

@@ -136,20 +136,14 @@ struct jffs2_full_dnode *jffs2_write_dnode(struct jffs2_sb_info *c, struct jffs2
	raw->__totlen = PAD(sizeof(*ri)+datalen);
	raw->next_phys = NULL;

	if ((alloc_mode!=ALLOC_GC) && (je32_to_cpu(ri->version) < f->highest_version))
	{
		if (! retried)
		{
			BUG();
		}
		else
		{
			D1(printk(KERN_DEBUG "jffs2_write_dnode : dnode_version %d,  highest version %d -> updating dnode\n", 
	if ((alloc_mode!=ALLOC_GC) && (je32_to_cpu(ri->version) < f->highest_version)) {
		BUG_ON(!retried);
		D1(printk(KERN_DEBUG "jffs2_write_dnode : dnode_version %d, "
				"highest version %d -> updating dnode\n", 
				je32_to_cpu(ri->version), f->highest_version));
		ri->version = cpu_to_je32(++f->highest_version);
		ri->node_crc = cpu_to_je32(crc32(0, ri, sizeof(*ri)-8));
	}
	}

	ret = jffs2_flash_writev(c, vecs, cnt, flash_ofs, &retlen,
				 (alloc_mode==ALLOC_GC)?0:f->inocache->ino);
@@ -295,21 +289,15 @@ struct jffs2_full_dirent *jffs2_write_dirent(struct jffs2_sb_info *c, struct jff
	raw->__totlen = PAD(sizeof(*rd)+namelen);
	raw->next_phys = NULL;

	if ((alloc_mode!=ALLOC_GC) && (je32_to_cpu(rd->version) < f->highest_version))
	{
		if (! retried)
		{
			BUG();
		}
		else
		{
			D1(printk(KERN_DEBUG "jffs2_write_dirent : dirent_version %d,  highest version %d -> updating dirent\n", 
	if ((alloc_mode!=ALLOC_GC) && (je32_to_cpu(rd->version) < f->highest_version)) {
		BUG_ON(!retried);
		D1(printk(KERN_DEBUG "jffs2_write_dirent : dirent_version %d, "
				     "highest version %d -> updating dirent\n",
				     je32_to_cpu(rd->version), f->highest_version));
		rd->version = cpu_to_je32(++f->highest_version);
		fd->version = je32_to_cpu(rd->version);
		rd->node_crc = cpu_to_je32(crc32(0, rd, sizeof(*rd)-8));
	}
	}

	ret = jffs2_flash_writev(c, vecs, 2, flash_ofs, &retlen,
				 (alloc_mode==ALLOC_GC)?0:je32_to_cpu(rd->pino));