diff options
author | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2008-10-22 14:58:05 +0300 |
---|---|---|
committer | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2008-10-22 15:41:01 +0300 |
commit | 5469d56155ec75f3bb6682a74bae80c8e66d28b9 (patch) | |
tree | 0bac5ec3f1292b3cdaed823d976165aaf4f1dfdc /mkfs.ubifs | |
parent | 38b8f4dc72e3aff117f66042a5d4ce0d71ef8b9c (diff) |
Introduce favor_lzo compressor options
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Diffstat (limited to 'mkfs.ubifs')
-rw-r--r-- | mkfs.ubifs/mkfs.ubifs.c | 34 | ||||
-rw-r--r-- | mkfs.ubifs/ubifs.h | 4 |
2 files changed, 31 insertions, 7 deletions
diff --git a/mkfs.ubifs/mkfs.ubifs.c b/mkfs.ubifs/mkfs.ubifs.c index 46f8058..8394df9 100644 --- a/mkfs.ubifs/mkfs.ubifs.c +++ b/mkfs.ubifs/mkfs.ubifs.c @@ -128,7 +128,7 @@ static struct inum_mapping **hash_table; /* Inode creation sequence number */ static unsigned long long creat_sqnum; -static const char *optstring = "d:r:m:o:D:h?vVe:c:g:f:P:k:x:j:l:j:U"; +static const char *optstring = "d:r:m:o:D:h?vVe:c:g:f:P:k:x:X:j:l:j:U"; static const struct option longopts[] = { {"root", 1, NULL, 'r'}, @@ -143,6 +143,7 @@ static const struct option longopts[] = { {"debug-level", 1, NULL, 'g'}, {"jrn-size", 1, NULL, 'j'}, {"compr", 1, NULL, 'x'}, + {"favor-percent", 1, NULL, 'X'}, {"fanout", 1, NULL, 'f'}, {"keyhash", 1, NULL, 'k'}, {"log-lebs", 1, NULL, 'l'}, @@ -161,8 +162,11 @@ static const char *helptext = "-c, --max-leb-cnt=COUNT maximum logical erase block count\n" "-o, --output=FILE output to FILE\n" "-j, --jrn-size=SIZE journal size\n" -"-x, --compr=TYPE compression type - \"lzo\", \"zlib\" or \"none\"\n" -" (default: \"lzo\")\n" +"-x, --compr=TYPE compression type - \"lzo\", \"favor_lzo\", \"zlib\" or\n" +" \"none\" (default: \"lzo\")\n" +"-X, --favor-percent may only be used with favor LZO compression and defines\n" +" how many percent better zlib should compress to make\n" +" mkfs.ubifs use zlib instead of LZO (default 20%)\n" "-f, --fanout=NUM fanout NUM (default: 8)\n" "-k, --keyhash=TYPE key hash type - \"r5\" or \"test\" (default: \"r5\")\n" "-p, --orph-lebs=COUNT count of erase blocks for orphans (default: 1)\n" @@ -176,7 +180,15 @@ static const char *helptext = " 2 - files, 3 - more details)\n" "-h, --help display this help text\n\n" "Note, SIZE is specified in bytes, but it may also be specified in Kilobytes,\n" -"Megabytes, and Gigabytes if a KiB, MiB, or GiB suffix is used.\n"; +"Megabytes, and Gigabytes if a KiB, MiB, or GiB suffix is used.\n\n" +"If you specify \"lzo\" or \"zlib\" compressors, mkfs.ubifs will use this compressor\n" +"for all data. The \"none\" disables any data compression. The \"favor_lzo\" is not\n" +"really a separate compressor. It is just a method of combining \"lzo\" and \"zlib\"\n" +"compressors. Namely, mkfs.ubifs tries to compress data with both \"lzo\" and \"zlib\"\n" +"compressors, then it compares which compressor is better. If \"zlib\" compresses 20\n" +"or more percent better than \"lzo\", mkfs.ubifs chooses \"lzo\", otherwise it chooses\n" +"\"zlib\". The \"--favor-percent\" may specify arbitrary threshold instead of the\n" +"default 20%.\n"; /** * make_path - make a path name from a directory and a name. @@ -437,6 +449,7 @@ static int get_options(int argc, char**argv) c->key_hash = key_r5_hash; c->key_len = UBIFS_SK_LEN; c->default_compr = UBIFS_COMPR_LZO; + c->favor_percent = 20; c->lsave_cnt = 256; c->leb_size = -1; c->min_io_size = -1; @@ -540,15 +553,22 @@ static int get_options(int argc, char**argv) return err_msg("bad key hash"); break; case 'x': - if (strcmp(optarg, "lzo") == 0) - c->default_compr = UBIFS_COMPR_LZO; + if (strcmp(optarg, "favor_lzo") == 0) + c->favor_lzo = 1; else if (strcmp(optarg, "zlib") == 0) c->default_compr = UBIFS_COMPR_ZLIB; else if (strcmp(optarg, "none") == 0) c->default_compr = UBIFS_COMPR_NONE; - else + else if (strcmp(optarg, "lzo") != 0) return err_msg("bad compressor name"); break; + case 'X': + c->favor_percent = strtol(optarg, &endp, 0); + if (*endp != '\0' || endp == optarg || + c->favor_percent <= 0 || c->favor_percent >= 100) + return err_msg("bad favor LZO percent '%s'", + optarg); + break; case 'j': c->max_bud_bytes = get_bytes(optarg); if (c->max_bud_bytes <= 0) diff --git a/mkfs.ubifs/ubifs.h b/mkfs.ubifs/ubifs.h index 0804801..fbefc53 100644 --- a/mkfs.ubifs/ubifs.h +++ b/mkfs.ubifs/ubifs.h @@ -272,6 +272,8 @@ struct ubifs_znode * @main_lebs: count of LEBs in the main area * @main_first: first LEB of the main area * @default_compr: default compression type + * @favor_lzo: favor LZO compression method + * @favor_percent: lzo vs. zlib threshold used in case favor LZO * * @key_hash_type: type of the key hash * @key_hash: direntry key hash function @@ -342,6 +344,8 @@ struct ubifs_info int main_lebs; int main_first; int default_compr; + int favor_lzo; + int favor_percent; uint8_t key_hash_type; uint32_t (*key_hash)(const char *str, int len); |