diff options
author | Estelle Hammache <estelle.hammache@st.com> | 2005-01-28 13:53:05 -0500 |
---|---|---|
committer | Thomas Gleixner <tglx@mtd.linutronix.de> | 2005-05-23 06:16:06 -0400 |
commit | 9b88f47390efb72540b050628ebc04202d91c6ec (patch) | |
tree | 13d56b9a76a76b7dca5509cad63827570b3496b1 /fs/jffs2/wbuf.c | |
parent | 6170b43401a3230756ff76287ee07db0d75eddde (diff) |
[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>
Diffstat (limited to 'fs/jffs2/wbuf.c')
-rw-r--r-- | fs/jffs2/wbuf.c | 23 |
1 files changed, 8 insertions, 15 deletions
diff --git a/fs/jffs2/wbuf.c b/fs/jffs2/wbuf.c index 4e583bfecf6e..b43aac7496ae 100644 --- a/fs/jffs2/wbuf.c +++ b/fs/jffs2/wbuf.c | |||
@@ -9,7 +9,7 @@ | |||
9 | * | 9 | * |
10 | * For licensing information, see the file 'LICENCE' in this directory. | 10 | * For licensing information, see the file 'LICENCE' in this directory. |
11 | * | 11 | * |
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 $ |
13 | * | 13 | * |
14 | */ | 14 | */ |
15 | 15 | ||
@@ -147,8 +147,7 @@ static void jffs2_block_refile(struct jffs2_sb_info *c, struct jffs2_eraseblock | |||
147 | D1(printk("Refiling block at %08x to bad_used_list\n", jeb->offset)); | 147 | D1(printk("Refiling block at %08x to bad_used_list\n", jeb->offset)); |
148 | list_add(&jeb->list, &c->bad_used_list); | 148 | list_add(&jeb->list, &c->bad_used_list); |
149 | } else { | 149 | } else { |
150 | if (allow_empty == REFILE_NOTEMPTY) | 150 | BUG_ON(allow_empty == REFILE_NOTEMPTY); |
151 | BUG(); | ||
152 | /* It has to have had some nodes or we couldn't be here */ | 151 | /* It has to have had some nodes or we couldn't be here */ |
153 | D1(printk("Refiling block at %08x to erase_pending_list\n", jeb->offset)); | 152 | D1(printk("Refiling block at %08x to erase_pending_list\n", jeb->offset)); |
154 | list_add(&jeb->list, &c->erase_pending_list); | 153 | list_add(&jeb->list, &c->erase_pending_list); |
@@ -268,16 +267,15 @@ static void jffs2_wbuf_recover(struct jffs2_sb_info *c) | |||
268 | ret = jffs2_reserve_space_gc(c, end-start, &ofs, &len); | 267 | ret = jffs2_reserve_space_gc(c, end-start, &ofs, &len); |
269 | if (ret) { | 268 | if (ret) { |
270 | printk(KERN_WARNING "Failed to allocate space for wbuf recovery. Data loss ensues.\n"); | 269 | printk(KERN_WARNING "Failed to allocate space for wbuf recovery. Data loss ensues.\n"); |
271 | if (buf) | 270 | kfree(buf); |
272 | kfree(buf); | ||
273 | return; | 271 | return; |
274 | } | 272 | } |
275 | if (end-start >= c->wbuf_pagesize) { | 273 | if (end-start >= c->wbuf_pagesize) { |
276 | /* Need to do another write immediately, but it's possible | 274 | /* Need to do another write immediately, but it's possible |
277 | that this is just because the wbuf itself is completely | 275 | that this is just because the wbuf itself is completely |
278 | full, and there's nothing earlier read back from the | 276 | full, and there's nothing earlier read back from the |
279 | flash. Hence 'buf' isn't necessarily what we're writing | 277 | flash. Hence 'buf' isn't necessarily what we're writing |
280 | from. */ | 278 | from. */ |
281 | unsigned char *rewrite_buf = buf?:c->wbuf; | 279 | unsigned char *rewrite_buf = buf?:c->wbuf; |
282 | uint32_t towrite = (end-start) - ((end-start)%c->wbuf_pagesize); | 280 | uint32_t towrite = (end-start) - ((end-start)%c->wbuf_pagesize); |
283 | 281 | ||
@@ -303,8 +301,7 @@ static void jffs2_wbuf_recover(struct jffs2_sb_info *c) | |||
303 | if (ret || retlen != towrite) { | 301 | if (ret || retlen != towrite) { |
304 | /* Argh. We tried. Really we did. */ | 302 | /* Argh. We tried. Really we did. */ |
305 | printk(KERN_CRIT "Recovery of wbuf failed due to a second write error\n"); | 303 | printk(KERN_CRIT "Recovery of wbuf failed due to a second write error\n"); |
306 | if (buf) | 304 | kfree(buf); |
307 | kfree(buf); | ||
308 | 305 | ||
309 | if (retlen) { | 306 | if (retlen) { |
310 | struct jffs2_raw_node_ref *raw2; | 307 | struct jffs2_raw_node_ref *raw2; |
@@ -555,9 +552,7 @@ int jffs2_flush_wbuf_gc(struct jffs2_sb_info *c, uint32_t ino) | |||
555 | /* retry flushing wbuf in case jffs2_wbuf_recover | 552 | /* retry flushing wbuf in case jffs2_wbuf_recover |
556 | left some data in the wbuf */ | 553 | left some data in the wbuf */ |
557 | if (ret) | 554 | if (ret) |
558 | { | ||
559 | ret = __jffs2_flush_wbuf(c, PAD_ACCOUNTING); | 555 | ret = __jffs2_flush_wbuf(c, PAD_ACCOUNTING); |
560 | } | ||
561 | up_write(&c->wbuf_sem); | 556 | up_write(&c->wbuf_sem); |
562 | } else while (old_wbuf_len && | 557 | } else while (old_wbuf_len && |
563 | old_wbuf_ofs == c->wbuf_ofs) { | 558 | old_wbuf_ofs == c->wbuf_ofs) { |
@@ -575,9 +570,7 @@ int jffs2_flush_wbuf_gc(struct jffs2_sb_info *c, uint32_t ino) | |||
575 | /* retry flushing wbuf in case jffs2_wbuf_recover | 570 | /* retry flushing wbuf in case jffs2_wbuf_recover |
576 | left some data in the wbuf */ | 571 | left some data in the wbuf */ |
577 | if (ret) | 572 | if (ret) |
578 | { | ||
579 | ret = __jffs2_flush_wbuf(c, PAD_ACCOUNTING); | 573 | ret = __jffs2_flush_wbuf(c, PAD_ACCOUNTING); |
580 | } | ||
581 | up_write(&c->wbuf_sem); | 574 | up_write(&c->wbuf_sem); |
582 | break; | 575 | break; |
583 | } | 576 | } |