From: Daniel Golle <daniel@makrotopia.org>
To: dedekind1@gmail.com, linux-mtd@lists.infradead.org
Subject: [PATCH] ubifs: respect MS_SILENT mount flag
Date: Sat, 17 May 2014 03:55:50 +0200 [thread overview]
Message-ID: <20140517015541.GA6399@earthship.local> (raw)
[-- Attachment #1: Type: text/plain, Size: 5735 bytes --]
When attempting to mount a non-ubifs formatted volume, lots of error
messages (including a stack dump) are thrown to the kernel log even if
the MS_SILENT mount flag is set.
Fix this by introducing an additional parameter in ubifs_read_node and
use it to pass down the MS_SILENT flag in ubifs_read_sb_node.
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
---
fs/ubifs/commit.c | 4 ++--
fs/ubifs/io.c | 23 ++++++++++++++---------
fs/ubifs/sb.c | 5 +++--
fs/ubifs/tnc_misc.c | 4 ++--
fs/ubifs/ubifs.h | 2 +-
5 files changed, 22 insertions(+), 16 deletions(-)
diff --git a/fs/ubifs/commit.c b/fs/ubifs/commit.c
index ff82293..865d13f 100644
--- a/fs/ubifs/commit.c
+++ b/fs/ubifs/commit.c
@@ -542,7 +542,7 @@ int dbg_old_index_check_init(struct ubifs_info *c, struct ubifs_zbranch *zroot)
if (!idx)
return -ENOMEM;
- err = ubifs_read_node(c, idx, UBIFS_IDX_NODE, len, lnum, offs);
+ err = ubifs_read_node(c, idx, UBIFS_IDX_NODE, len, lnum, offs, 0);
if (err)
goto out;
@@ -610,7 +610,7 @@ int dbg_check_old_index(struct ubifs_info *c, struct ubifs_zbranch *zroot)
list_add_tail(&i->list, &list);
/* Read the index node */
idx = &i->idx;
- err = ubifs_read_node(c, idx, UBIFS_IDX_NODE, len, lnum, offs);
+ err = ubifs_read_node(c, idx, UBIFS_IDX_NODE, len, lnum, offs, 0);
if (err)
goto out_free;
/* Validate index node */
diff --git a/fs/ubifs/io.c b/fs/ubifs/io.c
index e18b988..51c4072 100644
--- a/fs/ubifs/io.c
+++ b/fs/ubifs/io.c
@@ -912,7 +912,7 @@ int ubifs_read_node_wbuf(struct ubifs_wbuf *wbuf, void *buf, int type, int len,
if (!overlap) {
/* We may safely unlock the write-buffer and read the data */
spin_unlock(&wbuf->lock);
- return ubifs_read_node(c, buf, type, len, lnum, offs);
+ return ubifs_read_node(c, buf, type, len, lnum, offs, 0);
}
/* Don't read under wbuf */
@@ -966,13 +966,14 @@ out:
* @len: node length (not aligned)
* @lnum: logical eraseblock number
* @offs: offset within the logical eraseblock
+ * @silent: suppress error messages
*
* This function reads a node of known type and and length, checks it and
* stores in @buf. Returns zero in case of success, %-EUCLEAN if CRC mismatched
* and a negative error code in case of failure.
*/
int ubifs_read_node(const struct ubifs_info *c, void *buf, int type, int len,
- int lnum, int offs)
+ int lnum, int offs, int silent)
{
int err, l;
struct ubifs_ch *ch = buf;
@@ -988,30 +989,34 @@ int ubifs_read_node(const struct ubifs_info *c, void *buf, int type, int len,
return err;
if (type != ch->node_type) {
- ubifs_err("bad node type (%d but expected %d)",
+ if (!silent) ubifs_err("bad node type (%d but expected %d)",
ch->node_type, type);
goto out;
}
err = ubifs_check_node(c, buf, lnum, offs, 0, 0);
if (err) {
- ubifs_err("expected node type %d", type);
+ if (!silent)
+ ubifs_err("expected node type %d", type);
return err;
}
l = le32_to_cpu(ch->len);
if (l != len) {
- ubifs_err("bad node length %d, expected %d", l, len);
+ if (!silent)
+ ubifs_err("bad node length %d, expected %d", l, len);
goto out;
}
return 0;
out:
- ubifs_err("bad node at LEB %d:%d, LEB mapping status %d", lnum, offs,
- ubi_is_mapped(c->ubi, lnum));
- ubifs_dump_node(c, buf);
- dump_stack();
+ if (!silent) {
+ ubifs_err("bad node at LEB %d:%d, LEB mapping status %d", lnum,
+ offs, ubi_is_mapped(c->ubi, lnum));
+ ubifs_dump_node(c, buf);
+ dump_stack();
+ }
return -EINVAL;
}
diff --git a/fs/ubifs/sb.c b/fs/ubifs/sb.c
index 4c37607..b46847d 100644
--- a/fs/ubifs/sb.c
+++ b/fs/ubifs/sb.c
@@ -482,14 +482,15 @@ failed:
struct ubifs_sb_node *ubifs_read_sb_node(struct ubifs_info *c)
{
struct ubifs_sb_node *sup;
- int err;
+ int silent, err;
sup = kmalloc(ALIGN(UBIFS_SB_NODE_SZ, c->min_io_size), GFP_NOFS);
if (!sup)
return ERR_PTR(-ENOMEM);
+ silent = !!(c->vfs_sb->s_flags & MS_SILENT);
err = ubifs_read_node(c, sup, UBIFS_SB_NODE, UBIFS_SB_NODE_SZ,
- UBIFS_SB_LNUM, 0);
+ UBIFS_SB_LNUM, 0, silent);
if (err) {
kfree(sup);
return ERR_PTR(err);
diff --git a/fs/ubifs/tnc_misc.c b/fs/ubifs/tnc_misc.c
index f6bf899..e128689 100644
--- a/fs/ubifs/tnc_misc.c
+++ b/fs/ubifs/tnc_misc.c
@@ -280,7 +280,7 @@ static int read_znode(struct ubifs_info *c, int lnum, int offs, int len,
if (!idx)
return -ENOMEM;
- err = ubifs_read_node(c, idx, UBIFS_IDX_NODE, len, lnum, offs);
+ err = ubifs_read_node(c, idx, UBIFS_IDX_NODE, len, lnum, offs, 0);
if (err < 0) {
kfree(idx);
return err;
@@ -472,7 +472,7 @@ int ubifs_tnc_read_node(struct ubifs_info *c, struct ubifs_zbranch *zbr,
zbr->lnum, zbr->offs);
else
err = ubifs_read_node(c, node, type, zbr->len, zbr->lnum,
- zbr->offs);
+ zbr->offs, 0);
if (err) {
dbg_tnck(key, "key ");
diff --git a/fs/ubifs/ubifs.h b/fs/ubifs/ubifs.h
index e8c8cfe..85fdd11 100644
--- a/fs/ubifs/ubifs.h
+++ b/fs/ubifs/ubifs.h
@@ -1481,7 +1481,7 @@ int ubifs_wbuf_write_nolock(struct ubifs_wbuf *wbuf, void *buf, int len);
int ubifs_wbuf_seek_nolock(struct ubifs_wbuf *wbuf, int lnum, int offs);
int ubifs_wbuf_init(struct ubifs_info *c, struct ubifs_wbuf *wbuf);
int ubifs_read_node(const struct ubifs_info *c, void *buf, int type, int len,
- int lnum, int offs);
+ int lnum, int offs, int silent);
int ubifs_read_node_wbuf(struct ubifs_wbuf *wbuf, void *buf, int type, int len,
int lnum, int offs);
int ubifs_write_node(struct ubifs_info *c, void *node, int len, int lnum,
--
1.9.2
[-- Attachment #2: Type: application/pgp-signature, Size: 490 bytes --]
next reply other threads:[~2014-05-17 1:56 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-17 1:55 Daniel Golle [this message]
2014-05-27 12:18 ` [PATCH] ubifs: respect MS_SILENT mount flag Artem Bityutskiy
2014-05-27 14:11 ` [PATCH v2] " Daniel Golle
2014-05-27 14:56 ` Artem Bityutskiy
2014-05-27 16:04 ` Daniel
2014-05-28 2:11 ` hujianyang
2014-05-28 8:01 ` Artem Bityutskiy
2014-05-28 8:07 ` Bityutskiy, Artem
2014-05-28 8:14 ` Artem Bityutskiy
2014-05-28 8:28 ` Artem Bityutskiy
2014-05-28 8:42 ` hujianyang
2014-05-28 9:29 ` Artem Bityutskiy
2014-05-30 22:01 ` [PATCH v3] " Daniel Golle
2014-05-30 23:20 ` Brian Norris
2014-05-30 23:32 ` [PATCH v4] " Daniel Golle
2014-05-31 0:01 ` [PATCH v5] " Daniel Golle
2014-06-02 7:59 ` Artem Bityutskiy
2014-06-02 13:51 ` [PATCH v6] " Daniel Golle
2014-06-02 15:01 ` Artem Bityutskiy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140517015541.GA6399@earthship.local \
--to=daniel@makrotopia.org \
--cc=dedekind1@gmail.com \
--cc=linux-mtd@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.