+++ /dev/null
-Index: linux-3.0.101-0.5/fs/ext4/ext4.h
-===================================================================
---- linux-3.0.101-0.5.orig/fs/ext4/ext4.h
-+++ linux-3.0.101-0.5/fs/ext4/ext4.h
-@@ -911,6 +911,7 @@ struct ext4_inode_info {
- #define EXT4_MOUNT_POSIX_ACL 0x08000 /* POSIX Access Control Lists */
- #define EXT4_MOUNT_NO_AUTO_DA_ALLOC 0x10000 /* No auto delalloc mapping */
- #define EXT4_MOUNT_BARRIER 0x20000 /* Use block barriers */
-+#define EXT4_MOUNT_EXTENTS 0x40000 /* Extents support */
- #define EXT4_MOUNT_QUOTA 0x80000 /* Some quota option set */
- #define EXT4_MOUNT_USRQUOTA 0x100000 /* "old" user quota */
- #define EXT4_MOUNT_GRPQUOTA 0x200000 /* "old" group quota */
-Index: linux-3.0.101-0.5/fs/ext4/ext4_jbd2.h
-===================================================================
---- linux-3.0.101-0.5.orig/fs/ext4/ext4_jbd2.h
-+++ linux-3.0.101-0.5/fs/ext4/ext4_jbd2.h
-@@ -33,7 +33,7 @@
-
- #define EXT4_SINGLEDATA_TRANS_BLOCKS(sb) \
- (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_EXTENTS) \
-- ? 27U : 8U)
-+ || test_opt(sb, EXTENTS) ? 27U : 8U)
-
- /* Extended attribute operations touch at most two data buffers,
- * two bitmap buffers, and two group summaries, in addition to the inode
-Index: linux-3.0.101-0.5/fs/ext4/extents.c
-===================================================================
---- linux-3.0.101-0.5.orig/fs/ext4/extents.c
-+++ linux-3.0.101-0.5/fs/ext4/extents.c
-@@ -2751,7 +2751,7 @@ void ext4_ext_init(struct super_block *s
- * possible initialization would be here
- */
-
-- if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_EXTENTS)) {
-+ if (test_opt(sb, EXTENTS)) {
- #if defined(AGGRESSIVE_TEST) || defined(CHECK_BINSEARCH) || defined(EXTENTS_STATS)
- printk(KERN_INFO "EXT4-fs: file extents enabled");
- #ifdef AGGRESSIVE_TEST
-@@ -2778,7 +2778,7 @@ void ext4_ext_init(struct super_block *s
- */
- void ext4_ext_release(struct super_block *sb)
- {
-- if (!EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_EXTENTS))
-+ if (!test_opt(sb, EXTENTS))
- return;
-
- #ifdef EXTENTS_STATS
-Index: linux-3.0.101-0.5/fs/ext4/ialloc.c
-===================================================================
---- linux-3.0.101-0.5.orig/fs/ext4/ialloc.c
-+++ linux-3.0.101-0.5/fs/ext4/ialloc.c
-@@ -1054,7 +1054,7 @@ got:
- if (err)
- goto fail_free_drop;
-
-- if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_EXTENTS)) {
-+ if (test_opt(sb, EXTENTS)) {
- /* set extent flag only for directory, file and normal symlink*/
- if (S_ISDIR(mode) || S_ISREG(mode) || S_ISLNK(mode)) {
- ext4_set_inode_flag(inode, EXT4_INODE_EXTENTS);
-Index: linux-3.0.101-0.5/fs/ext4/migrate.c
-===================================================================
---- linux-3.0.101-0.5.orig/fs/ext4/migrate.c
-+++ linux-3.0.101-0.5/fs/ext4/migrate.c
-@@ -469,13 +469,10 @@ int ext4_ext_migrate(struct inode *inode
- unsigned long max_entries;
- __u32 goal;
-
-- /*
-- * If the filesystem does not support extents, or the inode
-- * already is extent-based, error out.
-- */
-- if (!EXT4_HAS_INCOMPAT_FEATURE(inode->i_sb,
-- EXT4_FEATURE_INCOMPAT_EXTENTS) ||
-- (ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS)))
-+ if (!test_opt(inode->i_sb, EXTENTS))
-+ /*
-+ * if mounted with noextents we don't allow the migrate
-+ */
- return -EINVAL;
-
- if (S_ISLNK(inode->i_mode) && inode->i_blocks == 0)
-Index: linux-3.0.101-0.5/fs/ext4/super.c
-===================================================================
---- linux-3.0.101-0.5.orig/fs/ext4/super.c
-+++ linux-3.0.101-0.5/fs/ext4/super.c
-@@ -1128,6 +1128,8 @@ static int ext4_show_options(struct seq_
- seq_puts(seq, ",journal_async_commit");
- else if (test_opt(sb, JOURNAL_CHECKSUM))
- seq_puts(seq, ",journal_checksum");
-+ if (!test_opt(sb, EXTENTS))
-+ seq_puts(seq, ",noextents");
- if (test_opt(sb, I_VERSION))
- seq_puts(seq, ",i_version");
- if (!test_opt(sb, DELALLOC) &&
-@@ -1369,6 +1371,7 @@ enum {
- Opt_inode_readahead_blks, Opt_journal_ioprio,
- Opt_dioread_nolock, Opt_dioread_lock,
- Opt_mballoc, Opt_bigendian_extents, Opt_force_over_128tb,
-+ Opt_extents, Opt_noextents,
- Opt_discard, Opt_nodiscard, Opt_init_itable, Opt_noinit_itable,
- };
-
-@@ -1446,6 +1449,8 @@ static const match_table_t tokens = {
- {Opt_bigendian_extents, "bigendian_extents"},
- {Opt_force_over_128tb, "force_over_128tb"},
- {Opt_mballoc, "mballoc"},
-+ {Opt_extents, "extents"},
-+ {Opt_noextents, "noextents"},
- {Opt_discard, "discard"},
- {Opt_nodiscard, "nodiscard"},
- {Opt_init_itable, "init_itable=%u"},
-@@ -1538,6 +1543,7 @@ static int clear_qf_name(struct super_bl
- return 1;
- }
- #endif
-+ ext4_fsblk_t last_block;
-
- static int parse_options(char *options, struct super_block *sb,
- unsigned long *journal_devnum,
-@@ -1953,6 +1959,32 @@ set_qf_format:
- case Opt_force_over_128tb:
- force_over_128tb = 1;
- break;
-+ case Opt_extents:
-+ if (!EXT4_HAS_INCOMPAT_FEATURE(sb,
-+ EXT4_FEATURE_INCOMPAT_EXTENTS)) {
-+ ext4_warning(sb, "extents feature not enabled "
-+ "on this filesystem, use tune2fs");
-+ return 0;
-+ }
-+ set_opt(sb, EXTENTS);
-+ break;
-+ case Opt_noextents:
-+ /*
-+ * When e2fsprogs support resizing an already existing
-+ * ext4 file system to greater than 2**32 we need to
-+ * add support to block allocator to handle growing
-+ * already existing block mapped inode so that blocks
-+ * allocated for them fall within 2**32
-+ */
-+ last_block = ext4_blocks_count(sbi->s_es) - 1;
-+ if (last_block > 0xffffffffULL) {
-+ printk(KERN_ERR "EXT4-fs: Filesystem too "
-+ "large to mount with "
-+ "-o noextents options\n");
-+ return 0;
-+ }
-+ clear_opt(sb, EXTENTS);
-+ break;
- default:
- ext4_msg(sb, KERN_ERR,
- "Unrecognized mount option \"%s\" "
-@@ -3276,6 +3308,14 @@ static int ext4_fill_super(struct super_
- set_opt(sb, BARRIER);
-
- /*
-+ * turn on extents feature by default in ext4 filesystem
-+ * only if feature flag already set by mkfs or tune2fs.
-+ * Use -o noextents to turn it off
-+ */
-+ if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_EXTENTS))
-+ set_opt(sb, EXTENTS);
-+
-+ /*
- * enable delayed allocation by default
- * Use -o nodelalloc to turn it off
- */