aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Woodhouse <dwmw2@infradead.org>2006-05-22 10:23:10 -0400
committerDavid Woodhouse <dwmw2@infradead.org>2006-05-22 10:23:10 -0400
commitfcb7578719529898aef9edce8e409e457a1c2d15 (patch)
tree58022b22d175b69e4b267f2f19ab26d93f7d4910
parenta1b563d652b54647ffacb2d6edf7859d3e97a723 (diff)
[JFFS2] Extend jffs2_link_node_ref() to link into per-inode list too.
Let's avoid the potential for forgetting to set ref->next_in_ino, by doing it within jffs2_link_node_ref() instead. This highlights the ugliness of what we're currently doing with xattr_datum and xattr_ref structures -- we should find a nicer way of dealing with that. Signed-off-by: David Woodhouse <dwmw2@infradead.org>
-rw-r--r--fs/jffs2/erase.c3
-rw-r--r--fs/jffs2/gc.c17
-rw-r--r--fs/jffs2/nodelist.c13
-rw-r--r--fs/jffs2/nodelist.h8
-rw-r--r--fs/jffs2/nodemgmt.c5
-rw-r--r--fs/jffs2/scan.c24
-rw-r--r--fs/jffs2/summary.c30
-rw-r--r--fs/jffs2/wbuf.c6
-rw-r--r--fs/jffs2/write.c23
-rw-r--r--fs/jffs2/xattr.c15
10 files changed, 53 insertions, 91 deletions
diff --git a/fs/jffs2/erase.c b/fs/jffs2/erase.c
index f677d6950fd..0fc19a2fb5d 100644
--- a/fs/jffs2/erase.c
+++ b/fs/jffs2/erase.c
@@ -410,10 +410,9 @@ static void jffs2_mark_erased_block(struct jffs2_sb_info *c, struct jffs2_eraseb
410 /* Everything else got zeroed before the erase */ 410 /* Everything else got zeroed before the erase */
411 jeb->free_size = c->sector_size; 411 jeb->free_size = c->sector_size;
412 412
413 marker_ref->next_in_ino = NULL;
414 marker_ref->flash_offset = jeb->offset | REF_NORMAL; 413 marker_ref->flash_offset = jeb->offset | REF_NORMAL;
415 414
416 jffs2_link_node_ref(c, jeb, marker_ref, c->cleanmarker_size); 415 jffs2_link_node_ref(c, jeb, marker_ref, c->cleanmarker_size, NULL);
417 } 416 }
418 417
419 spin_lock(&c->erase_completion_lock); 418 spin_lock(&c->erase_completion_lock);
diff --git a/fs/jffs2/gc.c b/fs/jffs2/gc.c
index 4773ba24304..153755bc1d5 100644
--- a/fs/jffs2/gc.c
+++ b/fs/jffs2/gc.c
@@ -634,11 +634,8 @@ static int jffs2_garbage_collect_pristine(struct jffs2_sb_info *c,
634 printk(KERN_NOTICE "Write of %d bytes at 0x%08x failed. returned %d, retlen %zd\n", 634 printk(KERN_NOTICE "Write of %d bytes at 0x%08x failed. returned %d, retlen %zd\n",
635 rawlen, phys_ofs, ret, retlen); 635 rawlen, phys_ofs, ret, retlen);
636 if (retlen) { 636 if (retlen) {
637 /* Doesn't belong to any inode */
638 nraw->next_in_ino = NULL;
639
640 nraw->flash_offset |= REF_OBSOLETE; 637 nraw->flash_offset |= REF_OBSOLETE;
641 jffs2_add_physical_node_ref(c, nraw, rawlen); 638 jffs2_add_physical_node_ref(c, nraw, rawlen, NULL);
642 jffs2_mark_node_obsolete(c, nraw); 639 jffs2_mark_node_obsolete(c, nraw);
643 } else { 640 } else {
644 printk(KERN_NOTICE "Not marking the space at 0x%08x as dirty because the flash driver returned retlen zero\n", nraw->flash_offset); 641 printk(KERN_NOTICE "Not marking the space at 0x%08x as dirty because the flash driver returned retlen zero\n", nraw->flash_offset);
@@ -678,18 +675,8 @@ static int jffs2_garbage_collect_pristine(struct jffs2_sb_info *c,
678 goto out_node; 675 goto out_node;
679 } 676 }
680 nraw->flash_offset |= REF_PRISTINE; 677 nraw->flash_offset |= REF_PRISTINE;
681 jffs2_add_physical_node_ref(c, nraw, rawlen); 678 jffs2_add_physical_node_ref(c, nraw, rawlen, ic);
682 679
683 if (ic) {
684 /* Link into per-inode list. This is safe because of the ic
685 state being INO_STATE_GC. Note that if we're doing this
686 for an inode which is in-core, the 'nraw' pointer is then
687 going to be fetched from ic->nodes by our caller. */
688 spin_lock(&c->erase_completion_lock);
689 nraw->next_in_ino = ic->nodes;
690 ic->nodes = nraw;
691 spin_unlock(&c->erase_completion_lock);
692 }
693 jffs2_mark_node_obsolete(c, raw); 680 jffs2_mark_node_obsolete(c, raw);
694 D1(printk(KERN_DEBUG "WHEEE! GC REF_PRISTINE node at 0x%08x succeeded\n", ref_offset(raw))); 681 D1(printk(KERN_DEBUG "WHEEE! GC REF_PRISTINE node at 0x%08x succeeded\n", ref_offset(raw)));
695 682
diff --git a/fs/jffs2/nodelist.c b/fs/jffs2/nodelist.c
index 7d563f938b1..d25d4919ca9 100644
--- a/fs/jffs2/nodelist.c
+++ b/fs/jffs2/nodelist.c
@@ -1048,7 +1048,8 @@ void jffs2_kill_fragtree(struct rb_root *root, struct jffs2_sb_info *c)
1048} 1048}
1049 1049
1050void jffs2_link_node_ref(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, 1050void jffs2_link_node_ref(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb,
1051 struct jffs2_raw_node_ref *ref, uint32_t len) 1051 struct jffs2_raw_node_ref *ref, uint32_t len,
1052 struct jffs2_inode_cache *ic)
1052{ 1053{
1053 if (!jeb->first_node) 1054 if (!jeb->first_node)
1054 jeb->first_node = ref; 1055 jeb->first_node = ref;
@@ -1065,6 +1066,13 @@ void jffs2_link_node_ref(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb,
1065 } 1066 }
1066 jeb->last_node = ref; 1067 jeb->last_node = ref;
1067 1068
1069 if (ic) {
1070 ref->next_in_ino = ic->nodes;
1071 ic->nodes = ref;
1072 } else {
1073 ref->next_in_ino = NULL;
1074 }
1075
1068 switch(ref_flags(ref)) { 1076 switch(ref_flags(ref)) {
1069 case REF_UNCHECKED: 1077 case REF_UNCHECKED:
1070 c->unchecked_size += len; 1078 c->unchecked_size += len;
@@ -1120,12 +1128,11 @@ int jffs2_scan_dirty_space(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb
1120 1128
1121 ref->flash_offset = jeb->offset + c->sector_size - jeb->free_size; 1129 ref->flash_offset = jeb->offset + c->sector_size - jeb->free_size;
1122 ref->flash_offset |= REF_OBSOLETE; 1130 ref->flash_offset |= REF_OBSOLETE;
1123 ref->next_in_ino = 0;
1124#ifdef TEST_TOTLEN 1131#ifdef TEST_TOTLEN
1125 ref->__totlen = size; 1132 ref->__totlen = size;
1126#endif 1133#endif
1127 1134
1128 jffs2_link_node_ref(c, jeb, ref, size); 1135 jffs2_link_node_ref(c, jeb, ref, size, NULL);
1129 } 1136 }
1130 1137
1131 return 0; 1138 return 0;
diff --git a/fs/jffs2/nodelist.h b/fs/jffs2/nodelist.h
index 80d1fda2212..ee5aedcffc1 100644
--- a/fs/jffs2/nodelist.h
+++ b/fs/jffs2/nodelist.h
@@ -307,7 +307,8 @@ int jffs2_add_full_dnode_to_inode(struct jffs2_sb_info *c, struct jffs2_inode_in
307void jffs2_truncate_fragtree (struct jffs2_sb_info *c, struct rb_root *list, uint32_t size); 307void jffs2_truncate_fragtree (struct jffs2_sb_info *c, struct rb_root *list, uint32_t size);
308int jffs2_add_older_frag_to_fragtree(struct jffs2_sb_info *c, struct jffs2_inode_info *f, struct jffs2_tmp_dnode_info *tn); 308int jffs2_add_older_frag_to_fragtree(struct jffs2_sb_info *c, struct jffs2_inode_info *f, struct jffs2_tmp_dnode_info *tn);
309void jffs2_link_node_ref(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, 309void jffs2_link_node_ref(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb,
310 struct jffs2_raw_node_ref *ref, uint32_t len); 310 struct jffs2_raw_node_ref *ref, uint32_t len,
311 struct jffs2_inode_cache *ic);
311extern uint32_t __jffs2_ref_totlen(struct jffs2_sb_info *c, 312extern uint32_t __jffs2_ref_totlen(struct jffs2_sb_info *c,
312 struct jffs2_eraseblock *jeb, 313 struct jffs2_eraseblock *jeb,
313 struct jffs2_raw_node_ref *ref); 314 struct jffs2_raw_node_ref *ref);
@@ -318,7 +319,10 @@ int jffs2_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, uint32_t *ofs
318 uint32_t *len, int prio, uint32_t sumsize); 319 uint32_t *len, int prio, uint32_t sumsize);
319int jffs2_reserve_space_gc(struct jffs2_sb_info *c, uint32_t minsize, uint32_t *ofs, 320int jffs2_reserve_space_gc(struct jffs2_sb_info *c, uint32_t minsize, uint32_t *ofs,
320 uint32_t *len, uint32_t sumsize); 321 uint32_t *len, uint32_t sumsize);
321int jffs2_add_physical_node_ref(struct jffs2_sb_info *c, struct jffs2_raw_node_ref *new, uint32_t len); 322int jffs2_add_physical_node_ref(struct jffs2_sb_info *c,
323 struct jffs2_raw_node_ref *new,
324 uint32_t len,
325 struct jffs2_inode_cache *ic);
322void jffs2_complete_reservation(struct jffs2_sb_info *c); 326void jffs2_complete_reservation(struct jffs2_sb_info *c);
323void jffs2_mark_node_obsolete(struct jffs2_sb_info *c, struct jffs2_raw_node_ref *raw); 327void jffs2_mark_node_obsolete(struct jffs2_sb_info *c, struct jffs2_raw_node_ref *raw);
324 328
diff --git a/fs/jffs2/nodemgmt.c b/fs/jffs2/nodemgmt.c
index 9a0f312cfcd..e10e58eab8e 100644
--- a/fs/jffs2/nodemgmt.c
+++ b/fs/jffs2/nodemgmt.c
@@ -381,7 +381,8 @@ static int jffs2_do_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, uin
381 * Must be called with the alloc_sem held. 381 * Must be called with the alloc_sem held.
382 */ 382 */
383 383
384int jffs2_add_physical_node_ref(struct jffs2_sb_info *c, struct jffs2_raw_node_ref *new, uint32_t len) 384int jffs2_add_physical_node_ref(struct jffs2_sb_info *c, struct jffs2_raw_node_ref *new,
385 uint32_t len, struct jffs2_inode_cache *ic)
385{ 386{
386 struct jffs2_eraseblock *jeb; 387 struct jffs2_eraseblock *jeb;
387 388
@@ -403,7 +404,7 @@ int jffs2_add_physical_node_ref(struct jffs2_sb_info *c, struct jffs2_raw_node_r
403#endif 404#endif
404 spin_lock(&c->erase_completion_lock); 405 spin_lock(&c->erase_completion_lock);
405 406
406 jffs2_link_node_ref(c, jeb, new, len); 407 jffs2_link_node_ref(c, jeb, new, len, ic);
407 408
408 if (!jeb->free_size && !jeb->dirty_size && !ISDIRTY(jeb->wasted_size)) { 409 if (!jeb->free_size && !jeb->dirty_size && !ISDIRTY(jeb->wasted_size)) {
409 /* If it lives on the dirty_list, jffs2_reserve_space will put it there */ 410 /* If it lives on the dirty_list, jffs2_reserve_space will put it there */
diff --git a/fs/jffs2/scan.c b/fs/jffs2/scan.c
index cffafec01e4..6fce703c054 100644
--- a/fs/jffs2/scan.c
+++ b/fs/jffs2/scan.c
@@ -361,9 +361,9 @@ static int jffs2_scan_xattr_node(struct jffs2_sb_info *c, struct jffs2_erasebloc
361 xd->node = raw; 361 xd->node = raw;
362 362
363 raw->flash_offset = ofs | REF_PRISTINE; 363 raw->flash_offset = ofs | REF_PRISTINE;
364 raw->next_in_ino = (void *)xd;
365 364
366 jffs2_link_node_ref(c, jeb, raw, totlen); 365 jffs2_link_node_ref(c, jeb, raw, totlen, NULL);
366 /* FIXME */ raw->next_in_ino = (void *)xd;
367 367
368 if (jffs2_sum_active()) 368 if (jffs2_sum_active())
369 jffs2_sum_add_xattr_mem(s, rx, ofs - jeb->offset); 369 jffs2_sum_add_xattr_mem(s, rx, ofs - jeb->offset);
@@ -425,9 +425,9 @@ static int jffs2_scan_xref_node(struct jffs2_sb_info *c, struct jffs2_eraseblock
425 c->xref_temp = ref; 425 c->xref_temp = ref;
426 426
427 raw->flash_offset = ofs | REF_PRISTINE; 427 raw->flash_offset = ofs | REF_PRISTINE;
428 raw->next_in_ino = (void *)ref;
429 428
430 jffs2_link_node_ref(c, jeb, raw, PAD(je32_to_cpu(rr->totlen))); 429 jffs2_link_node_ref(c, jeb, raw, PAD(je32_to_cpu(rr->totlen)), NULL);
430 /* FIXME */ raw->next_in_ino = (void *)ref;
431 431
432 if (jffs2_sum_active()) 432 if (jffs2_sum_active())
433 jffs2_sum_add_xref_mem(s, rr, ofs - jeb->offset); 433 jffs2_sum_add_xref_mem(s, rr, ofs - jeb->offset);
@@ -844,10 +844,9 @@ scan_more:
844 printk(KERN_NOTICE "Failed to allocate node ref for clean marker\n"); 844 printk(KERN_NOTICE "Failed to allocate node ref for clean marker\n");
845 return -ENOMEM; 845 return -ENOMEM;
846 } 846 }
847 marker_ref->next_in_ino = NULL;
848 marker_ref->flash_offset = ofs | REF_NORMAL; 847 marker_ref->flash_offset = ofs | REF_NORMAL;
849 848
850 jffs2_link_node_ref(c, jeb, marker_ref, c->cleanmarker_size); 849 jffs2_link_node_ref(c, jeb, marker_ref, c->cleanmarker_size, NULL);
851 850
852 ofs += PAD(c->cleanmarker_size); 851 ofs += PAD(c->cleanmarker_size);
853 } 852 }
@@ -892,8 +891,7 @@ scan_more:
892 if (!ref) 891 if (!ref)
893 return -ENOMEM; 892 return -ENOMEM;
894 ref->flash_offset = ofs | REF_PRISTINE; 893 ref->flash_offset = ofs | REF_PRISTINE;
895 ref->next_in_ino = 0; 894 jffs2_link_node_ref(c, jeb, ref, PAD(je32_to_cpu(node->totlen)), NULL);
896 jffs2_link_node_ref(c, jeb, ref, PAD(je32_to_cpu(node->totlen)));
897 895
898 /* We can't summarise nodes we don't grok */ 896 /* We can't summarise nodes we don't grok */
899 jffs2_sum_disable_collecting(s); 897 jffs2_sum_disable_collecting(s);
@@ -1004,10 +1002,7 @@ static int jffs2_scan_inode_node(struct jffs2_sb_info *c, struct jffs2_erasebloc
1004 1002
1005 raw->flash_offset = ofs | REF_UNCHECKED; 1003 raw->flash_offset = ofs | REF_UNCHECKED;
1006 1004
1007 raw->next_in_ino = ic->nodes; 1005 jffs2_link_node_ref(c, jeb, raw, PAD(je32_to_cpu(ri->totlen)), ic);
1008 ic->nodes = raw;
1009
1010 jffs2_link_node_ref(c, jeb, raw, PAD(je32_to_cpu(ri->totlen)));
1011 1006
1012 D1(printk(KERN_DEBUG "Node is ino #%u, version %d. Range 0x%x-0x%x\n", 1007 D1(printk(KERN_DEBUG "Node is ino #%u, version %d. Range 0x%x-0x%x\n",
1013 je32_to_cpu(ri->ino), je32_to_cpu(ri->version), 1008 je32_to_cpu(ri->ino), je32_to_cpu(ri->version),
@@ -1082,10 +1077,7 @@ static int jffs2_scan_dirent_node(struct jffs2_sb_info *c, struct jffs2_eraseblo
1082 } 1077 }
1083 1078
1084 raw->flash_offset = ofs | REF_PRISTINE; 1079 raw->flash_offset = ofs | REF_PRISTINE;
1085 raw->next_in_ino = ic->nodes; 1080 jffs2_link_node_ref(c, jeb, raw, PAD(je32_to_cpu(rd->totlen)), ic);
1086 ic->nodes = raw;
1087
1088 jffs2_link_node_ref(c, jeb, raw, PAD(je32_to_cpu(rd->totlen)));
1089 1081
1090 fd->raw = raw; 1082 fd->raw = raw;
1091 fd->next = NULL; 1083 fd->next = NULL;
diff --git a/fs/jffs2/summary.c b/fs/jffs2/summary.c
index 1451732e1fa..351ba9f8185 100644
--- a/fs/jffs2/summary.c
+++ b/fs/jffs2/summary.c
@@ -430,10 +430,7 @@ static int jffs2_sum_process_sum_data(struct jffs2_sb_info *c, struct jffs2_eras
430 430
431 raw->flash_offset |= REF_UNCHECKED; 431 raw->flash_offset |= REF_UNCHECKED;
432 432
433 raw->next_in_ino = ic->nodes; 433 jffs2_link_node_ref(c, jeb, raw, PAD(je32_to_cpu(spi->totlen)), ic);
434 ic->nodes = raw;
435
436 jffs2_link_node_ref(c, jeb, raw, PAD(je32_to_cpu(spi->totlen)));
437 434
438 *pseudo_random += je32_to_cpu(spi->version); 435 *pseudo_random += je32_to_cpu(spi->version);
439 436
@@ -473,10 +470,7 @@ static int jffs2_sum_process_sum_data(struct jffs2_sb_info *c, struct jffs2_eras
473 } 470 }
474 471
475 raw->flash_offset |= REF_PRISTINE; 472 raw->flash_offset |= REF_PRISTINE;
476 raw->next_in_ino = ic->nodes; 473 jffs2_link_node_ref(c, jeb, raw, PAD(je32_to_cpu(spd->totlen)), ic);
477 ic->nodes = raw;
478
479 jffs2_link_node_ref(c, jeb, raw, PAD(je32_to_cpu(spd->totlen)));
480 474
481 fd->raw = raw; 475 fd->raw = raw;
482 fd->next = NULL; 476 fd->next = NULL;
@@ -525,9 +519,9 @@ static int jffs2_sum_process_sum_data(struct jffs2_sb_info *c, struct jffs2_eras
525 xd->node = raw; 519 xd->node = raw;
526 520
527 raw->flash_offset |= REF_UNCHECKED; 521 raw->flash_offset |= REF_UNCHECKED;
528 raw->next_in_ino = (void *)xd;
529 522
530 jffs2_link_node_ref(c, jeb, raw, PAD(je32_to_cpu(spx->totlen))); 523 jffs2_link_node_ref(c, jeb, raw, PAD(je32_to_cpu(spx->totlen)), NULL);
524 /* FIXME */ raw->next_in_ino = (void *)xd;
531 525
532 *pseudo_random += je32_to_cpu(spx->xid); 526 *pseudo_random += je32_to_cpu(spx->xid);
533 sp += JFFS2_SUMMARY_XATTR_SIZE; 527 sp += JFFS2_SUMMARY_XATTR_SIZE;
@@ -561,9 +555,9 @@ static int jffs2_sum_process_sum_data(struct jffs2_sb_info *c, struct jffs2_eras
561 c->xref_temp = ref; 555 c->xref_temp = ref;
562 556
563 raw->flash_offset |= REF_UNCHECKED; 557 raw->flash_offset |= REF_UNCHECKED;
564 raw->next_in_ino = (void *)ref;
565 558
566 jffs2_link_node_ref(c, jeb, raw, PAD(sizeof(struct jffs2_raw_xref))); 559 jffs2_link_node_ref(c, jeb, raw, PAD(sizeof(struct jffs2_raw_xref)), NULL);
560 /* FIXME */ raw->next_in_ino = (void *)ref;
567 561
568 *pseudo_random += raw->flash_offset; 562 *pseudo_random += raw->flash_offset;
569 sp += JFFS2_SUMMARY_XREF_SIZE; 563 sp += JFFS2_SUMMARY_XREF_SIZE;
@@ -664,9 +658,8 @@ int jffs2_sum_scan_sumnode(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb
664 } 658 }
665 659
666 marker_ref->flash_offset = jeb->offset | REF_NORMAL; 660 marker_ref->flash_offset = jeb->offset | REF_NORMAL;
667 marker_ref->next_in_ino = NULL;
668 661
669 jffs2_link_node_ref(c, jeb, marker_ref, je32_to_cpu(summary->cln_mkr)); 662 jffs2_link_node_ref(c, jeb, marker_ref, je32_to_cpu(summary->cln_mkr), NULL);
670 } 663 }
671 } 664 }
672 665
@@ -686,10 +679,9 @@ int jffs2_sum_scan_sumnode(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb
686 return -ENOMEM; 679 return -ENOMEM;
687 } 680 }
688 681
689 cache_ref->next_in_ino = NULL;
690 cache_ref->flash_offset |= REF_NORMAL; 682 cache_ref->flash_offset |= REF_NORMAL;
691 683
692 jffs2_link_node_ref(c, jeb, cache_ref, sumsize); 684 jffs2_link_node_ref(c, jeb, cache_ref, sumsize, NULL);
693 685
694 if (unlikely(jeb->free_size)) { 686 if (unlikely(jeb->free_size)) {
695 JFFS2_WARNING("Free size 0x%x bytes in eraseblock @0x%08x with summary?\n", 687 JFFS2_WARNING("Free size 0x%x bytes in eraseblock @0x%08x with summary?\n",
@@ -849,9 +841,8 @@ static int jffs2_sum_write_data(struct jffs2_sb_info *c, struct jffs2_eraseblock
849 841
850 ref->flash_offset = jeb->offset + c->sector_size - jeb->free_size; 842 ref->flash_offset = jeb->offset + c->sector_size - jeb->free_size;
851 ref->flash_offset |= REF_OBSOLETE; 843 ref->flash_offset |= REF_OBSOLETE;
852 ref->next_in_ino = 0;
853 844
854 jffs2_link_node_ref(c, jeb, ref, c->sector_size - jeb->free_size); 845 jffs2_link_node_ref(c, jeb, ref, c->sector_size - jeb->free_size, NULL);
855 } 846 }
856 847
857 c->summary->sum_size = JFFS2_SUMMARY_NOSUM_SIZE; 848 c->summary->sum_size = JFFS2_SUMMARY_NOSUM_SIZE;
@@ -909,11 +900,10 @@ int jffs2_sum_write_sumnode(struct jffs2_sb_info *c)
909 return -ENOMEM; 900 return -ENOMEM;
910 } 901 }
911 902
912 summary_ref->next_in_ino = NULL;
913 summary_ref->flash_offset = (jeb->offset + c->sector_size - jeb->free_size) | REF_NORMAL; 903 summary_ref->flash_offset = (jeb->offset + c->sector_size - jeb->free_size) | REF_NORMAL;
914 904
915 spin_lock(&c->erase_completion_lock); 905 spin_lock(&c->erase_completion_lock);
916 jffs2_link_node_ref(c, jeb, summary_ref, infosize); 906 jffs2_link_node_ref(c, jeb, summary_ref, infosize, NULL);
917 907
918 return 0; 908 return 0;
919} 909}
diff --git a/fs/jffs2/wbuf.c b/fs/jffs2/wbuf.c
index 45e3573cf10..62f685faeba 100644
--- a/fs/jffs2/wbuf.c
+++ b/fs/jffs2/wbuf.c
@@ -312,9 +312,8 @@ static void jffs2_wbuf_recover(struct jffs2_sb_info *c)
312 return; 312 return;
313 313
314 raw2->flash_offset = ofs | REF_OBSOLETE; 314 raw2->flash_offset = ofs | REF_OBSOLETE;
315 raw2->next_in_ino = NULL;
316 315
317 jffs2_add_physical_node_ref(c, raw2, ref_totlen(c, jeb, *first_raw)); 316 jffs2_add_physical_node_ref(c, raw2, ref_totlen(c, jeb, *first_raw), NULL);
318 } 317 }
319 return; 318 return;
320 } 319 }
@@ -507,11 +506,10 @@ static int __jffs2_flush_wbuf(struct jffs2_sb_info *c, int pad)
507 return -ENOMEM; 506 return -ENOMEM;
508 ref->flash_offset = c->wbuf_ofs + c->wbuf_len; 507 ref->flash_offset = c->wbuf_ofs + c->wbuf_len;
509 ref->flash_offset |= REF_OBSOLETE; 508 ref->flash_offset |= REF_OBSOLETE;
510 ref->next_in_ino = NULL;
511 509
512 spin_lock(&c->erase_completion_lock); 510 spin_lock(&c->erase_completion_lock);
513 511
514 jffs2_link_node_ref(c, jeb, ref, waste); 512 jffs2_link_node_ref(c, jeb, ref, waste, NULL);
515 /* FIXME: that made it count as dirty. Convert to wasted */ 513 /* FIXME: that made it count as dirty. Convert to wasted */
516 jeb->dirty_size -= waste; 514 jeb->dirty_size -= waste;
517 c->dirty_size -= waste; 515 c->dirty_size -= waste;
diff --git a/fs/jffs2/write.c b/fs/jffs2/write.c
index 4462541d11f..319a70f531f 100644
--- a/fs/jffs2/write.c
+++ b/fs/jffs2/write.c
@@ -122,16 +122,13 @@ struct jffs2_full_dnode *jffs2_write_dnode(struct jffs2_sb_info *c, struct jffs2
122 122
123 /* Mark the space as dirtied */ 123 /* Mark the space as dirtied */
124 if (retlen) { 124 if (retlen) {
125 /* Doesn't belong to any inode */
126 raw->next_in_ino = NULL;
127
128 /* Don't change raw->size to match retlen. We may have 125 /* Don't change raw->size to match retlen. We may have
129 written the node header already, and only the data will 126 written the node header already, and only the data will
130 seem corrupted, in which case the scan would skip over 127 seem corrupted, in which case the scan would skip over
131 any node we write before the original intended end of 128 any node we write before the original intended end of
132 this node */ 129 this node */
133 raw->flash_offset |= REF_OBSOLETE; 130 raw->flash_offset |= REF_OBSOLETE;
134 jffs2_add_physical_node_ref(c, raw, PAD(sizeof(*ri)+datalen)); 131 jffs2_add_physical_node_ref(c, raw, PAD(sizeof(*ri)+datalen), NULL);
135 jffs2_mark_node_obsolete(c, raw); 132 jffs2_mark_node_obsolete(c, raw);
136 } else { 133 } else {
137 printk(KERN_NOTICE "Not marking the space at 0x%08x as dirty because the flash driver returned retlen zero\n", raw->flash_offset); 134 printk(KERN_NOTICE "Not marking the space at 0x%08x as dirty because the flash driver returned retlen zero\n", raw->flash_offset);
@@ -189,13 +186,7 @@ struct jffs2_full_dnode *jffs2_write_dnode(struct jffs2_sb_info *c, struct jffs2
189 } else { 186 } else {
190 raw->flash_offset |= REF_NORMAL; 187 raw->flash_offset |= REF_NORMAL;
191 } 188 }
192 jffs2_add_physical_node_ref(c, raw, PAD(sizeof(*ri)+datalen)); 189 jffs2_add_physical_node_ref(c, raw, PAD(sizeof(*ri)+datalen), f->inocache);
193
194 /* Link into per-inode list */
195 spin_lock(&c->erase_completion_lock);
196 raw->next_in_ino = f->inocache->nodes;
197 f->inocache->nodes = raw;
198 spin_unlock(&c->erase_completion_lock);
199 190
200 D1(printk(KERN_DEBUG "jffs2_write_dnode wrote node at 0x%08x(%d) with dsize 0x%x, csize 0x%x, node_crc 0x%08x, data_crc 0x%08x, totlen 0x%08x\n", 191 D1(printk(KERN_DEBUG "jffs2_write_dnode wrote node at 0x%08x(%d) with dsize 0x%x, csize 0x%x, node_crc 0x%08x, data_crc 0x%08x, totlen 0x%08x\n",
201 flash_ofs, ref_flags(raw), je32_to_cpu(ri->dsize), 192 flash_ofs, ref_flags(raw), je32_to_cpu(ri->dsize),
@@ -275,9 +266,8 @@ struct jffs2_full_dirent *jffs2_write_dirent(struct jffs2_sb_info *c, struct jff
275 sizeof(*rd)+namelen, flash_ofs, ret, retlen); 266 sizeof(*rd)+namelen, flash_ofs, ret, retlen);
276 /* Mark the space as dirtied */ 267 /* Mark the space as dirtied */
277 if (retlen) { 268 if (retlen) {
278 raw->next_in_ino = NULL;
279 raw->flash_offset |= REF_OBSOLETE; 269 raw->flash_offset |= REF_OBSOLETE;
280 jffs2_add_physical_node_ref(c, raw, PAD(sizeof(*rd)+namelen)); 270 jffs2_add_physical_node_ref(c, raw, PAD(sizeof(*rd)+namelen), NULL);
281 jffs2_mark_node_obsolete(c, raw); 271 jffs2_mark_node_obsolete(c, raw);
282 } else { 272 } else {
283 printk(KERN_NOTICE "Not marking the space at 0x%08x as dirty because the flash driver returned retlen zero\n", raw->flash_offset); 273 printk(KERN_NOTICE "Not marking the space at 0x%08x as dirty because the flash driver returned retlen zero\n", raw->flash_offset);
@@ -323,12 +313,7 @@ struct jffs2_full_dirent *jffs2_write_dirent(struct jffs2_sb_info *c, struct jff
323 } 313 }
324 /* Mark the space used */ 314 /* Mark the space used */
325 raw->flash_offset |= REF_PRISTINE; 315 raw->flash_offset |= REF_PRISTINE;
326 jffs2_add_physical_node_ref(c, raw, PAD(sizeof(*rd)+namelen)); 316 jffs2_add_physical_node_ref(c, raw, PAD(sizeof(*rd)+namelen), f->inocache);
327
328 spin_lock(&c->erase_completion_lock);
329 raw->next_in_ino = f->inocache->nodes;
330 f->inocache->nodes = raw;
331 spin_unlock(&c->erase_completion_lock);
332 317
333 if (retried) { 318 if (retried) {
334 jffs2_dbg_acct_sanity_check(c,NULL); 319 jffs2_dbg_acct_sanity_check(c,NULL);
diff --git a/fs/jffs2/xattr.c b/fs/jffs2/xattr.c
index e16f8460ff0..76d16614038 100644
--- a/fs/jffs2/xattr.c
+++ b/fs/jffs2/xattr.c
@@ -322,7 +322,6 @@ static int save_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum *x
322 if (!raw) 322 if (!raw)
323 return -ENOMEM; 323 return -ENOMEM;
324 raw->flash_offset = phys_ofs; 324 raw->flash_offset = phys_ofs;
325 raw->next_in_ino = (void *)xd;
326 325
327 /* Setup raw-xattr */ 326 /* Setup raw-xattr */
328 rx.magic = cpu_to_je16(JFFS2_MAGIC_BITMASK); 327 rx.magic = cpu_to_je16(JFFS2_MAGIC_BITMASK);
@@ -345,8 +344,7 @@ static int save_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum *x
345 rc = rc ? rc : -EIO; 344 rc = rc ? rc : -EIO;
346 if (length) { 345 if (length) {
347 raw->flash_offset |= REF_OBSOLETE; 346 raw->flash_offset |= REF_OBSOLETE;
348 raw->next_in_ino = NULL; 347 jffs2_add_physical_node_ref(c, raw, PAD(totlen), NULL);
349 jffs2_add_physical_node_ref(c, raw, PAD(totlen));
350 jffs2_mark_node_obsolete(c, raw); 348 jffs2_mark_node_obsolete(c, raw);
351 } else { 349 } else {
352 jffs2_free_raw_node_ref(raw); 350 jffs2_free_raw_node_ref(raw);
@@ -356,7 +354,9 @@ static int save_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum *x
356 354
357 /* success */ 355 /* success */
358 raw->flash_offset |= REF_PRISTINE; 356 raw->flash_offset |= REF_PRISTINE;
359 jffs2_add_physical_node_ref(c, raw, PAD(totlen)); 357 jffs2_add_physical_node_ref(c, raw, PAD(totlen), NULL);
358 /* FIXME */ raw->next_in_ino = (void *)xd;
359
360 if (xd->node) 360 if (xd->node)
361 delete_xattr_datum_node(c, xd); 361 delete_xattr_datum_node(c, xd);
362 xd->node = raw; 362 xd->node = raw;
@@ -566,7 +566,6 @@ static int save_xattr_ref(struct jffs2_sb_info *c, struct jffs2_xattr_ref *ref,
566 if (!raw) 566 if (!raw)
567 return -ENOMEM; 567 return -ENOMEM;
568 raw->flash_offset = phys_ofs; 568 raw->flash_offset = phys_ofs;
569 raw->next_in_ino = (void *)ref;
570 569
571 rr.magic = cpu_to_je16(JFFS2_MAGIC_BITMASK); 570 rr.magic = cpu_to_je16(JFFS2_MAGIC_BITMASK);
572 rr.nodetype = cpu_to_je16(JFFS2_NODETYPE_XREF); 571 rr.nodetype = cpu_to_je16(JFFS2_NODETYPE_XREF);
@@ -584,8 +583,7 @@ static int save_xattr_ref(struct jffs2_sb_info *c, struct jffs2_xattr_ref *ref,
584 ret = ret ? ret : -EIO; 583 ret = ret ? ret : -EIO;
585 if (length) { 584 if (length) {
586 raw->flash_offset |= REF_OBSOLETE; 585 raw->flash_offset |= REF_OBSOLETE;
587 raw->next_in_ino = NULL; 586 jffs2_add_physical_node_ref(c, raw, PAD(sizeof(rr)), NULL);
588 jffs2_add_physical_node_ref(c, raw, PAD(sizeof(rr)));
589 jffs2_mark_node_obsolete(c, raw); 587 jffs2_mark_node_obsolete(c, raw);
590 } else { 588 } else {
591 jffs2_free_raw_node_ref(raw); 589 jffs2_free_raw_node_ref(raw);
@@ -594,7 +592,8 @@ static int save_xattr_ref(struct jffs2_sb_info *c, struct jffs2_xattr_ref *ref,
594 } 592 }
595 raw->flash_offset |= REF_PRISTINE; 593 raw->flash_offset |= REF_PRISTINE;
596 594
597 jffs2_add_physical_node_ref(c, raw, PAD(sizeof(rr))); 595 jffs2_add_physical_node_ref(c, raw, PAD(sizeof(rr)), NULL);
596 /* FIXME */ raw->next_in_ino = (void *)ref;
598 if (ref->node) 597 if (ref->node)
599 delete_xattr_ref_node(c, ref); 598 delete_xattr_ref_node(c, ref);
600 ref->node = raw; 599 ref->node = raw;