kernel: add missing patch
[oweals/openwrt.git] / target / linux / generic / pending-4.9 / 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 diff --git a/fs/ubifs/sb.c b/fs/ubifs/sb.c
10 index 3cbb904a6d7d..460cb9e3b4ea 100644
11 --- a/fs/ubifs/sb.c
12 +++ b/fs/ubifs/sb.c
13 @@ -63,6 +63,17 @@
14  /* Default time granularity in nanoseconds */
15  #define DEFAULT_TIME_GRAN 1000000000
16  
17 +static int get_default_compressor(void)
18 +{
19 +       if (ubifs_compr_present(UBIFS_COMPR_LZO))
20 +               return UBIFS_COMPR_LZO;
21 +
22 +       if (ubifs_compr_present(UBIFS_COMPR_ZLIB))
23 +               return UBIFS_COMPR_ZLIB;
24 +
25 +       return UBIFS_COMPR_NONE;
26 +}
27 +
28  /**
29   * create_default_filesystem - format empty UBI volume.
30   * @c: UBIFS file-system description object
31 @@ -183,7 +194,7 @@ static int create_default_filesystem(struct ubifs_info *c)
32         if (c->mount_opts.override_compr)
33                 sup->default_compr = cpu_to_le16(c->mount_opts.compr_type);
34         else
35 -               sup->default_compr = cpu_to_le16(UBIFS_COMPR_LZO);
36 +               sup->default_compr = cpu_to_le16(get_default_compressor());
37  
38         generate_random_uuid(sup->uuid);
39  
40 -- 
41 2.11.0
42