diff options
Diffstat (limited to 'fs/ubifs/budget.c')
-rw-r--r-- | fs/ubifs/budget.c | 25 |
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 | */ |
259 | int ubifs_calc_min_idx_lebs(struct ubifs_info *c) | 259 | int 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 | */ |
721 | long long ubifs_reported_space(const struct ubifs_info *c, uint64_t free) | 719 | long 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 | /** |