mtd/fs/jffs3 write.c, 3.10, 3.11 wbuf.c, 3.11, 3.12 nodemgmt.c, 3.14,
3.15 debug.h, 1.22, 1.23
hammache at infradead.org
hammache at infradead.org
Tue Jan 25 15:11:15 EST 2005
Update of /home/cvs/mtd/fs/jffs3
In directory phoenix.infradead.org:/tmp/cvs-serv32224/mtd/fs/jffs3
Modified Files:
write.c wbuf.c nodemgmt.c debug.h
Log Message:
Code beautification and block filing correction for optimization.
Index: write.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs3/write.c,v
retrieving revision 3.10
retrieving revision 3.11
diff -u -r3.10 -r3.11
--- write.c 24 Jan 2005 21:17:32 -0000 3.10
+++ write.c 25 Jan 2005 20:11:12 -0000 3.11
@@ -119,17 +119,12 @@
if ((alloc_mode!=ALLOC_GC) && (je32_to_cpu(ri->version) < f->highest_version))
{
- if (! retried)
- {
- BUG();
- }
- else
- {
- DBG_WRITE(1,"jffs3_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));
- }
+ BUG_ON(!retried);
+ DBG_WRITE(1,"jffs3_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 = jffs3_flash_writev(c, vecs, cnt, flash_ofs, &retlen,
@@ -283,18 +278,13 @@
raw->next_phys = NULL;
if ((alloc_mode!=ALLOC_GC) && (je32_to_cpu(rd->version) < f->highest_version))
{
- if (! retried)
- {
- BUG();
- }
- else
- {
- DBG_WRITE(1,"jffs3_write_dirent : dirent_version %d, highest version %d -> updating dirent\n",
+ BUG_ON(!retried);
+ DBG_WRITE(1,"jffs3_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));
- }
+ 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 = jffs3_flash_writev(c, vecs, 2, flash_ofs, &retlen,
Index: wbuf.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs3/wbuf.c,v
retrieving revision 3.11
retrieving revision 3.12
diff -u -r3.11 -r3.12
--- wbuf.c 24 Jan 2005 21:26:59 -0000 3.11
+++ wbuf.c 25 Jan 2005 20:11:12 -0000 3.12
@@ -144,8 +144,7 @@
DBG_WBUF(1, "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 */
DBG_WBUF(1, "Refiling block at %08x to erase_pending_list\n", jeb->offset);
list_add(&jeb->list, &c->erase_pending_list);
@@ -267,16 +266,15 @@
ret = jffs3_reserve_space_gc(c, end-start, &ofs, &len, JFFS3_SUMMARY_NOSUM_SIZE);
if (ret) {
WARNING_MSG("Failed to allocate space for wbuf recovery. Data loss ensues.\n");
- if (buf)
- kfree(buf);
+ kfree(buf);
return;
}
if (end-start >= c->wbuf_pagesize) {
/* Need to do another write immediately, but it's possible
- that this is just because the wbuf itself is completely
- full, and there's nothing earlier read back from the
- flash. Hence 'buf' isn't necessarily what we're writing
- from. */
+ that this is just because the wbuf itself is completely
+ full, and there's nothing earlier read back from the
+ flash. Hence 'buf' isn't necessarily what we're writing
+ from. */
unsigned char *rewrite_buf = buf?:c->wbuf;
uint32_t towrite = (end-start) - ((end-start)%c->wbuf_pagesize);
@@ -292,8 +290,7 @@
if (ret || retlen != towrite) {
/* Argh. We tried. Really we did. */
WARNING_MSG("Recovery of wbuf failed due to a second write error\n");
- if (buf)
- kfree(buf);
+ kfree(buf);
if (retlen) {
struct jffs3_raw_node_ref *raw2;
@@ -320,8 +317,7 @@
c->wbuf_ofs = ofs + towrite;
memmove(c->wbuf, rewrite_buf + towrite, c->wbuf_len);
/* Don't muck about with c->wbuf_inodes. False positives are harmless. */
- if (buf)
- kfree(buf);
+ kfree(buf);
} else {
/* OK, now we're left with the dregs in whichever buffer we're using */
if (buf) {
@@ -538,9 +534,7 @@
/* retry flushing wbuf in case jffs3_wbuf_recover
left some data in the wbuf */
if (ret)
- {
ret = __jffs3_flush_wbuf(c, PAD_ACCOUNTING);
- }
up_write(&c->wbuf_sem);
} else while (old_wbuf_len &&
old_wbuf_ofs == c->wbuf_ofs) {
@@ -558,9 +552,7 @@
/* retry flushing wbuf in case jffs3_wbuf_recover
left some data in the wbuf */
if (ret)
- {
ret = __jffs3_flush_wbuf(c, PAD_ACCOUNTING);
- }
up_write(&c->wbuf_sem);
break;
}
Index: nodemgmt.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs3/nodemgmt.c,v
retrieving revision 3.14
retrieving revision 3.15
diff -u -r3.14 -r3.15
--- nodemgmt.c 24 Jan 2005 21:44:43 -0000 3.14
+++ nodemgmt.c 25 Jan 2005 20:11:12 -0000 3.15
@@ -426,7 +426,7 @@
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, jffs3_reserve_space will put it there */
DBG_BL(1, "Adding full erase block at 0x%08x to clean_list "
"(free 0x%08x, dirty 0x%08x, used 0x%08x\n",
Index: debug.h
===================================================================
RCS file: /home/cvs/mtd/fs/jffs3/debug.h,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- debug.h 24 Jan 2005 21:44:43 -0000 1.22
+++ debug.h 25 Jan 2005 20:11:12 -0000 1.23
@@ -386,7 +386,7 @@
*/
/* we could get some obsolete nodes after nextblock was refiled
in wbuf.c */
- if ( (c->nextblock || !ref_obsolete(ref))
+ if ((c->nextblock || !ref_obsolete(ref))
&& (jeb != c->nextblock
|| ref_offset(ref) != jeb->offset + (c->sector_size - jeb->free_size)) ) {
WARNING_MSG("Argh. Node added in wrong place.\n");
More information about the linux-mtd-cvs
mailing list