1 Index: linux-stage/fs/ext4/ext4.h
2 ===================================================================
3 --- linux-stage.orig/fs/ext4/ext4.h 2011-05-20 11:01:37.000000000 +0300
4 +++ linux-stage/fs/ext4/ext4.h 2011-05-20 11:01:44.000000000 +0300
5 @@ -859,6 +859,7 @@ struct ext4_inode_info {
6 #define EXT4_MOUNT_QUOTA 0x80000 /* Some quota option set */
7 #define EXT4_MOUNT_USRQUOTA 0x100000 /* "old" user quota */
8 #define EXT4_MOUNT_GRPQUOTA 0x200000 /* "old" group quota */
9 +#define EXT4_MOUNT_EXTENTS 0x400000 /* Extents support */
10 #define EXT4_MOUNT_JOURNAL_CHECKSUM 0x800000 /* Journal checksums */
11 #define EXT4_MOUNT_JOURNAL_ASYNC_COMMIT 0x1000000 /* Journal Async Commit */
12 #define EXT4_MOUNT_I_VERSION 0x2000000 /* i_version support */
13 Index: linux-stage/fs/ext4/ext4_jbd2.h
14 ===================================================================
15 --- linux-stage.orig/fs/ext4/ext4_jbd2.h 2011-05-20 11:00:01.000000000 +0300
16 +++ linux-stage/fs/ext4/ext4_jbd2.h 2011-05-20 11:01:44.000000000 +0300
19 #define EXT4_SINGLEDATA_TRANS_BLOCKS(sb) \
20 (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_EXTENTS) \
22 + || test_opt(sb, EXTENTS) ? 27U : 8U)
24 #define ext4_journal_dirty_metadata(handle, bh) \
25 ext4_handle_dirty_metadata(handle, NULL, bh)
26 Index: linux-stage/fs/ext4/extents.c
27 ===================================================================
28 --- linux-stage.orig/fs/ext4/extents.c 2011-05-20 11:00:01.000000000 +0300
29 +++ linux-stage/fs/ext4/extents.c 2011-05-20 11:01:44.000000000 +0300
30 @@ -2555,7 +2555,7 @@ void ext4_ext_init(struct super_block *s
31 * possible initialization would be here
34 - if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_EXTENTS)) {
35 + if (test_opt(sb, EXTENTS)) {
36 #if defined(AGGRESSIVE_TEST) || defined(CHECK_BINSEARCH) || defined(EXTENTS_STATS)
37 printk(KERN_INFO "EXT4-fs: file extents enabled");
38 #ifdef AGGRESSIVE_TEST
39 @@ -2582,7 +2582,7 @@ void ext4_ext_init(struct super_block *s
41 void ext4_ext_release(struct super_block *sb)
43 - if (!EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_EXTENTS))
44 + if (!test_opt(sb, EXTENTS))
48 Index: linux-stage/fs/ext4/ialloc.c
49 ===================================================================
50 --- linux-stage.orig/fs/ext4/ialloc.c 2011-05-20 11:01:36.000000000 +0300
51 +++ linux-stage/fs/ext4/ialloc.c 2011-05-20 11:01:44.000000000 +0300
52 @@ -1049,7 +1049,7 @@ got:
56 - if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_EXTENTS)) {
57 + if (test_opt(sb, EXTENTS)) {
58 /* set extent flag only for directory, file and normal symlink*/
59 if (S_ISDIR(mode) || S_ISREG(mode) || S_ISLNK(mode)) {
60 ext4_set_inode_flag(inode, EXT4_INODE_EXTENTS);
61 Index: linux-stage/fs/ext4/migrate.c
62 ===================================================================
63 --- linux-stage.orig/fs/ext4/migrate.c 2011-05-20 10:59:29.000000000 +0300
64 +++ linux-stage/fs/ext4/migrate.c 2011-05-20 11:03:22.000000000 +0300
65 @@ -459,13 +459,10 @@ int ext4_ext_migrate(struct inode *inode
66 unsigned long max_entries;
70 - * If the filesystem does not support extents, or the inode
71 - * already is extent-based, error out.
73 - if (!EXT4_HAS_INCOMPAT_FEATURE(inode->i_sb,
74 - EXT4_FEATURE_INCOMPAT_EXTENTS) ||
75 - (ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS)))
76 + if (!test_opt(inode->i_sb, EXTENTS))
78 + * if mounted with noextents we don't allow the migrate
82 if (S_ISLNK(inode->i_mode) && inode->i_blocks == 0)
83 Index: linux-stage/fs/ext4/super.c
84 ===================================================================
85 --- linux-stage.orig/fs/ext4/super.c 2011-05-20 11:01:37.000000000 +0300
86 +++ linux-stage/fs/ext4/super.c 2011-05-20 11:01:44.000000000 +0300
87 @@ -945,6 +945,8 @@ static int ext4_show_options(struct seq_
88 seq_puts(seq, ",journal_async_commit");
89 if (test_opt(sb, NOBH))
90 seq_puts(seq, ",nobh");
91 + if (!test_opt(sb, EXTENTS))
92 + seq_puts(seq, ",noextents");
93 if (test_opt(sb, I_VERSION))
94 seq_puts(seq, ",i_version");
95 if (!test_opt(sb, DELALLOC))
96 @@ -1515,6 +1517,7 @@ enum {
97 Opt_inode_readahead_blks, Opt_journal_ioprio,
98 Opt_discard, Opt_nodiscard,
99 Opt_mballoc, Opt_bigendian_extents, Opt_force_over_16tb,
100 + Opt_extents, Opt_noextents,
103 static const match_table_t tokens = {
104 @@ -1589,6 +1592,8 @@ static const match_table_t tokens = {
105 {Opt_mballoc, "mballoc"},
106 {Opt_discard, "discard"},
107 {Opt_nodiscard, "nodiscard"},
108 + {Opt_extents, "extents"},
109 + {Opt_noextents, "noextents"},
113 @@ -1631,6 +1636,7 @@ static int parse_options(char *options,
117 + ext4_fsblk_t last_block;
121 @@ -2039,6 +2045,32 @@ set_qf_format:
122 case Opt_force_over_16tb:
126 + if (!EXT4_HAS_INCOMPAT_FEATURE(sb,
127 + EXT4_FEATURE_INCOMPAT_EXTENTS)) {
128 + ext4_warning(sb, "extents feature not enabled "
129 + "on this filesystem, use tune2fs");
132 + set_opt(sbi->s_mount_opt, EXTENTS);
134 + case Opt_noextents:
136 + * When e2fsprogs support resizing an already existing
137 + * ext4 file system to greater than 2**32 we need to
138 + * add support to block allocator to handle growing
139 + * already existing block mapped inode so that blocks
140 + * allocated for them fall within 2**32
142 + last_block = ext4_blocks_count(sbi->s_es) - 1;
143 + if (last_block > 0xffffffffULL) {
144 + printk(KERN_ERR "EXT4-fs: Filesystem too "
145 + "large to mount with "
146 + "-o noextents options\n");
149 + clear_opt(sbi->s_mount_opt, EXTENTS);
152 ext4_msg(sb, KERN_ERR,
153 "Unrecognized mount option \"%s\" "
154 @@ -2901,6 +2933,17 @@ static int ext4_fill_super(struct super_
155 set_opt(sbi->s_mount_opt, BARRIER);
158 + * turn on extents feature by default in ext4 filesystem
159 + * only if feature flag already set by mkfs or tune2fs.
160 + * Use -o noextents to turn it off
162 + if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_EXTENTS))
163 + set_opt(sbi->s_mount_opt, EXTENTS);
165 + ext4_warning(sb, "extents feature not enabled on this filesystem, "
169 * enable delayed allocation by default
170 * Use -o nodelalloc to turn it off