]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/3.5.1/ext4-use-proper-csum-calculation-in-ext4_rename.patch
4.9-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 3.5.1 / ext4-use-proper-csum-calculation-in-ext4_rename.patch
1 From ef58f69c3c34f6377f1e21d3533c806dbd980ad0 Mon Sep 17 00:00:00 2001
2 From: Tao Ma <boyu.mt@taobao.com>
3 Date: Mon, 9 Jul 2012 16:29:05 -0400
4 Subject: ext4: use proper csum calculation in ext4_rename
5
6 From: Tao Ma <boyu.mt@taobao.com>
7
8 commit ef58f69c3c34f6377f1e21d3533c806dbd980ad0 upstream.
9
10 In ext4_rename, when the old name is a dir, we need to
11 change ".." to its new parent and journal the change, so
12 with metadata_csum enabled, we have to re-calc the csum.
13
14 As the first block of the dir can be either a htree root
15 or a normal directory block and we have different csum
16 calculation for these 2 types, we have to choose the right
17 one in ext4_rename.
18
19 btw, it is found by xfstests 013.
20
21 Signed-off-by: Tao Ma <boyu.mt@taobao.com>
22 Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
23 Acked-by: Darrick J. Wong <djwong@us.ibm.com>
24 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
25
26 ---
27 fs/ext4/namei.c | 11 +++++++++--
28 1 file changed, 9 insertions(+), 2 deletions(-)
29
30 --- a/fs/ext4/namei.c
31 +++ b/fs/ext4/namei.c
32 @@ -2918,8 +2918,15 @@ static int ext4_rename(struct inode *old
33 PARENT_INO(dir_bh->b_data, new_dir->i_sb->s_blocksize) =
34 cpu_to_le32(new_dir->i_ino);
35 BUFFER_TRACE(dir_bh, "call ext4_handle_dirty_metadata");
36 - retval = ext4_handle_dirty_dirent_node(handle, old_inode,
37 - dir_bh);
38 + if (is_dx(old_inode)) {
39 + retval = ext4_handle_dirty_dx_node(handle,
40 + old_inode,
41 + dir_bh);
42 + } else {
43 + retval = ext4_handle_dirty_dirent_node(handle,
44 + old_inode,
45 + dir_bh);
46 + }
47 if (retval) {
48 ext4_std_error(old_dir->i_sb, retval);
49 goto end_rename;