kernel: update 3.14 to 3.14.7
[openwrt.git] / target / linux / generic / patches-3.14 / 552-ubifs-respect-silent-mount-flag.patch
1 From 248b89b95d27659c5360ef5b68cca21d096ee909 Mon Sep 17 00:00:00 2001
2 From: Daniel Golle <daniel@makrotopia.org>
3 Date: Sat, 17 May 2014 03:16:54 +0200
4 Subject: [PATCH 3/5] ubifs: respect MS_SILENT mount flag
5 To: dedekind1@gmail.com,
6     linux-mtd@lists.infradead.org
7
8 When attempting to mount a non-ubifs formatted volume, lots of error
9 messages (including a stack dump) are thrown to the kernel log even if
10 the MS_SILENT mount flag is set.
11 Fix this by checking the MS_SILENT flag in ubifs_read_sb_node and
12 passing it down to ubifs_read_node, which now got an additional
13 parameter for that purpose.
14
15 Signed-off-by: Daniel Golle <daniel@makrotopia.org>
16 ---
17  fs/ubifs/commit.c   |  4 ++--
18  fs/ubifs/io.c       | 23 ++++++++++++++---------
19  fs/ubifs/sb.c       |  5 +++--
20  fs/ubifs/tnc_misc.c |  4 ++--
21  fs/ubifs/ubifs.h    |  2 +-
22  5 files changed, 22 insertions(+), 16 deletions(-)
23
24 --- a/fs/ubifs/commit.c
25 +++ b/fs/ubifs/commit.c
26 @@ -542,7 +542,7 @@ int dbg_old_index_check_init(struct ubif
27         if (!idx)
28                 return -ENOMEM;
29  
30 -       err = ubifs_read_node(c, idx, UBIFS_IDX_NODE, len, lnum, offs);
31 +       err = ubifs_read_node(c, idx, UBIFS_IDX_NODE, len, lnum, offs, 0);
32         if (err)
33                 goto out;
34  
35 @@ -610,7 +610,7 @@ int dbg_check_old_index(struct ubifs_inf
36                 list_add_tail(&i->list, &list);
37                 /* Read the index node */
38                 idx = &i->idx;
39 -               err = ubifs_read_node(c, idx, UBIFS_IDX_NODE, len, lnum, offs);
40 +               err = ubifs_read_node(c, idx, UBIFS_IDX_NODE, len, lnum, offs, 0);
41                 if (err)
42                         goto out_free;
43                 /* Validate index node */
44 --- a/fs/ubifs/io.c
45 +++ b/fs/ubifs/io.c
46 @@ -912,7 +912,7 @@ int ubifs_read_node_wbuf(struct ubifs_wb
47         if (!overlap) {
48                 /* We may safely unlock the write-buffer and read the data */
49                 spin_unlock(&wbuf->lock);
50 -               return ubifs_read_node(c, buf, type, len, lnum, offs);
51 +               return ubifs_read_node(c, buf, type, len, lnum, offs, 0);
52         }
53  
54         /* Don't read under wbuf */
55 @@ -966,13 +966,14 @@ out:
56   * @len: node length (not aligned)
57   * @lnum: logical eraseblock number
58   * @offs: offset within the logical eraseblock
59 + * @silent: suppress error messages
60   *
61   * This function reads a node of known type and and length, checks it and
62   * stores in @buf. Returns zero in case of success, %-EUCLEAN if CRC mismatched
63   * and a negative error code in case of failure.
64   */
65  int ubifs_read_node(const struct ubifs_info *c, void *buf, int type, int len,
66 -                   int lnum, int offs)
67 +                   int lnum, int offs, int silent)
68  {
69         int err, l;
70         struct ubifs_ch *ch = buf;
71 @@ -988,30 +989,34 @@ int ubifs_read_node(const struct ubifs_i
72                 return err;
73  
74         if (type != ch->node_type) {
75 -               ubifs_err("bad node type (%d but expected %d)",
76 +               if (!silent) ubifs_err("bad node type (%d but expected %d)",
77                           ch->node_type, type);
78                 goto out;
79         }
80  
81         err = ubifs_check_node(c, buf, lnum, offs, 0, 0);
82         if (err) {
83 -               ubifs_err("expected node type %d", type);
84 +               if (!silent)
85 +                       ubifs_err("expected node type %d", type);
86                 return err;
87         }
88  
89         l = le32_to_cpu(ch->len);
90         if (l != len) {
91 -               ubifs_err("bad node length %d, expected %d", l, len);
92 +               if (!silent)
93 +                       ubifs_err("bad node length %d, expected %d", l, len);
94                 goto out;
95         }
96  
97         return 0;
98  
99  out:
100 -       ubifs_err("bad node at LEB %d:%d, LEB mapping status %d", lnum, offs,
101 -                 ubi_is_mapped(c->ubi, lnum));
102 -       ubifs_dump_node(c, buf);
103 -       dump_stack();
104 +       if (!silent) {
105 +               ubifs_err("bad node at LEB %d:%d, LEB mapping status %d", lnum,
106 +                         offs, ubi_is_mapped(c->ubi, lnum));
107 +               ubifs_dump_node(c, buf);
108 +               dump_stack();
109 +       }
110         return -EINVAL;
111  }
112  
113 --- a/fs/ubifs/sb.c
114 +++ b/fs/ubifs/sb.c
115 @@ -493,14 +493,15 @@ failed:
116  struct ubifs_sb_node *ubifs_read_sb_node(struct ubifs_info *c)
117  {
118         struct ubifs_sb_node *sup;
119 -       int err;
120 +       int silent, err;
121  
122         sup = kmalloc(ALIGN(UBIFS_SB_NODE_SZ, c->min_io_size), GFP_NOFS);
123         if (!sup)
124                 return ERR_PTR(-ENOMEM);
125  
126 +       silent = !!(c->vfs_sb->s_flags & MS_SILENT);
127         err = ubifs_read_node(c, sup, UBIFS_SB_NODE, UBIFS_SB_NODE_SZ,
128 -                             UBIFS_SB_LNUM, 0);
129 +                             UBIFS_SB_LNUM, 0, silent);
130         if (err) {
131                 kfree(sup);
132                 return ERR_PTR(err);
133 --- a/fs/ubifs/tnc_misc.c
134 +++ b/fs/ubifs/tnc_misc.c
135 @@ -280,7 +280,7 @@ static int read_znode(struct ubifs_info
136         if (!idx)
137                 return -ENOMEM;
138  
139 -       err = ubifs_read_node(c, idx, UBIFS_IDX_NODE, len, lnum, offs);
140 +       err = ubifs_read_node(c, idx, UBIFS_IDX_NODE, len, lnum, offs, 0);
141         if (err < 0) {
142                 kfree(idx);
143                 return err;
144 @@ -472,7 +472,7 @@ int ubifs_tnc_read_node(struct ubifs_inf
145                                            zbr->lnum, zbr->offs);
146         else
147                 err = ubifs_read_node(c, node, type, zbr->len, zbr->lnum,
148 -                                     zbr->offs);
149 +                                     zbr->offs, 0);
150  
151         if (err) {
152                 dbg_tnck(key, "key ");
153 --- a/fs/ubifs/ubifs.h
154 +++ b/fs/ubifs/ubifs.h
155 @@ -1481,7 +1481,7 @@ int ubifs_wbuf_write_nolock(struct ubifs
156  int ubifs_wbuf_seek_nolock(struct ubifs_wbuf *wbuf, int lnum, int offs);
157  int ubifs_wbuf_init(struct ubifs_info *c, struct ubifs_wbuf *wbuf);
158  int ubifs_read_node(const struct ubifs_info *c, void *buf, int type, int len,
159 -                   int lnum, int offs);
160 +                   int lnum, int offs, int silent);
161  int ubifs_read_node_wbuf(struct ubifs_wbuf *wbuf, void *buf, int type, int len,
162                          int lnum, int offs);
163  int ubifs_write_node(struct ubifs_info *c, void *node, int len, int lnum,