kernel: add support for kernel 5.4
[openwrt/staging/rmilecki.git] / target / linux / generic / pending-5.4 / 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,6 +85,19 @@ config UBIFS_FS_SECURITY
24
25 If you are not using a security module, say N.
26
27 +config UBIFS_FS_FORMAT4
28 + bool "Use file system format version 4 for new file systems"
29 + depends on UBIFS_FS
30 + help
31 + Instead of creating new file systems with the new ubifs file
32 + system version 5, use the old format version 4 for implicitly
33 + by the driver created file systems on an empty UBI volume. This
34 + makes it possible to mount these file systems also with kernel
35 + versions before 4.10. The driver will still support file system
36 + format version 5 for ubifs file systems created with version 5.
37 +
38 + If you are unsure, say N.
39 +
40 config UBIFS_FS_AUTHENTICATION
41 bool "UBIFS authentication support"
42 select KEYS
43 --- a/fs/ubifs/sb.c
44 +++ b/fs/ubifs/sb.c
45 @@ -175,7 +175,9 @@ static int create_default_filesystem(str
46 tmp64 = (long long)max_buds * c->leb_size;
47 if (big_lpt)
48 sup_flags |= UBIFS_FLG_BIGLPT;
49 +#ifndef CONFIG_UBIFS_FS_FORMAT4
50 sup_flags |= UBIFS_FLG_DOUBLE_HASH;
51 +#endif
52
53 if (ubifs_authenticated(c)) {
54 sup_flags |= UBIFS_FLG_AUTHENTICATION;
55 @@ -201,7 +203,11 @@ static int create_default_filesystem(str
56 sup->jhead_cnt = cpu_to_le32(DEFAULT_JHEADS_CNT);
57 sup->fanout = cpu_to_le32(DEFAULT_FANOUT);
58 sup->lsave_cnt = cpu_to_le32(c->lsave_cnt);
59 +#ifdef CONFIG_UBIFS_FS_FORMAT4
60 + sup->fmt_version = cpu_to_le32(4);
61 +#else
62 sup->fmt_version = cpu_to_le32(UBIFS_FORMAT_VERSION);
63 +#endif
64 sup->time_gran = cpu_to_le32(DEFAULT_TIME_GRAN);
65 if (c->mount_opts.override_compr)
66 sup->default_compr = cpu_to_le16(c->mount_opts.compr_type);