Add luci mirror repository
[librecmc/librecmc.git] / target / linux / generic / pending-4.19 / 553-ubifs-Add-option-to-create-UBI-FS-version-4-on-empty.patch
1 From 93c33e6a7f3b0aef99d02252e6232a3d8b80f2d5 Mon Sep 17 00:00:00 2001
2 From: Hauke Mehrtens <hauke@hauke-m.de>
3 Date: Sun, 21 Jan 2018 15:47:50 +0100
4 Subject: ubifs: Add option to create UBI FS version 4 on empty UBI volume
5
6 Instead of creating an ubifs file system with format version 5 by
7 default on empty UBI volumes add a compile option to create an older ubi
8 with file system format version 4 instated. This allows it to be mount
9 as a volume on kernel versions < 4.10, which does not support format
10 version 5.
11 We saw that some people can not access their older data when they
12 downgraded from kernel 4.14 to kernel 4.9 to prevent this this option
13 would help.
14
15 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
16 ---
17  fs/ubifs/Kconfig | 13 +++++++++++++
18  fs/ubifs/sb.c    |  6 ++++++
19  2 files changed, 19 insertions(+)
20
21 --- a/fs/ubifs/Kconfig
22 +++ b/fs/ubifs/Kconfig
23 @@ -85,3 +85,16 @@ config UBIFS_FS_SECURITY
24           the extended attribute support in advance.
25  
26           If you are not using a security module, say N.
27 +
28 +config UBIFS_FS_FORMAT4
29 +       bool "Use file system format version 4 for new file systems"
30 +       depends on UBIFS_FS
31 +       help
32 +         Instead of creating new file systems with the new ubifs file
33 +         system version 5, use the old format version 4 for implicitly
34 +         by the driver created file systems on an empty UBI volume. This
35 +         makes it possible to  mount these file systems also with kernel
36 +         versions before 4.10. The driver will still support file system
37 +         format version 5 for ubifs file systems created with version 5.
38 +
39 +         If you are unsure, say N.
40 --- a/fs/ubifs/sb.c
41 +++ b/fs/ubifs/sb.c
42 @@ -176,7 +176,9 @@ static int create_default_filesystem(str
43         tmp64 = (long long)max_buds * c->leb_size;
44         if (big_lpt)
45                 sup_flags |= UBIFS_FLG_BIGLPT;
46 +#ifndef CONFIG_UBIFS_FS_FORMAT4
47         sup_flags |= UBIFS_FLG_DOUBLE_HASH;
48 +#endif
49  
50         sup->ch.node_type  = UBIFS_SB_NODE;
51         sup->key_hash      = UBIFS_KEY_HASH_R5;
52 @@ -192,7 +194,11 @@ static int create_default_filesystem(str
53         sup->jhead_cnt     = cpu_to_le32(DEFAULT_JHEADS_CNT);
54         sup->fanout        = cpu_to_le32(DEFAULT_FANOUT);
55         sup->lsave_cnt     = cpu_to_le32(c->lsave_cnt);
56 +#ifdef CONFIG_UBIFS_FS_FORMAT4
57 +       sup->fmt_version   = cpu_to_le32(4);
58 +#else
59         sup->fmt_version   = cpu_to_le32(UBIFS_FORMAT_VERSION);
60 +#endif
61         sup->time_gran     = cpu_to_le32(DEFAULT_TIME_GRAN);
62         if (c->mount_opts.override_compr)
63                 sup->default_compr = cpu_to_le16(c->mount_opts.compr_type);