aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ubifs/super.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/super.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/super.c')
-rw-r--r--fs/ubifs/super.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c
index a6a7798d020b..c3cefc841374 100644
--- a/fs/ubifs/super.c
+++ b/fs/ubifs/super.c
@@ -34,6 +34,7 @@
34#include <linux/parser.h> 34#include <linux/parser.h>
35#include <linux/seq_file.h> 35#include <linux/seq_file.h>
36#include <linux/mount.h> 36#include <linux/mount.h>
37#include <linux/math64.h>
37#include "ubifs.h" 38#include "ubifs.h"
38 39
39/* 40/*
@@ -612,7 +613,7 @@ static int bud_wbuf_callback(struct ubifs_info *c, int lnum, int free, int pad)
612static int init_constants_late(struct ubifs_info *c) 613static int init_constants_late(struct ubifs_info *c)
613{ 614{
614 int tmp, err; 615 int tmp, err;
615 uint64_t tmp64; 616 long long tmp64;
616 617
617 c->main_bytes = (long long)c->main_lebs * c->leb_size; 618 c->main_bytes = (long long)c->main_lebs * c->leb_size;
618 c->max_znode_sz = sizeof(struct ubifs_znode) + 619 c->max_znode_sz = sizeof(struct ubifs_znode) +
@@ -639,9 +640,8 @@ static int init_constants_late(struct ubifs_info *c)
639 * Make sure that the log is large enough to fit reference nodes for 640 * Make sure that the log is large enough to fit reference nodes for
640 * all buds plus one reserved LEB. 641 * all buds plus one reserved LEB.
641 */ 642 */
642 tmp64 = c->max_bud_bytes; 643 tmp64 = c->max_bud_bytes + c->leb_size - 1;
643 tmp = do_div(tmp64, c->leb_size); 644 c->max_bud_cnt = div_u64(tmp64, c->leb_size);
644 c->max_bud_cnt = tmp64 + !!tmp;
645 tmp = (c->ref_node_alsz * c->max_bud_cnt + c->leb_size - 1); 645 tmp = (c->ref_node_alsz * c->max_bud_cnt + c->leb_size - 1);
646 tmp /= c->leb_size; 646 tmp /= c->leb_size;
647 tmp += 1; 647 tmp += 1;
@@ -677,7 +677,7 @@ static int init_constants_late(struct ubifs_info *c)
677 * Consequently, if the journal is too small, UBIFS will treat it as 677 * Consequently, if the journal is too small, UBIFS will treat it as
678 * always full. 678 * always full.
679 */ 679 */
680 tmp64 = (uint64_t)(c->jhead_cnt + 1) * c->leb_size + 1; 680 tmp64 = (long long)(c->jhead_cnt + 1) * c->leb_size + 1;
681 if (c->bg_bud_bytes < tmp64) 681 if (c->bg_bud_bytes < tmp64)
682 c->bg_bud_bytes = tmp64; 682 c->bg_bud_bytes = tmp64;
683 if (c->max_bud_bytes < tmp64 + c->leb_size) 683 if (c->max_bud_bytes < tmp64 + c->leb_size)
@@ -699,7 +699,7 @@ static int init_constants_late(struct ubifs_info *c)
699 * head is available. 699 * head is available.
700 */ 700 */
701 tmp64 = c->main_lebs - 1 - 1 - MIN_INDEX_LEBS - c->jhead_cnt + 1; 701 tmp64 = c->main_lebs - 1 - 1 - MIN_INDEX_LEBS - c->jhead_cnt + 1;
702 tmp64 *= (uint64_t)c->leb_size - c->leb_overhead; 702 tmp64 *= (long long)c->leb_size - c->leb_overhead;
703 tmp64 = ubifs_reported_space(c, tmp64); 703 tmp64 = ubifs_reported_space(c, tmp64);
704 c->block_cnt = tmp64 >> UBIFS_BLOCK_SHIFT; 704 c->block_cnt = tmp64 >> UBIFS_BLOCK_SHIFT;
705 705