Add missing patches (centralize-proc-functions and make-proc-generic)
[ext4-patch-queue.git] / avoid-WARN-messages.patch
blobb4005c8dff657f2ff9af298cc0b2b1d2dab87ec7
1 ext4/jbd2: Avoid WARN() messages when failing to write to the superblock
3 From: Theodore Ts'o <tytso@mit.edu>
5 This fixes some very common warnings reported by kerneloops.org
7 Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
8 diff --git a/fs/ext4/super.c b/fs/ext4/super.c
9 index 8175318..c057c6b 100644
10 --- a/fs/ext4/super.c
11 +++ b/fs/ext4/super.c
12 @@ -509,7 +509,6 @@ static void ext4_put_super(struct super_block *sb)
13 EXT4_CLEAR_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER);
14 es->s_state = cpu_to_le16(sbi->s_mount_state);
15 BUFFER_TRACE(sbi->s_sbh, "marking dirty");
16 - mark_buffer_dirty(sbi->s_sbh);
17 ext4_commit_super(sb, es, 1);
20 @@ -2810,13 +2809,34 @@ static void ext4_commit_super(struct super_block *sb,
22 if (!sbh)
23 return;
24 + if (buffer_write_io_error(sbh)) {
25 + /*
26 + * Oh, dear. A previous attempt to write the
27 + * superblock failed. This could happen because the
28 + * USB device was yanked out. Or it could happen to
29 + * be a transient write error and maybe the block will
30 + * be remapped. Nothing we can do but to retry the
31 + * write and hope for the best.
32 + */
33 + printk(KERN_ERR "ext4: previous I/O error to "
34 + "superblock detected for %s.\n", sb->s_id);
35 + clear_buffer_write_io_error(sbh);
36 + set_buffer_uptodate(sbh);
37 + }
38 es->s_wtime = cpu_to_le32(get_seconds());
39 ext4_free_blocks_count_set(es, ext4_count_free_blocks(sb));
40 es->s_free_inodes_count = cpu_to_le32(ext4_count_free_inodes(sb));
41 BUFFER_TRACE(sbh, "marking dirty");
42 mark_buffer_dirty(sbh);
43 - if (sync)
44 + if (sync) {
45 sync_dirty_buffer(sbh);
46 + if (buffer_write_io_error(sbh)) {
47 + printk(KERN_ERR "ext4: I/O error while writing "
48 + "superblock for %s.\n", sb->s_id);
49 + clear_buffer_write_io_error(sbh);
50 + set_buffer_uptodate(sbh);
51 + }
52 + }
56 diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
57 index 81186a2..01c3901 100644
58 --- a/fs/jbd2/journal.c
59 +++ b/fs/jbd2/journal.c
60 @@ -1255,6 +1255,22 @@ void jbd2_journal_update_superblock(journal_t *journal, int wait)
61 goto out;
64 + if (buffer_write_io_error(bh)) {
65 + /*
66 + * Oh, dear. A previous attempt to write the journal
67 + * superblock failed. This could happen because the
68 + * USB device was yanked out. Or it could happen to
69 + * be a transient write error and maybe the block will
70 + * be remapped. Nothing we can do but to retry the
71 + * write and hope for the best.
72 + */
73 + printk(KERN_ERR "JBD2: previous I/O error detected "
74 + "for journal superblock update for %s.\n",
75 + journal->j_devname);
76 + clear_buffer_write_io_error(bh);
77 + set_buffer_uptodate(bh);
78 + }
80 spin_lock(&journal->j_state_lock);
81 jbd_debug(1,"JBD: updating superblock (start %ld, seq %d, errno %d)\n",
82 journal->j_tail, journal->j_tail_sequence, journal->j_errno);
83 @@ -1266,9 +1282,16 @@ void jbd2_journal_update_superblock(journal_t *journal, int wait)
85 BUFFER_TRACE(bh, "marking dirty");
86 mark_buffer_dirty(bh);
87 - if (wait)
88 + if (wait) {
89 sync_dirty_buffer(bh);
90 - else
91 + if (buffer_write_io_error(bh)) {
92 + printk(KERN_ERR "JBD2: I/O error detected "
93 + "when updating journal superblock for %s.\n",
94 + journal->j_devname);
95 + clear_buffer_write_io_error(bh);
96 + set_buffer_uptodate(bh);
97 + }
98 + } else
99 ll_rw_block(SWRITE, 1, &bh);
101 out: