Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ubifs: Fix default compression selection in ubifs

When ubifs is build without the LZO compressor and no compressor is
given the creation of the default file system will fail. before
selection the LZO compressor check if it is present and if not fall back
to the zlib or none.

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
Signed-off-by: Richard Weinberger <richard@nod.at>

authored by

Gabor Juhos and committed by
Richard Weinberger
d62e98ed 6554a56f

+12 -1
+12 -1
fs/ubifs/sb.c
··· 63 63 /* Default time granularity in nanoseconds */ 64 64 #define DEFAULT_TIME_GRAN 1000000000 65 65 66 + static int get_default_compressor(struct ubifs_info *c) 67 + { 68 + if (ubifs_compr_present(c, UBIFS_COMPR_LZO)) 69 + return UBIFS_COMPR_LZO; 70 + 71 + if (ubifs_compr_present(c, UBIFS_COMPR_ZLIB)) 72 + return UBIFS_COMPR_ZLIB; 73 + 74 + return UBIFS_COMPR_NONE; 75 + } 76 + 66 77 /** 67 78 * create_default_filesystem - format empty UBI volume. 68 79 * @c: UBIFS file-system description object ··· 218 207 if (c->mount_opts.override_compr) 219 208 sup->default_compr = cpu_to_le16(c->mount_opts.compr_type); 220 209 else 221 - sup->default_compr = cpu_to_le16(UBIFS_COMPR_LZO); 210 + sup->default_compr = cpu_to_le16(get_default_compressor(c)); 222 211 223 212 generate_random_uuid(sup->uuid); 224 213