generic: early (incomplete!) 4.0 support
[openwrt/svn-archive/archive.git] / target / linux / generic / patches-4.0 / 503-yaffs-add-tags-9bytes-mount-option.patch
1 Subject: yaffs: add support for tags-9bytes mount option
2
3 Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
4 ---
5 --- a/fs/yaffs2/yaffs_vfs.c
6 +++ b/fs/yaffs2/yaffs_vfs.c
7 @@ -2634,6 +2634,7 @@ static const struct super_operations yaf
8
9 struct yaffs_options {
10 int inband_tags;
11 + int tags_9bytes;
12 int skip_checkpoint_read;
13 int skip_checkpoint_write;
14 int no_cache;
15 @@ -2673,6 +2674,8 @@ static int yaffs_parse_options(struct ya
16
17 if (!strcmp(cur_opt, "inband-tags")) {
18 options->inband_tags = 1;
19 + } else if (!strcmp(cur_opt, "tags-9bytes")) {
20 + options->tags_9bytes = 1;
21 } else if (!strcmp(cur_opt, "tags-ecc-off")) {
22 options->tags_ecc_on = 0;
23 options->tags_ecc_overridden = 1;
24 @@ -2746,7 +2749,6 @@ static struct super_block *yaffs_interna
25 struct yaffs_param *param;
26
27 int read_only = 0;
28 - int inband_tags = 0;
29
30 struct yaffs_options options;
31
32 @@ -2786,6 +2788,9 @@ static struct super_block *yaffs_interna
33
34 memset(&options, 0, sizeof(options));
35
36 + if (IS_ENABLED(CONFIG_YAFFS_9BYTE_TAGS))
37 + options.tags_9bytes = 1;
38 +
39 if (yaffs_parse_options(&options, data_str)) {
40 /* Option parsing failed */
41 return NULL;
42 @@ -2819,17 +2824,22 @@ static struct super_block *yaffs_interna
43 }
44
45 /* Added NCB 26/5/2006 for completeness */
46 - if (yaffs_version == 2 && !options.inband_tags
47 - && WRITE_SIZE(mtd) == 512) {
48 + if (yaffs_version == 2 &&
49 + (!options.inband_tags || options.tags_9bytes) &&
50 + WRITE_SIZE(mtd) == 512) {
51 yaffs_trace(YAFFS_TRACE_ALWAYS, "auto selecting yaffs1");
52 yaffs_version = 1;
53 }
54
55 - if (mtd->oobavail < sizeof(struct yaffs_packed_tags2) ||
56 - options.inband_tags)
57 - inband_tags = 1;
58 + if (yaffs_version == 2 &&
59 + mtd->oobavail < sizeof(struct yaffs_packed_tags2)) {
60 + yaffs_trace(YAFFS_TRACE_ALWAYS, "auto selecting inband tags");
61 + options.inband_tags = 1;
62 + }
63
64 - if(yaffs_verify_mtd(mtd, yaffs_version, inband_tags) < 0)
65 + err = yaffs_verify_mtd(mtd, yaffs_version, options.inband_tags,
66 + options.tags_9bytes);
67 + if (err < 0)
68 return NULL;
69
70 /* OK, so if we got here, we have an MTD that's NAND and looks
71 @@ -2890,7 +2900,8 @@ static struct super_block *yaffs_interna
72
73 param->n_reserved_blocks = 5;
74 param->n_caches = (options.no_cache) ? 0 : 10;
75 - param->inband_tags = inband_tags;
76 + param->inband_tags = options.inband_tags;
77 + param->tags_9bytes = options.tags_9bytes;
78
79 param->enable_xattr = 1;
80 if (options.lazy_loading_overridden)
81 --- a/fs/yaffs2/yaffs_mtdif.c
82 +++ b/fs/yaffs2/yaffs_mtdif.c
83 @@ -16,6 +16,7 @@
84 #include "yaffs_mtdif.h"
85
86 #include "linux/mtd/mtd.h"
87 +#include "uapi/linux/major.h"
88 #include "linux/types.h"
89 #include "linux/time.h"
90 #include "linux/mtd/nand.h"
91 @@ -276,7 +277,8 @@ struct mtd_info * yaffs_get_mtd_device(d
92 return mtd;
93 }
94
95 -int yaffs_verify_mtd(struct mtd_info *mtd, int yaffs_version, int inband_tags)
96 +int yaffs_verify_mtd(struct mtd_info *mtd, int yaffs_version, int inband_tags,
97 + int tags_9bytes)
98 {
99 if (yaffs_version == 2) {
100 if ((WRITE_SIZE(mtd) < YAFFS_MIN_YAFFS2_CHUNK_SIZE ||
101 @@ -295,6 +297,12 @@ int yaffs_verify_mtd(struct mtd_info *mt
102 );
103 return -1;
104 }
105 +
106 + if (tags_9bytes && mtd->oobavail < 9) {
107 + yaffs_trace(YAFFS_TRACE_ALWAYS,
108 + "MTD device does not support 9-byte tags");
109 + return -1;
110 + }
111 }
112
113 return 0;
114 --- a/fs/yaffs2/yaffs_mtdif.h
115 +++ b/fs/yaffs2/yaffs_mtdif.h
116 @@ -21,5 +21,6 @@
117 void yaffs_mtd_drv_install(struct yaffs_dev *dev);
118 struct mtd_info * yaffs_get_mtd_device(dev_t sdev);
119 void yaffs_put_mtd_device(struct mtd_info *mtd);
120 -int yaffs_verify_mtd(struct mtd_info *mtd, int yaffs_version, int inband_tags);
121 +int yaffs_verify_mtd(struct mtd_info *mtd, int yaffs_version, int inband_tags,
122 + int tags_9bytes);
123 #endif