diff options
Diffstat (limited to 'fs/ubifs/debug.c')
-rw-r--r-- | fs/ubifs/debug.c | 167 |
1 files changed, 108 insertions, 59 deletions
diff --git a/fs/ubifs/debug.c b/fs/ubifs/debug.c index 004d3745dc4..0bb2bcef0de 100644 --- a/fs/ubifs/debug.c +++ b/fs/ubifs/debug.c | |||
@@ -34,7 +34,6 @@ | |||
34 | #include <linux/moduleparam.h> | 34 | #include <linux/moduleparam.h> |
35 | #include <linux/debugfs.h> | 35 | #include <linux/debugfs.h> |
36 | #include <linux/math64.h> | 36 | #include <linux/math64.h> |
37 | #include <linux/slab.h> | ||
38 | 37 | ||
39 | #ifdef CONFIG_UBIFS_FS_DEBUG | 38 | #ifdef CONFIG_UBIFS_FS_DEBUG |
40 | 39 | ||
@@ -43,15 +42,12 @@ DEFINE_SPINLOCK(dbg_lock); | |||
43 | static char dbg_key_buf0[128]; | 42 | static char dbg_key_buf0[128]; |
44 | static char dbg_key_buf1[128]; | 43 | static char dbg_key_buf1[128]; |
45 | 44 | ||
46 | unsigned int ubifs_msg_flags; | ||
47 | unsigned int ubifs_chk_flags; | 45 | unsigned int ubifs_chk_flags; |
48 | unsigned int ubifs_tst_flags; | 46 | unsigned int ubifs_tst_flags; |
49 | 47 | ||
50 | module_param_named(debug_msgs, ubifs_msg_flags, uint, S_IRUGO | S_IWUSR); | ||
51 | module_param_named(debug_chks, ubifs_chk_flags, uint, S_IRUGO | S_IWUSR); | 48 | module_param_named(debug_chks, ubifs_chk_flags, uint, S_IRUGO | S_IWUSR); |
52 | module_param_named(debug_tsts, ubifs_tst_flags, uint, S_IRUGO | S_IWUSR); | 49 | module_param_named(debug_tsts, ubifs_tst_flags, uint, S_IRUGO | S_IWUSR); |
53 | 50 | ||
54 | MODULE_PARM_DESC(debug_msgs, "Debug message type flags"); | ||
55 | MODULE_PARM_DESC(debug_chks, "Debug check flags"); | 51 | MODULE_PARM_DESC(debug_chks, "Debug check flags"); |
56 | MODULE_PARM_DESC(debug_tsts, "Debug special test flags"); | 52 | MODULE_PARM_DESC(debug_tsts, "Debug special test flags"); |
57 | 53 | ||
@@ -317,6 +313,8 @@ void dbg_dump_node(const struct ubifs_info *c, const void *node) | |||
317 | printk(KERN_DEBUG "\tflags %#x\n", sup_flags); | 313 | printk(KERN_DEBUG "\tflags %#x\n", sup_flags); |
318 | printk(KERN_DEBUG "\t big_lpt %u\n", | 314 | printk(KERN_DEBUG "\t big_lpt %u\n", |
319 | !!(sup_flags & UBIFS_FLG_BIGLPT)); | 315 | !!(sup_flags & UBIFS_FLG_BIGLPT)); |
316 | printk(KERN_DEBUG "\t space_fixup %u\n", | ||
317 | !!(sup_flags & UBIFS_FLG_SPACE_FIXUP)); | ||
320 | printk(KERN_DEBUG "\tmin_io_size %u\n", | 318 | printk(KERN_DEBUG "\tmin_io_size %u\n", |
321 | le32_to_cpu(sup->min_io_size)); | 319 | le32_to_cpu(sup->min_io_size)); |
322 | printk(KERN_DEBUG "\tleb_size %u\n", | 320 | printk(KERN_DEBUG "\tleb_size %u\n", |
@@ -602,7 +600,7 @@ void dbg_dump_lstats(const struct ubifs_lp_stats *lst) | |||
602 | spin_unlock(&dbg_lock); | 600 | spin_unlock(&dbg_lock); |
603 | } | 601 | } |
604 | 602 | ||
605 | void dbg_dump_budg(struct ubifs_info *c) | 603 | void dbg_dump_budg(struct ubifs_info *c, const struct ubifs_budg_info *bi) |
606 | { | 604 | { |
607 | int i; | 605 | int i; |
608 | struct rb_node *rb; | 606 | struct rb_node *rb; |
@@ -610,26 +608,42 @@ void dbg_dump_budg(struct ubifs_info *c) | |||
610 | struct ubifs_gced_idx_leb *idx_gc; | 608 | struct ubifs_gced_idx_leb *idx_gc; |
611 | long long available, outstanding, free; | 609 | long long available, outstanding, free; |
612 | 610 | ||
613 | ubifs_assert(spin_is_locked(&c->space_lock)); | 611 | spin_lock(&c->space_lock); |
614 | spin_lock(&dbg_lock); | 612 | spin_lock(&dbg_lock); |
615 | printk(KERN_DEBUG "(pid %d) Budgeting info: budg_data_growth %lld, " | 613 | printk(KERN_DEBUG "(pid %d) Budgeting info: data budget sum %lld, " |
616 | "budg_dd_growth %lld, budg_idx_growth %lld\n", current->pid, | 614 | "total budget sum %lld\n", current->pid, |
617 | c->budg_data_growth, c->budg_dd_growth, c->budg_idx_growth); | 615 | bi->data_growth + bi->dd_growth, |
618 | printk(KERN_DEBUG "\tdata budget sum %lld, total budget sum %lld, " | 616 | bi->data_growth + bi->dd_growth + bi->idx_growth); |
619 | "freeable_cnt %d\n", c->budg_data_growth + c->budg_dd_growth, | 617 | printk(KERN_DEBUG "\tbudg_data_growth %lld, budg_dd_growth %lld, " |
620 | c->budg_data_growth + c->budg_dd_growth + c->budg_idx_growth, | 618 | "budg_idx_growth %lld\n", bi->data_growth, bi->dd_growth, |
621 | c->freeable_cnt); | 619 | bi->idx_growth); |
622 | printk(KERN_DEBUG "\tmin_idx_lebs %d, old_idx_sz %lld, " | 620 | printk(KERN_DEBUG "\tmin_idx_lebs %d, old_idx_sz %llu, " |
623 | "calc_idx_sz %lld, idx_gc_cnt %d\n", c->min_idx_lebs, | 621 | "uncommitted_idx %lld\n", bi->min_idx_lebs, bi->old_idx_sz, |
624 | c->old_idx_sz, c->calc_idx_sz, c->idx_gc_cnt); | 622 | bi->uncommitted_idx); |
623 | printk(KERN_DEBUG "\tpage_budget %d, inode_budget %d, dent_budget %d\n", | ||
624 | bi->page_budget, bi->inode_budget, bi->dent_budget); | ||
625 | printk(KERN_DEBUG "\tnospace %u, nospace_rp %u\n", | ||
626 | bi->nospace, bi->nospace_rp); | ||
627 | printk(KERN_DEBUG "\tdark_wm %d, dead_wm %d, max_idx_node_sz %d\n", | ||
628 | c->dark_wm, c->dead_wm, c->max_idx_node_sz); | ||
629 | |||
630 | if (bi != &c->bi) | ||
631 | /* | ||
632 | * If we are dumping saved budgeting data, do not print | ||
633 | * additional information which is about the current state, not | ||
634 | * the old one which corresponded to the saved budgeting data. | ||
635 | */ | ||
636 | goto out_unlock; | ||
637 | |||
638 | printk(KERN_DEBUG "\tfreeable_cnt %d, calc_idx_sz %lld, idx_gc_cnt %d\n", | ||
639 | c->freeable_cnt, c->calc_idx_sz, c->idx_gc_cnt); | ||
625 | printk(KERN_DEBUG "\tdirty_pg_cnt %ld, dirty_zn_cnt %ld, " | 640 | printk(KERN_DEBUG "\tdirty_pg_cnt %ld, dirty_zn_cnt %ld, " |
626 | "clean_zn_cnt %ld\n", atomic_long_read(&c->dirty_pg_cnt), | 641 | "clean_zn_cnt %ld\n", atomic_long_read(&c->dirty_pg_cnt), |
627 | atomic_long_read(&c->dirty_zn_cnt), | 642 | atomic_long_read(&c->dirty_zn_cnt), |
628 | atomic_long_read(&c->clean_zn_cnt)); | 643 | atomic_long_read(&c->clean_zn_cnt)); |
629 | printk(KERN_DEBUG "\tdark_wm %d, dead_wm %d, max_idx_node_sz %d\n", | ||
630 | c->dark_wm, c->dead_wm, c->max_idx_node_sz); | ||
631 | printk(KERN_DEBUG "\tgc_lnum %d, ihead_lnum %d\n", | 644 | printk(KERN_DEBUG "\tgc_lnum %d, ihead_lnum %d\n", |
632 | c->gc_lnum, c->ihead_lnum); | 645 | c->gc_lnum, c->ihead_lnum); |
646 | |||
633 | /* If we are in R/O mode, journal heads do not exist */ | 647 | /* If we are in R/O mode, journal heads do not exist */ |
634 | if (c->jheads) | 648 | if (c->jheads) |
635 | for (i = 0; i < c->jhead_cnt; i++) | 649 | for (i = 0; i < c->jhead_cnt; i++) |
@@ -648,13 +662,15 @@ void dbg_dump_budg(struct ubifs_info *c) | |||
648 | printk(KERN_DEBUG "\tcommit state %d\n", c->cmt_state); | 662 | printk(KERN_DEBUG "\tcommit state %d\n", c->cmt_state); |
649 | 663 | ||
650 | /* Print budgeting predictions */ | 664 | /* Print budgeting predictions */ |
651 | available = ubifs_calc_available(c, c->min_idx_lebs); | 665 | available = ubifs_calc_available(c, c->bi.min_idx_lebs); |
652 | outstanding = c->budg_data_growth + c->budg_dd_growth; | 666 | outstanding = c->bi.data_growth + c->bi.dd_growth; |
653 | free = ubifs_get_free_space_nolock(c); | 667 | free = ubifs_get_free_space_nolock(c); |
654 | printk(KERN_DEBUG "Budgeting predictions:\n"); | 668 | printk(KERN_DEBUG "Budgeting predictions:\n"); |
655 | printk(KERN_DEBUG "\tavailable: %lld, outstanding %lld, free %lld\n", | 669 | printk(KERN_DEBUG "\tavailable: %lld, outstanding %lld, free %lld\n", |
656 | available, outstanding, free); | 670 | available, outstanding, free); |
671 | out_unlock: | ||
657 | spin_unlock(&dbg_lock); | 672 | spin_unlock(&dbg_lock); |
673 | spin_unlock(&c->space_lock); | ||
658 | } | 674 | } |
659 | 675 | ||
660 | void dbg_dump_lprop(const struct ubifs_info *c, const struct ubifs_lprops *lp) | 676 | void dbg_dump_lprop(const struct ubifs_info *c, const struct ubifs_lprops *lp) |
@@ -729,7 +745,13 @@ void dbg_dump_lprop(const struct ubifs_info *c, const struct ubifs_lprops *lp) | |||
729 | if (bud->lnum == lp->lnum) { | 745 | if (bud->lnum == lp->lnum) { |
730 | int head = 0; | 746 | int head = 0; |
731 | for (i = 0; i < c->jhead_cnt; i++) { | 747 | for (i = 0; i < c->jhead_cnt; i++) { |
732 | if (lp->lnum == c->jheads[i].wbuf.lnum) { | 748 | /* |
749 | * Note, if we are in R/O mode or in the middle | ||
750 | * of mounting/re-mounting, the write-buffers do | ||
751 | * not exist. | ||
752 | */ | ||
753 | if (c->jheads && | ||
754 | lp->lnum == c->jheads[i].wbuf.lnum) { | ||
733 | printk(KERN_CONT ", jhead %s", | 755 | printk(KERN_CONT ", jhead %s", |
734 | dbg_jhead(i)); | 756 | dbg_jhead(i)); |
735 | head = 1; | 757 | head = 1; |
@@ -976,6 +998,8 @@ void dbg_save_space_info(struct ubifs_info *c) | |||
976 | 998 | ||
977 | spin_lock(&c->space_lock); | 999 | spin_lock(&c->space_lock); |
978 | memcpy(&d->saved_lst, &c->lst, sizeof(struct ubifs_lp_stats)); | 1000 | memcpy(&d->saved_lst, &c->lst, sizeof(struct ubifs_lp_stats)); |
1001 | memcpy(&d->saved_bi, &c->bi, sizeof(struct ubifs_budg_info)); | ||
1002 | d->saved_idx_gc_cnt = c->idx_gc_cnt; | ||
979 | 1003 | ||
980 | /* | 1004 | /* |
981 | * We use a dirty hack here and zero out @c->freeable_cnt, because it | 1005 | * We use a dirty hack here and zero out @c->freeable_cnt, because it |
@@ -1042,14 +1066,14 @@ int dbg_check_space_info(struct ubifs_info *c) | |||
1042 | out: | 1066 | out: |
1043 | ubifs_msg("saved lprops statistics dump"); | 1067 | ubifs_msg("saved lprops statistics dump"); |
1044 | dbg_dump_lstats(&d->saved_lst); | 1068 | dbg_dump_lstats(&d->saved_lst); |
1045 | ubifs_get_lp_stats(c, &lst); | 1069 | ubifs_msg("saved budgeting info dump"); |
1046 | 1070 | dbg_dump_budg(c, &d->saved_bi); | |
1071 | ubifs_msg("saved idx_gc_cnt %d", d->saved_idx_gc_cnt); | ||
1047 | ubifs_msg("current lprops statistics dump"); | 1072 | ubifs_msg("current lprops statistics dump"); |
1073 | ubifs_get_lp_stats(c, &lst); | ||
1048 | dbg_dump_lstats(&lst); | 1074 | dbg_dump_lstats(&lst); |
1049 | 1075 | ubifs_msg("current budgeting info dump"); | |
1050 | spin_lock(&c->space_lock); | 1076 | dbg_dump_budg(c, &c->bi); |
1051 | dbg_dump_budg(c); | ||
1052 | spin_unlock(&c->space_lock); | ||
1053 | dump_stack(); | 1077 | dump_stack(); |
1054 | return -EINVAL; | 1078 | return -EINVAL; |
1055 | } | 1079 | } |
@@ -1793,6 +1817,8 @@ static struct fsck_inode *add_inode(struct ubifs_info *c, | |||
1793 | struct rb_node **p, *parent = NULL; | 1817 | struct rb_node **p, *parent = NULL; |
1794 | struct fsck_inode *fscki; | 1818 | struct fsck_inode *fscki; |
1795 | ino_t inum = key_inum_flash(c, &ino->key); | 1819 | ino_t inum = key_inum_flash(c, &ino->key); |
1820 | struct inode *inode; | ||
1821 | struct ubifs_inode *ui; | ||
1796 | 1822 | ||
1797 | p = &fsckd->inodes.rb_node; | 1823 | p = &fsckd->inodes.rb_node; |
1798 | while (*p) { | 1824 | while (*p) { |
@@ -1816,19 +1842,46 @@ static struct fsck_inode *add_inode(struct ubifs_info *c, | |||
1816 | if (!fscki) | 1842 | if (!fscki) |
1817 | return ERR_PTR(-ENOMEM); | 1843 | return ERR_PTR(-ENOMEM); |
1818 | 1844 | ||
1845 | inode = ilookup(c->vfs_sb, inum); | ||
1846 | |||
1819 | fscki->inum = inum; | 1847 | fscki->inum = inum; |
1820 | fscki->nlink = le32_to_cpu(ino->nlink); | 1848 | /* |
1821 | fscki->size = le64_to_cpu(ino->size); | 1849 | * If the inode is present in the VFS inode cache, use it instead of |
1822 | fscki->xattr_cnt = le32_to_cpu(ino->xattr_cnt); | 1850 | * the on-flash inode which might be out-of-date. E.g., the size might |
1823 | fscki->xattr_sz = le32_to_cpu(ino->xattr_size); | 1851 | * be out-of-date. If we do not do this, the following may happen, for |
1824 | fscki->xattr_nms = le32_to_cpu(ino->xattr_names); | 1852 | * example: |
1825 | fscki->mode = le32_to_cpu(ino->mode); | 1853 | * 1. A power cut happens |
1854 | * 2. We mount the file-system R/O, the replay process fixes up the | ||
1855 | * inode size in the VFS cache, but on on-flash. | ||
1856 | * 3. 'check_leaf()' fails because it hits a data node beyond inode | ||
1857 | * size. | ||
1858 | */ | ||
1859 | if (!inode) { | ||
1860 | fscki->nlink = le32_to_cpu(ino->nlink); | ||
1861 | fscki->size = le64_to_cpu(ino->size); | ||
1862 | fscki->xattr_cnt = le32_to_cpu(ino->xattr_cnt); | ||
1863 | fscki->xattr_sz = le32_to_cpu(ino->xattr_size); | ||
1864 | fscki->xattr_nms = le32_to_cpu(ino->xattr_names); | ||
1865 | fscki->mode = le32_to_cpu(ino->mode); | ||
1866 | } else { | ||
1867 | ui = ubifs_inode(inode); | ||
1868 | fscki->nlink = inode->i_nlink; | ||
1869 | fscki->size = inode->i_size; | ||
1870 | fscki->xattr_cnt = ui->xattr_cnt; | ||
1871 | fscki->xattr_sz = ui->xattr_size; | ||
1872 | fscki->xattr_nms = ui->xattr_names; | ||
1873 | fscki->mode = inode->i_mode; | ||
1874 | iput(inode); | ||
1875 | } | ||
1876 | |||
1826 | if (S_ISDIR(fscki->mode)) { | 1877 | if (S_ISDIR(fscki->mode)) { |
1827 | fscki->calc_sz = UBIFS_INO_NODE_SZ; | 1878 | fscki->calc_sz = UBIFS_INO_NODE_SZ; |
1828 | fscki->calc_cnt = 2; | 1879 | fscki->calc_cnt = 2; |
1829 | } | 1880 | } |
1881 | |||
1830 | rb_link_node(&fscki->rb, parent, p); | 1882 | rb_link_node(&fscki->rb, parent, p); |
1831 | rb_insert_color(&fscki->rb, &fsckd->inodes); | 1883 | rb_insert_color(&fscki->rb, &fsckd->inodes); |
1884 | |||
1832 | return fscki; | 1885 | return fscki; |
1833 | } | 1886 | } |
1834 | 1887 | ||
@@ -2421,7 +2474,8 @@ int dbg_check_nondata_nodes_order(struct ubifs_info *c, struct list_head *head) | |||
2421 | hashb = key_block(c, &sb->key); | 2474 | hashb = key_block(c, &sb->key); |
2422 | 2475 | ||
2423 | if (hasha > hashb) { | 2476 | if (hasha > hashb) { |
2424 | ubifs_err("larger hash %u goes before %u", hasha, hashb); | 2477 | ubifs_err("larger hash %u goes before %u", |
2478 | hasha, hashb); | ||
2425 | goto error_dump; | 2479 | goto error_dump; |
2426 | } | 2480 | } |
2427 | } | 2481 | } |
@@ -2437,14 +2491,12 @@ error_dump: | |||
2437 | return 0; | 2491 | return 0; |
2438 | } | 2492 | } |
2439 | 2493 | ||
2440 | static int invocation_cnt; | ||
2441 | |||
2442 | int dbg_force_in_the_gaps(void) | 2494 | int dbg_force_in_the_gaps(void) |
2443 | { | 2495 | { |
2444 | if (!dbg_force_in_the_gaps_enabled) | 2496 | if (!(ubifs_chk_flags & UBIFS_CHK_GEN)) |
2445 | return 0; | 2497 | return 0; |
2446 | /* Force in-the-gaps every 8th commit */ | 2498 | |
2447 | return !((invocation_cnt++) & 0x7); | 2499 | return !(random32() & 7); |
2448 | } | 2500 | } |
2449 | 2501 | ||
2450 | /* Failure mode for recovery testing */ | 2502 | /* Failure mode for recovery testing */ |
@@ -2632,7 +2684,7 @@ int dbg_leb_read(struct ubi_volume_desc *desc, int lnum, char *buf, int offset, | |||
2632 | int len, int check) | 2684 | int len, int check) |
2633 | { | 2685 | { |
2634 | if (in_failure_mode(desc)) | 2686 | if (in_failure_mode(desc)) |
2635 | return -EIO; | 2687 | return -EROFS; |
2636 | return ubi_leb_read(desc, lnum, buf, offset, len, check); | 2688 | return ubi_leb_read(desc, lnum, buf, offset, len, check); |
2637 | } | 2689 | } |
2638 | 2690 | ||
@@ -2642,7 +2694,7 @@ int dbg_leb_write(struct ubi_volume_desc *desc, int lnum, const void *buf, | |||
2642 | int err, failing; | 2694 | int err, failing; |
2643 | 2695 | ||
2644 | if (in_failure_mode(desc)) | 2696 | if (in_failure_mode(desc)) |
2645 | return -EIO; | 2697 | return -EROFS; |
2646 | failing = do_fail(desc, lnum, 1); | 2698 | failing = do_fail(desc, lnum, 1); |
2647 | if (failing) | 2699 | if (failing) |
2648 | cut_data(buf, len); | 2700 | cut_data(buf, len); |
@@ -2650,7 +2702,7 @@ int dbg_leb_write(struct ubi_volume_desc *desc, int lnum, const void *buf, | |||
2650 | if (err) | 2702 | if (err) |
2651 | return err; | 2703 | return err; |
2652 | if (failing) | 2704 | if (failing) |
2653 | return -EIO; | 2705 | return -EROFS; |
2654 | return 0; | 2706 | return 0; |
2655 | } | 2707 | } |
2656 | 2708 | ||
@@ -2660,12 +2712,12 @@ int dbg_leb_change(struct ubi_volume_desc *desc, int lnum, const void *buf, | |||
2660 | int err; | 2712 | int err; |
2661 | 2713 | ||
2662 | if (do_fail(desc, lnum, 1)) | 2714 | if (do_fail(desc, lnum, 1)) |
2663 | return -EIO; | 2715 | return -EROFS; |
2664 | err = ubi_leb_change(desc, lnum, buf, len, dtype); | 2716 | err = ubi_leb_change(desc, lnum, buf, len, dtype); |
2665 | if (err) | 2717 | if (err) |
2666 | return err; | 2718 | return err; |
2667 | if (do_fail(desc, lnum, 1)) | 2719 | if (do_fail(desc, lnum, 1)) |
2668 | return -EIO; | 2720 | return -EROFS; |
2669 | return 0; | 2721 | return 0; |
2670 | } | 2722 | } |
2671 | 2723 | ||
@@ -2674,12 +2726,12 @@ int dbg_leb_erase(struct ubi_volume_desc *desc, int lnum) | |||
2674 | int err; | 2726 | int err; |
2675 | 2727 | ||
2676 | if (do_fail(desc, lnum, 0)) | 2728 | if (do_fail(desc, lnum, 0)) |
2677 | return -EIO; | 2729 | return -EROFS; |
2678 | err = ubi_leb_erase(desc, lnum); | 2730 | err = ubi_leb_erase(desc, lnum); |
2679 | if (err) | 2731 | if (err) |
2680 | return err; | 2732 | return err; |
2681 | if (do_fail(desc, lnum, 0)) | 2733 | if (do_fail(desc, lnum, 0)) |
2682 | return -EIO; | 2734 | return -EROFS; |
2683 | return 0; | 2735 | return 0; |
2684 | } | 2736 | } |
2685 | 2737 | ||
@@ -2688,19 +2740,19 @@ int dbg_leb_unmap(struct ubi_volume_desc *desc, int lnum) | |||
2688 | int err; | 2740 | int err; |
2689 | 2741 | ||
2690 | if (do_fail(desc, lnum, 0)) | 2742 | if (do_fail(desc, lnum, 0)) |
2691 | return -EIO; | 2743 | return -EROFS; |
2692 | err = ubi_leb_unmap(desc, lnum); | 2744 | err = ubi_leb_unmap(desc, lnum); |
2693 | if (err) | 2745 | if (err) |
2694 | return err; | 2746 | return err; |
2695 | if (do_fail(desc, lnum, 0)) | 2747 | if (do_fail(desc, lnum, 0)) |
2696 | return -EIO; | 2748 | return -EROFS; |
2697 | return 0; | 2749 | return 0; |
2698 | } | 2750 | } |
2699 | 2751 | ||
2700 | int dbg_is_mapped(struct ubi_volume_desc *desc, int lnum) | 2752 | int dbg_is_mapped(struct ubi_volume_desc *desc, int lnum) |
2701 | { | 2753 | { |
2702 | if (in_failure_mode(desc)) | 2754 | if (in_failure_mode(desc)) |
2703 | return -EIO; | 2755 | return -EROFS; |
2704 | return ubi_is_mapped(desc, lnum); | 2756 | return ubi_is_mapped(desc, lnum); |
2705 | } | 2757 | } |
2706 | 2758 | ||
@@ -2709,12 +2761,12 @@ int dbg_leb_map(struct ubi_volume_desc *desc, int lnum, int dtype) | |||
2709 | int err; | 2761 | int err; |
2710 | 2762 | ||
2711 | if (do_fail(desc, lnum, 0)) | 2763 | if (do_fail(desc, lnum, 0)) |
2712 | return -EIO; | 2764 | return -EROFS; |
2713 | err = ubi_leb_map(desc, lnum, dtype); | 2765 | err = ubi_leb_map(desc, lnum, dtype); |
2714 | if (err) | 2766 | if (err) |
2715 | return err; | 2767 | return err; |
2716 | if (do_fail(desc, lnum, 0)) | 2768 | if (do_fail(desc, lnum, 0)) |
2717 | return -EIO; | 2769 | return -EROFS; |
2718 | return 0; | 2770 | return 0; |
2719 | } | 2771 | } |
2720 | 2772 | ||
@@ -2784,7 +2836,7 @@ void dbg_debugfs_exit(void) | |||
2784 | static int open_debugfs_file(struct inode *inode, struct file *file) | 2836 | static int open_debugfs_file(struct inode *inode, struct file *file) |
2785 | { | 2837 | { |
2786 | file->private_data = inode->i_private; | 2838 | file->private_data = inode->i_private; |
2787 | return 0; | 2839 | return nonseekable_open(inode, file); |
2788 | } | 2840 | } |
2789 | 2841 | ||
2790 | static ssize_t write_debugfs_file(struct file *file, const char __user *buf, | 2842 | static ssize_t write_debugfs_file(struct file *file, const char __user *buf, |
@@ -2795,18 +2847,15 @@ static ssize_t write_debugfs_file(struct file *file, const char __user *buf, | |||
2795 | 2847 | ||
2796 | if (file->f_path.dentry == d->dfs_dump_lprops) | 2848 | if (file->f_path.dentry == d->dfs_dump_lprops) |
2797 | dbg_dump_lprops(c); | 2849 | dbg_dump_lprops(c); |
2798 | else if (file->f_path.dentry == d->dfs_dump_budg) { | 2850 | else if (file->f_path.dentry == d->dfs_dump_budg) |
2799 | spin_lock(&c->space_lock); | 2851 | dbg_dump_budg(c, &c->bi); |
2800 | dbg_dump_budg(c); | 2852 | else if (file->f_path.dentry == d->dfs_dump_tnc) { |
2801 | spin_unlock(&c->space_lock); | ||
2802 | } else if (file->f_path.dentry == d->dfs_dump_tnc) { | ||
2803 | mutex_lock(&c->tnc_mutex); | 2853 | mutex_lock(&c->tnc_mutex); |
2804 | dbg_dump_tnc(c); | 2854 | dbg_dump_tnc(c); |
2805 | mutex_unlock(&c->tnc_mutex); | 2855 | mutex_unlock(&c->tnc_mutex); |
2806 | } else | 2856 | } else |
2807 | return -EINVAL; | 2857 | return -EINVAL; |
2808 | 2858 | ||
2809 | *ppos += count; | ||
2810 | return count; | 2859 | return count; |
2811 | } | 2860 | } |
2812 | 2861 | ||
@@ -2814,7 +2863,7 @@ static const struct file_operations dfs_fops = { | |||
2814 | .open = open_debugfs_file, | 2863 | .open = open_debugfs_file, |
2815 | .write = write_debugfs_file, | 2864 | .write = write_debugfs_file, |
2816 | .owner = THIS_MODULE, | 2865 | .owner = THIS_MODULE, |
2817 | .llseek = default_llseek, | 2866 | .llseek = no_llseek, |
2818 | }; | 2867 | }; |
2819 | 2868 | ||
2820 | /** | 2869 | /** |