Skip to content

Commit 9b88f47

Browse files
Estelle HammacheThomas Gleixner
authored andcommitted
[JFFS2] Code cleanup
Code beautification and block filing correction for optimization. Signed-off-by: Estelle Hammache <estelle.hammache@st.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
1 parent 6170b43 commit 9b88f47

3 files changed

Lines changed: 28 additions & 47 deletions

File tree

‎fs/jffs2/nodemgmt.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
* For licensing information, see the file 'LICENCE' in this directory.
99
*
10-
* $Id: nodemgmt.c,v 1.116 2005/01/24 21:30:22 hammache Exp $
10+
* $Id: nodemgmt.c,v 1.117 2005/01/25 20:11:11 hammache Exp $
1111
*
1212
*/
1313

@@ -310,8 +310,8 @@ int jffs2_add_physical_node_ref(struct jffs2_sb_info *c, struct jffs2_raw_node_r
310310
#if 1
311311
/* we could get some obsolete nodes after nextblock was refiled
312312
in wbuf.c */
313-
if ( (c->nextblock || !ref_obsolete(new))
314-
&&(jeb != c->nextblock || (ref_offset(new)) != jeb->offset + (c->sector_size - jeb->free_size))) {
313+
if ((c->nextblock || !ref_obsolete(new))
314+
&&(jeb != c->nextblock || ref_offset(new) != jeb->offset + (c->sector_size - jeb->free_size))) {
315315
printk(KERN_WARNING "argh. node added in wrong place\n");
316316
jffs2_free_raw_node_ref(new);
317317
return -EINVAL;
@@ -335,7 +335,7 @@ int jffs2_add_physical_node_ref(struct jffs2_sb_info *c, struct jffs2_raw_node_r
335335
c->used_size += len;
336336
}
337337

338-
if (!jeb->free_size && !jeb->dirty_size && !jeb->wasted_size) {
338+
if (!jeb->free_size && !jeb->dirty_size && !ISDIRTY(jeb->wasted_size)) {
339339
/* If it lives on the dirty_list, jffs2_reserve_space will put it there */
340340
D1(printk(KERN_DEBUG "Adding full erase block at 0x%08x to clean_list (free 0x%08x, dirty 0x%08x, used 0x%08x\n",
341341
jeb->offset, jeb->free_size, jeb->dirty_size, jeb->used_size));

‎fs/jffs2/wbuf.c‎

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
* For licensing information, see the file 'LICENCE' in this directory.
1111
*
12-
* $Id: wbuf.c,v 1.83 2005/01/24 21:24:15 hammache Exp $
12+
* $Id: wbuf.c,v 1.84 2005/01/25 20:11:11 hammache Exp $
1313
*
1414
*/
1515

@@ -147,8 +147,7 @@ static void jffs2_block_refile(struct jffs2_sb_info *c, struct jffs2_eraseblock
147147
D1(printk("Refiling block at %08x to bad_used_list\n", jeb->offset));
148148
list_add(&jeb->list, &c->bad_used_list);
149149
} else {
150-
if (allow_empty == REFILE_NOTEMPTY)
151-
BUG();
150+
BUG_ON(allow_empty == REFILE_NOTEMPTY);
152151
/* It has to have had some nodes or we couldn't be here */
153152
D1(printk("Refiling block at %08x to erase_pending_list\n", jeb->offset));
154153
list_add(&jeb->list, &c->erase_pending_list);
@@ -268,16 +267,15 @@ static void jffs2_wbuf_recover(struct jffs2_sb_info *c)
268267
ret = jffs2_reserve_space_gc(c, end-start, &ofs, &len);
269268
if (ret) {
270269
printk(KERN_WARNING "Failed to allocate space for wbuf recovery. Data loss ensues.\n");
271-
if (buf)
272-
kfree(buf);
270+
kfree(buf);
273271
return;
274272
}
275273
if (end-start >= c->wbuf_pagesize) {
276274
/* Need to do another write immediately, but it's possible
277-
that this is just because the wbuf itself is completely
278-
full, and there's nothing earlier read back from the
279-
flash. Hence 'buf' isn't necessarily what we're writing
280-
from. */
275+
that this is just because the wbuf itself is completely
276+
full, and there's nothing earlier read back from the
277+
flash. Hence 'buf' isn't necessarily what we're writing
278+
from. */
281279
unsigned char *rewrite_buf = buf?:c->wbuf;
282280
uint32_t towrite = (end-start) - ((end-start)%c->wbuf_pagesize);
283281

@@ -303,8 +301,7 @@ static void jffs2_wbuf_recover(struct jffs2_sb_info *c)
303301
if (ret || retlen != towrite) {
304302
/* Argh. We tried. Really we did. */
305303
printk(KERN_CRIT "Recovery of wbuf failed due to a second write error\n");
306-
if (buf)
307-
kfree(buf);
304+
kfree(buf);
308305

309306
if (retlen) {
310307
struct jffs2_raw_node_ref *raw2;
@@ -555,9 +552,7 @@ int jffs2_flush_wbuf_gc(struct jffs2_sb_info *c, uint32_t ino)
555552
/* retry flushing wbuf in case jffs2_wbuf_recover
556553
left some data in the wbuf */
557554
if (ret)
558-
{
559555
ret = __jffs2_flush_wbuf(c, PAD_ACCOUNTING);
560-
}
561556
up_write(&c->wbuf_sem);
562557
} else while (old_wbuf_len &&
563558
old_wbuf_ofs == c->wbuf_ofs) {
@@ -575,9 +570,7 @@ int jffs2_flush_wbuf_gc(struct jffs2_sb_info *c, uint32_t ino)
575570
/* retry flushing wbuf in case jffs2_wbuf_recover
576571
left some data in the wbuf */
577572
if (ret)
578-
{
579573
ret = __jffs2_flush_wbuf(c, PAD_ACCOUNTING);
580-
}
581574
up_write(&c->wbuf_sem);
582575
break;
583576
}

‎fs/jffs2/write.c‎

Lines changed: 16 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
* For licensing information, see the file 'LICENCE' in this directory.
99
*
10-
* $Id: write.c,v 1.88 2005/01/24 21:13:39 hammache Exp $
10+
* $Id: write.c,v 1.90 2005/01/28 18:53:01 hammache Exp $
1111
*
1212
*/
1313

@@ -136,19 +136,13 @@ struct jffs2_full_dnode *jffs2_write_dnode(struct jffs2_sb_info *c, struct jffs2
136136
raw->__totlen = PAD(sizeof(*ri)+datalen);
137137
raw->next_phys = NULL;
138138

139-
if ((alloc_mode!=ALLOC_GC) && (je32_to_cpu(ri->version) < f->highest_version))
140-
{
141-
if (! retried)
142-
{
143-
BUG();
144-
}
145-
else
146-
{
147-
D1(printk(KERN_DEBUG "jffs2_write_dnode : dnode_version %d, highest version %d -> updating dnode\n",
148-
je32_to_cpu(ri->version), f->highest_version));
149-
ri->version = cpu_to_je32(++f->highest_version);
150-
ri->node_crc = cpu_to_je32(crc32(0, ri, sizeof(*ri)-8));
151-
}
139+
if ((alloc_mode!=ALLOC_GC) && (je32_to_cpu(ri->version) < f->highest_version)) {
140+
BUG_ON(!retried);
141+
D1(printk(KERN_DEBUG "jffs2_write_dnode : dnode_version %d, "
142+
"highest version %d -> updating dnode\n",
143+
je32_to_cpu(ri->version), f->highest_version));
144+
ri->version = cpu_to_je32(++f->highest_version);
145+
ri->node_crc = cpu_to_je32(crc32(0, ri, sizeof(*ri)-8));
152146
}
153147

154148
ret = jffs2_flash_writev(c, vecs, cnt, flash_ofs, &retlen,
@@ -295,20 +289,14 @@ struct jffs2_full_dirent *jffs2_write_dirent(struct jffs2_sb_info *c, struct jff
295289
raw->__totlen = PAD(sizeof(*rd)+namelen);
296290
raw->next_phys = NULL;
297291

298-
if ((alloc_mode!=ALLOC_GC) && (je32_to_cpu(rd->version) < f->highest_version))
299-
{
300-
if (! retried)
301-
{
302-
BUG();
303-
}
304-
else
305-
{
306-
D1(printk(KERN_DEBUG "jffs2_write_dirent : dirent_version %d, highest version %d -> updating dirent\n",
307-
je32_to_cpu(rd->version), f->highest_version));
308-
rd->version = cpu_to_je32(++f->highest_version);
309-
fd->version = je32_to_cpu(rd->version);
310-
rd->node_crc = cpu_to_je32(crc32(0, rd, sizeof(*rd)-8));
311-
}
292+
if ((alloc_mode!=ALLOC_GC) && (je32_to_cpu(rd->version) < f->highest_version)) {
293+
BUG_ON(!retried);
294+
D1(printk(KERN_DEBUG "jffs2_write_dirent : dirent_version %d, "
295+
"highest version %d -> updating dirent\n",
296+
je32_to_cpu(rd->version), f->highest_version));
297+
rd->version = cpu_to_je32(++f->highest_version);
298+
fd->version = je32_to_cpu(rd->version);
299+
rd->node_crc = cpu_to_je32(crc32(0, rd, sizeof(*rd)-8));
312300
}
313301

314302
ret = jffs2_flash_writev(c, vecs, 2, flash_ofs, &retlen,

0 commit comments

Comments
 (0)