]>
Commit | Line | Data |
---|---|---|
7d777456 GKH |
1 | From 7765050b0f7e5ffc9146c5cea83a14774ff03a73 Mon Sep 17 00:00:00 2001 |
2 | From: Dmitry Monakhov <dmonakhov@openvz.org> | |
3 | Date: Sun, 30 May 2010 22:49:33 -0400 | |
4 | Subject: ext4: Handle non empty on-disk orphan link | |
5 | ||
6 | commit 6e3617e579e070d3655a93ee9ed7149113e795e0 upstream (as of v2.6.33-git11) | |
7 | ||
8 | In case of truncate errors we explicitly remove inode from in-core | |
9 | orphan list via orphan_del(NULL, inode) without modifying the on-disk list. | |
10 | ||
11 | But later on, the same inode may be inserted in the orphan list again | |
12 | which will result the on-disk linked list getting corrupted. If inode | |
13 | i_dtime contains valid value, then skip on-disk list modification. | |
14 | ||
15 | Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org> | |
16 | Signed-off-by: "Theodore Ts'o" <tytso@mit.edu> | |
17 | Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> | |
18 | --- | |
19 | fs/ext4/namei.c | 8 ++++++++ | |
20 | 1 file changed, 8 insertions(+) | |
21 | ||
22 | --- a/fs/ext4/namei.c | |
23 | +++ b/fs/ext4/namei.c | |
24 | @@ -2020,6 +2020,13 @@ int ext4_orphan_add(handle_t *handle, st | |
25 | err = ext4_reserve_inode_write(handle, inode, &iloc); | |
26 | if (err) | |
27 | goto out_unlock; | |
28 | + /* | |
29 | + * Due to previous errors inode may be already a part of on-disk | |
30 | + * orphan list. If so skip on-disk list modification. | |
31 | + */ | |
32 | + if (NEXT_ORPHAN(inode) && NEXT_ORPHAN(inode) <= | |
33 | + (le32_to_cpu(EXT4_SB(sb)->s_es->s_inodes_count))) | |
34 | + goto mem_insert; | |
35 | ||
36 | /* Insert this inode at the head of the on-disk orphan list... */ | |
37 | NEXT_ORPHAN(inode) = le32_to_cpu(EXT4_SB(sb)->s_es->s_last_orphan); | |
38 | @@ -2037,6 +2044,7 @@ int ext4_orphan_add(handle_t *handle, st | |
39 | * | |
40 | * This is safe: on error we're going to ignore the orphan list | |
41 | * anyway on the next recovery. */ | |
42 | +mem_insert: | |
43 | if (!err) | |
44 | list_add(&EXT4_I(inode)->i_orphan, &EXT4_SB(sb)->s_orphan); | |
45 |