diff options
Diffstat (limited to 'fs/jffs2/fs.c')
-rw-r--r-- | fs/jffs2/fs.c | 67 |
1 files changed, 40 insertions, 27 deletions
diff --git a/fs/jffs2/fs.c b/fs/jffs2/fs.c index c0d5c9d770da..bb6f993ebca9 100644 --- a/fs/jffs2/fs.c +++ b/fs/jffs2/fs.c | |||
@@ -10,6 +10,8 @@ | |||
10 | * | 10 | * |
11 | */ | 11 | */ |
12 | 12 | ||
13 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
14 | |||
13 | #include <linux/capability.h> | 15 | #include <linux/capability.h> |
14 | #include <linux/kernel.h> | 16 | #include <linux/kernel.h> |
15 | #include <linux/sched.h> | 17 | #include <linux/sched.h> |
@@ -39,7 +41,7 @@ int jffs2_do_setattr (struct inode *inode, struct iattr *iattr) | |||
39 | int ret; | 41 | int ret; |
40 | int alloc_type = ALLOC_NORMAL; | 42 | int alloc_type = ALLOC_NORMAL; |
41 | 43 | ||
42 | D1(printk(KERN_DEBUG "jffs2_setattr(): ino #%lu\n", inode->i_ino)); | 44 | jffs2_dbg(1, "%s(): ino #%lu\n", __func__, inode->i_ino); |
43 | 45 | ||
44 | /* Special cases - we don't want more than one data node | 46 | /* Special cases - we don't want more than one data node |
45 | for these types on the medium at any time. So setattr | 47 | for these types on the medium at any time. So setattr |
@@ -50,7 +52,8 @@ int jffs2_do_setattr (struct inode *inode, struct iattr *iattr) | |||
50 | /* For these, we don't actually need to read the old node */ | 52 | /* For these, we don't actually need to read the old node */ |
51 | mdatalen = jffs2_encode_dev(&dev, inode->i_rdev); | 53 | mdatalen = jffs2_encode_dev(&dev, inode->i_rdev); |
52 | mdata = (char *)&dev; | 54 | mdata = (char *)&dev; |
53 | D1(printk(KERN_DEBUG "jffs2_setattr(): Writing %d bytes of kdev_t\n", mdatalen)); | 55 | jffs2_dbg(1, "%s(): Writing %d bytes of kdev_t\n", |
56 | __func__, mdatalen); | ||
54 | } else if (S_ISLNK(inode->i_mode)) { | 57 | } else if (S_ISLNK(inode->i_mode)) { |
55 | mutex_lock(&f->sem); | 58 | mutex_lock(&f->sem); |
56 | mdatalen = f->metadata->size; | 59 | mdatalen = f->metadata->size; |
@@ -66,7 +69,8 @@ int jffs2_do_setattr (struct inode *inode, struct iattr *iattr) | |||
66 | return ret; | 69 | return ret; |
67 | } | 70 | } |
68 | mutex_unlock(&f->sem); | 71 | mutex_unlock(&f->sem); |
69 | D1(printk(KERN_DEBUG "jffs2_setattr(): Writing %d bytes of symlink target\n", mdatalen)); | 72 | jffs2_dbg(1, "%s(): Writing %d bytes of symlink target\n", |
73 | __func__, mdatalen); | ||
70 | } | 74 | } |
71 | 75 | ||
72 | ri = jffs2_alloc_raw_inode(); | 76 | ri = jffs2_alloc_raw_inode(); |
@@ -233,7 +237,8 @@ void jffs2_evict_inode (struct inode *inode) | |||
233 | struct jffs2_sb_info *c = JFFS2_SB_INFO(inode->i_sb); | 237 | struct jffs2_sb_info *c = JFFS2_SB_INFO(inode->i_sb); |
234 | struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode); | 238 | struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode); |
235 | 239 | ||
236 | D1(printk(KERN_DEBUG "jffs2_evict_inode(): ino #%lu mode %o\n", inode->i_ino, inode->i_mode)); | 240 | jffs2_dbg(1, "%s(): ino #%lu mode %o\n", |
241 | __func__, inode->i_ino, inode->i_mode); | ||
237 | truncate_inode_pages(&inode->i_data, 0); | 242 | truncate_inode_pages(&inode->i_data, 0); |
238 | end_writeback(inode); | 243 | end_writeback(inode); |
239 | jffs2_do_clear_inode(c, f); | 244 | jffs2_do_clear_inode(c, f); |
@@ -249,7 +254,7 @@ struct inode *jffs2_iget(struct super_block *sb, unsigned long ino) | |||
249 | dev_t rdev = 0; | 254 | dev_t rdev = 0; |
250 | int ret; | 255 | int ret; |
251 | 256 | ||
252 | D1(printk(KERN_DEBUG "jffs2_iget(): ino == %lu\n", ino)); | 257 | jffs2_dbg(1, "%s(): ino == %lu\n", __func__, ino); |
253 | 258 | ||
254 | inode = iget_locked(sb, ino); | 259 | inode = iget_locked(sb, ino); |
255 | if (!inode) | 260 | if (!inode) |
@@ -317,14 +322,16 @@ struct inode *jffs2_iget(struct super_block *sb, unsigned long ino) | |||
317 | /* Read the device numbers from the media */ | 322 | /* Read the device numbers from the media */ |
318 | if (f->metadata->size != sizeof(jdev.old_id) && | 323 | if (f->metadata->size != sizeof(jdev.old_id) && |
319 | f->metadata->size != sizeof(jdev.new_id)) { | 324 | f->metadata->size != sizeof(jdev.new_id)) { |
320 | printk(KERN_NOTICE "Device node has strange size %d\n", f->metadata->size); | 325 | pr_notice("Device node has strange size %d\n", |
326 | f->metadata->size); | ||
321 | goto error_io; | 327 | goto error_io; |
322 | } | 328 | } |
323 | D1(printk(KERN_DEBUG "Reading device numbers from flash\n")); | 329 | jffs2_dbg(1, "Reading device numbers from flash\n"); |
324 | ret = jffs2_read_dnode(c, f, f->metadata, (char *)&jdev, 0, f->metadata->size); | 330 | ret = jffs2_read_dnode(c, f, f->metadata, (char *)&jdev, 0, f->metadata->size); |
325 | if (ret < 0) { | 331 | if (ret < 0) { |
326 | /* Eep */ | 332 | /* Eep */ |
327 | printk(KERN_NOTICE "Read device numbers for inode %lu failed\n", (unsigned long)inode->i_ino); | 333 | pr_notice("Read device numbers for inode %lu failed\n", |
334 | (unsigned long)inode->i_ino); | ||
328 | goto error; | 335 | goto error; |
329 | } | 336 | } |
330 | if (f->metadata->size == sizeof(jdev.old_id)) | 337 | if (f->metadata->size == sizeof(jdev.old_id)) |
@@ -339,12 +346,13 @@ struct inode *jffs2_iget(struct super_block *sb, unsigned long ino) | |||
339 | break; | 346 | break; |
340 | 347 | ||
341 | default: | 348 | default: |
342 | printk(KERN_WARNING "jffs2_read_inode(): Bogus imode %o for ino %lu\n", inode->i_mode, (unsigned long)inode->i_ino); | 349 | pr_warn("%s(): Bogus i_mode %o for ino %lu\n", |
350 | __func__, inode->i_mode, (unsigned long)inode->i_ino); | ||
343 | } | 351 | } |
344 | 352 | ||
345 | mutex_unlock(&f->sem); | 353 | mutex_unlock(&f->sem); |
346 | 354 | ||
347 | D1(printk(KERN_DEBUG "jffs2_read_inode() returning\n")); | 355 | jffs2_dbg(1, "jffs2_read_inode() returning\n"); |
348 | unlock_new_inode(inode); | 356 | unlock_new_inode(inode); |
349 | return inode; | 357 | return inode; |
350 | 358 | ||
@@ -362,11 +370,13 @@ void jffs2_dirty_inode(struct inode *inode, int flags) | |||
362 | struct iattr iattr; | 370 | struct iattr iattr; |
363 | 371 | ||
364 | if (!(inode->i_state & I_DIRTY_DATASYNC)) { | 372 | if (!(inode->i_state & I_DIRTY_DATASYNC)) { |
365 | D2(printk(KERN_DEBUG "jffs2_dirty_inode() not calling setattr() for ino #%lu\n", inode->i_ino)); | 373 | jffs2_dbg(2, "%s(): not calling setattr() for ino #%lu\n", |
374 | __func__, inode->i_ino); | ||
366 | return; | 375 | return; |
367 | } | 376 | } |
368 | 377 | ||
369 | D1(printk(KERN_DEBUG "jffs2_dirty_inode() calling setattr() for ino #%lu\n", inode->i_ino)); | 378 | jffs2_dbg(1, "%s(): calling setattr() for ino #%lu\n", |
379 | __func__, inode->i_ino); | ||
370 | 380 | ||
371 | iattr.ia_valid = ATTR_MODE|ATTR_UID|ATTR_GID|ATTR_ATIME|ATTR_MTIME|ATTR_CTIME; | 381 | iattr.ia_valid = ATTR_MODE|ATTR_UID|ATTR_GID|ATTR_ATIME|ATTR_MTIME|ATTR_CTIME; |
372 | iattr.ia_mode = inode->i_mode; | 382 | iattr.ia_mode = inode->i_mode; |
@@ -414,7 +424,8 @@ struct inode *jffs2_new_inode (struct inode *dir_i, umode_t mode, struct jffs2_r | |||
414 | struct jffs2_inode_info *f; | 424 | struct jffs2_inode_info *f; |
415 | int ret; | 425 | int ret; |
416 | 426 | ||
417 | D1(printk(KERN_DEBUG "jffs2_new_inode(): dir_i %ld, mode 0x%x\n", dir_i->i_ino, mode)); | 427 | jffs2_dbg(1, "%s(): dir_i %ld, mode 0x%x\n", |
428 | __func__, dir_i->i_ino, mode); | ||
418 | 429 | ||
419 | c = JFFS2_SB_INFO(sb); | 430 | c = JFFS2_SB_INFO(sb); |
420 | 431 | ||
@@ -504,11 +515,11 @@ int jffs2_do_fill_super(struct super_block *sb, void *data, int silent) | |||
504 | 515 | ||
505 | #ifndef CONFIG_JFFS2_FS_WRITEBUFFER | 516 | #ifndef CONFIG_JFFS2_FS_WRITEBUFFER |
506 | if (c->mtd->type == MTD_NANDFLASH) { | 517 | if (c->mtd->type == MTD_NANDFLASH) { |
507 | printk(KERN_ERR "jffs2: Cannot operate on NAND flash unless jffs2 NAND support is compiled in.\n"); | 518 | pr_err("Cannot operate on NAND flash unless jffs2 NAND support is compiled in\n"); |
508 | return -EINVAL; | 519 | return -EINVAL; |
509 | } | 520 | } |
510 | if (c->mtd->type == MTD_DATAFLASH) { | 521 | if (c->mtd->type == MTD_DATAFLASH) { |
511 | printk(KERN_ERR "jffs2: Cannot operate on DataFlash unless jffs2 DataFlash support is compiled in.\n"); | 522 | pr_err("Cannot operate on DataFlash unless jffs2 DataFlash support is compiled in\n"); |
512 | return -EINVAL; | 523 | return -EINVAL; |
513 | } | 524 | } |
514 | #endif | 525 | #endif |
@@ -522,12 +533,13 @@ int jffs2_do_fill_super(struct super_block *sb, void *data, int silent) | |||
522 | */ | 533 | */ |
523 | if ((c->sector_size * blocks) != c->flash_size) { | 534 | if ((c->sector_size * blocks) != c->flash_size) { |
524 | c->flash_size = c->sector_size * blocks; | 535 | c->flash_size = c->sector_size * blocks; |
525 | printk(KERN_INFO "jffs2: Flash size not aligned to erasesize, reducing to %dKiB\n", | 536 | pr_info("Flash size not aligned to erasesize, reducing to %dKiB\n", |
526 | c->flash_size / 1024); | 537 | c->flash_size / 1024); |
527 | } | 538 | } |
528 | 539 | ||
529 | if (c->flash_size < 5*c->sector_size) { | 540 | if (c->flash_size < 5*c->sector_size) { |
530 | printk(KERN_ERR "jffs2: Too few erase blocks (%d)\n", c->flash_size / c->sector_size); | 541 | pr_err("Too few erase blocks (%d)\n", |
542 | c->flash_size / c->sector_size); | ||
531 | return -EINVAL; | 543 | return -EINVAL; |
532 | } | 544 | } |
533 | 545 | ||
@@ -550,17 +562,17 @@ int jffs2_do_fill_super(struct super_block *sb, void *data, int silent) | |||
550 | if ((ret = jffs2_do_mount_fs(c))) | 562 | if ((ret = jffs2_do_mount_fs(c))) |
551 | goto out_inohash; | 563 | goto out_inohash; |
552 | 564 | ||
553 | D1(printk(KERN_DEBUG "jffs2_do_fill_super(): Getting root inode\n")); | 565 | jffs2_dbg(1, "%s(): Getting root inode\n", __func__); |
554 | root_i = jffs2_iget(sb, 1); | 566 | root_i = jffs2_iget(sb, 1); |
555 | if (IS_ERR(root_i)) { | 567 | if (IS_ERR(root_i)) { |
556 | D1(printk(KERN_WARNING "get root inode failed\n")); | 568 | jffs2_dbg(1, "get root inode failed\n"); |
557 | ret = PTR_ERR(root_i); | 569 | ret = PTR_ERR(root_i); |
558 | goto out_root; | 570 | goto out_root; |
559 | } | 571 | } |
560 | 572 | ||
561 | ret = -ENOMEM; | 573 | ret = -ENOMEM; |
562 | 574 | ||
563 | D1(printk(KERN_DEBUG "jffs2_do_fill_super(): d_alloc_root()\n")); | 575 | jffs2_dbg(1, "%s(): d_make_root()\n", __func__); |
564 | sb->s_root = d_make_root(root_i); | 576 | sb->s_root = d_make_root(root_i); |
565 | if (!sb->s_root) | 577 | if (!sb->s_root) |
566 | goto out_root; | 578 | goto out_root; |
@@ -618,20 +630,21 @@ struct jffs2_inode_info *jffs2_gc_fetch_inode(struct jffs2_sb_info *c, | |||
618 | */ | 630 | */ |
619 | inode = ilookup(OFNI_BS_2SFFJ(c), inum); | 631 | inode = ilookup(OFNI_BS_2SFFJ(c), inum); |
620 | if (!inode) { | 632 | if (!inode) { |
621 | D1(printk(KERN_DEBUG "ilookup() failed for ino #%u; inode is probably deleted.\n", | 633 | jffs2_dbg(1, "ilookup() failed for ino #%u; inode is probably deleted.\n", |
622 | inum)); | 634 | inum); |
623 | 635 | ||
624 | spin_lock(&c->inocache_lock); | 636 | spin_lock(&c->inocache_lock); |
625 | ic = jffs2_get_ino_cache(c, inum); | 637 | ic = jffs2_get_ino_cache(c, inum); |
626 | if (!ic) { | 638 | if (!ic) { |
627 | D1(printk(KERN_DEBUG "Inode cache for ino #%u is gone.\n", inum)); | 639 | jffs2_dbg(1, "Inode cache for ino #%u is gone\n", |
640 | inum); | ||
628 | spin_unlock(&c->inocache_lock); | 641 | spin_unlock(&c->inocache_lock); |
629 | return NULL; | 642 | return NULL; |
630 | } | 643 | } |
631 | if (ic->state != INO_STATE_CHECKEDABSENT) { | 644 | if (ic->state != INO_STATE_CHECKEDABSENT) { |
632 | /* Wait for progress. Don't just loop */ | 645 | /* Wait for progress. Don't just loop */ |
633 | D1(printk(KERN_DEBUG "Waiting for ino #%u in state %d\n", | 646 | jffs2_dbg(1, "Waiting for ino #%u in state %d\n", |
634 | ic->ino, ic->state)); | 647 | ic->ino, ic->state); |
635 | sleep_on_spinunlock(&c->inocache_wq, &c->inocache_lock); | 648 | sleep_on_spinunlock(&c->inocache_wq, &c->inocache_lock); |
636 | } else { | 649 | } else { |
637 | spin_unlock(&c->inocache_lock); | 650 | spin_unlock(&c->inocache_lock); |
@@ -649,8 +662,8 @@ struct jffs2_inode_info *jffs2_gc_fetch_inode(struct jffs2_sb_info *c, | |||
649 | return ERR_CAST(inode); | 662 | return ERR_CAST(inode); |
650 | } | 663 | } |
651 | if (is_bad_inode(inode)) { | 664 | if (is_bad_inode(inode)) { |
652 | printk(KERN_NOTICE "Eep. read_inode() failed for ino #%u. unlinked %d\n", | 665 | pr_notice("Eep. read_inode() failed for ino #%u. unlinked %d\n", |
653 | inum, unlinked); | 666 | inum, unlinked); |
654 | /* NB. This will happen again. We need to do something appropriate here. */ | 667 | /* NB. This will happen again. We need to do something appropriate here. */ |
655 | iput(inode); | 668 | iput(inode); |
656 | return ERR_PTR(-EIO); | 669 | return ERR_PTR(-EIO); |