aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ubifs
diff options
context:
space:
mode:
authorArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2008-11-01 08:57:49 -0400
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2008-12-03 06:14:05 -0500
commit553dea4dd531562688ba01c641c7f8fc7abaaf8c (patch)
tree823d2cb0b8684e7975ca3193a9fec2a53e3995b1 /fs/ubifs
parenta1dc080c27ec8ea7ca1c8a9b499362a71ebff792 (diff)
UBIFS: introduce compression mount options
It is very handy to be able to change default UBIFS compressor via mount options. Introduce -o compr=<name> mount option support. Currently only "none", "lzo" and "zlib" compressors are supported. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Diffstat (limited to 'fs/ubifs')
-rw-r--r--fs/ubifs/compress.c6
-rw-r--r--fs/ubifs/sb.c10
-rw-r--r--fs/ubifs/super.c44
-rw-r--r--fs/ubifs/ubifs.h12
4 files changed, 56 insertions, 16 deletions
diff --git a/fs/ubifs/compress.c b/fs/ubifs/compress.c
index 6414d50780e1..4afb3ea24d44 100644
--- a/fs/ubifs/compress.c
+++ b/fs/ubifs/compress.c
@@ -33,7 +33,7 @@
33/* Fake description object for the "none" compressor */ 33/* Fake description object for the "none" compressor */
34static struct ubifs_compressor none_compr = { 34static struct ubifs_compressor none_compr = {
35 .compr_type = UBIFS_COMPR_NONE, 35 .compr_type = UBIFS_COMPR_NONE,
36 .name = "no compression", 36 .name = "none",
37 .capi_name = "", 37 .capi_name = "",
38}; 38};
39 39
@@ -43,13 +43,13 @@ static DEFINE_MUTEX(lzo_mutex);
43static struct ubifs_compressor lzo_compr = { 43static struct ubifs_compressor lzo_compr = {
44 .compr_type = UBIFS_COMPR_LZO, 44 .compr_type = UBIFS_COMPR_LZO,
45 .comp_mutex = &lzo_mutex, 45 .comp_mutex = &lzo_mutex,
46 .name = "LZO", 46 .name = "lzo",
47 .capi_name = "lzo", 47 .capi_name = "lzo",
48}; 48};
49#else 49#else
50static struct ubifs_compressor lzo_compr = { 50static struct ubifs_compressor lzo_compr = {
51 .compr_type = UBIFS_COMPR_LZO, 51 .compr_type = UBIFS_COMPR_LZO,
52 .name = "LZO", 52 .name = "lzo",
53}; 53};
54#endif 54#endif
55 55
diff --git a/fs/ubifs/sb.c b/fs/ubifs/sb.c
index 0f392351dc5a..c5da201ab54f 100644
--- a/fs/ubifs/sb.c
+++ b/fs/ubifs/sb.c
@@ -179,8 +179,11 @@ static int create_default_filesystem(struct ubifs_info *c)
179 sup->fanout = cpu_to_le32(DEFAULT_FANOUT); 179 sup->fanout = cpu_to_le32(DEFAULT_FANOUT);
180 sup->lsave_cnt = cpu_to_le32(c->lsave_cnt); 180 sup->lsave_cnt = cpu_to_le32(c->lsave_cnt);
181 sup->fmt_version = cpu_to_le32(UBIFS_FORMAT_VERSION); 181 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); 182 sup->time_gran = cpu_to_le32(DEFAULT_TIME_GRAN);
183 if (c->mount_opts.override_compr)
184 sup->default_compr = cpu_to_le16(c->mount_opts.compr_type);
185 else
186 sup->default_compr = cpu_to_le16(UBIFS_COMPR_LZO);
184 187
185 generate_random_uuid(sup->uuid); 188 generate_random_uuid(sup->uuid);
186 189
@@ -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 */
diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c
index 21b4103271ec..fc81022cc26d 100644
--- a/fs/ubifs/super.c
+++ b/fs/ubifs/super.c
@@ -417,6 +417,11 @@ static int ubifs_show_options(struct seq_file *s, struct vfsmount *mnt)
417 else if (c->mount_opts.chk_data_crc == 1) 417 else if (c->mount_opts.chk_data_crc == 1)
418 seq_printf(s, ",no_chk_data_crc"); 418 seq_printf(s, ",no_chk_data_crc");
419 419
420 if (c->mount_opts.override_compr) {
421 seq_printf(s, ",compr=");
422 seq_printf(s, ubifs_compr_name(c->mount_opts.compr_type));
423 }
424
420 return 0; 425 return 0;
421} 426}
422 427
@@ -878,6 +883,7 @@ static int check_volume_empty(struct ubifs_info *c)
878 * Opt_no_bulk_read: disable bulk-reads 883 * Opt_no_bulk_read: disable bulk-reads
879 * Opt_chk_data_crc: check CRCs when reading data nodes 884 * Opt_chk_data_crc: check CRCs when reading data nodes
880 * Opt_no_chk_data_crc: do not check CRCs when reading data nodes 885 * Opt_no_chk_data_crc: do not check CRCs when reading data nodes
886 * Opt_override_compr: override default compressor
881 * Opt_err: just end of array marker 887 * Opt_err: just end of array marker
882 */ 888 */
883enum { 889enum {
@@ -887,6 +893,7 @@ enum {
887 Opt_no_bulk_read, 893 Opt_no_bulk_read,
888 Opt_chk_data_crc, 894 Opt_chk_data_crc,
889 Opt_no_chk_data_crc, 895 Opt_no_chk_data_crc,
896 Opt_override_compr,
890 Opt_err, 897 Opt_err,
891}; 898};
892 899
@@ -897,6 +904,7 @@ static const match_table_t tokens = {
897 {Opt_no_bulk_read, "no_bulk_read"}, 904 {Opt_no_bulk_read, "no_bulk_read"},
898 {Opt_chk_data_crc, "chk_data_crc"}, 905 {Opt_chk_data_crc, "chk_data_crc"},
899 {Opt_no_chk_data_crc, "no_chk_data_crc"}, 906 {Opt_no_chk_data_crc, "no_chk_data_crc"},
907 {Opt_override_compr, "compr=%s"},
900 {Opt_err, NULL}, 908 {Opt_err, NULL},
901}; 909};
902 910
@@ -950,6 +958,28 @@ static int ubifs_parse_options(struct ubifs_info *c, char *options,
950 c->mount_opts.chk_data_crc = 1; 958 c->mount_opts.chk_data_crc = 1;
951 c->no_chk_data_crc = 1; 959 c->no_chk_data_crc = 1;
952 break; 960 break;
961 case Opt_override_compr:
962 {
963 char *name = match_strdup(&args[0]);
964
965 if (!name)
966 return -ENOMEM;
967 if (!strcmp(name, "none"))
968 c->mount_opts.compr_type = UBIFS_COMPR_NONE;
969 else if (!strcmp(name, "lzo"))
970 c->mount_opts.compr_type = UBIFS_COMPR_LZO;
971 else if (!strcmp(name, "zlib"))
972 c->mount_opts.compr_type = UBIFS_COMPR_ZLIB;
973 else {
974 ubifs_err("unknown compressor \"%s\"", name);
975 kfree(name);
976 return -EINVAL;
977 }
978 kfree(name);
979 c->mount_opts.override_compr = 1;
980 c->default_compr = c->mount_opts.compr_type;
981 break;
982 }
953 default: 983 default:
954 ubifs_err("unrecognized mount option \"%s\" " 984 ubifs_err("unrecognized mount option \"%s\" "
955 "or missing value", p); 985 "or missing value", p);
@@ -1100,13 +1130,13 @@ static int mount_ubifs(struct ubifs_info *c)
1100 goto out_free; 1130 goto out_free;
1101 1131
1102 /* 1132 /*
1103 * Make sure the compressor which is set as the default on in the 1133 * Make sure the compressor which is set as default in the superblock
1104 * superblock was actually compiled in. 1134 * or overriden by mount options is actually compiled in.
1105 */ 1135 */
1106 if (!ubifs_compr_present(c->default_compr)) { 1136 if (!ubifs_compr_present(c->default_compr)) {
1107 ubifs_warn("'%s' compressor is set by superblock, but not " 1137 ubifs_err("'compressor \"%s\" is not compiled in",
1108 "compiled in", ubifs_compr_name(c->default_compr)); 1138 ubifs_compr_name(c->default_compr));
1109 c->default_compr = UBIFS_COMPR_NONE; 1139 goto out_free;
1110 } 1140 }
1111 1141
1112 dbg_failure_mode_registration(c); 1142 dbg_failure_mode_registration(c);
@@ -2023,8 +2053,8 @@ static int __init ubifs_init(void)
2023 /* 2053 /*
2024 * We use 2 bit wide bit-fields to store compression type, which should 2054 * We use 2 bit wide bit-fields to store compression type, which should
2025 * be amended if more compressors are added. The bit-fields are: 2055 * be amended if more compressors are added. The bit-fields are:
2026 * @compr_type in 'struct ubifs_inode' and @default_compr in 2056 * @compr_type in 'struct ubifs_inode', @default_compr in
2027 * 'struct ubifs_info'. 2057 * 'struct ubifs_info' and @compr_type in 'struct ubifs_mount_opts'.
2028 */ 2058 */
2029 BUILD_BUG_ON(UBIFS_COMPR_TYPES_CNT > 4); 2059 BUILD_BUG_ON(UBIFS_COMPR_TYPES_CNT > 4);
2030 2060
diff --git a/fs/ubifs/ubifs.h b/fs/ubifs/ubifs.h
index 4d76aba57ee1..16840e099eff 100644
--- a/fs/ubifs/ubifs.h
+++ b/fs/ubifs/ubifs.h
@@ -893,13 +893,21 @@ struct ubifs_orphan {
893/** 893/**
894 * struct ubifs_mount_opts - UBIFS-specific mount options information. 894 * struct ubifs_mount_opts - UBIFS-specific mount options information.
895 * @unmount_mode: selected unmount mode (%0 default, %1 normal, %2 fast) 895 * @unmount_mode: selected unmount mode (%0 default, %1 normal, %2 fast)
896 * @bulk_read: enable bulk-reads 896 * @bulk_read: enable/disable bulk-reads (%0 default, %1 disabe, %2 enable)
897 * @chk_data_crc: check CRCs when reading data nodes 897 * @chk_data_crc: enable/disable CRC data checking when reading data nodes
898 * (%0 default, %1 disabe, %2 enable)
899 * @override_compr: override default compressor (%0 - do not override and use
900 * superblock compressor, %1 - override and use compressor
901 * specified in @compr_type)
902 * @compr_type: compressor type to override the superblock compressor with
903 * (%UBIFS_COMPR_NONE, etc)
898 */ 904 */
899struct ubifs_mount_opts { 905struct ubifs_mount_opts {
900 unsigned int unmount_mode:2; 906 unsigned int unmount_mode:2;
901 unsigned int bulk_read:2; 907 unsigned int bulk_read:2;
902 unsigned int chk_data_crc:2; 908 unsigned int chk_data_crc:2;
909 unsigned int override_compr:1;
910 unsigned int compr_type:2;
903}; 911};
904 912
905/** 913/**