aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ubifs/budget.c
diff options
context:
space:
mode:
authorArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2008-12-18 07:06:51 -0500
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2008-12-23 05:23:40 -0500
commit4d61db4f87b527734ac0cc830dda8fcc4e2add2f (patch)
tree881cb7614a928ba004f588a82c064592f461fee3 /fs/ubifs/budget.c
parentaf14a1ad792621942a03e4bd0e5f17b6e177e2e0 (diff)
UBIFS: use nicer 64-bit math
Instead of using do_div(), use better primitives from linux/math64.h. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Diffstat (limited to 'fs/ubifs/budget.c')
-rw-r--r--fs/ubifs/budget.c25
1 files changed, 11 insertions, 14 deletions
diff --git a/fs/ubifs/budget.c b/fs/ubifs/budget.c
index e42342547001..0bcb8031ca18 100644
--- a/fs/ubifs/budget.c
+++ b/fs/ubifs/budget.c
@@ -32,7 +32,7 @@
32 32
33#include "ubifs.h" 33#include "ubifs.h"
34#include <linux/writeback.h> 34#include <linux/writeback.h>
35#include <asm/div64.h> 35#include <linux/math64.h>
36 36
37/* 37/*
38 * When pessimistic budget calculations say that there is no enough space, 38 * When pessimistic budget calculations say that there is no enough space,
@@ -258,8 +258,8 @@ static int make_free_space(struct ubifs_info *c, struct retries_info *ri)
258 */ 258 */
259int ubifs_calc_min_idx_lebs(struct ubifs_info *c) 259int ubifs_calc_min_idx_lebs(struct ubifs_info *c)
260{ 260{
261 int ret; 261 int idx_lebs, eff_leb_size = c->leb_size - c->max_idx_node_sz;
262 uint64_t idx_size; 262 long long idx_size;
263 263
264 idx_size = c->old_idx_sz + c->budg_idx_growth + c->budg_uncommitted_idx; 264 idx_size = c->old_idx_sz + c->budg_idx_growth + c->budg_uncommitted_idx;
265 265
@@ -271,18 +271,16 @@ int ubifs_calc_min_idx_lebs(struct ubifs_info *c)
271 * pair, nor similarly the two variables for the new index size, so we 271 * pair, nor similarly the two variables for the new index size, so we
272 * have to do this costly 64-bit division on fast-path. 272 * have to do this costly 64-bit division on fast-path.
273 */ 273 */
274 if (do_div(idx_size, c->leb_size - c->max_idx_node_sz)) 274 idx_size += eff_leb_size - 1;
275 ret = idx_size + 1; 275 idx_lebs = div_u64(idx_size, eff_leb_size);
276 else
277 ret = idx_size;
278 /* 276 /*
279 * The index head is not available for the in-the-gaps method, so add an 277 * The index head is not available for the in-the-gaps method, so add an
280 * extra LEB to compensate. 278 * extra LEB to compensate.
281 */ 279 */
282 ret += 1; 280 idx_lebs += 1;
283 if (ret < MIN_INDEX_LEBS) 281 if (idx_lebs < MIN_INDEX_LEBS)
284 ret = MIN_INDEX_LEBS; 282 idx_lebs = MIN_INDEX_LEBS;
285 return ret; 283 return idx_lebs;
286} 284}
287 285
288/** 286/**
@@ -718,7 +716,7 @@ void ubifs_release_dirty_inode_budget(struct ubifs_info *c,
718 * Note, the calculation is pessimistic, which means that most of the time 716 * Note, the calculation is pessimistic, which means that most of the time
719 * UBIFS reports less space than it actually has. 717 * UBIFS reports less space than it actually has.
720 */ 718 */
721long long ubifs_reported_space(const struct ubifs_info *c, uint64_t free) 719long long ubifs_reported_space(const struct ubifs_info *c, long long free)
722{ 720{
723 int divisor, factor, f; 721 int divisor, factor, f;
724 722
@@ -740,8 +738,7 @@ long long ubifs_reported_space(const struct ubifs_info *c, uint64_t free)
740 divisor = UBIFS_MAX_DATA_NODE_SZ; 738 divisor = UBIFS_MAX_DATA_NODE_SZ;
741 divisor += (c->max_idx_node_sz * 3) / (f - 1); 739 divisor += (c->max_idx_node_sz * 3) / (f - 1);
742 free *= factor; 740 free *= factor;
743 do_div(free, divisor); 741 return div_u64(free, divisor);
744 return free;
745} 742}
746 743
747/** 744/**