4782fc9ed827d295425b59c543f53e73e11c1f4a
[openwrt/openwrt.git] / target / linux / generic / pending-4.14 / 551-ubifs-fix-default-compression-selection.patch
1 From: Gabor Juhos <juhosg@openwrt.org>
2 Subject: fs: ubifs: fix default compression selection in ubifs
3
4 Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
5 ---
6 fs/ubifs/sb.c | 13 ++++++++++++-
7 1 file changed, 12 insertions(+), 1 deletion(-)
8
9 --- a/fs/ubifs/sb.c
10 +++ b/fs/ubifs/sb.c
11 @@ -63,6 +63,17 @@
12 /* Default time granularity in nanoseconds */
13 #define DEFAULT_TIME_GRAN 1000000000
14
15 +static int get_default_compressor(void)
16 +{
17 + if (ubifs_compr_present(UBIFS_COMPR_LZO))
18 + return UBIFS_COMPR_LZO;
19 +
20 + if (ubifs_compr_present(UBIFS_COMPR_ZLIB))
21 + return UBIFS_COMPR_ZLIB;
22 +
23 + return UBIFS_COMPR_NONE;
24 +}
25 +
26 /**
27 * create_default_filesystem - format empty UBI volume.
28 * @c: UBIFS file-system description object
29 @@ -186,7 +197,7 @@ static int create_default_filesystem(str
30 if (c->mount_opts.override_compr)
31 sup->default_compr = cpu_to_le16(c->mount_opts.compr_type);
32 else
33 - sup->default_compr = cpu_to_le16(UBIFS_COMPR_LZO);
34 + sup->default_compr = cpu_to_le16(get_default_compressor());
35
36 generate_random_uuid(sup->uuid);
37