aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ubifs/super.c
diff options
context:
space:
mode:
authorArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2008-12-27 12:18:00 -0500
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2008-12-31 07:13:23 -0500
commit79807d075ab8d1ca3574f5f52421e0047c1f1256 (patch)
treed94b099c4d69a1d1f1ad5c33d2ad533649c837ce /fs/ubifs/super.c
parentc8f915913afdfe1a796e312e21658b8edcf20868 (diff)
UBIFS: fix constants initialization
The c->min_idx_lebs constant depends on c->old_idx_sz, which is read from the master node. This means that we have to initialize c->min_idx_lebs only after we have read the master node. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Diffstat (limited to 'fs/ubifs/super.c')
-rw-r--r--fs/ubifs/super.c25
1 files changed, 20 insertions, 5 deletions
diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c
index c3cefc841374..13097830e8bc 100644
--- a/fs/ubifs/super.c
+++ b/fs/ubifs/super.c
@@ -602,7 +602,7 @@ static int bud_wbuf_callback(struct ubifs_info *c, int lnum, int free, int pad)
602} 602}
603 603
604/* 604/*
605 * init_constants_late - initialize UBIFS constants. 605 * init_constants_sb - initialize UBIFS constants.
606 * @c: UBIFS file-system description object 606 * @c: UBIFS file-system description object
607 * 607 *
608 * This is a helper function which initializes various UBIFS constants after 608 * This is a helper function which initializes various UBIFS constants after
@@ -610,7 +610,7 @@ static int bud_wbuf_callback(struct ubifs_info *c, int lnum, int free, int pad)
610 * makes sure they are all right. Returns zero in case of success and a 610 * makes sure they are all right. Returns zero in case of success and a
611 * negative error code in case of failure. 611 * negative error code in case of failure.
612 */ 612 */
613static int init_constants_late(struct ubifs_info *c) 613static int init_constants_sb(struct ubifs_info *c)
614{ 614{
615 int tmp, err; 615 int tmp, err;
616 long long tmp64; 616 long long tmp64;
@@ -687,6 +687,21 @@ static int init_constants_late(struct ubifs_info *c)
687 if (err) 687 if (err)
688 return err; 688 return err;
689 689
690 return 0;
691}
692
693/*
694 * init_constants_master - initialize UBIFS constants.
695 * @c: UBIFS file-system description object
696 *
697 * This is a helper function which initializes various UBIFS constants after
698 * the master node has been read. It also checks various UBIFS parameters and
699 * makes sure they are all right.
700 */
701static void init_constants_master(struct ubifs_info *c)
702{
703 long long tmp64;
704
690 c->min_idx_lebs = ubifs_calc_min_idx_lebs(c); 705 c->min_idx_lebs = ubifs_calc_min_idx_lebs(c);
691 706
692 /* 707 /*
@@ -702,8 +717,6 @@ static int init_constants_late(struct ubifs_info *c)
702 tmp64 *= (long long)c->leb_size - c->leb_overhead; 717 tmp64 *= (long long)c->leb_size - c->leb_overhead;
703 tmp64 = ubifs_reported_space(c, tmp64); 718 tmp64 = ubifs_reported_space(c, tmp64);
704 c->block_cnt = tmp64 >> UBIFS_BLOCK_SHIFT; 719 c->block_cnt = tmp64 >> UBIFS_BLOCK_SHIFT;
705
706 return 0;
707} 720}
708 721
709/** 722/**
@@ -1138,7 +1151,7 @@ static int mount_ubifs(struct ubifs_info *c)
1138 goto out_free; 1151 goto out_free;
1139 } 1152 }
1140 1153
1141 err = init_constants_late(c); 1154 err = init_constants_sb(c);
1142 if (err) 1155 if (err)
1143 goto out_free; 1156 goto out_free;
1144 1157
@@ -1172,6 +1185,8 @@ static int mount_ubifs(struct ubifs_info *c)
1172 if (err) 1185 if (err)
1173 goto out_master; 1186 goto out_master;
1174 1187
1188 init_constants_master(c);
1189
1175 if ((c->mst_node->flags & cpu_to_le32(UBIFS_MST_DIRTY)) != 0) { 1190 if ((c->mst_node->flags & cpu_to_le32(UBIFS_MST_DIRTY)) != 0) {
1176 ubifs_msg("recovery needed"); 1191 ubifs_msg("recovery needed");
1177 c->need_recovery = 1; 1192 c->need_recovery = 1;