diff options
Diffstat (limited to 'fs')
-rw-r--r-- | fs/ubifs/budget.c | 35 | ||||
-rw-r--r-- | fs/ubifs/debug.c | 120 | ||||
-rw-r--r-- | fs/ubifs/debug.h | 36 | ||||
-rw-r--r-- | fs/ubifs/file.c | 1 | ||||
-rw-r--r-- | fs/ubifs/lprops.c | 4 | ||||
-rw-r--r-- | fs/ubifs/super.c | 14 | ||||
-rw-r--r-- | fs/ubifs/ubifs.h | 3 |
7 files changed, 148 insertions, 65 deletions
diff --git a/fs/ubifs/budget.c b/fs/ubifs/budget.c index 175f9c590b77..f393620890ee 100644 --- a/fs/ubifs/budget.c +++ b/fs/ubifs/budget.c | |||
@@ -689,7 +689,7 @@ long long ubifs_reported_space(const struct ubifs_info *c, long long free) | |||
689 | } | 689 | } |
690 | 690 | ||
691 | /** | 691 | /** |
692 | * ubifs_get_free_space - return amount of free space. | 692 | * ubifs_get_free_space_nolock - return amount of free space. |
693 | * @c: UBIFS file-system description object | 693 | * @c: UBIFS file-system description object |
694 | * | 694 | * |
695 | * This function calculates amount of free space to report to user-space. | 695 | * This function calculates amount of free space to report to user-space. |
@@ -704,16 +704,14 @@ long long ubifs_reported_space(const struct ubifs_info *c, long long free) | |||
704 | * traditional file-systems, because they have way less overhead than UBIFS. | 704 | * traditional file-systems, because they have way less overhead than UBIFS. |
705 | * So, to keep users happy, UBIFS tries to take the overhead into account. | 705 | * So, to keep users happy, UBIFS tries to take the overhead into account. |
706 | */ | 706 | */ |
707 | long long ubifs_get_free_space(struct ubifs_info *c) | 707 | long long ubifs_get_free_space_nolock(struct ubifs_info *c) |
708 | { | 708 | { |
709 | int min_idx_lebs, rsvd_idx_lebs, lebs; | 709 | int rsvd_idx_lebs, lebs; |
710 | long long available, outstanding, free; | 710 | long long available, outstanding, free; |
711 | 711 | ||
712 | spin_lock(&c->space_lock); | 712 | ubifs_assert(c->min_idx_lebs == ubifs_calc_min_idx_lebs(c)); |
713 | min_idx_lebs = c->min_idx_lebs; | ||
714 | ubifs_assert(min_idx_lebs == ubifs_calc_min_idx_lebs(c)); | ||
715 | outstanding = c->budg_data_growth + c->budg_dd_growth; | 713 | outstanding = c->budg_data_growth + c->budg_dd_growth; |
716 | available = ubifs_calc_available(c, min_idx_lebs); | 714 | available = ubifs_calc_available(c, c->min_idx_lebs); |
717 | 715 | ||
718 | /* | 716 | /* |
719 | * When reporting free space to user-space, UBIFS guarantees that it is | 717 | * When reporting free space to user-space, UBIFS guarantees that it is |
@@ -726,15 +724,14 @@ long long ubifs_get_free_space(struct ubifs_info *c) | |||
726 | * Note, the calculations below are similar to what we have in | 724 | * Note, the calculations below are similar to what we have in |
727 | * 'do_budget_space()', so refer there for comments. | 725 | * 'do_budget_space()', so refer there for comments. |
728 | */ | 726 | */ |
729 | if (min_idx_lebs > c->lst.idx_lebs) | 727 | if (c->min_idx_lebs > c->lst.idx_lebs) |
730 | rsvd_idx_lebs = min_idx_lebs - c->lst.idx_lebs; | 728 | rsvd_idx_lebs = c->min_idx_lebs - c->lst.idx_lebs; |
731 | else | 729 | else |
732 | rsvd_idx_lebs = 0; | 730 | rsvd_idx_lebs = 0; |
733 | lebs = c->lst.empty_lebs + c->freeable_cnt + c->idx_gc_cnt - | 731 | lebs = c->lst.empty_lebs + c->freeable_cnt + c->idx_gc_cnt - |
734 | c->lst.taken_empty_lebs; | 732 | c->lst.taken_empty_lebs; |
735 | lebs -= rsvd_idx_lebs; | 733 | lebs -= rsvd_idx_lebs; |
736 | available += lebs * (c->dark_wm - c->leb_overhead); | 734 | available += lebs * (c->dark_wm - c->leb_overhead); |
737 | spin_unlock(&c->space_lock); | ||
738 | 735 | ||
739 | if (available > outstanding) | 736 | if (available > outstanding) |
740 | free = ubifs_reported_space(c, available - outstanding); | 737 | free = ubifs_reported_space(c, available - outstanding); |
@@ -742,3 +739,21 @@ long long ubifs_get_free_space(struct ubifs_info *c) | |||
742 | free = 0; | 739 | free = 0; |
743 | return free; | 740 | return free; |
744 | } | 741 | } |
742 | |||
743 | /** | ||
744 | * ubifs_get_free_space - return amount of free space. | ||
745 | * @c: UBIFS file-system description object | ||
746 | * | ||
747 | * This function calculates and retuns amount of free space to report to | ||
748 | * user-space. | ||
749 | */ | ||
750 | long long ubifs_get_free_space(struct ubifs_info *c) | ||
751 | { | ||
752 | long long free; | ||
753 | |||
754 | spin_lock(&c->space_lock); | ||
755 | free = ubifs_get_free_space_nolock(c); | ||
756 | spin_unlock(&c->space_lock); | ||
757 | |||
758 | return free; | ||
759 | } | ||
diff --git a/fs/ubifs/debug.c b/fs/ubifs/debug.c index 792c5a16c182..9a41f6f245b7 100644 --- a/fs/ubifs/debug.c +++ b/fs/ubifs/debug.c | |||
@@ -620,9 +620,11 @@ void dbg_dump_budg(struct ubifs_info *c) | |||
620 | c->dark_wm, c->dead_wm, c->max_idx_node_sz); | 620 | c->dark_wm, c->dead_wm, c->max_idx_node_sz); |
621 | printk(KERN_DEBUG "\tgc_lnum %d, ihead_lnum %d\n", | 621 | printk(KERN_DEBUG "\tgc_lnum %d, ihead_lnum %d\n", |
622 | c->gc_lnum, c->ihead_lnum); | 622 | c->gc_lnum, c->ihead_lnum); |
623 | for (i = 0; i < c->jhead_cnt; i++) | 623 | /* If we are in R/O mode, journal heads do not exist */ |
624 | printk(KERN_DEBUG "\tjhead %d\t LEB %d\n", | 624 | if (c->jheads) |
625 | c->jheads[i].wbuf.jhead, c->jheads[i].wbuf.lnum); | 625 | for (i = 0; i < c->jhead_cnt; i++) |
626 | printk(KERN_DEBUG "\tjhead %d\t LEB %d\n", | ||
627 | c->jheads[i].wbuf.jhead, c->jheads[i].wbuf.lnum); | ||
626 | for (rb = rb_first(&c->buds); rb; rb = rb_next(rb)) { | 628 | for (rb = rb_first(&c->buds); rb; rb = rb_next(rb)) { |
627 | bud = rb_entry(rb, struct ubifs_bud, rb); | 629 | bud = rb_entry(rb, struct ubifs_bud, rb); |
628 | printk(KERN_DEBUG "\tbud LEB %d\n", bud->lnum); | 630 | printk(KERN_DEBUG "\tbud LEB %d\n", bud->lnum); |
@@ -637,10 +639,7 @@ void dbg_dump_budg(struct ubifs_info *c) | |||
637 | /* Print budgeting predictions */ | 639 | /* Print budgeting predictions */ |
638 | available = ubifs_calc_available(c, c->min_idx_lebs); | 640 | available = ubifs_calc_available(c, c->min_idx_lebs); |
639 | outstanding = c->budg_data_growth + c->budg_dd_growth; | 641 | outstanding = c->budg_data_growth + c->budg_dd_growth; |
640 | if (available > outstanding) | 642 | free = ubifs_get_free_space_nolock(c); |
641 | free = ubifs_reported_space(c, available - outstanding); | ||
642 | else | ||
643 | free = 0; | ||
644 | printk(KERN_DEBUG "Budgeting predictions:\n"); | 643 | printk(KERN_DEBUG "Budgeting predictions:\n"); |
645 | printk(KERN_DEBUG "\tavailable: %lld, outstanding %lld, free %lld\n", | 644 | printk(KERN_DEBUG "\tavailable: %lld, outstanding %lld, free %lld\n", |
646 | available, outstanding, free); | 645 | available, outstanding, free); |
@@ -861,6 +860,65 @@ void dbg_dump_index(struct ubifs_info *c) | |||
861 | } | 860 | } |
862 | 861 | ||
863 | /** | 862 | /** |
863 | * dbg_save_space_info - save information about flash space. | ||
864 | * @c: UBIFS file-system description object | ||
865 | * | ||
866 | * This function saves information about UBIFS free space, dirty space, etc, in | ||
867 | * order to check it later. | ||
868 | */ | ||
869 | void dbg_save_space_info(struct ubifs_info *c) | ||
870 | { | ||
871 | struct ubifs_debug_info *d = c->dbg; | ||
872 | |||
873 | ubifs_get_lp_stats(c, &d->saved_lst); | ||
874 | |||
875 | spin_lock(&c->space_lock); | ||
876 | d->saved_free = ubifs_get_free_space_nolock(c); | ||
877 | spin_unlock(&c->space_lock); | ||
878 | } | ||
879 | |||
880 | /** | ||
881 | * dbg_check_space_info - check flash space information. | ||
882 | * @c: UBIFS file-system description object | ||
883 | * | ||
884 | * This function compares current flash space information with the information | ||
885 | * which was saved when the 'dbg_save_space_info()' function was called. | ||
886 | * Returns zero if the information has not changed, and %-EINVAL it it has | ||
887 | * changed. | ||
888 | */ | ||
889 | int dbg_check_space_info(struct ubifs_info *c) | ||
890 | { | ||
891 | struct ubifs_debug_info *d = c->dbg; | ||
892 | struct ubifs_lp_stats lst; | ||
893 | long long avail, free; | ||
894 | |||
895 | spin_lock(&c->space_lock); | ||
896 | avail = ubifs_calc_available(c, c->min_idx_lebs); | ||
897 | spin_unlock(&c->space_lock); | ||
898 | free = ubifs_get_free_space(c); | ||
899 | |||
900 | if (free != d->saved_free) { | ||
901 | ubifs_err("free space changed from %lld to %lld", | ||
902 | d->saved_free, free); | ||
903 | goto out; | ||
904 | } | ||
905 | |||
906 | return 0; | ||
907 | |||
908 | out: | ||
909 | ubifs_msg("saved lprops statistics dump"); | ||
910 | dbg_dump_lstats(&d->saved_lst); | ||
911 | ubifs_get_lp_stats(c, &lst); | ||
912 | ubifs_msg("current lprops statistics dump"); | ||
913 | dbg_dump_lstats(&d->saved_lst); | ||
914 | spin_lock(&c->space_lock); | ||
915 | dbg_dump_budg(c); | ||
916 | spin_unlock(&c->space_lock); | ||
917 | dump_stack(); | ||
918 | return -EINVAL; | ||
919 | } | ||
920 | |||
921 | /** | ||
864 | * dbg_check_synced_i_size - check synchronized inode size. | 922 | * dbg_check_synced_i_size - check synchronized inode size. |
865 | * @inode: inode to check | 923 | * @inode: inode to check |
866 | * | 924 | * |
@@ -2409,7 +2467,7 @@ void ubifs_debugging_exit(struct ubifs_info *c) | |||
2409 | * Root directory for UBIFS stuff in debugfs. Contains sub-directories which | 2467 | * Root directory for UBIFS stuff in debugfs. Contains sub-directories which |
2410 | * contain the stuff specific to particular file-system mounts. | 2468 | * contain the stuff specific to particular file-system mounts. |
2411 | */ | 2469 | */ |
2412 | static struct dentry *debugfs_rootdir; | 2470 | static struct dentry *dfs_rootdir; |
2413 | 2471 | ||
2414 | /** | 2472 | /** |
2415 | * dbg_debugfs_init - initialize debugfs file-system. | 2473 | * dbg_debugfs_init - initialize debugfs file-system. |
@@ -2421,9 +2479,9 @@ static struct dentry *debugfs_rootdir; | |||
2421 | */ | 2479 | */ |
2422 | int dbg_debugfs_init(void) | 2480 | int dbg_debugfs_init(void) |
2423 | { | 2481 | { |
2424 | debugfs_rootdir = debugfs_create_dir("ubifs", NULL); | 2482 | dfs_rootdir = debugfs_create_dir("ubifs", NULL); |
2425 | if (IS_ERR(debugfs_rootdir)) { | 2483 | if (IS_ERR(dfs_rootdir)) { |
2426 | int err = PTR_ERR(debugfs_rootdir); | 2484 | int err = PTR_ERR(dfs_rootdir); |
2427 | ubifs_err("cannot create \"ubifs\" debugfs directory, " | 2485 | ubifs_err("cannot create \"ubifs\" debugfs directory, " |
2428 | "error %d\n", err); | 2486 | "error %d\n", err); |
2429 | return err; | 2487 | return err; |
@@ -2437,7 +2495,7 @@ int dbg_debugfs_init(void) | |||
2437 | */ | 2495 | */ |
2438 | void dbg_debugfs_exit(void) | 2496 | void dbg_debugfs_exit(void) |
2439 | { | 2497 | { |
2440 | debugfs_remove(debugfs_rootdir); | 2498 | debugfs_remove(dfs_rootdir); |
2441 | } | 2499 | } |
2442 | 2500 | ||
2443 | static int open_debugfs_file(struct inode *inode, struct file *file) | 2501 | static int open_debugfs_file(struct inode *inode, struct file *file) |
@@ -2452,13 +2510,13 @@ static ssize_t write_debugfs_file(struct file *file, const char __user *buf, | |||
2452 | struct ubifs_info *c = file->private_data; | 2510 | struct ubifs_info *c = file->private_data; |
2453 | struct ubifs_debug_info *d = c->dbg; | 2511 | struct ubifs_debug_info *d = c->dbg; |
2454 | 2512 | ||
2455 | if (file->f_path.dentry == d->dump_lprops) | 2513 | if (file->f_path.dentry == d->dfs_dump_lprops) |
2456 | dbg_dump_lprops(c); | 2514 | dbg_dump_lprops(c); |
2457 | else if (file->f_path.dentry == d->dump_budg) { | 2515 | else if (file->f_path.dentry == d->dfs_dump_budg) { |
2458 | spin_lock(&c->space_lock); | 2516 | spin_lock(&c->space_lock); |
2459 | dbg_dump_budg(c); | 2517 | dbg_dump_budg(c); |
2460 | spin_unlock(&c->space_lock); | 2518 | spin_unlock(&c->space_lock); |
2461 | } else if (file->f_path.dentry == d->dump_tnc) { | 2519 | } else if (file->f_path.dentry == d->dfs_dump_tnc) { |
2462 | mutex_lock(&c->tnc_mutex); | 2520 | mutex_lock(&c->tnc_mutex); |
2463 | dbg_dump_tnc(c); | 2521 | dbg_dump_tnc(c); |
2464 | mutex_unlock(&c->tnc_mutex); | 2522 | mutex_unlock(&c->tnc_mutex); |
@@ -2469,7 +2527,7 @@ static ssize_t write_debugfs_file(struct file *file, const char __user *buf, | |||
2469 | return count; | 2527 | return count; |
2470 | } | 2528 | } |
2471 | 2529 | ||
2472 | static const struct file_operations debugfs_fops = { | 2530 | static const struct file_operations dfs_fops = { |
2473 | .open = open_debugfs_file, | 2531 | .open = open_debugfs_file, |
2474 | .write = write_debugfs_file, | 2532 | .write = write_debugfs_file, |
2475 | .owner = THIS_MODULE, | 2533 | .owner = THIS_MODULE, |
@@ -2494,36 +2552,32 @@ int dbg_debugfs_init_fs(struct ubifs_info *c) | |||
2494 | struct dentry *dent; | 2552 | struct dentry *dent; |
2495 | struct ubifs_debug_info *d = c->dbg; | 2553 | struct ubifs_debug_info *d = c->dbg; |
2496 | 2554 | ||
2497 | sprintf(d->debugfs_dir_name, "ubi%d_%d", c->vi.ubi_num, c->vi.vol_id); | 2555 | sprintf(d->dfs_dir_name, "ubi%d_%d", c->vi.ubi_num, c->vi.vol_id); |
2498 | d->debugfs_dir = debugfs_create_dir(d->debugfs_dir_name, | 2556 | d->dfs_dir = debugfs_create_dir(d->dfs_dir_name, dfs_rootdir); |
2499 | debugfs_rootdir); | 2557 | if (IS_ERR(d->dfs_dir)) { |
2500 | if (IS_ERR(d->debugfs_dir)) { | 2558 | err = PTR_ERR(d->dfs_dir); |
2501 | err = PTR_ERR(d->debugfs_dir); | ||
2502 | ubifs_err("cannot create \"%s\" debugfs directory, error %d\n", | 2559 | ubifs_err("cannot create \"%s\" debugfs directory, error %d\n", |
2503 | d->debugfs_dir_name, err); | 2560 | d->dfs_dir_name, err); |
2504 | goto out; | 2561 | goto out; |
2505 | } | 2562 | } |
2506 | 2563 | ||
2507 | fname = "dump_lprops"; | 2564 | fname = "dump_lprops"; |
2508 | dent = debugfs_create_file(fname, S_IWUGO, d->debugfs_dir, c, | 2565 | dent = debugfs_create_file(fname, S_IWUGO, d->dfs_dir, c, &dfs_fops); |
2509 | &debugfs_fops); | ||
2510 | if (IS_ERR(dent)) | 2566 | if (IS_ERR(dent)) |
2511 | goto out_remove; | 2567 | goto out_remove; |
2512 | d->dump_lprops = dent; | 2568 | d->dfs_dump_lprops = dent; |
2513 | 2569 | ||
2514 | fname = "dump_budg"; | 2570 | fname = "dump_budg"; |
2515 | dent = debugfs_create_file(fname, S_IWUGO, d->debugfs_dir, c, | 2571 | dent = debugfs_create_file(fname, S_IWUGO, d->dfs_dir, c, &dfs_fops); |
2516 | &debugfs_fops); | ||
2517 | if (IS_ERR(dent)) | 2572 | if (IS_ERR(dent)) |
2518 | goto out_remove; | 2573 | goto out_remove; |
2519 | d->dump_budg = dent; | 2574 | d->dfs_dump_budg = dent; |
2520 | 2575 | ||
2521 | fname = "dump_tnc"; | 2576 | fname = "dump_tnc"; |
2522 | dent = debugfs_create_file(fname, S_IWUGO, d->debugfs_dir, c, | 2577 | dent = debugfs_create_file(fname, S_IWUGO, d->dfs_dir, c, &dfs_fops); |
2523 | &debugfs_fops); | ||
2524 | if (IS_ERR(dent)) | 2578 | if (IS_ERR(dent)) |
2525 | goto out_remove; | 2579 | goto out_remove; |
2526 | d->dump_tnc = dent; | 2580 | d->dfs_dump_tnc = dent; |
2527 | 2581 | ||
2528 | return 0; | 2582 | return 0; |
2529 | 2583 | ||
@@ -2531,7 +2585,7 @@ out_remove: | |||
2531 | err = PTR_ERR(dent); | 2585 | err = PTR_ERR(dent); |
2532 | ubifs_err("cannot create \"%s\" debugfs directory, error %d\n", | 2586 | ubifs_err("cannot create \"%s\" debugfs directory, error %d\n", |
2533 | fname, err); | 2587 | fname, err); |
2534 | debugfs_remove_recursive(d->debugfs_dir); | 2588 | debugfs_remove_recursive(d->dfs_dir); |
2535 | out: | 2589 | out: |
2536 | return err; | 2590 | return err; |
2537 | } | 2591 | } |
@@ -2542,7 +2596,7 @@ out: | |||
2542 | */ | 2596 | */ |
2543 | void dbg_debugfs_exit_fs(struct ubifs_info *c) | 2597 | void dbg_debugfs_exit_fs(struct ubifs_info *c) |
2544 | { | 2598 | { |
2545 | debugfs_remove_recursive(c->dbg->debugfs_dir); | 2599 | debugfs_remove_recursive(c->dbg->dfs_dir); |
2546 | } | 2600 | } |
2547 | 2601 | ||
2548 | #endif /* CONFIG_UBIFS_FS_DEBUG */ | 2602 | #endif /* CONFIG_UBIFS_FS_DEBUG */ |
diff --git a/fs/ubifs/debug.h b/fs/ubifs/debug.h index 9820d6999f7e..c1cd73b2e06e 100644 --- a/fs/ubifs/debug.h +++ b/fs/ubifs/debug.h | |||
@@ -41,15 +41,17 @@ | |||
41 | * @chk_lpt_wastage: used by LPT tree size checker | 41 | * @chk_lpt_wastage: used by LPT tree size checker |
42 | * @chk_lpt_lebs: used by LPT tree size checker | 42 | * @chk_lpt_lebs: used by LPT tree size checker |
43 | * @new_nhead_offs: used by LPT tree size checker | 43 | * @new_nhead_offs: used by LPT tree size checker |
44 | * @new_ihead_lnum: used by debugging to check ihead_lnum | 44 | * @new_ihead_lnum: used by debugging to check @c->ihead_lnum |
45 | * @new_ihead_offs: used by debugging to check ihead_offs | 45 | * @new_ihead_offs: used by debugging to check @c->ihead_offs |
46 | * | 46 | * |
47 | * debugfs_dir_name: name of debugfs directory containing this file-system's | 47 | * @saved_lst: saved lprops statistics (used by 'dbg_save_space_info()') |
48 | * files | 48 | * @saved_free: saved free space (used by 'dbg_save_space_info()') |
49 | * debugfs_dir: direntry object of the file-system debugfs directory | 49 | * |
50 | * dump_lprops: "dump lprops" debugfs knob | 50 | * dfs_dir_name: name of debugfs directory containing this file-system's files |
51 | * dump_budg: "dump budgeting information" debugfs knob | 51 | * dfs_dir: direntry object of the file-system debugfs directory |
52 | * dump_tnc: "dump TNC" debugfs knob | 52 | * dfs_dump_lprops: "dump lprops" debugfs knob |
53 | * dfs_dump_budg: "dump budgeting information" debugfs knob | ||
54 | * dfs_dump_tnc: "dump TNC" debugfs knob | ||
53 | */ | 55 | */ |
54 | struct ubifs_debug_info { | 56 | struct ubifs_debug_info { |
55 | void *buf; | 57 | void *buf; |
@@ -69,11 +71,14 @@ struct ubifs_debug_info { | |||
69 | int new_ihead_lnum; | 71 | int new_ihead_lnum; |
70 | int new_ihead_offs; | 72 | int new_ihead_offs; |
71 | 73 | ||
72 | char debugfs_dir_name[100]; | 74 | struct ubifs_lp_stats saved_lst; |
73 | struct dentry *debugfs_dir; | 75 | long long saved_free; |
74 | struct dentry *dump_lprops; | 76 | |
75 | struct dentry *dump_budg; | 77 | char dfs_dir_name[100]; |
76 | struct dentry *dump_tnc; | 78 | struct dentry *dfs_dir; |
79 | struct dentry *dfs_dump_lprops; | ||
80 | struct dentry *dfs_dump_budg; | ||
81 | struct dentry *dfs_dump_tnc; | ||
77 | }; | 82 | }; |
78 | 83 | ||
79 | #define ubifs_assert(expr) do { \ | 84 | #define ubifs_assert(expr) do { \ |
@@ -297,7 +302,8 @@ int dbg_walk_index(struct ubifs_info *c, dbg_leaf_callback leaf_cb, | |||
297 | dbg_znode_callback znode_cb, void *priv); | 302 | dbg_znode_callback znode_cb, void *priv); |
298 | 303 | ||
299 | /* Checking functions */ | 304 | /* Checking functions */ |
300 | 305 | void dbg_save_space_info(struct ubifs_info *c); | |
306 | int dbg_check_space_info(struct ubifs_info *c); | ||
301 | int dbg_check_lprops(struct ubifs_info *c); | 307 | int dbg_check_lprops(struct ubifs_info *c); |
302 | int dbg_old_index_check_init(struct ubifs_info *c, struct ubifs_zbranch *zroot); | 308 | int dbg_old_index_check_init(struct ubifs_info *c, struct ubifs_zbranch *zroot); |
303 | int dbg_check_old_index(struct ubifs_info *c, struct ubifs_zbranch *zroot); | 309 | int dbg_check_old_index(struct ubifs_info *c, struct ubifs_zbranch *zroot); |
@@ -439,6 +445,8 @@ void dbg_debugfs_exit_fs(struct ubifs_info *c); | |||
439 | 445 | ||
440 | #define dbg_walk_index(c, leaf_cb, znode_cb, priv) 0 | 446 | #define dbg_walk_index(c, leaf_cb, znode_cb, priv) 0 |
441 | #define dbg_old_index_check_init(c, zroot) 0 | 447 | #define dbg_old_index_check_init(c, zroot) 0 |
448 | #define dbg_save_space_info(c) ({}) | ||
449 | #define dbg_check_space_info(c) 0 | ||
442 | #define dbg_check_old_index(c, zroot) 0 | 450 | #define dbg_check_old_index(c, zroot) 0 |
443 | #define dbg_check_cats(c) 0 | 451 | #define dbg_check_cats(c) 0 |
444 | #define dbg_check_ltab(c) 0 | 452 | #define dbg_check_ltab(c) 0 |
diff --git a/fs/ubifs/file.c b/fs/ubifs/file.c index 17443d97e6f1..93b6de51f261 100644 --- a/fs/ubifs/file.c +++ b/fs/ubifs/file.c | |||
@@ -432,7 +432,6 @@ static int ubifs_write_begin(struct file *file, struct address_space *mapping, | |||
432 | int uninitialized_var(err), appending = !!(pos + len > inode->i_size); | 432 | int uninitialized_var(err), appending = !!(pos + len > inode->i_size); |
433 | struct page *page; | 433 | struct page *page; |
434 | 434 | ||
435 | |||
436 | ubifs_assert(ubifs_inode(inode)->ui_size == inode->i_size); | 435 | ubifs_assert(ubifs_inode(inode)->ui_size == inode->i_size); |
437 | 436 | ||
438 | if (unlikely(c->ro_media)) | 437 | if (unlikely(c->ro_media)) |
diff --git a/fs/ubifs/lprops.c b/fs/ubifs/lprops.c index 68328c59762b..4cdd284dea56 100644 --- a/fs/ubifs/lprops.c +++ b/fs/ubifs/lprops.c | |||
@@ -635,10 +635,10 @@ const struct ubifs_lprops *ubifs_change_lp(struct ubifs_info *c, | |||
635 | * @c: UBIFS file-system description object | 635 | * @c: UBIFS file-system description object |
636 | * @st: return statistics | 636 | * @st: return statistics |
637 | */ | 637 | */ |
638 | void ubifs_get_lp_stats(struct ubifs_info *c, struct ubifs_lp_stats *st) | 638 | void ubifs_get_lp_stats(struct ubifs_info *c, struct ubifs_lp_stats *lst) |
639 | { | 639 | { |
640 | spin_lock(&c->space_lock); | 640 | spin_lock(&c->space_lock); |
641 | memcpy(st, &c->lst, sizeof(struct ubifs_lp_stats)); | 641 | memcpy(lst, &c->lst, sizeof(struct ubifs_lp_stats)); |
642 | spin_unlock(&c->space_lock); | 642 | spin_unlock(&c->space_lock); |
643 | } | 643 | } |
644 | 644 | ||
diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c index 807bbd3c8b4b..5c814a71f33a 100644 --- a/fs/ubifs/super.c +++ b/fs/ubifs/super.c | |||
@@ -1470,6 +1470,7 @@ static int ubifs_remount_rw(struct ubifs_info *c) | |||
1470 | int err, lnum; | 1470 | int err, lnum; |
1471 | 1471 | ||
1472 | mutex_lock(&c->umount_mutex); | 1472 | mutex_lock(&c->umount_mutex); |
1473 | dbg_save_space_info(c); | ||
1473 | c->remounting_rw = 1; | 1474 | c->remounting_rw = 1; |
1474 | c->always_chk_crc = 1; | 1475 | c->always_chk_crc = 1; |
1475 | 1476 | ||
@@ -1573,8 +1574,9 @@ static int ubifs_remount_rw(struct ubifs_info *c) | |||
1573 | c->vfs_sb->s_flags &= ~MS_RDONLY; | 1574 | c->vfs_sb->s_flags &= ~MS_RDONLY; |
1574 | c->remounting_rw = 0; | 1575 | c->remounting_rw = 0; |
1575 | c->always_chk_crc = 0; | 1576 | c->always_chk_crc = 0; |
1577 | err = dbg_check_space_info(c); | ||
1576 | mutex_unlock(&c->umount_mutex); | 1578 | mutex_unlock(&c->umount_mutex); |
1577 | return 0; | 1579 | return err; |
1578 | 1580 | ||
1579 | out: | 1581 | out: |
1580 | vfree(c->orph_buf); | 1582 | vfree(c->orph_buf); |
@@ -1629,8 +1631,8 @@ static void commit_on_unmount(struct ubifs_info *c) | |||
1629 | * ubifs_remount_ro - re-mount in read-only mode. | 1631 | * ubifs_remount_ro - re-mount in read-only mode. |
1630 | * @c: UBIFS file-system description object | 1632 | * @c: UBIFS file-system description object |
1631 | * | 1633 | * |
1632 | * We rely on VFS to have stopped writing. Possibly the background thread could | 1634 | * We assume VFS has stopped writing. Possibly the background thread could be |
1633 | * be running a commit, however kthread_stop will wait in that case. | 1635 | * running a commit, however kthread_stop will wait in that case. |
1634 | */ | 1636 | */ |
1635 | static void ubifs_remount_ro(struct ubifs_info *c) | 1637 | static void ubifs_remount_ro(struct ubifs_info *c) |
1636 | { | 1638 | { |
@@ -1640,13 +1642,14 @@ static void ubifs_remount_ro(struct ubifs_info *c) | |||
1640 | ubifs_assert(!c->ro_media); | 1642 | ubifs_assert(!c->ro_media); |
1641 | 1643 | ||
1642 | commit_on_unmount(c); | 1644 | commit_on_unmount(c); |
1643 | |||
1644 | mutex_lock(&c->umount_mutex); | 1645 | mutex_lock(&c->umount_mutex); |
1645 | if (c->bgt) { | 1646 | if (c->bgt) { |
1646 | kthread_stop(c->bgt); | 1647 | kthread_stop(c->bgt); |
1647 | c->bgt = NULL; | 1648 | c->bgt = NULL; |
1648 | } | 1649 | } |
1649 | 1650 | ||
1651 | dbg_save_space_info(c); | ||
1652 | |||
1650 | for (i = 0; i < c->jhead_cnt; i++) { | 1653 | for (i = 0; i < c->jhead_cnt; i++) { |
1651 | ubifs_wbuf_sync(&c->jheads[i].wbuf); | 1654 | ubifs_wbuf_sync(&c->jheads[i].wbuf); |
1652 | del_timer_sync(&c->jheads[i].wbuf.timer); | 1655 | del_timer_sync(&c->jheads[i].wbuf.timer); |
@@ -1669,6 +1672,9 @@ static void ubifs_remount_ro(struct ubifs_info *c) | |||
1669 | vfree(c->ileb_buf); | 1672 | vfree(c->ileb_buf); |
1670 | c->ileb_buf = NULL; | 1673 | c->ileb_buf = NULL; |
1671 | ubifs_lpt_free(c, 1); | 1674 | ubifs_lpt_free(c, 1); |
1675 | err = dbg_check_space_info(c); | ||
1676 | if (err) | ||
1677 | ubifs_ro_mode(c, err); | ||
1672 | mutex_unlock(&c->umount_mutex); | 1678 | mutex_unlock(&c->umount_mutex); |
1673 | } | 1679 | } |
1674 | 1680 | ||
diff --git a/fs/ubifs/ubifs.h b/fs/ubifs/ubifs.h index ee9517a7b024..f1754354029f 100644 --- a/fs/ubifs/ubifs.h +++ b/fs/ubifs/ubifs.h | |||
@@ -1495,6 +1495,7 @@ void ubifs_release_ino_dirty(struct ubifs_info *c, struct inode *inode, | |||
1495 | void ubifs_cancel_ino_op(struct ubifs_info *c, struct inode *inode, | 1495 | void ubifs_cancel_ino_op(struct ubifs_info *c, struct inode *inode, |
1496 | struct ubifs_budget_req *req); | 1496 | struct ubifs_budget_req *req); |
1497 | long long ubifs_get_free_space(struct ubifs_info *c); | 1497 | long long ubifs_get_free_space(struct ubifs_info *c); |
1498 | long long ubifs_get_free_space_nolock(struct ubifs_info *c); | ||
1498 | int ubifs_calc_min_idx_lebs(struct ubifs_info *c); | 1499 | int ubifs_calc_min_idx_lebs(struct ubifs_info *c); |
1499 | void ubifs_convert_page_budget(struct ubifs_info *c); | 1500 | void ubifs_convert_page_budget(struct ubifs_info *c); |
1500 | long long ubifs_reported_space(const struct ubifs_info *c, long long free); | 1501 | long long ubifs_reported_space(const struct ubifs_info *c, long long free); |
@@ -1646,7 +1647,7 @@ const struct ubifs_lprops *ubifs_change_lp(struct ubifs_info *c, | |||
1646 | const struct ubifs_lprops *lp, | 1647 | const struct ubifs_lprops *lp, |
1647 | int free, int dirty, int flags, | 1648 | int free, int dirty, int flags, |
1648 | int idx_gc_cnt); | 1649 | int idx_gc_cnt); |
1649 | void ubifs_get_lp_stats(struct ubifs_info *c, struct ubifs_lp_stats *stats); | 1650 | void ubifs_get_lp_stats(struct ubifs_info *c, struct ubifs_lp_stats *lst); |
1650 | void ubifs_add_to_cat(struct ubifs_info *c, struct ubifs_lprops *lprops, | 1651 | void ubifs_add_to_cat(struct ubifs_info *c, struct ubifs_lprops *lprops, |
1651 | int cat); | 1652 | int cat); |
1652 | void ubifs_replace_cat(struct ubifs_info *c, struct ubifs_lprops *old_lprops, | 1653 | void ubifs_replace_cat(struct ubifs_info *c, struct ubifs_lprops *old_lprops, |