aboutsummaryrefslogtreecommitdiffstats
path: root/fs/jffs2/wbuf.c
diff options
context:
space:
mode:
authorThomas Gleixner <tglx@cruncher.tec.linutronix.de>2006-05-23 06:37:31 -0400
committerThomas Gleixner <tglx@cruncher.tec.linutronix.de>2006-05-23 06:37:31 -0400
commit4cbb9b80e171107c6c34116283fe38e5a396c68b (patch)
tree9463f2e4774f14752cf4bb52431e14e569256f72 /fs/jffs2/wbuf.c
parent6dfc6d250d0b7ebaa6423c44dcd09fcfe68deabd (diff)
parent9fe4854cd1f60273f9a3ece053f4789605f58a5e (diff)
Merge branch 'master' of /home/tglx/work/kernel/git/mtd-2.6/
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'fs/jffs2/wbuf.c')
-rw-r--r--fs/jffs2/wbuf.c52
1 files changed, 10 insertions, 42 deletions
diff --git a/fs/jffs2/wbuf.c b/fs/jffs2/wbuf.c
index 0442a5753d33..916c87d3393b 100644
--- a/fs/jffs2/wbuf.c
+++ b/fs/jffs2/wbuf.c
@@ -265,12 +265,14 @@ static void jffs2_wbuf_recover(struct jffs2_sb_info *c)
265 265
266 266
267 /* ... and get an allocation of space from a shiny new block instead */ 267 /* ... and get an allocation of space from a shiny new block instead */
268 ret = jffs2_reserve_space_gc(c, end-start, &ofs, &len, JFFS2_SUMMARY_NOSUM_SIZE); 268 ret = jffs2_reserve_space_gc(c, end-start, &len, JFFS2_SUMMARY_NOSUM_SIZE);
269 if (ret) { 269 if (ret) {
270 printk(KERN_WARNING "Failed to allocate space for wbuf recovery. Data loss ensues.\n"); 270 printk(KERN_WARNING "Failed to allocate space for wbuf recovery. Data loss ensues.\n");
271 kfree(buf); 271 kfree(buf);
272 return; 272 return;
273 } 273 }
274 ofs = write_ofs(c);
275
274 if (end-start >= c->wbuf_pagesize) { 276 if (end-start >= c->wbuf_pagesize) {
275 /* Need to do another write immediately, but it's possible 277 /* Need to do another write immediately, but it's possible
276 that this is just because the wbuf itself is completely 278 that this is just because the wbuf itself is completely
@@ -312,9 +314,8 @@ static void jffs2_wbuf_recover(struct jffs2_sb_info *c)
312 return; 314 return;
313 315
314 raw2->flash_offset = ofs | REF_OBSOLETE; 316 raw2->flash_offset = ofs | REF_OBSOLETE;
315 raw2->next_in_ino = NULL;
316 317
317 jffs2_add_physical_node_ref(c, raw2, ref_totlen(c, jeb, *first_raw)); 318 jffs2_add_physical_node_ref(c, raw2, ref_totlen(c, jeb, *first_raw), NULL);
318 } 319 }
319 return; 320 return;
320 } 321 }
@@ -507,11 +508,10 @@ static int __jffs2_flush_wbuf(struct jffs2_sb_info *c, int pad)
507 return -ENOMEM; 508 return -ENOMEM;
508 ref->flash_offset = c->wbuf_ofs + c->wbuf_len; 509 ref->flash_offset = c->wbuf_ofs + c->wbuf_len;
509 ref->flash_offset |= REF_OBSOLETE; 510 ref->flash_offset |= REF_OBSOLETE;
510 ref->next_in_ino = NULL;
511 511
512 spin_lock(&c->erase_completion_lock); 512 spin_lock(&c->erase_completion_lock);
513 513
514 jffs2_link_node_ref(c, jeb, ref, waste); 514 jffs2_link_node_ref(c, jeb, ref, waste, NULL);
515 /* FIXME: that made it count as dirty. Convert to wasted */ 515 /* FIXME: that made it count as dirty. Convert to wasted */
516 jeb->dirty_size -= waste; 516 jeb->dirty_size -= waste;
517 c->dirty_size -= waste; 517 c->dirty_size -= waste;
@@ -650,19 +650,6 @@ int jffs2_flash_writev(struct jffs2_sb_info *c, const struct kvec *invecs,
650 } 650 }
651 651
652 /* 652 /*
653 * Fixup the wbuf if we are moving to a new eraseblock. The
654 * checks below fail for ECC'd NOR because cleanmarker == 16,
655 * so a block starts at xxx0010.
656 */
657 if (jffs2_nor_ecc(c)) {
658 if (((c->wbuf_ofs % c->sector_size) == 0) && !c->wbuf_len) {
659 c->wbuf_ofs = PAGE_DIV(to);
660 c->wbuf_len = PAGE_MOD(to);
661 memset(c->wbuf,0xff,c->wbuf_pagesize);
662 }
663 }
664
665 /*
666 * Sanity checks on target address. It's permitted to write 653 * Sanity checks on target address. It's permitted to write
667 * at PAD(c->wbuf_len+c->wbuf_ofs), and it's permitted to 654 * at PAD(c->wbuf_len+c->wbuf_ofs), and it's permitted to
668 * write at the beginning of a new erase block. Anything else, 655 * write at the beginning of a new erase block. Anything else,
@@ -1107,7 +1094,7 @@ int jffs2_nand_flash_setup(struct jffs2_sb_info *c)
1107 1094
1108 /* Initialise write buffer */ 1095 /* Initialise write buffer */
1109 init_rwsem(&c->wbuf_sem); 1096 init_rwsem(&c->wbuf_sem);
1110 c->wbuf_pagesize = c->mtd->oobblock; 1097 c->wbuf_pagesize = c->mtd->writesize;
1111 c->wbuf_ofs = 0xFFFFFFFF; 1098 c->wbuf_ofs = 0xFFFFFFFF;
1112 1099
1113 c->wbuf = kmalloc(c->wbuf_pagesize, GFP_KERNEL); 1100 c->wbuf = kmalloc(c->wbuf_pagesize, GFP_KERNEL);
@@ -1178,33 +1165,14 @@ void jffs2_dataflash_cleanup(struct jffs2_sb_info *c) {
1178 kfree(c->wbuf); 1165 kfree(c->wbuf);
1179} 1166}
1180 1167
1181int jffs2_nor_ecc_flash_setup(struct jffs2_sb_info *c) {
1182 /* Cleanmarker is actually larger on the flashes */
1183 c->cleanmarker_size = 16;
1184
1185 /* Initialize write buffer */
1186 init_rwsem(&c->wbuf_sem);
1187 c->wbuf_pagesize = c->mtd->eccsize;
1188 c->wbuf_ofs = 0xFFFFFFFF;
1189
1190 c->wbuf = kmalloc(c->wbuf_pagesize, GFP_KERNEL);
1191 if (!c->wbuf)
1192 return -ENOMEM;
1193
1194 return 0;
1195}
1196
1197void jffs2_nor_ecc_flash_cleanup(struct jffs2_sb_info *c) {
1198 kfree(c->wbuf);
1199}
1200
1201int jffs2_nor_wbuf_flash_setup(struct jffs2_sb_info *c) { 1168int jffs2_nor_wbuf_flash_setup(struct jffs2_sb_info *c) {
1202 /* Cleanmarker currently occupies a whole programming region */ 1169 /* Cleanmarker currently occupies whole programming regions,
1203 c->cleanmarker_size = MTD_PROGREGION_SIZE(c->mtd); 1170 * either one or 2 for 8Byte STMicro flashes. */
1171 c->cleanmarker_size = max(16u, c->mtd->writesize);
1204 1172
1205 /* Initialize write buffer */ 1173 /* Initialize write buffer */
1206 init_rwsem(&c->wbuf_sem); 1174 init_rwsem(&c->wbuf_sem);
1207 c->wbuf_pagesize = MTD_PROGREGION_SIZE(c->mtd); 1175 c->wbuf_pagesize = c->mtd->writesize;
1208 c->wbuf_ofs = 0xFFFFFFFF; 1176 c->wbuf_ofs = 0xFFFFFFFF;
1209 1177
1210 c->wbuf = kmalloc(c->wbuf_pagesize, GFP_KERNEL); 1178 c->wbuf = kmalloc(c->wbuf_pagesize, GFP_KERNEL);