add patch replace-builtin_log-with-ilog2
[ext4-patch-queue.git] / add-squelch-errors-support
blobc4fd078e63879448001d92ca51185148d5794d2a
1 ext4: add option for squelching ext4 errors to prevent dmesg from filling up
3 Only print one error per inode; this is enough to know that something
4 is wrong with an inode, without filling dmesg by spamming the system
5 with messages over and over again.
7 This is enabled via sysfs option, which is currently off by default.
8 Some environments may want to turn this on by default.  Eventually we
9 may want to make this be something which is tunable by a superblock
10 flag, perhaps.
12 Addresses-Google-Bug: #2507977
14 Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
15 ---
16  fs/ext4/ext4.h  | 2 ++
17  fs/ext4/super.c | 2 ++
18  2 files changed, 4 insertions(+)
20 diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
21 index d6f57c0..88e1729 100644
22 --- a/fs/ext4/ext4.h
23 +++ b/fs/ext4/ext4.h
24 @@ -1155,6 +1155,7 @@ struct ext4_super_block {
25   */
26  #define EXT4_MF_MNTDIR_SAMPLED 0x0001
27  #define EXT4_MF_FS_ABORTED     0x0002  /* Fatal error detected */
28 +#define EXT4_MF_FS_SQUELCH     0x0004  /* Squelch file system errors */
30  /*
31   * fourth extended-fs super-block data in memory
32 @@ -1387,6 +1388,7 @@ enum {
33         EXT4_STATE_MAY_INLINE_DATA,     /* may have in-inode data */
34         EXT4_STATE_ORDERED_MODE,        /* data=ordered mode */
35         EXT4_STATE_EXT_PRECACHED,       /* extents have been precached */
36 +       EXT4_STATE_ERR_SQUELCHED,       /* squeched error */
37  };
39  #define EXT4_INODE_BIT_FNS(name, field, offset)                                \
40 diff --git a/fs/ext4/super.c b/fs/ext4/super.c
41 index bbad399..4ec18ec 100644
42 --- a/fs/ext4/super.c
43 +++ b/fs/ext4/super.c
44 @@ -2738,6 +2738,7 @@ EXT4_RW_ATTR_SBI_UI(warning_ratelimit_interval_ms, s_warning_ratelimit_state.int
45  EXT4_RW_ATTR_SBI_UI(warning_ratelimit_burst, s_warning_ratelimit_state.burst);
46  EXT4_RW_ATTR_SBI_UI(msg_ratelimit_interval_ms, s_msg_ratelimit_state.interval);
47  EXT4_RW_ATTR_SBI_UI(msg_ratelimit_burst, s_msg_ratelimit_state.burst);
48 +EXT4_RW_ATTR_SBI_BOOL(squelch_errors, s_mount_flags, EXT4_MF_FS_SQUELCH);
50  static struct attribute *ext4_attrs[] = {
51         ATTR_LIST(delayed_allocation_blocks),
52 @@ -2761,6 +2762,7 @@ static struct attribute *ext4_attrs[] = {
53         ATTR_LIST(warning_ratelimit_burst),
54         ATTR_LIST(msg_ratelimit_interval_ms),
55         ATTR_LIST(msg_ratelimit_burst),
56 +       ATTR_LIST(squelch_errors),
57         NULL,
58  };