Whamcloud - gitweb
Revert "LU-5276 ldiskfs: Remove extents-mount-option patch"
[fs/lustre-release.git] / ldiskfs / kernel_patches / patches / sles11sp2 / ext4-extents-mount-option.patch
diff --git a/ldiskfs/kernel_patches/patches/sles11sp2/ext4-extents-mount-option.patch b/ldiskfs/kernel_patches/patches/sles11sp2/ext4-extents-mount-option.patch
new file mode 100644 (file)
index 0000000..5174912
--- /dev/null
@@ -0,0 +1,162 @@
+diff -u -r linux-stage.orig/fs/ext4/ext4.h linux-stage/fs/ext4/ext4.h
+--- linux-stage.orig/fs/ext4/ext4.h    2012-12-31 15:07:27.000000000 -0500
++++ linux-stage/fs/ext4/ext4.h 2012-12-31 15:14:03.000000000 -0500
+@@ -912,6 +912,7 @@
+ #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 */
+diff -u -r linux-stage.orig/fs/ext4/ext4_jbd2.h linux-stage/fs/ext4/ext4_jbd2.h
+--- linux-stage.orig/fs/ext4/ext4_jbd2.h       2012-12-31 15:07:27.000000000 -0500
++++ linux-stage/fs/ext4/ext4_jbd2.h    2012-12-31 15:07:34.000000000 -0500
+@@ -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)
+
+ #define ext4_journal_dirty_metadata(handle, bh)  \
+               ext4_handle_dirty_metadata(handle, NULL, bh)
+diff -u -r linux-stage.orig/fs/ext4/extents.c linux-stage/fs/ext4/extents.c
+--- linux-stage.orig/fs/ext4/extents.c 2012-12-31 15:07:27.000000000 -0500
++++ linux-stage/fs/ext4/extents.c      2012-12-31 15:07:34.000000000 -0500
+@@ -2733,7 +2733,7 @@
+        * 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
+@@ -2760,7 +2760,7 @@
+  */
+ 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
+diff -u -r linux-stage.orig/fs/ext4/ialloc.c linux-stage/fs/ext4/ialloc.c
+--- linux-stage.orig/fs/ext4/ialloc.c  2012-12-31 15:07:27.000000000 -0500
++++ linux-stage/fs/ext4/ialloc.c       2012-12-31 15:07:34.000000000 -0500
+@@ -1057,7 +1057,7 @@
+       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);
+diff -u -r linux-stage.orig/fs/ext4/migrate.c linux-stage/fs/ext4/migrate.c
+--- linux-stage.orig/fs/ext4/migrate.c 2012-12-31 15:07:27.000000000 -0500
++++ linux-stage/fs/ext4/migrate.c      2012-12-31 15:07:34.000000000 -0500
+@@ -469,13 +469,10 @@
+       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)
+diff -u -r linux-stage.orig/fs/ext4/super.c linux-stage/fs/ext4/super.c
+--- linux-stage.orig/fs/ext4/super.c   2012-12-31 15:07:27.000000000 -0500
++++ linux-stage/fs/ext4/super.c        2012-12-31 15:15:49.000000000 -0500
+@@ -1078,6 +1078,8 @@
+               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) &&
+@@ -1303,6 +1305,7 @@
+       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,
+ };
+
+@@ -1380,6 +1383,8 @@
+       {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"},
+@@ -1472,6 +1477,7 @@
+       return 1;
+ }
+ #endif
++      ext4_fsblk_t last_block;
+
+ static int parse_options(char *options, struct super_block *sb,
+                        unsigned long *journal_devnum,
+@@ -1887,6 +1893,32 @@
+               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\" "
+@@ -3206,6 +3238,14 @@
+               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
+        */