1 ext4: set EXT4_EXTENTS_FL only for directory and regular files
3 From: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
5 Also don't inherit EXT4_EXTENTS_FL from parent directory.
6 If we have a directory with extent flag set and later mount the file
7 system with -o noextents, the files created in that directory will also
8 have extent flag set but we would not have called ext4_ext_tree_init for
9 them. This will cause error later when we are verifying the extent header
11 Also we don't want to set extent flag for symlinks, char, block, fifo
14 Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
15 Acked-off-by: Eric Sandeen <sandeen@redhat.com>
16 Signed-off-by: Mingming Cao <cmm@us.ibm.com>
17 Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
19 fs/ext4/ialloc.c | 22 +++++++++++++++-------
21 2 files changed, 15 insertions(+), 8 deletions(-)
23 Index: linux-2.6.25-rc2/fs/ext4/ialloc.c
24 ===================================================================
25 --- linux-2.6.25-rc2.orig/fs/ext4/ialloc.c 2008-02-19 13:43:24.000000000 -0800
26 +++ linux-2.6.25-rc2/fs/ext4/ialloc.c 2008-02-19 13:44:11.000000000 -0800
27 @@ -702,7 +702,12 @@ got:
28 ei->i_dir_start_lookup = 0;
31 - ei->i_flags = EXT4_I(dir)->i_flags & ~EXT4_INDEX_FL;
33 + * Don't inherit extent flag from directory. We set extent flag on
34 + * newly created directory and file only if -o extent mount option is
37 + ei->i_flags = EXT4_I(dir)->i_flags & ~(EXT4_INDEX_FL|EXT4_EXTENTS_FL);
39 ei->i_flags &= ~(EXT4_IMMUTABLE_FL|EXT4_APPEND_FL);
40 /* dirsync only applies to directories */
41 @@ -745,12 +750,15 @@ got:
44 if (test_opt(sb, EXTENTS)) {
45 - EXT4_I(inode)->i_flags |= EXT4_EXTENTS_FL;
46 - ext4_ext_tree_init(handle, inode);
47 - err = ext4_update_incompat_feature(handle, sb,
48 - EXT4_FEATURE_INCOMPAT_EXTENTS);
51 + /* set extent flag only for diretory and file */
52 + if (S_ISDIR(mode) || S_ISREG(mode)) {
53 + EXT4_I(inode)->i_flags |= EXT4_EXTENTS_FL;
54 + ext4_ext_tree_init(handle, inode);
55 + err = ext4_update_incompat_feature(handle, sb,
56 + EXT4_FEATURE_INCOMPAT_EXTENTS);
62 ext4_debug("allocating inode %lu\n", inode->i_ino);
63 Index: linux-2.6.25-rc2/fs/ext4/namei.c
64 ===================================================================
65 --- linux-2.6.25-rc2.orig/fs/ext4/namei.c 2008-02-19 13:43:24.000000000 -0800
66 +++ linux-2.6.25-rc2/fs/ext4/namei.c 2008-02-19 13:44:11.000000000 -0800
67 @@ -2220,7 +2220,6 @@ retry:
68 inode->i_op = &ext4_fast_symlink_inode_operations;
69 memcpy((char*)&EXT4_I(inode)->i_data,symname,l);
71 - EXT4_I(inode)->i_flags &= ~EXT4_EXTENTS_FL;
73 EXT4_I(inode)->i_disksize = inode->i_size;
74 err = ext4_add_nondir(handle, dentry, inode);