diff options
Diffstat (limited to 'fs/ubifs/sb.c')
-rw-r--r-- | fs/ubifs/sb.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/fs/ubifs/sb.c b/fs/ubifs/sb.c index 0f392351dc5a..e070c643d1bb 100644 --- a/fs/ubifs/sb.c +++ b/fs/ubifs/sb.c | |||
@@ -28,6 +28,7 @@ | |||
28 | 28 | ||
29 | #include "ubifs.h" | 29 | #include "ubifs.h" |
30 | #include <linux/random.h> | 30 | #include <linux/random.h> |
31 | #include <linux/math64.h> | ||
31 | 32 | ||
32 | /* | 33 | /* |
33 | * Default journal size in logical eraseblocks as a percent of total | 34 | * Default journal size in logical eraseblocks as a percent of total |
@@ -80,7 +81,7 @@ static int create_default_filesystem(struct ubifs_info *c) | |||
80 | int err, tmp, jnl_lebs, log_lebs, max_buds, main_lebs, main_first; | 81 | int err, tmp, jnl_lebs, log_lebs, max_buds, main_lebs, main_first; |
81 | int lpt_lebs, lpt_first, orph_lebs, big_lpt, ino_waste, sup_flags = 0; | 82 | int lpt_lebs, lpt_first, orph_lebs, big_lpt, ino_waste, sup_flags = 0; |
82 | int min_leb_cnt = UBIFS_MIN_LEB_CNT; | 83 | int min_leb_cnt = UBIFS_MIN_LEB_CNT; |
83 | uint64_t tmp64, main_bytes; | 84 | long long tmp64, main_bytes; |
84 | __le64 tmp_le64; | 85 | __le64 tmp_le64; |
85 | 86 | ||
86 | /* Some functions called from here depend on the @c->key_len filed */ | 87 | /* Some functions called from here depend on the @c->key_len filed */ |
@@ -160,7 +161,7 @@ static int create_default_filesystem(struct ubifs_info *c) | |||
160 | if (!sup) | 161 | if (!sup) |
161 | return -ENOMEM; | 162 | return -ENOMEM; |
162 | 163 | ||
163 | tmp64 = (uint64_t)max_buds * c->leb_size; | 164 | tmp64 = (long long)max_buds * c->leb_size; |
164 | if (big_lpt) | 165 | if (big_lpt) |
165 | sup_flags |= UBIFS_FLG_BIGLPT; | 166 | sup_flags |= UBIFS_FLG_BIGLPT; |
166 | 167 | ||
@@ -179,14 +180,16 @@ static int create_default_filesystem(struct ubifs_info *c) | |||
179 | sup->fanout = cpu_to_le32(DEFAULT_FANOUT); | 180 | sup->fanout = cpu_to_le32(DEFAULT_FANOUT); |
180 | sup->lsave_cnt = cpu_to_le32(c->lsave_cnt); | 181 | sup->lsave_cnt = cpu_to_le32(c->lsave_cnt); |
181 | sup->fmt_version = cpu_to_le32(UBIFS_FORMAT_VERSION); | 182 | sup->fmt_version = cpu_to_le32(UBIFS_FORMAT_VERSION); |
182 | sup->default_compr = cpu_to_le16(UBIFS_COMPR_LZO); | ||
183 | sup->time_gran = cpu_to_le32(DEFAULT_TIME_GRAN); | 183 | sup->time_gran = cpu_to_le32(DEFAULT_TIME_GRAN); |
184 | if (c->mount_opts.override_compr) | ||
185 | sup->default_compr = cpu_to_le16(c->mount_opts.compr_type); | ||
186 | else | ||
187 | sup->default_compr = cpu_to_le16(UBIFS_COMPR_LZO); | ||
184 | 188 | ||
185 | generate_random_uuid(sup->uuid); | 189 | generate_random_uuid(sup->uuid); |
186 | 190 | ||
187 | main_bytes = (uint64_t)main_lebs * c->leb_size; | 191 | main_bytes = (long long)main_lebs * c->leb_size; |
188 | tmp64 = main_bytes * DEFAULT_RP_PERCENT; | 192 | tmp64 = div_u64(main_bytes * DEFAULT_RP_PERCENT, 100); |
189 | do_div(tmp64, 100); | ||
190 | if (tmp64 > DEFAULT_MAX_RP_SIZE) | 193 | if (tmp64 > DEFAULT_MAX_RP_SIZE) |
191 | tmp64 = DEFAULT_MAX_RP_SIZE; | 194 | tmp64 = DEFAULT_MAX_RP_SIZE; |
192 | sup->rp_size = cpu_to_le64(tmp64); | 195 | sup->rp_size = cpu_to_le64(tmp64); |
@@ -582,16 +585,15 @@ int ubifs_read_superblock(struct ubifs_info *c) | |||
582 | c->jhead_cnt = le32_to_cpu(sup->jhead_cnt) + NONDATA_JHEADS_CNT; | 585 | c->jhead_cnt = le32_to_cpu(sup->jhead_cnt) + NONDATA_JHEADS_CNT; |
583 | c->fanout = le32_to_cpu(sup->fanout); | 586 | c->fanout = le32_to_cpu(sup->fanout); |
584 | c->lsave_cnt = le32_to_cpu(sup->lsave_cnt); | 587 | c->lsave_cnt = le32_to_cpu(sup->lsave_cnt); |
585 | c->default_compr = le16_to_cpu(sup->default_compr); | ||
586 | c->rp_size = le64_to_cpu(sup->rp_size); | 588 | c->rp_size = le64_to_cpu(sup->rp_size); |
587 | c->rp_uid = le32_to_cpu(sup->rp_uid); | 589 | c->rp_uid = le32_to_cpu(sup->rp_uid); |
588 | c->rp_gid = le32_to_cpu(sup->rp_gid); | 590 | c->rp_gid = le32_to_cpu(sup->rp_gid); |
589 | sup_flags = le32_to_cpu(sup->flags); | 591 | sup_flags = le32_to_cpu(sup->flags); |
592 | if (!c->mount_opts.override_compr) | ||
593 | c->default_compr = le16_to_cpu(sup->default_compr); | ||
590 | 594 | ||
591 | c->vfs_sb->s_time_gran = le32_to_cpu(sup->time_gran); | 595 | c->vfs_sb->s_time_gran = le32_to_cpu(sup->time_gran); |
592 | |||
593 | memcpy(&c->uuid, &sup->uuid, 16); | 596 | memcpy(&c->uuid, &sup->uuid, 16); |
594 | |||
595 | c->big_lpt = !!(sup_flags & UBIFS_FLG_BIGLPT); | 597 | c->big_lpt = !!(sup_flags & UBIFS_FLG_BIGLPT); |
596 | 598 | ||
597 | /* Automatically increase file system size to the maximum size */ | 599 | /* Automatically increase file system size to the maximum size */ |