From: Gao Xiang <[email protected]>

Set up -C >= EROFS_BLKSIZ (more specifically, >= lclustersize)
to enable big pcluster feature.

Signed-off-by: Gao Xiang <[email protected]>
---
 include/erofs/config.h |  2 ++
 lib/config.c           |  1 +
 mkfs/main.c            | 14 +++++++++++++-
 3 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/include/erofs/config.h b/include/erofs/config.h
index 02ddf594ca60..5f5a05a8b796 100644
--- a/include/erofs/config.h
+++ b/include/erofs/config.h
@@ -53,6 +53,8 @@ struct erofs_configure {
        int c_force_inodeversion;
        /* < 0, xattr disabled and INT_MAX, always use inline xattrs */
        int c_inline_xattr_tolerance;
+
+       u32 c_physical_clusterblks;
        u64 c_unix_timestamp;
 #ifdef WITH_ANDROID
        char *mount_point;
diff --git a/lib/config.c b/lib/config.c
index 3ecd48140cfd..352a77c8d639 100644
--- a/lib/config.c
+++ b/lib/config.c
@@ -24,6 +24,7 @@ void erofs_init_configure(void)
        cfg.c_force_inodeversion = 0;
        cfg.c_inline_xattr_tolerance = 2;
        cfg.c_unix_timestamp = -1;
+       cfg.c_physical_clusterblks = 1;
 }
 
 void erofs_show_config(void)
diff --git a/mkfs/main.c b/mkfs/main.c
index abd48be0fa4f..c4c67c962919 100644
--- a/mkfs/main.c
+++ b/mkfs/main.c
@@ -62,6 +62,7 @@ static void usage(void)
        fputs("usage: [options] FILE DIRECTORY\n\n"
              "Generate erofs image from DIRECTORY to FILE, and [options] 
are:\n"
              " -zX[,Y]            X=compressor (Y=compression level, 
optional)\n"
+             " -C#                specify the size of compress physical 
cluster in bytes\n"
              " -d#                set output message level to # (maximum 9)\n"
              " -x#                set xattr tolerance to # (< 0, disable 
xattrs; default 2)\n"
              " -EX[,...]          X=extended options\n"
@@ -152,7 +153,7 @@ static int mkfs_parse_options_cfg(int argc, char *argv[])
        char *endptr;
        int opt, i;
 
-       while((opt = getopt_long(argc, argv, "d:x:z:E:T:U:",
+       while((opt = getopt_long(argc, argv, "d:x:z:E:T:U:C:",
                                 long_options, NULL)) != -1) {
                switch (opt) {
                case 'z':
@@ -248,6 +249,17 @@ static int mkfs_parse_options_cfg(int argc, char *argv[])
                        cfg.fs_config_file = optarg;
                        break;
 #endif
+               case 'C':
+                       i = strtoull(optarg, &endptr, 0);
+                       if (*endptr != '\0' ||
+                           i < EROFS_BLKSIZ || i % EROFS_BLKSIZ) {
+                               erofs_err("invalid physical clustersize %s",
+                                         optarg);
+                               return -EINVAL;
+                       }
+                       cfg.c_physical_clusterblks = i / EROFS_BLKSIZ;
+                       break;
+
                case 1:
                        usage();
                        exit(0);
-- 
2.24.0

Reply via email to