Commit cdbf6dba28e8e6268c8420857696309470009fd9

Authored by Eric Sandeen
Committed by Linus Torvalds
1 parent 5ec8b75e3a

ext3: avoid printk floods in the face of directory corruption

A very large directory with many read failures (either due to storage
problems, or due to invalid size & blocks from corruption) will generate a
printk storm as the filesystem continues to try to read all the blocks.
This flood of messages can tie up the box until it is complete - which may
be a very long time, especially for very large corrupted values.

This is fixed by only reporting the corruption once each time we try to
read the directory.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Cc: Eugene Teo <eugeneteo@kernel.sg>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Showing 1 changed file with 7 additions and 3 deletions Side-by-side Diff

... ... @@ -102,6 +102,7 @@
102 102 int err;
103 103 struct inode *inode = filp->f_path.dentry->d_inode;
104 104 int ret = 0;
  105 + int dir_has_error = 0;
105 106  
106 107 sb = inode->i_sb;
107 108  
... ... @@ -148,9 +149,12 @@
148 149 * of recovering data when there's a bad sector
149 150 */
150 151 if (!bh) {
151   - ext3_error (sb, "ext3_readdir",
152   - "directory #%lu contains a hole at offset %lu",
153   - inode->i_ino, (unsigned long)filp->f_pos);
  152 + if (!dir_has_error) {
  153 + ext3_error(sb, __func__, "directory #%lu "
  154 + "contains a hole at offset %lld",
  155 + inode->i_ino, filp->f_pos);
  156 + dir_has_error = 1;
  157 + }
154 158 /* corrupt size? Maybe no more blocks to read */
155 159 if (filp->f_pos > inode->i_blocks << 9)
156 160 break;