aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2011-04-07 14:31:03 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2011-04-07 14:31:03 -0400
commitccfeef0ff76ebd632ae51bc56700f0072c4f1864 (patch)
tree83ec5932dac631a455a69212b505f68f57f68cdf /fs
parent42933bac11e811f02200c944d8562a15f8ec4ff0 (diff)
parent6bef0b67474d71e0d6484cbabcc87657a1176d8d (diff)
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
Diffstat (limited to 'fs')
-rw-r--r--fs/ubifs/Kconfig2
-rw-r--r--fs/ubifs/commit.c2
-rw-r--r--fs/ubifs/debug.c63
-rw-r--r--fs/ubifs/lpt.c7
-rw-r--r--fs/ubifs/super.c3
5 files changed, 53 insertions, 24 deletions
diff --git a/fs/ubifs/Kconfig b/fs/ubifs/Kconfig
index d7440904be17..f8b0160da2da 100644
--- a/fs/ubifs/Kconfig
+++ b/fs/ubifs/Kconfig
@@ -47,7 +47,7 @@ config UBIFS_FS_DEBUG
47 bool "Enable debugging support" 47 bool "Enable debugging support"
48 depends on UBIFS_FS 48 depends on UBIFS_FS
49 select DEBUG_FS 49 select DEBUG_FS
50 select KALLSYMS_ALL 50 select KALLSYMS
51 help 51 help
52 This option enables UBIFS debugging support. It makes sure various 52 This option enables UBIFS debugging support. It makes sure various
53 assertions, self-checks, debugging messages and test modes are compiled 53 assertions, self-checks, debugging messages and test modes are compiled
diff --git a/fs/ubifs/commit.c b/fs/ubifs/commit.c
index b148fbc80f8d..1bd01ded7123 100644
--- a/fs/ubifs/commit.c
+++ b/fs/ubifs/commit.c
@@ -577,7 +577,7 @@ int dbg_check_old_index(struct ubifs_info *c, struct ubifs_zbranch *zroot)
577 size_t sz; 577 size_t sz;
578 578
579 if (!(ubifs_chk_flags & UBIFS_CHK_OLD_IDX)) 579 if (!(ubifs_chk_flags & UBIFS_CHK_OLD_IDX))
580 goto out; 580 return 0;
581 581
582 INIT_LIST_HEAD(&list); 582 INIT_LIST_HEAD(&list);
583 583
diff --git a/fs/ubifs/debug.c b/fs/ubifs/debug.c
index f25a7339f800..004d3745dc45 100644
--- a/fs/ubifs/debug.c
+++ b/fs/ubifs/debug.c
@@ -972,11 +972,39 @@ void dbg_dump_index(struct ubifs_info *c)
972void dbg_save_space_info(struct ubifs_info *c) 972void dbg_save_space_info(struct ubifs_info *c)
973{ 973{
974 struct ubifs_debug_info *d = c->dbg; 974 struct ubifs_debug_info *d = c->dbg;
975 975 int freeable_cnt;
976 ubifs_get_lp_stats(c, &d->saved_lst);
977 976
978 spin_lock(&c->space_lock); 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 d->saved_free = ubifs_get_free_space_nolock(c); 1006 d->saved_free = ubifs_get_free_space_nolock(c);
1007 c->freeable_cnt = freeable_cnt;
980 spin_unlock(&c->space_lock); 1008 spin_unlock(&c->space_lock);
981} 1009}
982 1010
@@ -993,12 +1021,15 @@ int dbg_check_space_info(struct ubifs_info *c)
993{ 1021{
994 struct ubifs_debug_info *d = c->dbg; 1022 struct ubifs_debug_info *d = c->dbg;
995 struct ubifs_lp_stats lst; 1023 struct ubifs_lp_stats lst;
996 long long avail, free; 1024 long long free;
1025 int freeable_cnt;
997 1026
998 spin_lock(&c->space_lock); 1027 spin_lock(&c->space_lock);
999 avail = ubifs_calc_available(c, c->min_idx_lebs); 1028 freeable_cnt = c->freeable_cnt;
1029 c->freeable_cnt = 0;
1030 free = ubifs_get_free_space_nolock(c);
1031 c->freeable_cnt = freeable_cnt;
1000 spin_unlock(&c->space_lock); 1032 spin_unlock(&c->space_lock);
1001 free = ubifs_get_free_space(c);
1002 1033
1003 if (free != d->saved_free) { 1034 if (free != d->saved_free) {
1004 ubifs_err("free space changed from %lld to %lld", 1035 ubifs_err("free space changed from %lld to %lld",
@@ -2806,40 +2837,38 @@ int dbg_debugfs_init_fs(struct ubifs_info *c)
2806 struct ubifs_debug_info *d = c->dbg; 2837 struct ubifs_debug_info *d = c->dbg;
2807 2838
2808 sprintf(d->dfs_dir_name, "ubi%d_%d", c->vi.ubi_num, c->vi.vol_id); 2839 sprintf(d->dfs_dir_name, "ubi%d_%d", c->vi.ubi_num, c->vi.vol_id);
2809 d->dfs_dir = debugfs_create_dir(d->dfs_dir_name, dfs_rootdir); 2840 fname = d->dfs_dir_name;
2810 if (IS_ERR(d->dfs_dir)) { 2841 dent = debugfs_create_dir(fname, dfs_rootdir);
2811 err = PTR_ERR(d->dfs_dir); 2842 if (IS_ERR_OR_NULL(dent))
2812 ubifs_err("cannot create \"%s\" debugfs directory, error %d\n",
2813 d->dfs_dir_name, err);
2814 goto out; 2843 goto out;
2815 } 2844 d->dfs_dir = dent;
2816 2845
2817 fname = "dump_lprops"; 2846 fname = "dump_lprops";
2818 dent = debugfs_create_file(fname, S_IWUSR, d->dfs_dir, c, &dfs_fops); 2847 dent = debugfs_create_file(fname, S_IWUSR, d->dfs_dir, c, &dfs_fops);
2819 if (IS_ERR(dent)) 2848 if (IS_ERR_OR_NULL(dent))
2820 goto out_remove; 2849 goto out_remove;
2821 d->dfs_dump_lprops = dent; 2850 d->dfs_dump_lprops = dent;
2822 2851
2823 fname = "dump_budg"; 2852 fname = "dump_budg";
2824 dent = debugfs_create_file(fname, S_IWUSR, d->dfs_dir, c, &dfs_fops); 2853 dent = debugfs_create_file(fname, S_IWUSR, d->dfs_dir, c, &dfs_fops);
2825 if (IS_ERR(dent)) 2854 if (IS_ERR_OR_NULL(dent))
2826 goto out_remove; 2855 goto out_remove;
2827 d->dfs_dump_budg = dent; 2856 d->dfs_dump_budg = dent;
2828 2857
2829 fname = "dump_tnc"; 2858 fname = "dump_tnc";
2830 dent = debugfs_create_file(fname, S_IWUSR, d->dfs_dir, c, &dfs_fops); 2859 dent = debugfs_create_file(fname, S_IWUSR, d->dfs_dir, c, &dfs_fops);
2831 if (IS_ERR(dent)) 2860 if (IS_ERR_OR_NULL(dent))
2832 goto out_remove; 2861 goto out_remove;
2833 d->dfs_dump_tnc = dent; 2862 d->dfs_dump_tnc = dent;
2834 2863
2835 return 0; 2864 return 0;
2836 2865
2837out_remove: 2866out_remove:
2838 err = PTR_ERR(dent);
2839 ubifs_err("cannot create \"%s\" debugfs directory, error %d\n",
2840 fname, err);
2841 debugfs_remove_recursive(d->dfs_dir); 2867 debugfs_remove_recursive(d->dfs_dir);
2842out: 2868out:
2869 err = dent ? PTR_ERR(dent) : -ENODEV;
2870 ubifs_err("cannot create \"%s\" debugfs directory, error %d\n",
2871 fname, err);
2843 return err; 2872 return err;
2844} 2873}
2845 2874
diff --git a/fs/ubifs/lpt.c b/fs/ubifs/lpt.c
index 72775d35b99e..ef5155e109a2 100644
--- a/fs/ubifs/lpt.c
+++ b/fs/ubifs/lpt.c
@@ -1270,10 +1270,9 @@ static int read_pnode(struct ubifs_info *c, struct ubifs_nnode *parent, int iip)
1270 lnum = branch->lnum; 1270 lnum = branch->lnum;
1271 offs = branch->offs; 1271 offs = branch->offs;
1272 pnode = kzalloc(sizeof(struct ubifs_pnode), GFP_NOFS); 1272 pnode = kzalloc(sizeof(struct ubifs_pnode), GFP_NOFS);
1273 if (!pnode) { 1273 if (!pnode)
1274 err = -ENOMEM; 1274 return -ENOMEM;
1275 goto out; 1275
1276 }
1277 if (lnum == 0) { 1276 if (lnum == 0) {
1278 /* 1277 /*
1279 * This pnode was not written which just means that the LEB 1278 * This pnode was not written which just means that the LEB
diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c
index 6ddd9973e681..c75f6133206c 100644
--- a/fs/ubifs/super.c
+++ b/fs/ubifs/super.c
@@ -1568,6 +1568,7 @@ static int ubifs_remount_rw(struct ubifs_info *c)
1568 mutex_lock(&c->umount_mutex); 1568 mutex_lock(&c->umount_mutex);
1569 dbg_save_space_info(c); 1569 dbg_save_space_info(c);
1570 c->remounting_rw = 1; 1570 c->remounting_rw = 1;
1571 c->ro_mount = 0;
1571 1572
1572 err = check_free_space(c); 1573 err = check_free_space(c);
1573 if (err) 1574 if (err)
@@ -1676,13 +1677,13 @@ static int ubifs_remount_rw(struct ubifs_info *c)
1676 } 1677 }
1677 1678
1678 dbg_gen("re-mounted read-write"); 1679 dbg_gen("re-mounted read-write");
1679 c->ro_mount = 0;
1680 c->remounting_rw = 0; 1680 c->remounting_rw = 0;
1681 err = dbg_check_space_info(c); 1681 err = dbg_check_space_info(c);
1682 mutex_unlock(&c->umount_mutex); 1682 mutex_unlock(&c->umount_mutex);
1683 return err; 1683 return err;
1684 1684
1685out: 1685out:
1686 c->ro_mount = 1;
1686 vfree(c->orph_buf); 1687 vfree(c->orph_buf);
1687 c->orph_buf = NULL; 1688 c->orph_buf = NULL;
1688 if (c->bgt) { 1689 if (c->bgt) {