Commit af14a1ad authored by Artem Bityutskiy's avatar Artem Bityutskiy

UBIFS: fix available blocks count

Take into account that 2 eraseblocks are never available because
they are reserved for the index. This gives more realistic count
of FS blocks.

To avoid future confusions like this, introduce a constant.
Signed-off-by: default avatarArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
parent d3cf502b
...@@ -280,13 +280,8 @@ int ubifs_calc_min_idx_lebs(struct ubifs_info *c) ...@@ -280,13 +280,8 @@ int ubifs_calc_min_idx_lebs(struct ubifs_info *c)
* extra LEB to compensate. * extra LEB to compensate.
*/ */
ret += 1; ret += 1;
/* if (ret < MIN_INDEX_LEBS)
* At present the index needs at least 2 LEBs: one for the index head ret = MIN_INDEX_LEBS;
* and one for in-the-gaps method (which currently does not cater for
* the index head and so excludes it from consideration).
*/
if (ret < 2)
ret = 2;
return ret; return ret;
} }
......
...@@ -695,9 +695,10 @@ static int init_constants_late(struct ubifs_info *c) ...@@ -695,9 +695,10 @@ static int init_constants_late(struct ubifs_info *c)
* necessary to report something for the 'statfs()' call. * necessary to report something for the 'statfs()' call.
* *
* Subtract the LEB reserved for GC, the LEB which is reserved for * Subtract the LEB reserved for GC, the LEB which is reserved for
* deletions, and assume only one journal head is available. * deletions, minimum LEBs for the index, and assume only one journal
* head is available.
*/ */
tmp64 = c->main_lebs - 2 - c->jhead_cnt + 1; tmp64 = c->main_lebs - 1 - 1 - MIN_INDEX_LEBS - c->jhead_cnt + 1;
tmp64 *= (uint64_t)c->leb_size - c->leb_overhead; tmp64 *= (uint64_t)c->leb_size - c->leb_overhead;
tmp64 = ubifs_reported_space(c, tmp64); tmp64 = ubifs_reported_space(c, tmp64);
c->block_cnt = tmp64 >> UBIFS_BLOCK_SHIFT; c->block_cnt = tmp64 >> UBIFS_BLOCK_SHIFT;
......
...@@ -63,6 +63,14 @@ ...@@ -63,6 +63,14 @@
#define SQNUM_WARN_WATERMARK 0xFFFFFFFF00000000ULL #define SQNUM_WARN_WATERMARK 0xFFFFFFFF00000000ULL
#define SQNUM_WATERMARK 0xFFFFFFFFFF000000ULL #define SQNUM_WATERMARK 0xFFFFFFFFFF000000ULL
/*
* Minimum amount of LEBs reserved for the index. At present the index needs at
* least 2 LEBs: one for the index head and one for in-the-gaps method (which
* currently does not cater for the index head and so excludes it from
* consideration).
*/
#define MIN_INDEX_LEBS 2
/* Minimum amount of data UBIFS writes to the flash */ /* Minimum amount of data UBIFS writes to the flash */
#define MIN_WRITE_SZ (UBIFS_DATA_NODE_SZ + 8) #define MIN_WRITE_SZ (UBIFS_DATA_NODE_SZ + 8)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment