aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2008-08-25 10:29:43 -0400
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2008-08-31 10:15:53 -0400
commit9e5de3549615818cae9c20a0ee1fd3ad4a747758 (patch)
tree0ac4320ec95f9b0aa4a8fb4fb09ded2d739950e6
parent8191e1fa8131a422f4bf7b0f2dc1f8543fd17783 (diff)
UBIFS: push empty flash hack down
We have a hack which forces the amount of flash space to be equivalent to 'c->blocks_cnt' in case of empty FS. This is to make users happy and see '%0' used in 'df' when they mount an empty FS. This hack is not needed in 'ubifs_calc_available()', but it is only needed the caller, in 'ubifs_budg_get_free_space()'. So push it down there. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
-rw-r--r--fs/ubifs/budget.c24
-rw-r--r--fs/ubifs/super.c2
2 files changed, 11 insertions, 15 deletions
diff --git a/fs/ubifs/budget.c b/fs/ubifs/budget.c
index ac0d2e1e73b1..f6d2eaa7a067 100644
--- a/fs/ubifs/budget.c
+++ b/fs/ubifs/budget.c
@@ -302,18 +302,6 @@ long long ubifs_calc_available(const struct ubifs_info *c, int min_idx_lebs)
302 int subtract_lebs; 302 int subtract_lebs;
303 long long available; 303 long long available;
304 304
305 /*
306 * Force the amount available to the total size reported if the used
307 * space is zero.
308 */
309 if (c->lst.total_used <= UBIFS_INO_NODE_SZ &&
310 c->budg_data_growth + c->budg_dd_growth == 0) {
311 /* Do the same calculation as for c->block_cnt */
312 available = c->main_lebs - 2;
313 available *= c->leb_size - c->dark_wm;
314 return available;
315 }
316
317 available = c->main_bytes - c->lst.total_used; 305 available = c->main_bytes - c->lst.total_used;
318 306
319 /* 307 /*
@@ -739,8 +727,18 @@ long long ubifs_budg_get_free_space(struct ubifs_info *c)
739 return 0; 727 return 0;
740 } 728 }
741 729
742 available = ubifs_calc_available(c, min_idx_lebs);
743 outstanding = c->budg_data_growth + c->budg_dd_growth; 730 outstanding = c->budg_data_growth + c->budg_dd_growth;
731
732 /*
733 * Force the amount available to the total size reported if the used
734 * space is zero.
735 */
736 if (c->lst.total_used <= UBIFS_INO_NODE_SZ && !outstanding) {
737 spin_unlock(&c->space_lock);
738 return (long long)c->block_cnt << UBIFS_BLOCK_SHIFT;
739 }
740
741 available = ubifs_calc_available(c, min_idx_lebs);
744 spin_unlock(&c->space_lock); 742 spin_unlock(&c->space_lock);
745 743
746 if (available > outstanding) 744 if (available > outstanding)
diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c
index f71e6b8822c4..1018053519e6 100644
--- a/fs/ubifs/super.c
+++ b/fs/ubifs/super.c
@@ -649,8 +649,6 @@ static int init_constants_late(struct ubifs_info *c)
649 * 649 *
650 * Subtract the LEB reserved for GC and the LEB which is reserved for 650 * Subtract the LEB reserved for GC and the LEB which is reserved for
651 * deletions. 651 * deletions.
652 *
653 * Review 'ubifs_calc_available()' if changing this calculation.
654 */ 652 */
655 tmp64 = c->main_lebs - 2; 653 tmp64 = c->main_lebs - 2;
656 tmp64 *= (uint64_t)c->leb_size - c->dark_wm; 654 tmp64 *= (uint64_t)c->leb_size - c->dark_wm;