Rebase to 74dae4278546
[ext4-patch-queue.git] / add-squelch-errors-support
blob0bb4e04f1f2c7f8c10b9fb250d90605e80cab6ef
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 fca1efb..fafa312 100644
22 --- a/fs/ext4/ext4.h
23 +++ b/fs/ext4/ext4.h
24 @@ -1203,6 +1203,7 @@ struct ext4_super_block {
25  #define EXT4_MF_MNTDIR_SAMPLED         0x0001
26  #define EXT4_MF_FS_ABORTED             0x0002  /* Fatal error detected */
27  #define EXT4_MF_TEST_DUMMY_ENCRYPTION  0x0004
28 +#define EXT4_MF_FS_SQUELCH             0x0008  /* Squelch file system errors */
30  #ifdef CONFIG_EXT4_FS_ENCRYPTION
31  #define DUMMY_ENCRYPTION_ENABLED(sbi) (unlikely((sbi)->s_mount_flags & \
32 @@ -1450,6 +1451,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 f106700..e57ce82 100644
42 --- a/fs/ext4/super.c
43 +++ b/fs/ext4/super.c
44 @@ -2750,6 +2750,7 @@ EXT4_RW_ATTR_SBI_UI(msg_ratelimit_burst, s_msg_ratelimit_state.burst);
45  EXT4_RO_ATTR_ES_UI(errors_count, s_error_count);
46  EXT4_RO_ATTR_ES_UI(first_error_time, s_first_error_time);
47  EXT4_RO_ATTR_ES_UI(last_error_time, s_last_error_time);
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 @@ -2776,6 +2777,7 @@ static struct attribute *ext4_attrs[] = {
53         ATTR_LIST(errors_count),
54         ATTR_LIST(first_error_time),
55         ATTR_LIST(last_error_time),
56 +       ATTR_LIST(squelch_errors),
57         NULL,
58  };