import PULS_20180308
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / fs / ubifs / sb.c
index 52c21f4190f6ba50d9b4d58ef3d83e97af2cd421..20771ddbc79be302e915d3218b63674e8f246ad8 100644 (file)
@@ -58,7 +58,9 @@
 #define DEFAULT_RP_PERCENT 5
 
 /* The default maximum size of reserved pool in bytes */
-#define DEFAULT_MAX_RP_SIZE (5*1024*1024)
+#define DEFAULT_MAX_RP_SIZE (16*1024*1024)
+
+#define UBIFS_ONE_GIGA 1024*1024*1024
 
 /* Default time granularity in nanoseconds */
 #define DEFAULT_TIME_GRAN 1000000000
@@ -182,16 +184,26 @@ static int create_default_filesystem(struct ubifs_info *c)
        sup->time_gran     = cpu_to_le32(DEFAULT_TIME_GRAN);
        if (c->mount_opts.override_compr)
                sup->default_compr = cpu_to_le16(c->mount_opts.compr_type);
-       else
+       else {
+#if defined(CONFIG_UBIFS_FS_LZ4K)
+               sup->default_compr = cpu_to_le16(UBIFS_COMPR_LZ4K);
+#else
                sup->default_compr = cpu_to_le16(UBIFS_COMPR_LZO);
+#endif
+       }
 
        generate_random_uuid(sup->uuid);
 
        main_bytes = (long long)main_lebs * c->leb_size;
-       tmp64 = div_u64(main_bytes * DEFAULT_RP_PERCENT, 100);
-       if (tmp64 > DEFAULT_MAX_RP_SIZE)
+
+       /*If the size of a volume is bigger than 1G, set rp_size to DEFAULT_MAX_RP_SIZE(16M).*/
+       if (main_bytes >= UBIFS_ONE_GIGA)
                tmp64 = DEFAULT_MAX_RP_SIZE;
+       else
+               tmp64 = 0;
+
        sup->rp_size = cpu_to_le64(tmp64);
+       sup->rp_uid = 10010; //VID_CCCI
        sup->ro_compat_version = cpu_to_le32(UBIFS_RO_COMPAT_VERSION);
 
        err = ubifs_write_node(c, sup, UBIFS_SB_NODE_SZ, 0, 0);
@@ -391,9 +403,8 @@ static int validate_sb(struct ubifs_info *c, struct ubifs_sb_node *sup)
        min_leb_cnt += c->lpt_lebs + c->orph_lebs + c->jhead_cnt + 6;
 
        if (c->leb_cnt < min_leb_cnt || c->leb_cnt > c->vi.size) {
-               ubifs_err("bad LEB count: %d in superblock, %d on UBI volume, "
-                         "%d minimum required", c->leb_cnt, c->vi.size,
-                         min_leb_cnt);
+               ubifs_err("bad LEB count: %d in superblock, %d on UBI volume, %d minimum required",
+                         c->leb_cnt, c->vi.size, min_leb_cnt);
                goto failed;
        }
 
@@ -411,15 +422,14 @@ static int validate_sb(struct ubifs_info *c, struct ubifs_sb_node *sup)
 
        max_bytes = (long long)c->leb_size * UBIFS_MIN_BUD_LEBS;
        if (c->max_bud_bytes < max_bytes) {
-               ubifs_err("too small journal (%lld bytes), must be at least "
-                         "%lld bytes",  c->max_bud_bytes, max_bytes);
+               ubifs_err("too small journal (%lld bytes), must be at least %lld bytes",
+                         c->max_bud_bytes, max_bytes);
                goto failed;
        }
 
        max_bytes = (long long)c->leb_size * c->main_lebs;
        if (c->max_bud_bytes > max_bytes) {
-               ubifs_err("too large journal size (%lld bytes), only %lld bytes"
-                         "available in the main area",
+               ubifs_err("too large journal size (%lld bytes), only %lld bytes available in the main area",
                          c->max_bud_bytes, max_bytes);
                goto failed;
        }
@@ -549,10 +559,9 @@ int ubifs_read_superblock(struct ubifs_info *c)
                ubifs_assert(!c->ro_media || c->ro_mount);
                if (!c->ro_mount ||
                    c->ro_compat_version > UBIFS_RO_COMPAT_VERSION) {
-                       ubifs_err("on-flash format version is w%d/r%d, but "
-                                 "software only supports up to version "
-                                 "w%d/r%d", c->fmt_version,
-                                 c->ro_compat_version, UBIFS_FORMAT_VERSION,
+                       ubifs_err("on-flash format version is w%d/r%d, but software only supports up to version w%d/r%d",
+                                 c->fmt_version, c->ro_compat_version,
+                                 UBIFS_FORMAT_VERSION,
                                  UBIFS_RO_COMPAT_VERSION);
                        if (c->ro_compat_version <= UBIFS_RO_COMPAT_VERSION) {
                                ubifs_msg("only R/O mounting is possible");