diff options
author | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2008-11-01 08:57:49 -0400 |
---|---|---|
committer | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2008-12-03 06:14:05 -0500 |
commit | 553dea4dd531562688ba01c641c7f8fc7abaaf8c (patch) | |
tree | 823d2cb0b8684e7975ca3193a9fec2a53e3995b1 /fs/ubifs/super.c | |
parent | a1dc080c27ec8ea7ca1c8a9b499362a71ebff792 (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/super.c')
-rw-r--r-- | fs/ubifs/super.c | 44 |
1 files changed, 37 insertions, 7 deletions
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 | */ |
883 | enum { | 889 | enum { |
@@ -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 | ||