kernel: replace a ubifs patch by upstream commit
[openwrt.git] / target / linux / generic / patches-3.10 / 552-ubifs-respect-silent-mount-flag.patch
1 From 90bea5a3f0bf680b87b90516f3c231997f4b8f3b Mon Sep 17 00:00:00 2001
2 From: Daniel Golle <daniel@makrotopia.org>
3 Date: Mon, 2 Jun 2014 15:51:10 +0200
4 X-Git-Url: http://git.infradead.org/linux-ubifs.git/commitdiff_plain/90bea5a3f0bf680b87b90516f3c231997f4b8f3b
5 X-Git-Url: https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/commit/?id=90bea5a3f0bf680b87b90516f3c231997f4b8f3b
6 Subject: UBIFS: respect MS_SILENT mount flag
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 introducing adding an additional state-variable in
12 struct ubifs_info and suppress error messages in ubifs_read_node if
13 MS_SILENT is set.
14
15 Signed-off-by: Daniel Golle <daniel@makrotopia.org>
16 Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
17 ---
18  fs/ubifs/io.c    | 18 ++++++++++--------
19  fs/ubifs/super.c |  5 +++++
20  fs/ubifs/ubifs.h | 11 +++++++++++
21  3 files changed, 26 insertions(+), 8 deletions(-)
22
23 ---
24
25 diff --git a/fs/ubifs/io.c b/fs/ubifs/io.c
26 index e18b988..2290d58 100644
27 --- a/fs/ubifs/io.c
28 +++ b/fs/ubifs/io.c
29 @@ -988,30 +988,32 @@ int ubifs_read_node(const struct ubifs_info *c, void *buf, int type, int len,
30                 return err;
31  
32         if (type != ch->node_type) {
33 -               ubifs_err("bad node type (%d but expected %d)",
34 -                         ch->node_type, type);
35 +               ubifs_errc(c, "bad node type (%d but expected %d)",
36 +                          ch->node_type, type);
37                 goto out;
38         }
39  
40         err = ubifs_check_node(c, buf, lnum, offs, 0, 0);
41         if (err) {
42 -               ubifs_err("expected node type %d", type);
43 +               ubifs_errc(c, "expected node type %d", type);
44                 return err;
45         }
46  
47         l = le32_to_cpu(ch->len);
48         if (l != len) {
49 -               ubifs_err("bad node length %d, expected %d", l, len);
50 +               ubifs_errc(c, "bad node length %d, expected %d", l, len);
51                 goto out;
52         }
53  
54         return 0;
55  
56  out:
57 -       ubifs_err("bad node at LEB %d:%d, LEB mapping status %d", lnum, offs,
58 -                 ubi_is_mapped(c->ubi, lnum));
59 -       ubifs_dump_node(c, buf);
60 -       dump_stack();
61 +       ubifs_errc(c, "bad node at LEB %d:%d, LEB mapping status %d", lnum,
62 +                  offs, ubi_is_mapped(c->ubi, lnum));
63 +       if (!c->probing) {
64 +               ubifs_dump_node(c, buf);
65 +               dump_stack();
66 +       }
67         return -EINVAL;
68  }
69  
70 diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c
71 index a81c7b5..3904c85 100644
72 --- a/fs/ubifs/super.c
73 +++ b/fs/ubifs/super.c
74 @@ -1149,6 +1149,9 @@ static int mount_ubifs(struct ubifs_info *c)
75         size_t sz;
76  
77         c->ro_mount = !!(c->vfs_sb->s_flags & MS_RDONLY);
78 +       /* Suppress error messages while probing if MS_SILENT is set */
79 +       c->probing = !!(c->vfs_sb->s_flags & MS_SILENT);
80 +
81         err = init_constants_early(c);
82         if (err)
83                 return err;
84 @@ -1214,6 +1217,8 @@ static int mount_ubifs(struct ubifs_info *c)
85         if (err)
86                 goto out_free;
87  
88 +       c->probing = 0;
89 +
90         /*
91          * Make sure the compressor which is set as default in the superblock
92          * or overridden by mount options is actually compiled in.
93 diff --git a/fs/ubifs/ubifs.h b/fs/ubifs/ubifs.h
94 index e8c8cfe..c1f71fe 100644
95 --- a/fs/ubifs/ubifs.h
96 +++ b/fs/ubifs/ubifs.h
97 @@ -51,6 +51,15 @@
98  #define ubifs_warn(fmt, ...)                                        \
99         pr_warn("UBIFS warning (pid %d): %s: " fmt "\n",            \
100                 current->pid, __func__, ##__VA_ARGS__)
101 +/*
102 + * A variant of 'ubifs_err()' which takes the UBIFS file-sytem description
103 + * object as an argument.
104 + */
105 +#define ubifs_errc(c, fmt, ...)                                     \
106 +       do {                                                        \
107 +               if (!(c)->probing)                                  \
108 +                       ubifs_err(fmt, ##__VA_ARGS__);              \
109 +       } while (0)
110  
111  /* UBIFS file system VFS magic number */
112  #define UBIFS_SUPER_MAGIC 0x24051905
113 @@ -1209,6 +1218,7 @@ struct ubifs_debug_info;
114   * @need_recovery: %1 if the file-system needs recovery
115   * @replaying: %1 during journal replay
116   * @mounting: %1 while mounting
117 + * @probing: %1 while attempting to mount if MS_SILENT mount flag is set
118   * @remounting_rw: %1 while re-mounting from R/O mode to R/W mode
119   * @replay_list: temporary list used during journal replay
120   * @replay_buds: list of buds to replay
121 @@ -1441,6 +1451,7 @@ struct ubifs_info {
122         unsigned int replaying:1;
123         unsigned int mounting:1;
124         unsigned int remounting_rw:1;
125 +       unsigned int probing:1;
126         struct list_head replay_list;
127         struct list_head replay_buds;
128         unsigned long long cs_sqnum;