]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/2.6.32.17/0019-ext4-Handle-non-empty-on-disk-orphan-link.patch
4.9-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 2.6.32.17 / 0019-ext4-Handle-non-empty-on-disk-orphan-link.patch
CommitLineData
7d777456
GKH
1From 7765050b0f7e5ffc9146c5cea83a14774ff03a73 Mon Sep 17 00:00:00 2001
2From: Dmitry Monakhov <dmonakhov@openvz.org>
3Date: Sun, 30 May 2010 22:49:33 -0400
4Subject: ext4: Handle non empty on-disk orphan link
5
6commit 6e3617e579e070d3655a93ee9ed7149113e795e0 upstream (as of v2.6.33-git11)
7
8In case of truncate errors we explicitly remove inode from in-core
9orphan list via orphan_del(NULL, inode) without modifying the on-disk list.
10
11But later on, the same inode may be inserted in the orphan list again
12which will result the on-disk linked list getting corrupted. If inode
13i_dtime contains valid value, then skip on-disk list modification.
14
15Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
16Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
17Signed-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