kernel: update 3.14 to 3.14.8
[openwrt.git] / target / linux / generic / patches-3.14 / 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 --- a/fs/ubifs/io.c
26 +++ b/fs/ubifs/io.c
27 @@ -988,30 +988,32 @@ int ubifs_read_node(const struct ubifs_i
28                 return err;
29  
30         if (type != ch->node_type) {
31 -               ubifs_err("bad node type (%d but expected %d)",
32 -                         ch->node_type, type);
33 +               ubifs_errc(c, "bad node type (%d but expected %d)",
34 +                          ch->node_type, type);
35                 goto out;
36         }
37  
38         err = ubifs_check_node(c, buf, lnum, offs, 0, 0);
39         if (err) {
40 -               ubifs_err("expected node type %d", type);
41 +               ubifs_errc(c, "expected node type %d", type);
42                 return err;
43         }
44  
45         l = le32_to_cpu(ch->len);
46         if (l != len) {
47 -               ubifs_err("bad node length %d, expected %d", l, len);
48 +               ubifs_errc(c, "bad node length %d, expected %d", l, len);
49                 goto out;
50         }
51  
52         return 0;
53  
54  out:
55 -       ubifs_err("bad node at LEB %d:%d, LEB mapping status %d", lnum, offs,
56 -                 ubi_is_mapped(c->ubi, lnum));
57 -       ubifs_dump_node(c, buf);
58 -       dump_stack();
59 +       ubifs_errc(c, "bad node at LEB %d:%d, LEB mapping status %d", lnum,
60 +                  offs, ubi_is_mapped(c->ubi, lnum));
61 +       if (!c->probing) {
62 +               ubifs_dump_node(c, buf);
63 +               dump_stack();
64 +       }
65         return -EINVAL;
66  }
67  
68 --- a/fs/ubifs/super.c
69 +++ b/fs/ubifs/super.c
70 @@ -1149,6 +1149,9 @@ static int mount_ubifs(struct ubifs_info
71         size_t sz;
72  
73         c->ro_mount = !!(c->vfs_sb->s_flags & MS_RDONLY);
74 +       /* Suppress error messages while probing if MS_SILENT is set */
75 +       c->probing = !!(c->vfs_sb->s_flags & MS_SILENT);
76 +
77         err = init_constants_early(c);
78         if (err)
79                 return err;
80 @@ -1214,6 +1217,8 @@ static int mount_ubifs(struct ubifs_info
81         if (err)
82                 goto out_free;
83  
84 +       c->probing = 0;
85 +
86         /*
87          * Make sure the compressor which is set as default in the superblock
88          * or overridden by mount options is actually compiled in.
89 --- a/fs/ubifs/ubifs.h
90 +++ b/fs/ubifs/ubifs.h
91 @@ -51,6 +51,15 @@
92  #define ubifs_warn(fmt, ...)                                        \
93         pr_warn("UBIFS warning (pid %d): %s: " fmt "\n",            \
94                 current->pid, __func__, ##__VA_ARGS__)
95 +/*
96 + * A variant of 'ubifs_err()' which takes the UBIFS file-sytem description
97 + * object as an argument.
98 + */
99 +#define ubifs_errc(c, fmt, ...)                                     \
100 +       do {                                                        \
101 +               if (!(c)->probing)                                  \
102 +                       ubifs_err(fmt, ##__VA_ARGS__);              \
103 +       } while (0)
104  
105  /* UBIFS file system VFS magic number */
106  #define UBIFS_SUPER_MAGIC 0x24051905
107 @@ -1209,6 +1218,7 @@ struct ubifs_debug_info;
108   * @need_recovery: %1 if the file-system needs recovery
109   * @replaying: %1 during journal replay
110   * @mounting: %1 while mounting
111 + * @probing: %1 while attempting to mount if MS_SILENT mount flag is set
112   * @remounting_rw: %1 while re-mounting from R/O mode to R/W mode
113   * @replay_list: temporary list used during journal replay
114   * @replay_buds: list of buds to replay
115 @@ -1441,6 +1451,7 @@ struct ubifs_info {
116         unsigned int replaying:1;
117         unsigned int mounting:1;
118         unsigned int remounting_rw:1;
119 +       unsigned int probing:1;
120         struct list_head replay_list;
121         struct list_head replay_buds;
122         unsigned long long cs_sqnum;