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
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.
15 Signed-off-by: Daniel Golle <daniel@makrotopia.org>
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(-)
24 diff --git a/fs/ubifs/commit.c b/fs/ubifs/commit.c
25 index ff82293..865d13f 100644
26 --- a/fs/ubifs/commit.c
27 +++ b/fs/ubifs/commit.c
28 @@ -542,7 +542,7 @@ int dbg_old_index_check_init(struct ubifs_info *c, struct ubifs_zbranch *zroot)
32 - err = ubifs_read_node(c, idx, UBIFS_IDX_NODE, len, lnum, offs);
33 + err = ubifs_read_node(c, idx, UBIFS_IDX_NODE, len, lnum, offs, 0);
37 @@ -610,7 +610,7 @@ int dbg_check_old_index(struct ubifs_info *c, struct ubifs_zbranch *zroot)
38 list_add_tail(&i->list, &list);
39 /* Read the index node */
41 - err = ubifs_read_node(c, idx, UBIFS_IDX_NODE, len, lnum, offs);
42 + err = ubifs_read_node(c, idx, UBIFS_IDX_NODE, len, lnum, offs, 0);
45 /* Validate index node */
46 diff --git a/fs/ubifs/io.c b/fs/ubifs/io.c
47 index e18b988..51c4072 100644
50 @@ -912,7 +912,7 @@ int ubifs_read_node_wbuf(struct ubifs_wbuf *wbuf, void *buf, int type, int len,
52 /* We may safely unlock the write-buffer and read the data */
53 spin_unlock(&wbuf->lock);
54 - return ubifs_read_node(c, buf, type, len, lnum, offs);
55 + return ubifs_read_node(c, buf, type, len, lnum, offs, 0);
58 /* Don't read under wbuf */
59 @@ -966,13 +966,14 @@ out:
60 * @len: node length (not aligned)
61 * @lnum: logical eraseblock number
62 * @offs: offset within the logical eraseblock
63 + * @silent: suppress error messages
65 * This function reads a node of known type and and length, checks it and
66 * stores in @buf. Returns zero in case of success, %-EUCLEAN if CRC mismatched
67 * and a negative error code in case of failure.
69 int ubifs_read_node(const struct ubifs_info *c, void *buf, int type, int len,
71 + int lnum, int offs, int silent)
74 struct ubifs_ch *ch = buf;
75 @@ -988,30 +989,34 @@ int ubifs_read_node(const struct ubifs_info *c, void *buf, int type, int len,
78 if (type != ch->node_type) {
79 - ubifs_err("bad node type (%d but expected %d)",
80 + if (!silent) ubifs_err("bad node type (%d but expected %d)",
85 err = ubifs_check_node(c, buf, lnum, offs, 0, 0);
87 - ubifs_err("expected node type %d", type);
89 + ubifs_err("expected node type %d", type);
93 l = le32_to_cpu(ch->len);
95 - ubifs_err("bad node length %d, expected %d", l, len);
97 + ubifs_err("bad node length %d, expected %d", l, len);
104 - ubifs_err("bad node at LEB %d:%d, LEB mapping status %d", lnum, offs,
105 - ubi_is_mapped(c->ubi, lnum));
106 - ubifs_dump_node(c, buf);
109 + ubifs_err("bad node at LEB %d:%d, LEB mapping status %d", lnum,
110 + offs, ubi_is_mapped(c->ubi, lnum));
111 + ubifs_dump_node(c, buf);
117 diff --git a/fs/ubifs/sb.c b/fs/ubifs/sb.c
118 index 4c37607..b46847d 100644
121 @@ -482,14 +482,15 @@ failed:
122 struct ubifs_sb_node *ubifs_read_sb_node(struct ubifs_info *c)
124 struct ubifs_sb_node *sup;
128 sup = kmalloc(ALIGN(UBIFS_SB_NODE_SZ, c->min_io_size), GFP_NOFS);
130 return ERR_PTR(-ENOMEM);
132 + silent = !!(c->vfs_sb->s_flags & MS_SILENT);
133 err = ubifs_read_node(c, sup, UBIFS_SB_NODE, UBIFS_SB_NODE_SZ,
135 + UBIFS_SB_LNUM, 0, silent);
139 diff --git a/fs/ubifs/tnc_misc.c b/fs/ubifs/tnc_misc.c
140 index f6bf899..e128689 100644
141 --- a/fs/ubifs/tnc_misc.c
142 +++ b/fs/ubifs/tnc_misc.c
143 @@ -280,7 +280,7 @@ static int read_znode(struct ubifs_info *c, int lnum, int offs, int len,
147 - err = ubifs_read_node(c, idx, UBIFS_IDX_NODE, len, lnum, offs);
148 + err = ubifs_read_node(c, idx, UBIFS_IDX_NODE, len, lnum, offs, 0);
152 @@ -472,7 +472,7 @@ int ubifs_tnc_read_node(struct ubifs_info *c, struct ubifs_zbranch *zbr,
153 zbr->lnum, zbr->offs);
155 err = ubifs_read_node(c, node, type, zbr->len, zbr->lnum,
160 dbg_tnck(key, "key ");
161 diff --git a/fs/ubifs/ubifs.h b/fs/ubifs/ubifs.h
162 index e8c8cfe..85fdd11 100644
163 --- a/fs/ubifs/ubifs.h
164 +++ b/fs/ubifs/ubifs.h
165 @@ -1481,7 +1481,7 @@ int ubifs_wbuf_write_nolock(struct ubifs_wbuf *wbuf, void *buf, int len);
166 int ubifs_wbuf_seek_nolock(struct ubifs_wbuf *wbuf, int lnum, int offs);
167 int ubifs_wbuf_init(struct ubifs_info *c, struct ubifs_wbuf *wbuf);
168 int ubifs_read_node(const struct ubifs_info *c, void *buf, int type, int len,
169 - int lnum, int offs);
170 + int lnum, int offs, int silent);
171 int ubifs_read_node_wbuf(struct ubifs_wbuf *wbuf, void *buf, int type, int len,
173 int ubifs_write_node(struct ubifs_info *c, void *node, int len, int lnum,