aboutsummaryrefslogtreecommitdiffstats
path: root/fs/jffs2/nodelist.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/jffs2/nodelist.c')
-rw-r--r--fs/jffs2/nodelist.c107
1 files changed, 55 insertions, 52 deletions
diff --git a/fs/jffs2/nodelist.c b/fs/jffs2/nodelist.c
index 9abb5f4cfd75..80fe8feffb4d 100644
--- a/fs/jffs2/nodelist.c
+++ b/fs/jffs2/nodelist.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: nodelist.c,v 1.112 2005/08/22 09:07:09 dedekind Exp $ 10 * $Id: nodelist.c,v 1.114 2005/09/21 13:28:35 dedekind Exp $
11 * 11 *
12 */ 12 */
13 13
@@ -25,18 +25,18 @@ void jffs2_add_fd_to_list(struct jffs2_sb_info *c, struct jffs2_full_dirent *new
25{ 25{
26 struct jffs2_full_dirent **prev = list; 26 struct jffs2_full_dirent **prev = list;
27 27
28 JFFS2_DBG_DENTLIST("add dirent \"%s\", ino #%u\n", new->name, new->ino); 28 dbg_dentlist("add dirent \"%s\", ino #%u\n", new->name, new->ino);
29 29
30 while ((*prev) && (*prev)->nhash <= new->nhash) { 30 while ((*prev) && (*prev)->nhash <= new->nhash) {
31 if ((*prev)->nhash == new->nhash && !strcmp((*prev)->name, new->name)) { 31 if ((*prev)->nhash == new->nhash && !strcmp((*prev)->name, new->name)) {
32 /* Duplicate. Free one */ 32 /* Duplicate. Free one */
33 if (new->version < (*prev)->version) { 33 if (new->version < (*prev)->version) {
34 JFFS2_DBG_DENTLIST("Eep! Marking new dirent node is obsolete, old is \"%s\", ino #%u\n", 34 dbg_dentlist("Eep! Marking new dirent node is obsolete, old is \"%s\", ino #%u\n",
35 (*prev)->name, (*prev)->ino); 35 (*prev)->name, (*prev)->ino);
36 jffs2_mark_node_obsolete(c, new->raw); 36 jffs2_mark_node_obsolete(c, new->raw);
37 jffs2_free_full_dirent(new); 37 jffs2_free_full_dirent(new);
38 } else { 38 } else {
39 JFFS2_DBG_DENTLIST("marking old dirent \"%s\", ino #%u bsolete\n", 39 dbg_dentlist("marking old dirent \"%s\", ino #%u bsolete\n",
40 (*prev)->name, (*prev)->ino); 40 (*prev)->name, (*prev)->ino);
41 new->next = (*prev)->next; 41 new->next = (*prev)->next;
42 jffs2_mark_node_obsolete(c, ((*prev)->raw)); 42 jffs2_mark_node_obsolete(c, ((*prev)->raw));
@@ -55,7 +55,7 @@ void jffs2_truncate_fragtree(struct jffs2_sb_info *c, struct rb_root *list, uint
55{ 55{
56 struct jffs2_node_frag *frag = jffs2_lookup_node_frag(list, size); 56 struct jffs2_node_frag *frag = jffs2_lookup_node_frag(list, size);
57 57
58 JFFS2_DBG_FRAGTREE("truncating fragtree to 0x%08x bytes\n", size); 58 dbg_fragtree("truncating fragtree to 0x%08x bytes\n", size);
59 59
60 /* We know frag->ofs <= size. That's what lookup does for us */ 60 /* We know frag->ofs <= size. That's what lookup does for us */
61 if (frag && frag->ofs != size) { 61 if (frag && frag->ofs != size) {
@@ -81,7 +81,7 @@ void jffs2_truncate_fragtree(struct jffs2_sb_info *c, struct rb_root *list, uint
81 */ 81 */
82 frag = frag_last(list); 82 frag = frag_last(list);
83 if (frag->node && (frag->ofs & (PAGE_CACHE_SIZE - 1)) == 0) { 83 if (frag->node && (frag->ofs & (PAGE_CACHE_SIZE - 1)) == 0) {
84 JFFS2_DBG_FRAGTREE2("marking the last fragment 0x%08x-0x%08x REF_PRISTINE.\n", 84 dbg_fragtree2("marking the last fragment 0x%08x-0x%08x REF_PRISTINE.\n",
85 frag->ofs, frag->ofs + frag->size); 85 frag->ofs, frag->ofs + frag->size);
86 frag->node->raw->flash_offset = ref_offset(frag->node->raw) | REF_PRISTINE; 86 frag->node->raw->flash_offset = ref_offset(frag->node->raw) | REF_PRISTINE;
87 } 87 }
@@ -93,12 +93,12 @@ void jffs2_obsolete_node_frag(struct jffs2_sb_info *c, struct jffs2_node_frag *t
93 this->node->frags--; 93 this->node->frags--;
94 if (!this->node->frags) { 94 if (!this->node->frags) {
95 /* The node has no valid frags left. It's totally obsoleted */ 95 /* The node has no valid frags left. It's totally obsoleted */
96 JFFS2_DBG_FRAGTREE2("marking old node @0x%08x (0x%04x-0x%04x) obsolete\n", 96 dbg_fragtree2("marking old node @0x%08x (0x%04x-0x%04x) obsolete\n",
97 ref_offset(this->node->raw), this->node->ofs, this->node->ofs+this->node->size); 97 ref_offset(this->node->raw), this->node->ofs, this->node->ofs+this->node->size);
98 jffs2_mark_node_obsolete(c, this->node->raw); 98 jffs2_mark_node_obsolete(c, this->node->raw);
99 jffs2_free_full_dnode(this->node); 99 jffs2_free_full_dnode(this->node);
100 } else { 100 } else {
101 JFFS2_DBG_FRAGTREE2("marking old node @0x%08x (0x%04x-0x%04x) REF_NORMAL. frags is %d\n", 101 dbg_fragtree2("marking old node @0x%08x (0x%04x-0x%04x) REF_NORMAL. frags is %d\n",
102 ref_offset(this->node->raw), this->node->ofs, this->node->ofs+this->node->size, this->node->frags); 102 ref_offset(this->node->raw), this->node->ofs, this->node->ofs+this->node->size, this->node->frags);
103 mark_ref_normal(this->node->raw); 103 mark_ref_normal(this->node->raw);
104 } 104 }
@@ -112,7 +112,7 @@ static void jffs2_fragtree_insert(struct jffs2_node_frag *newfrag, struct jffs2_
112 struct rb_node *parent = &base->rb; 112 struct rb_node *parent = &base->rb;
113 struct rb_node **link = &parent; 113 struct rb_node **link = &parent;
114 114
115 JFFS2_DBG_FRAGTREE2("insert frag (0x%04x-0x%04x)\n", newfrag->ofs, newfrag->ofs + newfrag->size); 115 dbg_fragtree2("insert frag (0x%04x-0x%04x)\n", newfrag->ofs, newfrag->ofs + newfrag->size);
116 116
117 while (*link) { 117 while (*link) {
118 parent = *link; 118 parent = *link;
@@ -172,11 +172,11 @@ static int no_overlapping_node(struct jffs2_sb_info *c, struct rb_root *root,
172 /* By definition, the 'this' node has no right-hand child, 172 /* By definition, the 'this' node has no right-hand child,
173 because there are no frags with offset greater than it. 173 because there are no frags with offset greater than it.
174 So that's where we want to put the hole */ 174 So that's where we want to put the hole */
175 JFFS2_DBG_FRAGTREE2("add hole frag %#04x-%#04x on the right of the new frag.\n", 175 dbg_fragtree2("add hole frag %#04x-%#04x on the right of the new frag.\n",
176 holefrag->ofs, holefrag->ofs + holefrag->size); 176 holefrag->ofs, holefrag->ofs + holefrag->size);
177 rb_link_node(&holefrag->rb, &this->rb, &this->rb.rb_right); 177 rb_link_node(&holefrag->rb, &this->rb, &this->rb.rb_right);
178 } else { 178 } else {
179 JFFS2_DBG_FRAGTREE2("Add hole frag %#04x-%#04x to the root of the tree.\n", 179 dbg_fragtree2("Add hole frag %#04x-%#04x to the root of the tree.\n",
180 holefrag->ofs, holefrag->ofs + holefrag->size); 180 holefrag->ofs, holefrag->ofs + holefrag->size);
181 rb_link_node(&holefrag->rb, NULL, &root->rb_node); 181 rb_link_node(&holefrag->rb, NULL, &root->rb_node);
182 } 182 }
@@ -188,10 +188,10 @@ static int no_overlapping_node(struct jffs2_sb_info *c, struct rb_root *root,
188 /* By definition, the 'this' node has no right-hand child, 188 /* By definition, the 'this' node has no right-hand child,
189 because there are no frags with offset greater than it. 189 because there are no frags with offset greater than it.
190 So that's where we want to put new fragment */ 190 So that's where we want to put new fragment */
191 JFFS2_DBG_FRAGTREE2("add the new node at the right\n"); 191 dbg_fragtree2("add the new node at the right\n");
192 rb_link_node(&newfrag->rb, &this->rb, &this->rb.rb_right); 192 rb_link_node(&newfrag->rb, &this->rb, &this->rb.rb_right);
193 } else { 193 } else {
194 JFFS2_DBG_FRAGTREE2("insert the new node at the root of the tree\n"); 194 dbg_fragtree2("insert the new node at the root of the tree\n");
195 rb_link_node(&newfrag->rb, NULL, &root->rb_node); 195 rb_link_node(&newfrag->rb, NULL, &root->rb_node);
196 } 196 }
197 rb_insert_color(&newfrag->rb, root); 197 rb_insert_color(&newfrag->rb, root);
@@ -209,11 +209,11 @@ static int jffs2_add_frag_to_fragtree(struct jffs2_sb_info *c, struct rb_root *r
209 this = jffs2_lookup_node_frag(root, newfrag->node->ofs); 209 this = jffs2_lookup_node_frag(root, newfrag->node->ofs);
210 210
211 if (this) { 211 if (this) {
212 JFFS2_DBG_FRAGTREE2("lookup gave frag 0x%04x-0x%04x; phys 0x%08x (*%p)\n", 212 dbg_fragtree2("lookup gave frag 0x%04x-0x%04x; phys 0x%08x (*%p)\n",
213 this->ofs, this->ofs+this->size, this->node?(ref_offset(this->node->raw)):0xffffffff, this); 213 this->ofs, this->ofs+this->size, this->node?(ref_offset(this->node->raw)):0xffffffff, this);
214 lastend = this->ofs + this->size; 214 lastend = this->ofs + this->size;
215 } else { 215 } else {
216 JFFS2_DBG_FRAGTREE2("lookup gave no frag\n"); 216 dbg_fragtree2("lookup gave no frag\n");
217 lastend = 0; 217 lastend = 0;
218 } 218 }
219 219
@@ -235,11 +235,11 @@ static int jffs2_add_frag_to_fragtree(struct jffs2_sb_info *c, struct rb_root *r
235 } 235 }
236 236
237 if (this->node) 237 if (this->node)
238 JFFS2_DBG_FRAGTREE2("dealing with frag %u-%u, phys %#08x(%d).\n", 238 dbg_fragtree2("dealing with frag %u-%u, phys %#08x(%d).\n",
239 this->ofs, this->ofs + this->size, 239 this->ofs, this->ofs + this->size,
240 ref_offset(this->node->raw), ref_flags(this->node->raw)); 240 ref_offset(this->node->raw), ref_flags(this->node->raw));
241 else 241 else
242 JFFS2_DBG_FRAGTREE2("dealing with hole frag %u-%u.\n", 242 dbg_fragtree2("dealing with hole frag %u-%u.\n",
243 this->ofs, this->ofs + this->size); 243 this->ofs, this->ofs + this->size);
244 244
245 /* OK. 'this' is pointing at the first frag that newfrag->ofs at least partially obsoletes, 245 /* OK. 'this' is pointing at the first frag that newfrag->ofs at least partially obsoletes,
@@ -259,10 +259,10 @@ static int jffs2_add_frag_to_fragtree(struct jffs2_sb_info *c, struct rb_root *r
259 struct jffs2_node_frag *newfrag2; 259 struct jffs2_node_frag *newfrag2;
260 260
261 if (this->node) 261 if (this->node)
262 JFFS2_DBG_FRAGTREE2("split old frag 0x%04x-0x%04x, phys 0x%08x\n", 262 dbg_fragtree2("split old frag 0x%04x-0x%04x, phys 0x%08x\n",
263 this->ofs, this->ofs+this->size, ref_offset(this->node->raw)); 263 this->ofs, this->ofs+this->size, ref_offset(this->node->raw));
264 else 264 else
265 JFFS2_DBG_FRAGTREE2("split old hole frag 0x%04x-0x%04x\n", 265 dbg_fragtree2("split old hole frag 0x%04x-0x%04x\n",
266 this->ofs, this->ofs+this->size); 266 this->ofs, this->ofs+this->size);
267 267
268 /* New second frag pointing to this's node */ 268 /* New second frag pointing to this's node */
@@ -299,13 +299,13 @@ static int jffs2_add_frag_to_fragtree(struct jffs2_sb_info *c, struct rb_root *r
299 } else { 299 } else {
300 /* New frag starts at the same point as 'this' used to. Replace 300 /* New frag starts at the same point as 'this' used to. Replace
301 it in the tree without doing a delete and insertion */ 301 it in the tree without doing a delete and insertion */
302 JFFS2_DBG_FRAGTREE2("inserting newfrag (*%p),%d-%d in before 'this' (*%p),%d-%d\n", 302 dbg_fragtree2("inserting newfrag (*%p),%d-%d in before 'this' (*%p),%d-%d\n",
303 newfrag, newfrag->ofs, newfrag->ofs+newfrag->size, this, this->ofs, this->ofs+this->size); 303 newfrag, newfrag->ofs, newfrag->ofs+newfrag->size, this, this->ofs, this->ofs+this->size);
304 304
305 rb_replace_node(&this->rb, &newfrag->rb, root); 305 rb_replace_node(&this->rb, &newfrag->rb, root);
306 306
307 if (newfrag->ofs + newfrag->size >= this->ofs+this->size) { 307 if (newfrag->ofs + newfrag->size >= this->ofs+this->size) {
308 JFFS2_DBG_FRAGTREE2("obsoleting node frag %p (%x-%x)\n", this, this->ofs, this->ofs+this->size); 308 dbg_fragtree2("obsoleting node frag %p (%x-%x)\n", this, this->ofs, this->ofs+this->size);
309 jffs2_obsolete_node_frag(c, this); 309 jffs2_obsolete_node_frag(c, this);
310 } else { 310 } else {
311 this->ofs += newfrag->size; 311 this->ofs += newfrag->size;
@@ -321,7 +321,7 @@ static int jffs2_add_frag_to_fragtree(struct jffs2_sb_info *c, struct rb_root *r
321 */ 321 */
322 while ((this = frag_next(newfrag)) && newfrag->ofs + newfrag->size >= this->ofs + this->size) { 322 while ((this = frag_next(newfrag)) && newfrag->ofs + newfrag->size >= this->ofs + this->size) {
323 /* 'this' frag is obsoleted completely. */ 323 /* 'this' frag is obsoleted completely. */
324 JFFS2_DBG_FRAGTREE2("obsoleting node frag %p (%x-%x) and removing from tree\n", 324 dbg_fragtree2("obsoleting node frag %p (%x-%x) and removing from tree\n",
325 this, this->ofs, this->ofs+this->size); 325 this, this->ofs, this->ofs+this->size);
326 rb_erase(&this->rb, root); 326 rb_erase(&this->rb, root);
327 jffs2_obsolete_node_frag(c, this); 327 jffs2_obsolete_node_frag(c, this);
@@ -361,7 +361,7 @@ int jffs2_add_full_dnode_to_inode(struct jffs2_sb_info *c, struct jffs2_inode_in
361 return -ENOMEM; 361 return -ENOMEM;
362 newfrag->node->frags = 1; 362 newfrag->node->frags = 1;
363 363
364 JFFS2_DBG_FRAGTREE("adding node %#04x-%#04x @0x%08x on flash, newfrag *%p\n", 364 dbg_fragtree("adding node %#04x-%#04x @0x%08x on flash, newfrag *%p\n",
365 fn->ofs, fn->ofs+fn->size, ref_offset(fn->raw), newfrag); 365 fn->ofs, fn->ofs+fn->size, ref_offset(fn->raw), newfrag);
366 366
367 ret = jffs2_add_frag_to_fragtree(c, &f->fragtree, newfrag); 367 ret = jffs2_add_frag_to_fragtree(c, &f->fragtree, newfrag);
@@ -410,14 +410,17 @@ static int check_node_data(struct jffs2_sb_info *c, struct jffs2_tmp_dnode_info
410 410
411 BUG_ON(tn->csize == 0); 411 BUG_ON(tn->csize == 0);
412 412
413 if (!jffs2_is_writebuffered(c))
414 goto adj_acc;
415
413 /* Calculate how many bytes were already checked */ 416 /* Calculate how many bytes were already checked */
414 ofs = ref_offset(ref) + sizeof(struct jffs2_raw_inode); 417 ofs = ref_offset(ref) + sizeof(struct jffs2_raw_inode);
415 len = ofs & (c->wbuf_pagesize - 1); 418 len = ofs % c->wbuf_pagesize;
416 if (likely(len)) 419 if (likely(len))
417 len = c->wbuf_pagesize - len; 420 len = c->wbuf_pagesize - len;
418 421
419 if (len >= tn->csize) { 422 if (len >= tn->csize) {
420 JFFS2_DBG_READINODE("no need to check node at %#08x, data length %u, data starts at %#08x - it has already been checked.\n", 423 dbg_readinode("no need to check node at %#08x, data length %u, data starts at %#08x - it has already been checked.\n",
421 ref_offset(ref), tn->csize, ofs); 424 ref_offset(ref), tn->csize, ofs);
422 goto adj_acc; 425 goto adj_acc;
423 } 426 }
@@ -425,7 +428,7 @@ static int check_node_data(struct jffs2_sb_info *c, struct jffs2_tmp_dnode_info
425 ofs += len; 428 ofs += len;
426 len = tn->csize - len; 429 len = tn->csize - len;
427 430
428 JFFS2_DBG_READINODE("check node at %#08x, data length %u, partial CRC %#08x, correct CRC %#08x, data starts at %#08x, start checking from %#08x - %u bytes.\n", 431 dbg_readinode("check node at %#08x, data length %u, partial CRC %#08x, correct CRC %#08x, data starts at %#08x, start checking from %#08x - %u bytes.\n",
429 ref_offset(ref), tn->csize, tn->partial_crc, tn->data_crc, ofs - len, ofs, len); 432 ref_offset(ref), tn->csize, tn->partial_crc, tn->data_crc, ofs - len, ofs, len);
430 433
431#ifndef __ECOS 434#ifndef __ECOS
@@ -520,7 +523,7 @@ static inline int check_node(struct jffs2_sb_info *c, struct jffs2_inode_info *f
520 if (ref_flags(tn->fn->raw) != REF_UNCHECKED) 523 if (ref_flags(tn->fn->raw) != REF_UNCHECKED)
521 return 0; 524 return 0;
522 525
523 JFFS2_DBG_FRAGTREE2("check node %#04x-%#04x, phys offs %#08x.\n", 526 dbg_fragtree2("check node %#04x-%#04x, phys offs %#08x.\n",
524 tn->fn->ofs, tn->fn->ofs + tn->fn->size, ref_offset(tn->fn->raw)); 527 tn->fn->ofs, tn->fn->ofs + tn->fn->size, ref_offset(tn->fn->raw));
525 528
526 ret = check_node_data(c, tn); 529 ret = check_node_data(c, tn);
@@ -528,7 +531,7 @@ static inline int check_node(struct jffs2_sb_info *c, struct jffs2_inode_info *f
528 JFFS2_ERROR("check_node_data() returned error: %d.\n", 531 JFFS2_ERROR("check_node_data() returned error: %d.\n",
529 ret); 532 ret);
530 } else if (unlikely(ret > 0)) { 533 } else if (unlikely(ret > 0)) {
531 JFFS2_DBG_FRAGTREE2("CRC error, mark it obsolete.\n"); 534 dbg_fragtree2("CRC error, mark it obsolete.\n");
532 jffs2_mark_node_obsolete(c, tn->fn->raw); 535 jffs2_mark_node_obsolete(c, tn->fn->raw);
533 } 536 }
534 537
@@ -544,7 +547,7 @@ static inline int check_node(struct jffs2_sb_info *c, struct jffs2_inode_info *f
544static int split_hole(struct jffs2_sb_info *c, struct rb_root *root, 547static int split_hole(struct jffs2_sb_info *c, struct rb_root *root,
545 struct jffs2_node_frag *newfrag, struct jffs2_node_frag *hole) 548 struct jffs2_node_frag *newfrag, struct jffs2_node_frag *hole)
546{ 549{
547 JFFS2_DBG_FRAGTREE2("fragment %#04x-%#04x splits the hole %#04x-%#04x\n", 550 dbg_fragtree2("fragment %#04x-%#04x splits the hole %#04x-%#04x\n",
548 newfrag->ofs, newfrag->ofs + newfrag->size, hole->ofs, hole->ofs + hole->size); 551 newfrag->ofs, newfrag->ofs + newfrag->size, hole->ofs, hole->ofs + hole->size);
549 552
550 if (hole->ofs == newfrag->ofs) { 553 if (hole->ofs == newfrag->ofs) {
@@ -558,7 +561,7 @@ static int split_hole(struct jffs2_sb_info *c, struct rb_root *root,
558 * the new node. 561 * the new node.
559 */ 562 */
560 563
561 JFFS2_DBG_FRAGTREE2("insert fragment %#04x-%#04x and cut the left part of the hole\n", 564 dbg_fragtree2("insert fragment %#04x-%#04x and cut the left part of the hole\n",
562 newfrag->ofs, newfrag->ofs + newfrag->size); 565 newfrag->ofs, newfrag->ofs + newfrag->size);
563 rb_replace_node(&hole->rb, &newfrag->rb, root); 566 rb_replace_node(&hole->rb, &newfrag->rb, root);
564 567
@@ -576,7 +579,7 @@ static int split_hole(struct jffs2_sb_info *c, struct rb_root *root,
576 * Ah, the new fragment is of the same size as the hole. 579 * Ah, the new fragment is of the same size as the hole.
577 * Relace the hole by it. 580 * Relace the hole by it.
578 */ 581 */
579 JFFS2_DBG_FRAGTREE2("insert fragment %#04x-%#04x and overwrite hole\n", 582 dbg_fragtree2("insert fragment %#04x-%#04x and overwrite hole\n",
580 newfrag->ofs, newfrag->ofs + newfrag->size); 583 newfrag->ofs, newfrag->ofs + newfrag->size);
581 rb_replace_node(&hole->rb, &newfrag->rb, root); 584 rb_replace_node(&hole->rb, &newfrag->rb, root);
582 jffs2_free_node_frag(hole); 585 jffs2_free_node_frag(hole);
@@ -598,14 +601,14 @@ static int split_hole(struct jffs2_sb_info *c, struct rb_root *root,
598 } 601 }
599 602
600 hole->size = newfrag->ofs - hole->ofs; 603 hole->size = newfrag->ofs - hole->ofs;
601 JFFS2_DBG_FRAGTREE2("left the hole %#04x-%#04x at the left and inserd fragment %#04x-%#04x\n", 604 dbg_fragtree2("left the hole %#04x-%#04x at the left and inserd fragment %#04x-%#04x\n",
602 hole->ofs, hole->ofs + hole->size, newfrag->ofs, newfrag->ofs + newfrag->size); 605 hole->ofs, hole->ofs + hole->size, newfrag->ofs, newfrag->ofs + newfrag->size);
603 606
604 jffs2_fragtree_insert(newfrag, hole); 607 jffs2_fragtree_insert(newfrag, hole);
605 rb_insert_color(&newfrag->rb, root); 608 rb_insert_color(&newfrag->rb, root);
606 609
607 if (newfrag2) { 610 if (newfrag2) {
608 JFFS2_DBG_FRAGTREE2("left the hole %#04x-%#04x at the right\n", 611 dbg_fragtree2("left the hole %#04x-%#04x at the right\n",
609 newfrag2->ofs, newfrag2->ofs + newfrag2->size); 612 newfrag2->ofs, newfrag2->ofs + newfrag2->size);
610 jffs2_fragtree_insert(newfrag2, newfrag); 613 jffs2_fragtree_insert(newfrag2, newfrag);
611 rb_insert_color(&newfrag2->rb, root); 614 rb_insert_color(&newfrag2->rb, root);
@@ -640,12 +643,12 @@ int jffs2_add_older_frag_to_fragtree(struct jffs2_sb_info *c, struct jffs2_inode
640 int err, checked = 0; 643 int err, checked = 0;
641 int ref_flag; 644 int ref_flag;
642 645
643 JFFS2_DBG_FRAGTREE("insert fragment %#04x-%#04x, ver %u\n", fn_ofs, fn_ofs + fn_size, tn->version); 646 dbg_fragtree("insert fragment %#04x-%#04x, ver %u\n", fn_ofs, fn_ofs + fn_size, tn->version);
644 647
645 /* Skip all the nodes which are completed before this one starts */ 648 /* Skip all the nodes which are completed before this one starts */
646 this = jffs2_lookup_node_frag(root, fn_ofs); 649 this = jffs2_lookup_node_frag(root, fn_ofs);
647 if (this) 650 if (this)
648 JFFS2_DBG_FRAGTREE2("'this' found %#04x-%#04x (%s)\n", this->ofs, this->ofs + this->size, this->node ? "data" : "hole"); 651 dbg_fragtree2("'this' found %#04x-%#04x (%s)\n", this->ofs, this->ofs + this->size, this->node ? "data" : "hole");
649 652
650 if (this) 653 if (this)
651 lastend = this->ofs + this->size; 654 lastend = this->ofs + this->size;
@@ -745,7 +748,7 @@ int jffs2_add_older_frag_to_fragtree(struct jffs2_sb_info *c, struct jffs2_inode
745 * The new node starts at the same offset as 748 * The new node starts at the same offset as
746 * the hole and supersieds the hole. 749 * the hole and supersieds the hole.
747 */ 750 */
748 JFFS2_DBG_FRAGTREE2("add the new fragment instead of hole %#04x-%#04x, refcnt %d\n", 751 dbg_fragtree2("add the new fragment instead of hole %#04x-%#04x, refcnt %d\n",
749 fn_ofs, fn_ofs + this->ofs + this->size - fn_ofs, fn->frags); 752 fn_ofs, fn_ofs + this->ofs + this->size - fn_ofs, fn->frags);
750 753
751 rb_replace_node(&this->rb, &newfrag->rb, root); 754 rb_replace_node(&this->rb, &newfrag->rb, root);
@@ -755,10 +758,10 @@ int jffs2_add_older_frag_to_fragtree(struct jffs2_sb_info *c, struct jffs2_inode
755 * The hole becomes shorter as its right part 758 * The hole becomes shorter as its right part
756 * is supersieded by the new fragment. 759 * is supersieded by the new fragment.
757 */ 760 */
758 JFFS2_DBG_FRAGTREE2("reduce size of hole %#04x-%#04x to %#04x-%#04x\n", 761 dbg_fragtree2("reduce size of hole %#04x-%#04x to %#04x-%#04x\n",
759 this->ofs, this->ofs + this->size, this->ofs, this->ofs + this->size - newfrag->size); 762 this->ofs, this->ofs + this->size, this->ofs, this->ofs + this->size - newfrag->size);
760 763
761 JFFS2_DBG_FRAGTREE2("add new fragment %#04x-%#04x, refcnt %d\n", fn_ofs, 764 dbg_fragtree2("add new fragment %#04x-%#04x, refcnt %d\n", fn_ofs,
762 fn_ofs + this->ofs + this->size - fn_ofs, fn->frags); 765 fn_ofs + this->ofs + this->size - fn_ofs, fn->frags);
763 766
764 this->size -= newfrag->size; 767 this->size -= newfrag->size;
@@ -771,7 +774,7 @@ int jffs2_add_older_frag_to_fragtree(struct jffs2_sb_info *c, struct jffs2_inode
771 this = rb_entry(rb_next(&newfrag->rb), 774 this = rb_entry(rb_next(&newfrag->rb),
772 struct jffs2_node_frag, rb); 775 struct jffs2_node_frag, rb);
773 776
774 JFFS2_DBG_FRAGTREE2("switch to the next 'this' fragment: %#04x-%#04x %s\n", 777 dbg_fragtree2("switch to the next 'this' fragment: %#04x-%#04x %s\n",
775 this->ofs, this->ofs + this->size, this->node ? "(data)" : "(hole)"); 778 this->ofs, this->ofs + this->size, this->node ? "(data)" : "(hole)");
776 } 779 }
777 780
@@ -782,7 +785,7 @@ int jffs2_add_older_frag_to_fragtree(struct jffs2_sb_info *c, struct jffs2_inode
782 if (this->ofs + this->size >= fn_ofs + fn_size) { 785 if (this->ofs + this->size >= fn_ofs + fn_size) {
783 /* The new node is obsolete, drop it */ 786 /* The new node is obsolete, drop it */
784 if (fn->frags == 0) { 787 if (fn->frags == 0) {
785 JFFS2_DBG_FRAGTREE2("%#04x-%#04x is obsolete, mark it obsolete\n", fn_ofs, fn_ofs + fn_size); 788 dbg_fragtree2("%#04x-%#04x is obsolete, mark it obsolete\n", fn_ofs, fn_ofs + fn_size);
786 ref_flag = REF_OBSOLETE; 789 ref_flag = REF_OBSOLETE;
787 } 790 }
788 goto out_ok; 791 goto out_ok;
@@ -790,13 +793,13 @@ int jffs2_add_older_frag_to_fragtree(struct jffs2_sb_info *c, struct jffs2_inode
790 struct jffs2_node_frag *new_this; 793 struct jffs2_node_frag *new_this;
791 794
792 /* 'This' node obsoletes the beginning of the new node */ 795 /* 'This' node obsoletes the beginning of the new node */
793 JFFS2_DBG_FRAGTREE2("the beginning %#04x-%#04x is obsolete\n", fn_ofs, this->ofs + this->size); 796 dbg_fragtree2("the beginning %#04x-%#04x is obsolete\n", fn_ofs, this->ofs + this->size);
794 797
795 ref_flag = REF_NORMAL; 798 ref_flag = REF_NORMAL;
796 799
797 fn_size -= this->ofs + this->size - fn_ofs; 800 fn_size -= this->ofs + this->size - fn_ofs;
798 fn_ofs = this->ofs + this->size; 801 fn_ofs = this->ofs + this->size;
799 JFFS2_DBG_FRAGTREE2("now considering %#04x-%#04x\n", fn_ofs, fn_ofs + fn_size); 802 dbg_fragtree2("now considering %#04x-%#04x\n", fn_ofs, fn_ofs + fn_size);
800 803
801 new_this = rb_entry(rb_next(&this->rb), struct jffs2_node_frag, rb); 804 new_this = rb_entry(rb_next(&this->rb), struct jffs2_node_frag, rb);
802 if (!new_this) { 805 if (!new_this) {
@@ -816,14 +819,14 @@ int jffs2_add_older_frag_to_fragtree(struct jffs2_sb_info *c, struct jffs2_inode
816 if (unlikely(!newfrag)) 819 if (unlikely(!newfrag))
817 return -ENOMEM; 820 return -ENOMEM;
818 821
819 JFFS2_DBG_FRAGTREE2("there are no more fragments, insert %#04x-%#04x\n", 822 dbg_fragtree2("there are no more fragments, insert %#04x-%#04x\n",
820 newfrag->ofs, newfrag->ofs + newfrag->size); 823 newfrag->ofs, newfrag->ofs + newfrag->size);
821 rb_link_node(&newfrag->rb, &this->rb, &this->rb.rb_right); 824 rb_link_node(&newfrag->rb, &this->rb, &this->rb.rb_right);
822 rb_insert_color(&newfrag->rb, root); 825 rb_insert_color(&newfrag->rb, root);
823 goto out_ok; 826 goto out_ok;
824 } else { 827 } else {
825 this = new_this; 828 this = new_this;
826 JFFS2_DBG_FRAGTREE2("switch to the next 'this' fragment: %#04x-%#04x %s\n", 829 dbg_fragtree2("switch to the next 'this' fragment: %#04x-%#04x %s\n",
827 this->ofs, this->ofs + this->size, this->node ? "(data)" : "(hole)"); 830 this->ofs, this->ofs + this->size, this->node ? "(data)" : "(hole)");
828 } 831 }
829 } 832 }
@@ -833,13 +836,13 @@ out_ok:
833 BUG_ON(fn->size < PAGE_CACHE_SIZE && ref_flag == REF_PRISTINE); 836 BUG_ON(fn->size < PAGE_CACHE_SIZE && ref_flag == REF_PRISTINE);
834 837
835 if (ref_flag == REF_OBSOLETE) { 838 if (ref_flag == REF_OBSOLETE) {
836 JFFS2_DBG_FRAGTREE2("the node is obsolete now\n"); 839 dbg_fragtree2("the node is obsolete now\n");
837 /* jffs2_mark_node_obsolete() will adjust space accounting */ 840 /* jffs2_mark_node_obsolete() will adjust space accounting */
838 jffs2_mark_node_obsolete(c, fn->raw); 841 jffs2_mark_node_obsolete(c, fn->raw);
839 return 1; 842 return 1;
840 } 843 }
841 844
842 JFFS2_DBG_FRAGTREE2("the node is \"%s\" now\n", ref_flag == REF_NORMAL ? "REF_NORMAL" : "REF_PRISTINE"); 845 dbg_fragtree2("the node is \"%s\" now\n", ref_flag == REF_NORMAL ? "REF_NORMAL" : "REF_PRISTINE");
843 846
844 /* Space accounting was adjusted at check_node_data() */ 847 /* Space accounting was adjusted at check_node_data() */
845 spin_lock(&c->erase_completion_lock); 848 spin_lock(&c->erase_completion_lock);
@@ -885,7 +888,7 @@ void jffs2_add_ino_cache (struct jffs2_sb_info *c, struct jffs2_inode_cache *new
885 if (!new->ino) 888 if (!new->ino)
886 new->ino = ++c->highest_ino; 889 new->ino = ++c->highest_ino;
887 890
888 JFFS2_DBG_INOCACHE("add %p (ino #%u)\n", new, new->ino); 891 dbg_inocache("add %p (ino #%u)\n", new, new->ino);
889 892
890 prev = &c->inocache_list[new->ino % INOCACHE_HASHSIZE]; 893 prev = &c->inocache_list[new->ino % INOCACHE_HASHSIZE];
891 894
@@ -902,7 +905,7 @@ void jffs2_del_ino_cache(struct jffs2_sb_info *c, struct jffs2_inode_cache *old)
902{ 905{
903 struct jffs2_inode_cache **prev; 906 struct jffs2_inode_cache **prev;
904 907
905 JFFS2_DBG_INOCACHE("del %p (ino #%u)\n", old, old->ino); 908 dbg_inocache("del %p (ino #%u)\n", old, old->ino);
906 spin_lock(&c->inocache_lock); 909 spin_lock(&c->inocache_lock);
907 910
908 prev = &c->inocache_list[old->ino % INOCACHE_HASHSIZE]; 911 prev = &c->inocache_list[old->ino % INOCACHE_HASHSIZE];
@@ -965,7 +968,7 @@ struct jffs2_node_frag *jffs2_lookup_node_frag(struct rb_root *fragtree, uint32_
965 struct jffs2_node_frag *prev = NULL; 968 struct jffs2_node_frag *prev = NULL;
966 struct jffs2_node_frag *frag = NULL; 969 struct jffs2_node_frag *frag = NULL;
967 970
968 JFFS2_DBG_FRAGTREE2("root %p, offset %d\n", fragtree, offset); 971 dbg_fragtree2("root %p, offset %d\n", fragtree, offset);
969 972
970 next = fragtree->rb_node; 973 next = fragtree->rb_node;
971 974
@@ -988,10 +991,10 @@ struct jffs2_node_frag *jffs2_lookup_node_frag(struct rb_root *fragtree, uint32_
988 and return the closest smaller one */ 991 and return the closest smaller one */
989 992
990 if (prev) 993 if (prev)
991 JFFS2_DBG_FRAGTREE2("no match. Returning frag %#04x-%#04x, closest previous\n", 994 dbg_fragtree2("no match. Returning frag %#04x-%#04x, closest previous\n",
992 prev->ofs, prev->ofs+prev->size); 995 prev->ofs, prev->ofs+prev->size);
993 else 996 else
994 JFFS2_DBG_FRAGTREE2("returning NULL, empty fragtree\n"); 997 dbg_fragtree2("returning NULL, empty fragtree\n");
995 998
996 return prev; 999 return prev;
997} 1000}
@@ -1006,7 +1009,7 @@ void jffs2_kill_fragtree(struct rb_root *root, struct jffs2_sb_info *c)
1006 if (!root->rb_node) 1009 if (!root->rb_node)
1007 return; 1010 return;
1008 1011
1009 JFFS2_DBG_FRAGTREE("killing\n"); 1012 dbg_fragtree("killing\n");
1010 1013
1011 frag = (rb_entry(root->rb_node, struct jffs2_node_frag, rb)); 1014 frag = (rb_entry(root->rb_node, struct jffs2_node_frag, rb));
1012 while(frag) { 1015 while(frag) {