aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2008-12-19 12:26:29 -0500
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2008-12-23 05:23:29 -0500
commitaf14a1ad792621942a03e4bd0e5f17b6e177e2e0 (patch)
treeb91e77a8a1a373ca3dfcc84ec0feb243fb74e2e5
parentd3cf502b6ccee1c52890d42cd18cbc98b7526126 (diff)
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: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
-rw-r--r--fs/ubifs/budget.c9
-rw-r--r--fs/ubifs/super.c5
-rw-r--r--fs/ubifs/ubifs.h8
3 files changed, 13 insertions, 9 deletions
diff --git a/fs/ubifs/budget.c b/fs/ubifs/budget.c
index d5a65037e172..e42342547001 100644
--- a/fs/ubifs/budget.c
+++ b/fs/ubifs/budget.c
@@ -280,13 +280,8 @@ int ubifs_calc_min_idx_lebs(struct ubifs_info *c)
280 * extra LEB to compensate. 280 * extra LEB to compensate.
281 */ 281 */
282 ret += 1; 282 ret += 1;
283 /* 283 if (ret < MIN_INDEX_LEBS)
284 * At present the index needs at least 2 LEBs: one for the index head 284 ret = MIN_INDEX_LEBS;
285 * and one for in-the-gaps method (which currently does not cater for
286 * the index head and so excludes it from consideration).
287 */
288 if (ret < 2)
289 ret = 2;
290 return ret; 285 return ret;
291} 286}
292 287
diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c
index 2dbaa4fc2cbb..a6a7798d020b 100644
--- a/fs/ubifs/super.c
+++ b/fs/ubifs/super.c
@@ -695,9 +695,10 @@ static int init_constants_late(struct ubifs_info *c)
695 * necessary to report something for the 'statfs()' call. 695 * necessary to report something for the 'statfs()' call.
696 * 696 *
697 * Subtract the LEB reserved for GC, the LEB which is reserved for 697 * Subtract the LEB reserved for GC, the LEB which is reserved for
698 * deletions, and assume only one journal head is available. 698 * deletions, minimum LEBs for the index, and assume only one journal
699 * head is available.
699 */ 700 */
700 tmp64 = c->main_lebs - 2 - c->jhead_cnt + 1; 701 tmp64 = c->main_lebs - 1 - 1 - MIN_INDEX_LEBS - c->jhead_cnt + 1;
701 tmp64 *= (uint64_t)c->leb_size - c->leb_overhead; 702 tmp64 *= (uint64_t)c->leb_size - c->leb_overhead;
702 tmp64 = ubifs_reported_space(c, tmp64); 703 tmp64 = ubifs_reported_space(c, tmp64);
703 c->block_cnt = tmp64 >> UBIFS_BLOCK_SHIFT; 704 c->block_cnt = tmp64 >> UBIFS_BLOCK_SHIFT;
diff --git a/fs/ubifs/ubifs.h b/fs/ubifs/ubifs.h
index f8ef7c1def1f..543e850022eb 100644
--- a/fs/ubifs/ubifs.h
+++ b/fs/ubifs/ubifs.h
@@ -63,6 +63,14 @@
63#define SQNUM_WARN_WATERMARK 0xFFFFFFFF00000000ULL 63#define SQNUM_WARN_WATERMARK 0xFFFFFFFF00000000ULL
64#define SQNUM_WATERMARK 0xFFFFFFFFFF000000ULL 64#define SQNUM_WATERMARK 0xFFFFFFFFFF000000ULL
65 65
66/*
67 * Minimum amount of LEBs reserved for the index. At present the index needs at
68 * least 2 LEBs: one for the index head and one for in-the-gaps method (which
69 * currently does not cater for the index head and so excludes it from
70 * consideration).
71 */
72#define MIN_INDEX_LEBS 2
73
66/* Minimum amount of data UBIFS writes to the flash */ 74/* Minimum amount of data UBIFS writes to the flash */
67#define MIN_WRITE_SZ (UBIFS_DATA_NODE_SZ + 8) 75#define MIN_WRITE_SZ (UBIFS_DATA_NODE_SZ + 8)
68 76