diff options
-rw-r--r-- | fs/jffs2/nodemgmt.c | 8 | ||||
-rw-r--r-- | fs/jffs2/wbuf.c | 23 | ||||
-rw-r--r-- | fs/jffs2/write.c | 44 |
3 files changed, 28 insertions, 47 deletions
diff --git a/fs/jffs2/nodemgmt.c b/fs/jffs2/nodemgmt.c index b2a53879d3b9..5e1e8caf54e8 100644 --- a/fs/jffs2/nodemgmt.c +++ b/fs/jffs2/nodemgmt.c | |||
@@ -7,7 +7,7 @@ | |||
7 | * | 7 | * |
8 | * For licensing information, see the file 'LICENCE' in this directory. | 8 | * For licensing information, see the file 'LICENCE' in this directory. |
9 | * | 9 | * |
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 $ |
11 | * | 11 | * |
12 | */ | 12 | */ |
13 | 13 | ||
@@ -310,8 +310,8 @@ int jffs2_add_physical_node_ref(struct jffs2_sb_info *c, struct jffs2_raw_node_r | |||
310 | #if 1 | 310 | #if 1 |
311 | /* we could get some obsolete nodes after nextblock was refiled | 311 | /* we could get some obsolete nodes after nextblock was refiled |
312 | in wbuf.c */ | 312 | in wbuf.c */ |
313 | if ( (c->nextblock || !ref_obsolete(new)) | 313 | if ((c->nextblock || !ref_obsolete(new)) |
314 | &&(jeb != c->nextblock || (ref_offset(new)) != jeb->offset + (c->sector_size - jeb->free_size))) { | 314 | &&(jeb != c->nextblock || ref_offset(new) != jeb->offset + (c->sector_size - jeb->free_size))) { |
315 | printk(KERN_WARNING "argh. node added in wrong place\n"); | 315 | printk(KERN_WARNING "argh. node added in wrong place\n"); |
316 | jffs2_free_raw_node_ref(new); | 316 | jffs2_free_raw_node_ref(new); |
317 | return -EINVAL; | 317 | return -EINVAL; |
@@ -335,7 +335,7 @@ int jffs2_add_physical_node_ref(struct jffs2_sb_info *c, struct jffs2_raw_node_r | |||
335 | c->used_size += len; | 335 | c->used_size += len; |
336 | } | 336 | } |
337 | 337 | ||
338 | if (!jeb->free_size && !jeb->dirty_size && !jeb->wasted_size) { | 338 | if (!jeb->free_size && !jeb->dirty_size && !ISDIRTY(jeb->wasted_size)) { |
339 | /* If it lives on the dirty_list, jffs2_reserve_space will put it there */ | 339 | /* If it lives on the dirty_list, jffs2_reserve_space will put it there */ |
340 | D1(printk(KERN_DEBUG "Adding full erase block at 0x%08x to clean_list (free 0x%08x, dirty 0x%08x, used 0x%08x\n", | 340 | D1(printk(KERN_DEBUG "Adding full erase block at 0x%08x to clean_list (free 0x%08x, dirty 0x%08x, used 0x%08x\n", |
341 | jeb->offset, jeb->free_size, jeb->dirty_size, jeb->used_size)); | 341 | jeb->offset, jeb->free_size, jeb->dirty_size, jeb->used_size)); |
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 | } |
diff --git a/fs/jffs2/write.c b/fs/jffs2/write.c index 32c1efaf6a0f..d6b4d55e70e4 100644 --- a/fs/jffs2/write.c +++ b/fs/jffs2/write.c | |||
@@ -7,7 +7,7 @@ | |||
7 | * | 7 | * |
8 | * For licensing information, see the file 'LICENCE' in this directory. | 8 | * For licensing information, see the file 'LICENCE' in this directory. |
9 | * | 9 | * |
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 $ |
11 | * | 11 | * |
12 | */ | 12 | */ |
13 | 13 | ||
@@ -136,19 +136,13 @@ struct jffs2_full_dnode *jffs2_write_dnode(struct jffs2_sb_info *c, struct jffs2 | |||
136 | raw->__totlen = PAD(sizeof(*ri)+datalen); | 136 | raw->__totlen = PAD(sizeof(*ri)+datalen); |
137 | raw->next_phys = NULL; | 137 | raw->next_phys = NULL; |
138 | 138 | ||
139 | if ((alloc_mode!=ALLOC_GC) && (je32_to_cpu(ri->version) < f->highest_version)) | 139 | if ((alloc_mode!=ALLOC_GC) && (je32_to_cpu(ri->version) < f->highest_version)) { |
140 | { | 140 | BUG_ON(!retried); |
141 | if (! retried) | 141 | D1(printk(KERN_DEBUG "jffs2_write_dnode : dnode_version %d, " |
142 | { | 142 | "highest version %d -> updating dnode\n", |
143 | BUG(); | 143 | je32_to_cpu(ri->version), f->highest_version)); |
144 | } | 144 | ri->version = cpu_to_je32(++f->highest_version); |
145 | else | 145 | ri->node_crc = cpu_to_je32(crc32(0, ri, sizeof(*ri)-8)); |
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 | } | ||
152 | } | 146 | } |
153 | 147 | ||
154 | ret = jffs2_flash_writev(c, vecs, cnt, flash_ofs, &retlen, | 148 | 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 | |||
295 | raw->__totlen = PAD(sizeof(*rd)+namelen); | 289 | raw->__totlen = PAD(sizeof(*rd)+namelen); |
296 | raw->next_phys = NULL; | 290 | raw->next_phys = NULL; |
297 | 291 | ||
298 | if ((alloc_mode!=ALLOC_GC) && (je32_to_cpu(rd->version) < f->highest_version)) | 292 | if ((alloc_mode!=ALLOC_GC) && (je32_to_cpu(rd->version) < f->highest_version)) { |
299 | { | 293 | BUG_ON(!retried); |
300 | if (! retried) | 294 | D1(printk(KERN_DEBUG "jffs2_write_dirent : dirent_version %d, " |
301 | { | 295 | "highest version %d -> updating dirent\n", |
302 | BUG(); | 296 | je32_to_cpu(rd->version), f->highest_version)); |
303 | } | 297 | rd->version = cpu_to_je32(++f->highest_version); |
304 | else | 298 | fd->version = je32_to_cpu(rd->version); |
305 | { | 299 | rd->node_crc = cpu_to_je32(crc32(0, rd, sizeof(*rd)-8)); |
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 | } | ||
312 | } | 300 | } |
313 | 301 | ||
314 | ret = jffs2_flash_writev(c, vecs, 2, flash_ofs, &retlen, | 302 | ret = jffs2_flash_writev(c, vecs, 2, flash_ofs, &retlen, |