diff options
author | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2009-01-23 07:54:59 -0500 |
---|---|---|
committer | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2009-01-26 05:54:11 -0500 |
commit | 84abf972ccff5c13d10b672972949eba431a6e0e (patch) | |
tree | 378ebf8a77fbc1f906fa8eee2472f8bd6d935772 /fs/ubifs/budget.c | |
parent | e4d9b6cbfc98d696a28d2c24a3d49768695811ee (diff) |
UBIFS: add re-mount debugging checks
We observe space corrupted accounting when re-mounting. So add some
debbugging checks to catch problems like this.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Diffstat (limited to 'fs/ubifs/budget.c')
-rw-r--r-- | fs/ubifs/budget.c | 35 |
1 files changed, 25 insertions, 10 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 | } | ||