]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
UBIFS: push empty flash hack down
authorArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
Mon, 25 Aug 2008 14:29:43 +0000 (17:29 +0300)
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
Sun, 31 Aug 2008 14:15:53 +0000 (17:15 +0300)
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>
fs/ubifs/budget.c
fs/ubifs/super.c

index ac0d2e1e73b105a64bc92445301a0b9b5d25d1d6..f6d2eaa7a06717740416c190309ecb11d8d6a823 100644 (file)
@@ -302,18 +302,6 @@ long long ubifs_calc_available(const struct ubifs_info *c, int min_idx_lebs)
        int subtract_lebs;
        long long available;
 
-       /*
-        * Force the amount available to the total size reported if the used
-        * space is zero.
-        */
-       if (c->lst.total_used <= UBIFS_INO_NODE_SZ &&
-           c->budg_data_growth + c->budg_dd_growth == 0) {
-               /* Do the same calculation as for c->block_cnt */
-               available = c->main_lebs - 2;
-               available *= c->leb_size - c->dark_wm;
-               return available;
-       }
-
        available = c->main_bytes - c->lst.total_used;
 
        /*
@@ -739,8 +727,18 @@ long long ubifs_budg_get_free_space(struct ubifs_info *c)
                return 0;
        }
 
-       available = ubifs_calc_available(c, min_idx_lebs);
        outstanding = c->budg_data_growth + c->budg_dd_growth;
+
+       /*
+        * Force the amount available to the total size reported if the used
+        * space is zero.
+        */
+       if (c->lst.total_used <= UBIFS_INO_NODE_SZ && !outstanding) {
+               spin_unlock(&c->space_lock);
+               return (long long)c->block_cnt << UBIFS_BLOCK_SHIFT;
+       }
+
+       available = ubifs_calc_available(c, min_idx_lebs);
        spin_unlock(&c->space_lock);
 
        if (available > outstanding)
index f71e6b8822c4fac6dbaab1913098e7a61c81dcfa..1018053519e64c64df4d7eb845a865672cd80aba 100644 (file)
@@ -649,8 +649,6 @@ static int init_constants_late(struct ubifs_info *c)
         *
         * Subtract the LEB reserved for GC and the LEB which is reserved for
         * deletions.
-        *
-        * Review 'ubifs_calc_available()' if changing this calculation.
         */
        tmp64 = c->main_lebs - 2;
        tmp64 *= (uint64_t)c->leb_size - c->dark_wm;