add patch verify-extent-header-depth
[ext4-patch-queue.git] / short-cut-orphan-cleanup-on-error
blob666e8600672e25fdae1ebddb6a29f80003ff96c4
1 ext4: short-cut orphan cleanup on error
3 From: Vegard Nossum <vegard.nossum@oracle.com>
5 If we encounter a filesystem error during orphan cleanup, we should stop.
6 Otherwise, we may end up in an infinite loop where the same inode is
7 processed again and again.
9     EXT4-fs (loop0): warning: checktime reached, running e2fsck is recommended
10     EXT4-fs error (device loop0): ext4_mb_generate_buddy:758: group 2, block bitmap and bg descriptor inconsistent: 6117 vs 0 free clusters
11     Aborting journal on device loop0-8.
12     EXT4-fs (loop0): Remounting filesystem read-only
13     EXT4-fs error (device loop0) in ext4_free_blocks:4895: Journal has aborted
14     EXT4-fs error (device loop0) in ext4_do_update_inode:4893: Journal has aborted
15     EXT4-fs error (device loop0) in ext4_do_update_inode:4893: Journal has aborted
16     EXT4-fs error (device loop0) in ext4_ext_remove_space:3068: IO failure
17     EXT4-fs error (device loop0) in ext4_ext_truncate:4667: Journal has aborted
18     EXT4-fs error (device loop0) in ext4_orphan_del:2927: Journal has aborted
19     EXT4-fs error (device loop0) in ext4_do_update_inode:4893: Journal has aborted
20     EXT4-fs (loop0): Inode 16 (00000000618192a0): orphan list check failed!
21     [...]
22     EXT4-fs (loop0): Inode 16 (0000000061819748): orphan list check failed!
23     [...]
24     EXT4-fs (loop0): Inode 16 (0000000061819bf0): orphan list check failed!
25     [...]
27 See-also: c9eb13a9105 ("ext4: fix hang when processing corrupted orphaned inode list")
28 Cc: Jan Kara <jack@suse.cz>
29 Signed-off-by: Vegard Nossum <vegard.nossum@oracle.com>
30 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
31 Cc: stable@vger.kernel.org
32 ---
33  fs/ext4/super.c | 10 ++++++++++
34  1 file changed, 10 insertions(+)
36 diff --git a/fs/ext4/super.c b/fs/ext4/super.c
37 index 05ec0a7..b92802d 100644
38 --- a/fs/ext4/super.c
39 +++ b/fs/ext4/super.c
40 @@ -2284,6 +2284,16 @@ static void ext4_orphan_cleanup(struct super_block *sb,
41         while (es->s_last_orphan) {
42                 struct inode *inode;
44 +               /*
45 +                * We may have encountered an error during cleanup; if
46 +                * so, skip the rest.
47 +                */
48 +               if (EXT4_SB(sb)->s_mount_state & EXT4_ERROR_FS) {
49 +                       jbd_debug(1, "Skipping orphan recovery on fs with errors.\n");
50 +                       es->s_last_orphan = 0;
51 +                       break;
52 +               }
54                 inode = ext4_orphan_get(sb, le32_to_cpu(es->s_last_orphan));
55                 if (IS_ERR(inode)) {
56                         es->s_last_orphan = 0;
57 -- 
58 1.9.1