Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'for-linus' of git://git.infradead.org/ubifs-2.6

* 'for-linus' of git://git.infradead.org/ubifs-2.6:
UBI: do not select KALLSYMS_ALL
UBI: do not compare array with NULL
UBI: check if we are in RO mode in the erase routine
UBIFS: fix debugging failure in dbg_check_space_info
UBIFS: fix error path in dbg_debugfs_init_fs
UBIFS: unify error path dbg_debugfs_init_fs
UBIFS: do not select KALLSYMS_ALL
UBIFS: fix assertion warnings
UBIFS: fix oops on error path in read_pnode
UBIFS: do not read flash unnecessarily

+61 -31
+1 -1
drivers/mtd/ubi/Kconfig
··· 56 56 bool "UBI debugging" 57 57 depends on SYSFS 58 58 select DEBUG_FS 59 - select KALLSYMS_ALL if KALLSYMS && DEBUG_KERNEL 59 + select KALLSYMS 60 60 help 61 61 This option enables UBI debugging. 62 62
+7 -1
drivers/mtd/ubi/io.c
··· 344 344 wait_queue_head_t wq; 345 345 346 346 dbg_io("erase PEB %d", pnum); 347 + ubi_assert(pnum >= 0 && pnum < ubi->peb_count); 348 + 349 + if (ubi->ro_mode) { 350 + ubi_err("read-only mode"); 351 + return -EROFS; 352 + } 347 353 348 354 retry: 349 355 init_waitqueue_head(&wq); ··· 396 390 if (err) 397 391 return err; 398 392 399 - if (ubi_dbg_is_erase_failure() && !err) { 393 + if (ubi_dbg_is_erase_failure()) { 400 394 dbg_err("cannot erase PEB %d (emulated)", pnum); 401 395 return -EIO; 402 396 }
-5
drivers/mtd/ubi/vmt.c
··· 790 790 goto fail; 791 791 } 792 792 793 - if (!vol->name) { 794 - ubi_err("NULL volume name"); 795 - goto fail; 796 - } 797 - 798 793 n = strnlen(vol->name, vol->name_len + 1); 799 794 if (n != vol->name_len) { 800 795 ubi_err("bad name_len %lld", n);
+1 -1
fs/ubifs/Kconfig
··· 47 47 bool "Enable debugging support" 48 48 depends on UBIFS_FS 49 49 select DEBUG_FS 50 - select KALLSYMS_ALL 50 + select KALLSYMS 51 51 help 52 52 This option enables UBIFS debugging support. It makes sure various 53 53 assertions, self-checks, debugging messages and test modes are compiled
+1 -1
fs/ubifs/commit.c
··· 577 577 size_t sz; 578 578 579 579 if (!(ubifs_chk_flags & UBIFS_CHK_OLD_IDX)) 580 - goto out; 580 + return 0; 581 581 582 582 INIT_LIST_HEAD(&list); 583 583
+46 -17
fs/ubifs/debug.c
··· 972 972 void dbg_save_space_info(struct ubifs_info *c) 973 973 { 974 974 struct ubifs_debug_info *d = c->dbg; 975 - 976 - ubifs_get_lp_stats(c, &d->saved_lst); 975 + int freeable_cnt; 977 976 978 977 spin_lock(&c->space_lock); 978 + memcpy(&d->saved_lst, &c->lst, sizeof(struct ubifs_lp_stats)); 979 + 980 + /* 981 + * We use a dirty hack here and zero out @c->freeable_cnt, because it 982 + * affects the free space calculations, and UBIFS might not know about 983 + * all freeable eraseblocks. Indeed, we know about freeable eraseblocks 984 + * only when we read their lprops, and we do this only lazily, upon the 985 + * need. So at any given point of time @c->freeable_cnt might be not 986 + * exactly accurate. 987 + * 988 + * Just one example about the issue we hit when we did not zero 989 + * @c->freeable_cnt. 990 + * 1. The file-system is mounted R/O, c->freeable_cnt is %0. We save the 991 + * amount of free space in @d->saved_free 992 + * 2. We re-mount R/W, which makes UBIFS to read the "lsave" 993 + * information from flash, where we cache LEBs from various 994 + * categories ('ubifs_remount_fs()' -> 'ubifs_lpt_init()' 995 + * -> 'lpt_init_wr()' -> 'read_lsave()' -> 'ubifs_lpt_lookup()' 996 + * -> 'ubifs_get_pnode()' -> 'update_cats()' 997 + * -> 'ubifs_add_to_cat()'). 998 + * 3. Lsave contains a freeable eraseblock, and @c->freeable_cnt 999 + * becomes %1. 1000 + * 4. We calculate the amount of free space when the re-mount is 1001 + * finished in 'dbg_check_space_info()' and it does not match 1002 + * @d->saved_free. 1003 + */ 1004 + freeable_cnt = c->freeable_cnt; 1005 + c->freeable_cnt = 0; 979 1006 d->saved_free = ubifs_get_free_space_nolock(c); 1007 + c->freeable_cnt = freeable_cnt; 980 1008 spin_unlock(&c->space_lock); 981 1009 } 982 1010 ··· 1021 993 { 1022 994 struct ubifs_debug_info *d = c->dbg; 1023 995 struct ubifs_lp_stats lst; 1024 - long long avail, free; 996 + long long free; 997 + int freeable_cnt; 1025 998 1026 999 spin_lock(&c->space_lock); 1027 - avail = ubifs_calc_available(c, c->min_idx_lebs); 1000 + freeable_cnt = c->freeable_cnt; 1001 + c->freeable_cnt = 0; 1002 + free = ubifs_get_free_space_nolock(c); 1003 + c->freeable_cnt = freeable_cnt; 1028 1004 spin_unlock(&c->space_lock); 1029 - free = ubifs_get_free_space(c); 1030 1005 1031 1006 if (free != d->saved_free) { 1032 1007 ubifs_err("free space changed from %lld to %lld", ··· 2837 2806 struct ubifs_debug_info *d = c->dbg; 2838 2807 2839 2808 sprintf(d->dfs_dir_name, "ubi%d_%d", c->vi.ubi_num, c->vi.vol_id); 2840 - d->dfs_dir = debugfs_create_dir(d->dfs_dir_name, dfs_rootdir); 2841 - if (IS_ERR(d->dfs_dir)) { 2842 - err = PTR_ERR(d->dfs_dir); 2843 - ubifs_err("cannot create \"%s\" debugfs directory, error %d\n", 2844 - d->dfs_dir_name, err); 2809 + fname = d->dfs_dir_name; 2810 + dent = debugfs_create_dir(fname, dfs_rootdir); 2811 + if (IS_ERR_OR_NULL(dent)) 2845 2812 goto out; 2846 - } 2813 + d->dfs_dir = dent; 2847 2814 2848 2815 fname = "dump_lprops"; 2849 2816 dent = debugfs_create_file(fname, S_IWUSR, d->dfs_dir, c, &dfs_fops); 2850 - if (IS_ERR(dent)) 2817 + if (IS_ERR_OR_NULL(dent)) 2851 2818 goto out_remove; 2852 2819 d->dfs_dump_lprops = dent; 2853 2820 2854 2821 fname = "dump_budg"; 2855 2822 dent = debugfs_create_file(fname, S_IWUSR, d->dfs_dir, c, &dfs_fops); 2856 - if (IS_ERR(dent)) 2823 + if (IS_ERR_OR_NULL(dent)) 2857 2824 goto out_remove; 2858 2825 d->dfs_dump_budg = dent; 2859 2826 2860 2827 fname = "dump_tnc"; 2861 2828 dent = debugfs_create_file(fname, S_IWUSR, d->dfs_dir, c, &dfs_fops); 2862 - if (IS_ERR(dent)) 2829 + if (IS_ERR_OR_NULL(dent)) 2863 2830 goto out_remove; 2864 2831 d->dfs_dump_tnc = dent; 2865 2832 2866 2833 return 0; 2867 2834 2868 2835 out_remove: 2869 - err = PTR_ERR(dent); 2870 - ubifs_err("cannot create \"%s\" debugfs directory, error %d\n", 2871 - fname, err); 2872 2836 debugfs_remove_recursive(d->dfs_dir); 2873 2837 out: 2838 + err = dent ? PTR_ERR(dent) : -ENODEV; 2839 + ubifs_err("cannot create \"%s\" debugfs directory, error %d\n", 2840 + fname, err); 2874 2841 return err; 2875 2842 } 2876 2843
+3 -4
fs/ubifs/lpt.c
··· 1270 1270 lnum = branch->lnum; 1271 1271 offs = branch->offs; 1272 1272 pnode = kzalloc(sizeof(struct ubifs_pnode), GFP_NOFS); 1273 - if (!pnode) { 1274 - err = -ENOMEM; 1275 - goto out; 1276 - } 1273 + if (!pnode) 1274 + return -ENOMEM; 1275 + 1277 1276 if (lnum == 0) { 1278 1277 /* 1279 1278 * This pnode was not written which just means that the LEB
+2 -1
fs/ubifs/super.c
··· 1568 1568 mutex_lock(&c->umount_mutex); 1569 1569 dbg_save_space_info(c); 1570 1570 c->remounting_rw = 1; 1571 + c->ro_mount = 0; 1571 1572 1572 1573 err = check_free_space(c); 1573 1574 if (err) ··· 1677 1676 } 1678 1677 1679 1678 dbg_gen("re-mounted read-write"); 1680 - c->ro_mount = 0; 1681 1679 c->remounting_rw = 0; 1682 1680 err = dbg_check_space_info(c); 1683 1681 mutex_unlock(&c->umount_mutex); 1684 1682 return err; 1685 1683 1686 1684 out: 1685 + c->ro_mount = 1; 1687 1686 vfree(c->orph_buf); 1688 1687 c->orph_buf = NULL; 1689 1688 if (c->bgt) {