aboutsummaryrefslogtreecommitdiffstats
path: root/fs/jffs2/readinode.c
diff options
context:
space:
mode:
authorArtem B. Bityutskiy <dedekind@infradead.org>2005-07-28 10:46:43 -0400
committerThomas Gleixner <tglx@mtd.linutronix.de>2005-11-06 12:01:24 -0500
commite0d601373b1123ea43b1fdec08d9e58a079ae35c (patch)
treed3def6c56255fb3b2b98edbfdb522fa84e6741ca /fs/jffs2/readinode.c
parentf97117d15361b3a6aeaf9e347a287ef3f54b58f9 (diff)
[JFFS2] Debug code clean up - step 5
Replace the D1(printk()) style debugging with the new debug macros Signed-off-by: Artem B. Bityutskiy <dedekind@infradead.org> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'fs/jffs2/readinode.c')
-rw-r--r--fs/jffs2/readinode.c134
1 files changed, 59 insertions, 75 deletions
diff --git a/fs/jffs2/readinode.c b/fs/jffs2/readinode.c
index 85a285b2a309..67732ba08c3e 100644
--- a/fs/jffs2/readinode.c
+++ b/fs/jffs2/readinode.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: readinode.c,v 1.131 2005/07/27 14:46:11 dedekind Exp $ 10 * $Id: readinode.c,v 1.132 2005/07/28 14:46:40 dedekind Exp $
11 * 11 *
12 */ 12 */
13 13
@@ -24,12 +24,12 @@ void jffs2_truncate_fragtree (struct jffs2_sb_info *c, struct rb_root *list, uin
24{ 24{
25 struct jffs2_node_frag *frag = jffs2_lookup_node_frag(list, size); 25 struct jffs2_node_frag *frag = jffs2_lookup_node_frag(list, size);
26 26
27 D1(printk(KERN_DEBUG "Truncating fraglist to 0x%08x bytes\n", size)); 27 JFFS2_DBG_FRAGTREE("truncating fragtree to 0x%08x bytes\n", size);
28 28
29 /* We know frag->ofs <= size. That's what lookup does for us */ 29 /* We know frag->ofs <= size. That's what lookup does for us */
30 if (frag && frag->ofs != size) { 30 if (frag && frag->ofs != size) {
31 if (frag->ofs+frag->size >= size) { 31 if (frag->ofs+frag->size >= size) {
32 D1(printk(KERN_DEBUG "Truncating frag 0x%08x-0x%08x\n", frag->ofs, frag->ofs+frag->size)); 32 JFFS2_DBG_FRAGTREE2("truncating frag 0x%08x-0x%08x\n", frag->ofs, frag->ofs+frag->size);
33 frag->size = size - frag->ofs; 33 frag->size = size - frag->ofs;
34 } 34 }
35 frag = frag_next(frag); 35 frag = frag_next(frag);
@@ -37,7 +37,7 @@ void jffs2_truncate_fragtree (struct jffs2_sb_info *c, struct rb_root *list, uin
37 while (frag && frag->ofs >= size) { 37 while (frag && frag->ofs >= size) {
38 struct jffs2_node_frag *next = frag_next(frag); 38 struct jffs2_node_frag *next = frag_next(frag);
39 39
40 D1(printk(KERN_DEBUG "Removing frag 0x%08x-0x%08x\n", frag->ofs, frag->ofs+frag->size)); 40 JFFS2_DBG_FRAGTREE("removing frag 0x%08x-0x%08x\n", frag->ofs, frag->ofs+frag->size);
41 frag_erase(frag, list); 41 frag_erase(frag, list);
42 jffs2_obsolete_node_frag(c, frag); 42 jffs2_obsolete_node_frag(c, frag);
43 frag = next; 43 frag = next;
@@ -120,7 +120,7 @@ static struct jffs2_raw_node_ref *jffs2_first_valid_node(struct jffs2_raw_node_r
120 while (ref && ref->next_in_ino) { 120 while (ref && ref->next_in_ino) {
121 if (!ref_obsolete(ref)) 121 if (!ref_obsolete(ref))
122 return ref; 122 return ref;
123 D1(printk(KERN_DEBUG "node at 0x%08x is obsoleted. Ignoring.\n", ref_offset(ref))); 123 JFFS2_DBG_NODEREF("node at 0x%08x is obsoleted. Ignoring.\n", ref_offset(ref));
124 ref = ref->next_in_ino; 124 ref = ref->next_in_ino;
125 } 125 }
126 return NULL; 126 return NULL;
@@ -152,7 +152,7 @@ read_direntry(struct jffs2_sb_info *c,
152 152
153 /* Sanity check */ 153 /* Sanity check */
154 if (unlikely(PAD((rd->nsize + sizeof(*rd))) != PAD(je32_to_cpu(rd->totlen)))) { 154 if (unlikely(PAD((rd->nsize + sizeof(*rd))) != PAD(je32_to_cpu(rd->totlen)))) {
155 printk(KERN_ERR "Error! Illegal nsize in node at %#08x: nsize %#02x, totlen %#04x\n", 155 JFFS2_ERROR("illegal nsize in node at %#08x: nsize %#02x, totlen %#04x\n",
156 ref_offset(ref), rd->nsize, je32_to_cpu(rd->totlen)); 156 ref_offset(ref), rd->nsize, je32_to_cpu(rd->totlen));
157 return 1; 157 return 1;
158 } 158 }
@@ -192,7 +192,7 @@ read_direntry(struct jffs2_sb_info *c,
192 return -EIO; 192 return -EIO;
193 193
194 if (unlikely(err)) { 194 if (unlikely(err)) {
195 printk(KERN_WARNING "Read remainder of name: error %d\n", err); 195 JFFS2_ERROR("read remainder of name: error %d\n", err);
196 jffs2_free_full_dirent(fd); 196 jffs2_free_full_dirent(fd);
197 return -EIO; 197 return -EIO;
198 } 198 }
@@ -206,8 +206,6 @@ read_direntry(struct jffs2_sb_info *c,
206 * Wheee. We now have a complete jffs2_full_dirent structure, with 206 * Wheee. We now have a complete jffs2_full_dirent structure, with
207 * the name in it and everything. Link it into the list 207 * the name in it and everything. Link it into the list
208 */ 208 */
209 D1(printk(KERN_DEBUG "Adding fd \"%s\", ino #%u\n", fd->name, fd->ino));
210
211 jffs2_add_fd_to_list(c, fd, fdp); 209 jffs2_add_fd_to_list(c, fd, fdp);
212 210
213 return 0; 211 return 0;
@@ -242,7 +240,7 @@ read_dnode(struct jffs2_sb_info *c,
242 240
243 crc = crc32(0, rd, sizeof(*rd) - 8); 241 crc = crc32(0, rd, sizeof(*rd) - 8);
244 if (unlikely(crc != je32_to_cpu(rd->node_crc))) { 242 if (unlikely(crc != je32_to_cpu(rd->node_crc))) {
245 printk(KERN_WARNING "Header CRC failed on node at %#08x: read %#08x, calculated %#08x\n", 243 JFFS2_NOTICE("header CRC failed on node at %#08x: read %#08x, calculated %#08x\n",
246 ref_offset(ref), je32_to_cpu(rd->node_crc), crc); 244 ref_offset(ref), je32_to_cpu(rd->node_crc), crc);
247 return 1; 245 return 1;
248 } 246 }
@@ -250,11 +248,8 @@ read_dnode(struct jffs2_sb_info *c,
250 /* Sanity checks */ 248 /* Sanity checks */
251 if (unlikely(je32_to_cpu(rd->offset) > je32_to_cpu(rd->isize)) || 249 if (unlikely(je32_to_cpu(rd->offset) > je32_to_cpu(rd->isize)) ||
252 unlikely(PAD(je32_to_cpu(rd->csize) + sizeof(*rd)) != PAD(je32_to_cpu(rd->totlen)))) { 250 unlikely(PAD(je32_to_cpu(rd->csize) + sizeof(*rd)) != PAD(je32_to_cpu(rd->totlen)))) {
253 printk(KERN_WARNING "Inode corrupted at %#08x, totlen %d, #ino %d, version %d, " 251 JFFS2_WARNING("inode node header CRC is corrupted at %#08x\n", ref_offset(ref));
254 "isize %d, csize %d, dsize %d \n", 252 __jffs2_dbg_dump_node(c, ref_offset(ref));
255 ref_offset(ref), je32_to_cpu(rd->totlen), je32_to_cpu(rd->ino),
256 je32_to_cpu(rd->version), je32_to_cpu(rd->isize),
257 je32_to_cpu(rd->csize), je32_to_cpu(rd->dsize));
258 return 1; 253 return 1;
259 } 254 }
260 255
@@ -267,11 +262,11 @@ read_dnode(struct jffs2_sb_info *c,
267 err = c->mtd->point (c->mtd, ref_offset(ref) + sizeof(*rd), je32_to_cpu(rd->csize), 262 err = c->mtd->point (c->mtd, ref_offset(ref) + sizeof(*rd), je32_to_cpu(rd->csize),
268 &read, &buf); 263 &read, &buf);
269 if (unlikely(read < je32_to_cpu(rd->csize)) && likely(!err)) { 264 if (unlikely(read < je32_to_cpu(rd->csize)) && likely(!err)) {
270 D1(printk(KERN_DEBUG "MTD point returned len too short: 0x%zx\n", read)); 265 JFFS2_ERROR("MTD point returned len too short: 0x%zx\n", read);
271 c->mtd->unpoint(c->mtd, buf, ref_offset(ref) + sizeof(*rd), 266 c->mtd->unpoint(c->mtd, buf, ref_offset(ref) + sizeof(*rd),
272 je32_to_cpu(rd->csize)); 267 je32_to_cpu(rd->csize));
273 } else if (unlikely(err)){ 268 } else if (unlikely(err)){
274 D1(printk(KERN_DEBUG "MTD point failed %d\n", err)); 269 JFFS2_ERROR("MTD point failed %d\n", err);
275 } else 270 } else
276 pointed = 1; /* succefully pointed to device */ 271 pointed = 1; /* succefully pointed to device */
277 } 272 }
@@ -299,8 +294,8 @@ read_dnode(struct jffs2_sb_info *c,
299#endif 294#endif
300 295
301 if (crc != je32_to_cpu(rd->data_crc)) { 296 if (crc != je32_to_cpu(rd->data_crc)) {
302 printk(KERN_NOTICE "Data CRC failed on node at %#08x: read %#08x, calculated %#08x\n", 297 JFFS2_NOTICE("data CRC failed on node at %#08x: read %#08x, calculated %#08x\n",
303 ref_offset(ref), je32_to_cpu(rd->data_crc), crc); 298 ref_offset(ref), je32_to_cpu(rd->data_crc), crc);
304 return 1; 299 return 1;
305 } 300 }
306 301
@@ -326,10 +321,10 @@ read_dnode(struct jffs2_sb_info *c,
326 if ((je32_to_cpu(rd->dsize) >= PAGE_CACHE_SIZE) || 321 if ((je32_to_cpu(rd->dsize) >= PAGE_CACHE_SIZE) ||
327 ( ((je32_to_cpu(rd->offset) & (PAGE_CACHE_SIZE-1))==0) && 322 ( ((je32_to_cpu(rd->offset) & (PAGE_CACHE_SIZE-1))==0) &&
328 (je32_to_cpu(rd->dsize) + je32_to_cpu(rd->offset) == je32_to_cpu(rd->isize)))) { 323 (je32_to_cpu(rd->dsize) + je32_to_cpu(rd->offset) == je32_to_cpu(rd->isize)))) {
329 D1(printk(KERN_DEBUG "Marking node at %#08x REF_PRISTINE\n", ref_offset(ref))); 324 JFFS2_DBG_READINODE("marking node at %#08x REF_PRISTINE\n", ref_offset(ref));
330 ref->flash_offset = ref_offset(ref) | REF_PRISTINE; 325 ref->flash_offset = ref_offset(ref) | REF_PRISTINE;
331 } else { 326 } else {
332 D1(printk(KERN_DEBUG "Marking node at %#08x REF_NORMAL\n", ref_offset(ref))); 327 JFFS2_DBG_READINODE("marking node at %#08x REF_NORMAL\n", ref_offset(ref));
333 ref->flash_offset = ref_offset(ref) | REF_NORMAL; 328 ref->flash_offset = ref_offset(ref) | REF_NORMAL;
334 } 329 }
335 spin_unlock(&c->erase_completion_lock); 330 spin_unlock(&c->erase_completion_lock);
@@ -337,13 +332,13 @@ read_dnode(struct jffs2_sb_info *c,
337 332
338 tn = jffs2_alloc_tmp_dnode_info(); 333 tn = jffs2_alloc_tmp_dnode_info();
339 if (!tn) { 334 if (!tn) {
340 D1(printk(KERN_DEBUG "alloc tn failed\n")); 335 JFFS2_ERROR("alloc tn failed\n");
341 return -ENOMEM; 336 return -ENOMEM;
342 } 337 }
343 338
344 tn->fn = jffs2_alloc_full_dnode(); 339 tn->fn = jffs2_alloc_full_dnode();
345 if (!tn->fn) { 340 if (!tn->fn) {
346 D1(printk(KERN_DEBUG "alloc fn failed\n")); 341 JFFS2_ERROR("alloc fn failed\n");
347 jffs2_free_tmp_dnode_info(tn); 342 jffs2_free_tmp_dnode_info(tn);
348 return -ENOMEM; 343 return -ENOMEM;
349 } 344 }
@@ -359,9 +354,8 @@ read_dnode(struct jffs2_sb_info *c,
359 else // normal case... 354 else // normal case...
360 tn->fn->size = je32_to_cpu(rd->dsize); 355 tn->fn->size = je32_to_cpu(rd->dsize);
361 356
362 D1(printk(KERN_DEBUG "dnode @%08x: ver %u, offset %#04x, dsize %#04x\n", 357 JFFS2_DBG_READINODE("dnode @%08x: ver %u, offset %#04x, dsize %#04x\n",
363 ref_offset(ref), je32_to_cpu(rd->version), 358 ref_offset(ref), je32_to_cpu(rd->version), je32_to_cpu(rd->offset), je32_to_cpu(rd->dsize));
364 je32_to_cpu(rd->offset), je32_to_cpu(rd->dsize)));
365 359
366 jffs2_add_tn_to_tree(tn, tnp); 360 jffs2_add_tn_to_tree(tn, tnp);
367 361
@@ -388,37 +382,33 @@ read_unknown(struct jffs2_sb_info *c,
388 un->nodetype = cpu_to_je16(JFFS2_NODE_ACCURATE | je16_to_cpu(un->nodetype)); 382 un->nodetype = cpu_to_je16(JFFS2_NODE_ACCURATE | je16_to_cpu(un->nodetype));
389 383
390 if (crc32(0, un, sizeof(struct jffs2_unknown_node) - 4) != je32_to_cpu(un->hdr_crc)) { 384 if (crc32(0, un, sizeof(struct jffs2_unknown_node) - 4) != je32_to_cpu(un->hdr_crc)) {
391
392 /* Hmmm. This should have been caught at scan time. */ 385 /* Hmmm. This should have been caught at scan time. */
393 printk(KERN_WARNING "Warning! Node header CRC failed at %#08x. " 386 JFFS2_NOTICE("node header CRC failed at %#08x. But it must have been OK earlier.\n", ref_offset(ref));
394 "But it must have been OK earlier.\n", ref_offset(ref)); 387 __jffs2_dbg_dump_node(c, ref_offset(ref));
395 D1(printk(KERN_DEBUG "Node was: { %#04x, %#04x, %#08x, %#08x }\n",
396 je16_to_cpu(un->magic), je16_to_cpu(un->nodetype),
397 je32_to_cpu(un->totlen), je32_to_cpu(un->hdr_crc)));
398 return 1; 388 return 1;
399 } else { 389 } else {
400 switch(je16_to_cpu(un->nodetype) & JFFS2_COMPAT_MASK) { 390 switch(je16_to_cpu(un->nodetype) & JFFS2_COMPAT_MASK) {
401 391
402 case JFFS2_FEATURE_INCOMPAT: 392 case JFFS2_FEATURE_INCOMPAT:
403 printk(KERN_NOTICE "Unknown INCOMPAT nodetype %#04X at %#08x\n", 393 JFFS2_ERROR("unknown INCOMPAT nodetype %#04X at %#08x\n",
404 je16_to_cpu(un->nodetype), ref_offset(ref)); 394 je16_to_cpu(un->nodetype), ref_offset(ref));
405 /* EEP */ 395 /* EEP */
406 BUG(); 396 BUG();
407 break; 397 break;
408 398
409 case JFFS2_FEATURE_ROCOMPAT: 399 case JFFS2_FEATURE_ROCOMPAT:
410 printk(KERN_NOTICE "Unknown ROCOMPAT nodetype %#04X at %#08x\n", 400 JFFS2_ERROR("unknown ROCOMPAT nodetype %#04X at %#08x\n",
411 je16_to_cpu(un->nodetype), ref_offset(ref)); 401 je16_to_cpu(un->nodetype), ref_offset(ref));
412 BUG_ON(!(c->flags & JFFS2_SB_FLAG_RO)); 402 BUG_ON(!(c->flags & JFFS2_SB_FLAG_RO));
413 break; 403 break;
414 404
415 case JFFS2_FEATURE_RWCOMPAT_COPY: 405 case JFFS2_FEATURE_RWCOMPAT_COPY:
416 printk(KERN_NOTICE "Unknown RWCOMPAT_COPY nodetype %#04X at %#08x\n", 406 JFFS2_NOTICE("unknown RWCOMPAT_COPY nodetype %#04X at %#08x\n",
417 je16_to_cpu(un->nodetype), ref_offset(ref)); 407 je16_to_cpu(un->nodetype), ref_offset(ref));
418 break; 408 break;
419 409
420 case JFFS2_FEATURE_RWCOMPAT_DELETE: 410 case JFFS2_FEATURE_RWCOMPAT_DELETE:
421 printk(KERN_NOTICE "Unknown RWCOMPAT_DELETE nodetype %#04X at %#08x\n", 411 JFFS2_NOTICE("unknown RWCOMPAT_DELETE nodetype %#04X at %#08x\n",
422 je16_to_cpu(un->nodetype), ref_offset(ref)); 412 je16_to_cpu(un->nodetype), ref_offset(ref));
423 return 1; 413 return 1;
424 } 414 }
@@ -444,14 +434,14 @@ static int jffs2_get_inode_nodes(struct jffs2_sb_info *c, struct jffs2_inode_inf
444 434
445 *mctime_ver = 0; 435 *mctime_ver = 0;
446 436
447 D1(printk(KERN_DEBUG "jffs2_get_inode_nodes(): ino #%u\n", f->inocache->ino)); 437 JFFS2_DBG_READINODE("ino #%u\n", f->inocache->ino);
448 438
449 spin_lock(&c->erase_completion_lock); 439 spin_lock(&c->erase_completion_lock);
450 440
451 valid_ref = jffs2_first_valid_node(f->inocache->nodes); 441 valid_ref = jffs2_first_valid_node(f->inocache->nodes);
452 442
453 if (!valid_ref && (f->inocache->ino != 1)) 443 if (!valid_ref && (f->inocache->ino != 1))
454 printk(KERN_WARNING "Eep. No valid nodes for ino #%u\n", f->inocache->ino); 444 JFFS2_WARNING("no valid nodes for ino #%u\n", f->inocache->ino);
455 445
456 while (valid_ref) { 446 while (valid_ref) {
457 /* We can hold a pointer to a non-obsolete node without the spinlock, 447 /* We can hold a pointer to a non-obsolete node without the spinlock,
@@ -471,17 +461,17 @@ static int jffs2_get_inode_nodes(struct jffs2_sb_info *c, struct jffs2_inode_inf
471 min_t(uint32_t, ref_totlen(c, NULL, ref), sizeof(node)), 461 min_t(uint32_t, ref_totlen(c, NULL, ref), sizeof(node)),
472 &retlen, (void *)&node); 462 &retlen, (void *)&node);
473 if (err) { 463 if (err) {
474 printk(KERN_WARNING "error %d reading node at 0x%08x in get_inode_nodes()\n", err, ref_offset(ref)); 464 JFFS2_ERROR("error %d reading node at 0x%08x in get_inode_nodes()\n", err, ref_offset(ref));
475 goto free_out; 465 goto free_out;
476 } 466 }
477 467
478 switch (je16_to_cpu(node.u.nodetype)) { 468 switch (je16_to_cpu(node.u.nodetype)) {
479 469
480 case JFFS2_NODETYPE_DIRENT: 470 case JFFS2_NODETYPE_DIRENT:
481 D1(printk(KERN_DEBUG "Node at %08x (%d) is a dirent node\n", ref_offset(ref), ref_flags(ref))); 471 JFFS2_DBG_READINODE("node at %08x (%d) is a dirent node\n", ref_offset(ref), ref_flags(ref));
482 472
483 if (retlen < sizeof(node.d)) { 473 if (retlen < sizeof(node.d)) {
484 printk(KERN_WARNING "Warning! Short read dirent at %#08x\n", ref_offset(ref)); 474 JFFS2_ERROR("short read dirent at %#08x\n", ref_offset(ref));
485 err = -EIO; 475 err = -EIO;
486 goto free_out; 476 goto free_out;
487 } 477 }
@@ -499,10 +489,10 @@ static int jffs2_get_inode_nodes(struct jffs2_sb_info *c, struct jffs2_inode_inf
499 break; 489 break;
500 490
501 case JFFS2_NODETYPE_INODE: 491 case JFFS2_NODETYPE_INODE:
502 D1(printk(KERN_DEBUG "Node at %08x (%d) is a data node\n", ref_offset(ref), ref_flags(ref))); 492 JFFS2_DBG_READINODE("node at %08x (%d) is a data node\n", ref_offset(ref), ref_flags(ref));
503 493
504 if (retlen < sizeof(node.i)) { 494 if (retlen < sizeof(node.i)) {
505 printk(KERN_WARNING "Warning! Short read dnode at %#08x\n", ref_offset(ref)); 495 JFFS2_ERROR("short read dnode at %#08x\n", ref_offset(ref));
506 err = -EIO; 496 err = -EIO;
507 goto free_out; 497 goto free_out;
508 } 498 }
@@ -517,16 +507,15 @@ static int jffs2_get_inode_nodes(struct jffs2_sb_info *c, struct jffs2_inode_inf
517 if (je32_to_cpu(node.i.version) > *highest_version) 507 if (je32_to_cpu(node.i.version) > *highest_version)
518 *highest_version = je32_to_cpu(node.i.version); 508 *highest_version = je32_to_cpu(node.i.version);
519 509
520 D1(printk(KERN_DEBUG "version %d, highest_version now %d\n", 510 JFFS2_DBG_READINODE("version %d, highest_version now %d\n",
521 je32_to_cpu(node.i.version), *highest_version)); 511 je32_to_cpu(node.i.version), *highest_version);
522 512
523 break; 513 break;
524 514
525 default: 515 default:
526 /* Check we've managed to read at least the common node header */ 516 /* Check we've managed to read at least the common node header */
527 if (retlen < sizeof(struct jffs2_unknown_node)) { 517 if (retlen < sizeof(struct jffs2_unknown_node)) {
528 printk(KERN_WARNING "Warning! Short read unknown node at %#08x\n", 518 JFFS2_ERROR("short read unknown node at %#08x\n", ref_offset(ref));
529 ref_offset(ref));
530 return -EIO; 519 return -EIO;
531 } 520 }
532 521
@@ -568,13 +557,13 @@ static int jffs2_do_read_inode_internal(struct jffs2_sb_info *c,
568 size_t retlen; 557 size_t retlen;
569 int ret; 558 int ret;
570 559
571 D1(printk(KERN_DEBUG "jffs2_do_read_inode_internal(): ino #%u nlink is %d\n", f->inocache->ino, f->inocache->nlink)); 560 JFFS2_DBG_READINODE("ino #%u nlink is %d\n", f->inocache->ino, f->inocache->nlink);
572 561
573 /* Grab all nodes relevant to this ino */ 562 /* Grab all nodes relevant to this ino */
574 ret = jffs2_get_inode_nodes(c, f, &tn_list, &fd_list, &f->highest_version, &latest_mctime, &mctime_ver); 563 ret = jffs2_get_inode_nodes(c, f, &tn_list, &fd_list, &f->highest_version, &latest_mctime, &mctime_ver);
575 564
576 if (ret) { 565 if (ret) {
577 printk(KERN_CRIT "jffs2_get_inode_nodes() for ino %u returned %d\n", f->inocache->ino, ret); 566 JFFS2_ERROR("cannot read nodes for ino %u, returned error is %d\n", f->inocache->ino, ret);
578 if (f->inocache->state == INO_STATE_READING) 567 if (f->inocache->state == INO_STATE_READING)
579 jffs2_set_inocache_state(c, f->inocache, INO_STATE_CHECKEDABSENT); 568 jffs2_set_inocache_state(c, f->inocache, INO_STATE_CHECKEDABSENT);
580 return ret; 569 return ret;
@@ -589,7 +578,7 @@ static int jffs2_do_read_inode_internal(struct jffs2_sb_info *c,
589 578
590 if (f->metadata) { 579 if (f->metadata) {
591 if (likely(tn->version >= mdata_ver)) { 580 if (likely(tn->version >= mdata_ver)) {
592 D1(printk(KERN_DEBUG "Obsoleting old metadata at 0x%08x\n", ref_offset(f->metadata->raw))); 581 JFFS2_DBG_READINODE("obsoleting old metadata at 0x%08x\n", ref_offset(f->metadata->raw));
593 jffs2_mark_node_obsolete(c, f->metadata->raw); 582 jffs2_mark_node_obsolete(c, f->metadata->raw);
594 jffs2_free_full_dnode(f->metadata); 583 jffs2_free_full_dnode(f->metadata);
595 f->metadata = NULL; 584 f->metadata = NULL;
@@ -597,7 +586,7 @@ static int jffs2_do_read_inode_internal(struct jffs2_sb_info *c,
597 mdata_ver = 0; 586 mdata_ver = 0;
598 } else { 587 } else {
599 /* This should never happen. */ 588 /* This should never happen. */
600 printk(KERN_WARNING "Er. New metadata at 0x%08x with ver %d is actually older than previous ver %d at 0x%08x\n", 589 JFFS2_ERROR("Er. New metadata at 0x%08x with ver %d is actually older than previous ver %d at 0x%08x\n",
601 ref_offset(fn->raw), tn->version, mdata_ver, ref_offset(f->metadata->raw)); 590 ref_offset(fn->raw), tn->version, mdata_ver, ref_offset(f->metadata->raw));
602 jffs2_mark_node_obsolete(c, fn->raw); 591 jffs2_mark_node_obsolete(c, fn->raw);
603 jffs2_free_full_dnode(fn); 592 jffs2_free_full_dnode(fn);
@@ -611,7 +600,7 @@ static int jffs2_do_read_inode_internal(struct jffs2_sb_info *c,
611 jffs2_add_full_dnode_to_inode(c, f, fn); 600 jffs2_add_full_dnode_to_inode(c, f, fn);
612 } else { 601 } else {
613 /* Zero-sized node at end of version list. Just a metadata update */ 602 /* Zero-sized node at end of version list. Just a metadata update */
614 D1(printk(KERN_DEBUG "metadata @%08x: ver %d\n", ref_offset(fn->raw), tn->version)); 603 JFFS2_DBG_READINODE("metadata @%08x: ver %d\n", ref_offset(fn->raw), tn->version);
615 f->metadata = fn; 604 f->metadata = fn;
616 mdata_ver = tn->version; 605 mdata_ver = tn->version;
617 } 606 }
@@ -646,13 +635,13 @@ static int jffs2_do_read_inode_internal(struct jffs2_sb_info *c,
646 if (!fn) { 635 if (!fn) {
647 /* No data nodes for this inode. */ 636 /* No data nodes for this inode. */
648 if (f->inocache->ino != 1) { 637 if (f->inocache->ino != 1) {
649 printk(KERN_WARNING "jffs2_do_read_inode(): No data nodes found for ino #%u\n", f->inocache->ino); 638 JFFS2_WARNING("no data nodes found for ino #%u\n", f->inocache->ino);
650 if (!fd_list) { 639 if (!fd_list) {
651 if (f->inocache->state == INO_STATE_READING) 640 if (f->inocache->state == INO_STATE_READING)
652 jffs2_set_inocache_state(c, f->inocache, INO_STATE_CHECKEDABSENT); 641 jffs2_set_inocache_state(c, f->inocache, INO_STATE_CHECKEDABSENT);
653 return -EIO; 642 return -EIO;
654 } 643 }
655 printk(KERN_WARNING "jffs2_do_read_inode(): But it has children so we fake some modes for it\n"); 644 JFFS2_NOTICE("but it has children so we fake some modes for it\n");
656 } 645 }
657 latest_node->mode = cpu_to_jemode(S_IFDIR|S_IRUGO|S_IWUSR|S_IXUGO); 646 latest_node->mode = cpu_to_jemode(S_IFDIR|S_IRUGO|S_IWUSR|S_IXUGO);
658 latest_node->version = cpu_to_je32(0); 647 latest_node->version = cpu_to_je32(0);
@@ -667,8 +656,8 @@ static int jffs2_do_read_inode_internal(struct jffs2_sb_info *c,
667 656
668 ret = jffs2_flash_read(c, ref_offset(fn->raw), sizeof(*latest_node), &retlen, (void *)latest_node); 657 ret = jffs2_flash_read(c, ref_offset(fn->raw), sizeof(*latest_node), &retlen, (void *)latest_node);
669 if (ret || retlen != sizeof(*latest_node)) { 658 if (ret || retlen != sizeof(*latest_node)) {
670 printk(KERN_NOTICE "MTD read in jffs2_do_read_inode() failed: Returned %d, %zd of %zd bytes read\n", 659 JFFS2_ERROR("failed to read from flash: error %d, %zd of %zd bytes read\n",
671 ret, retlen, sizeof(*latest_node)); 660 ret, retlen, sizeof(*latest_node));
672 /* FIXME: If this fails, there seems to be a memory leak. Find it. */ 661 /* FIXME: If this fails, there seems to be a memory leak. Find it. */
673 up(&f->sem); 662 up(&f->sem);
674 jffs2_do_clear_inode(c, f); 663 jffs2_do_clear_inode(c, f);
@@ -677,7 +666,8 @@ static int jffs2_do_read_inode_internal(struct jffs2_sb_info *c,
677 666
678 crc = crc32(0, latest_node, sizeof(*latest_node)-8); 667 crc = crc32(0, latest_node, sizeof(*latest_node)-8);
679 if (crc != je32_to_cpu(latest_node->node_crc)) { 668 if (crc != je32_to_cpu(latest_node->node_crc)) {
680 printk(KERN_NOTICE "CRC failed for read_inode of inode %u at physical location 0x%x\n", f->inocache->ino, ref_offset(fn->raw)); 669 JFFS2_ERROR("CRC failed for read_inode of inode %u at physical location 0x%x\n",
670 f->inocache->ino, ref_offset(fn->raw));
681 up(&f->sem); 671 up(&f->sem);
682 jffs2_do_clear_inode(c, f); 672 jffs2_do_clear_inode(c, f);
683 return -EIO; 673 return -EIO;
@@ -712,9 +702,7 @@ static int jffs2_do_read_inode_internal(struct jffs2_sb_info *c,
712 * operation. */ 702 * operation. */
713 f->target = kmalloc(je32_to_cpu(latest_node->csize) + 1, GFP_KERNEL); 703 f->target = kmalloc(je32_to_cpu(latest_node->csize) + 1, GFP_KERNEL);
714 if (!f->target) { 704 if (!f->target) {
715 printk(KERN_WARNING "Can't allocate %d bytes of memory " 705 JFFS2_ERROR("can't allocate %d bytes of memory for the symlink target path cache\n", je32_to_cpu(latest_node->csize));
716 "for the symlink target path cache\n",
717 je32_to_cpu(latest_node->csize));
718 up(&f->sem); 706 up(&f->sem);
719 jffs2_do_clear_inode(c, f); 707 jffs2_do_clear_inode(c, f);
720 return -ENOMEM; 708 return -ENOMEM;
@@ -734,8 +722,7 @@ static int jffs2_do_read_inode_internal(struct jffs2_sb_info *c,
734 } 722 }
735 723
736 f->target[je32_to_cpu(latest_node->csize)] = '\0'; 724 f->target[je32_to_cpu(latest_node->csize)] = '\0';
737 D1(printk(KERN_DEBUG "jffs2_do_read_inode(): symlink's target '%s' cached\n", 725 JFFS2_DBG_READINODE("symlink's target '%s' cached\n", f->target);
738 f->target));
739 } 726 }
740 727
741 /* fall through... */ 728 /* fall through... */
@@ -745,14 +732,14 @@ static int jffs2_do_read_inode_internal(struct jffs2_sb_info *c,
745 /* Certain inode types should have only one data node, and it's 732 /* Certain inode types should have only one data node, and it's
746 kept as the metadata node */ 733 kept as the metadata node */
747 if (f->metadata) { 734 if (f->metadata) {
748 printk(KERN_WARNING "Argh. Special inode #%u with mode 0%o had metadata node\n", 735 JFFS2_ERROR("Argh. Special inode #%u with mode 0%o had metadata node\n",
749 f->inocache->ino, jemode_to_cpu(latest_node->mode)); 736 f->inocache->ino, jemode_to_cpu(latest_node->mode));
750 up(&f->sem); 737 up(&f->sem);
751 jffs2_do_clear_inode(c, f); 738 jffs2_do_clear_inode(c, f);
752 return -EIO; 739 return -EIO;
753 } 740 }
754 if (!frag_first(&f->fragtree)) { 741 if (!frag_first(&f->fragtree)) {
755 printk(KERN_WARNING "Argh. Special inode #%u with mode 0%o has no fragments\n", 742 JFFS2_ERROR("Argh. Special inode #%u with mode 0%o has no fragments\n",
756 f->inocache->ino, jemode_to_cpu(latest_node->mode)); 743 f->inocache->ino, jemode_to_cpu(latest_node->mode));
757 up(&f->sem); 744 up(&f->sem);
758 jffs2_do_clear_inode(c, f); 745 jffs2_do_clear_inode(c, f);
@@ -760,7 +747,7 @@ static int jffs2_do_read_inode_internal(struct jffs2_sb_info *c,
760 } 747 }
761 /* ASSERT: f->fraglist != NULL */ 748 /* ASSERT: f->fraglist != NULL */
762 if (frag_next(frag_first(&f->fragtree))) { 749 if (frag_next(frag_first(&f->fragtree))) {
763 printk(KERN_WARNING "Argh. Special inode #%u with mode 0x%x had more than one node\n", 750 JFFS2_ERROR("Argh. Special inode #%u with mode 0x%x had more than one node\n",
764 f->inocache->ino, jemode_to_cpu(latest_node->mode)); 751 f->inocache->ino, jemode_to_cpu(latest_node->mode));
765 /* FIXME: Deal with it - check crc32, check for duplicate node, check times and discard the older one */ 752 /* FIXME: Deal with it - check crc32, check for duplicate node, check times and discard the older one */
766 up(&f->sem); 753 up(&f->sem);
@@ -783,14 +770,12 @@ static int jffs2_do_read_inode_internal(struct jffs2_sb_info *c,
783int jffs2_do_read_inode(struct jffs2_sb_info *c, struct jffs2_inode_info *f, 770int jffs2_do_read_inode(struct jffs2_sb_info *c, struct jffs2_inode_info *f,
784 uint32_t ino, struct jffs2_raw_inode *latest_node) 771 uint32_t ino, struct jffs2_raw_inode *latest_node)
785{ 772{
786 D2(printk(KERN_DEBUG "jffs2_do_read_inode(): getting inocache\n")); 773 JFFS2_DBG_READINODE("read inode #%u\n", ino);
787 774
788 retry_inocache: 775 retry_inocache:
789 spin_lock(&c->inocache_lock); 776 spin_lock(&c->inocache_lock);
790 f->inocache = jffs2_get_ino_cache(c, ino); 777 f->inocache = jffs2_get_ino_cache(c, ino);
791 778
792 D2(printk(KERN_DEBUG "jffs2_do_read_inode(): Got inocache at %p\n", f->inocache));
793
794 if (f->inocache) { 779 if (f->inocache) {
795 /* Check its state. We may need to wait before we can use it */ 780 /* Check its state. We may need to wait before we can use it */
796 switch(f->inocache->state) { 781 switch(f->inocache->state) {
@@ -804,8 +789,7 @@ int jffs2_do_read_inode(struct jffs2_sb_info *c, struct jffs2_inode_info *f,
804 /* If it's in either of these states, we need 789 /* If it's in either of these states, we need
805 to wait for whoever's got it to finish and 790 to wait for whoever's got it to finish and
806 put it back. */ 791 put it back. */
807 D1(printk(KERN_DEBUG "jffs2_get_ino_cache_read waiting for ino #%u in state %d\n", 792 JFFS2_DBG_READINODE("waiting for ino #%u in state %d\n", ino, f->inocache->state);
808 ino, f->inocache->state));
809 sleep_on_spinunlock(&c->inocache_wq, &c->inocache_lock); 793 sleep_on_spinunlock(&c->inocache_wq, &c->inocache_lock);
810 goto retry_inocache; 794 goto retry_inocache;
811 795
@@ -814,7 +798,7 @@ int jffs2_do_read_inode(struct jffs2_sb_info *c, struct jffs2_inode_info *f,
814 /* Eep. This should never happen. It can 798 /* Eep. This should never happen. It can
815 happen if Linux calls read_inode() again 799 happen if Linux calls read_inode() again
816 before clear_inode() has finished though. */ 800 before clear_inode() has finished though. */
817 printk(KERN_WARNING "Eep. Trying to read_inode #%u when it's already in state %d!\n", ino, f->inocache->state); 801 JFFS2_ERROR("Eep. Trying to read_inode #%u when it's already in state %d!\n", ino, f->inocache->state);
818 /* Fail. That's probably better than allowing it to succeed */ 802 /* Fail. That's probably better than allowing it to succeed */
819 f->inocache = NULL; 803 f->inocache = NULL;
820 break; 804 break;
@@ -829,10 +813,10 @@ int jffs2_do_read_inode(struct jffs2_sb_info *c, struct jffs2_inode_info *f,
829 /* Special case - no root inode on medium */ 813 /* Special case - no root inode on medium */
830 f->inocache = jffs2_alloc_inode_cache(); 814 f->inocache = jffs2_alloc_inode_cache();
831 if (!f->inocache) { 815 if (!f->inocache) {
832 printk(KERN_CRIT "jffs2_do_read_inode(): Cannot allocate inocache for root inode\n"); 816 JFFS2_ERROR("cannot allocate inocache for root inode\n");
833 return -ENOMEM; 817 return -ENOMEM;
834 } 818 }
835 D1(printk(KERN_DEBUG "jffs2_do_read_inode(): Creating inocache for root inode\n")); 819 JFFS2_DBG_READINODE("creating inocache for root inode\n");
836 memset(f->inocache, 0, sizeof(struct jffs2_inode_cache)); 820 memset(f->inocache, 0, sizeof(struct jffs2_inode_cache));
837 f->inocache->ino = f->inocache->nlink = 1; 821 f->inocache->ino = f->inocache->nlink = 1;
838 f->inocache->nodes = (struct jffs2_raw_node_ref *)f->inocache; 822 f->inocache->nodes = (struct jffs2_raw_node_ref *)f->inocache;
@@ -840,7 +824,7 @@ int jffs2_do_read_inode(struct jffs2_sb_info *c, struct jffs2_inode_info *f,
840 jffs2_add_ino_cache(c, f->inocache); 824 jffs2_add_ino_cache(c, f->inocache);
841 } 825 }
842 if (!f->inocache) { 826 if (!f->inocache) {
843 printk(KERN_WARNING "jffs2_do_read_inode() on nonexistent ino %u\n", ino); 827 JFFS2_ERROR("requestied to read an nonexistent ino %u\n", ino);
844 return -ENOENT; 828 return -ENOENT;
845 } 829 }
846 830