Whamcloud - gitweb
LU-1812 ldiskfs: Add kernel patch series for SLES11SP2
[fs/lustre-release.git] / ldiskfs / kernel_patches / patches / sles11sp2 / ext4-extents-mount-option.patch
1 diff -u -r linux-stage.orig/fs/ext4/ext4.h linux-stage/fs/ext4/ext4.h
2 --- linux-stage.orig/fs/ext4/ext4.h     2012-12-31 15:07:27.000000000 -0500
3 +++ linux-stage/fs/ext4/ext4.h  2012-12-31 15:14:03.000000000 -0500
4 @@ -912,6 +912,7 @@
5  #define EXT4_MOUNT_POSIX_ACL           0x08000 /* POSIX Access Control Lists */
6  #define EXT4_MOUNT_NO_AUTO_DA_ALLOC    0x10000 /* No auto delalloc mapping */
7  #define EXT4_MOUNT_BARRIER             0x20000 /* Use block barriers */
8 +#define EXT4_MOUNT_EXTENTS             0x40000 /* Extents support */
9  #define EXT4_MOUNT_QUOTA               0x80000 /* Some quota option set */
10  #define EXT4_MOUNT_USRQUOTA            0x100000 /* "old" user quota */
11  #define EXT4_MOUNT_GRPQUOTA            0x200000 /* "old" group quota */
12 diff -u -r linux-stage.orig/fs/ext4/ext4_jbd2.h linux-stage/fs/ext4/ext4_jbd2.h
13 --- linux-stage.orig/fs/ext4/ext4_jbd2.h        2012-12-31 15:07:27.000000000 -0500
14 +++ linux-stage/fs/ext4/ext4_jbd2.h     2012-12-31 15:07:34.000000000 -0500
15 @@ -33,7 +33,7 @@
16
17  #define EXT4_SINGLEDATA_TRANS_BLOCKS(sb)                               \
18         (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_EXTENTS)   \
19 -        ? 27U : 8U)
20 +        || test_opt(sb, EXTENTS) ? 27U : 8U)
21
22  #define ext4_journal_dirty_metadata(handle, bh)  \
23                 ext4_handle_dirty_metadata(handle, NULL, bh)
24 diff -u -r linux-stage.orig/fs/ext4/extents.c linux-stage/fs/ext4/extents.c
25 --- linux-stage.orig/fs/ext4/extents.c  2012-12-31 15:07:27.000000000 -0500
26 +++ linux-stage/fs/ext4/extents.c       2012-12-31 15:07:34.000000000 -0500
27 @@ -2733,7 +2733,7 @@
28          * possible initialization would be here
29          */
30
31 -       if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_EXTENTS)) {
32 +       if (test_opt(sb, EXTENTS)) {
33  #if defined(AGGRESSIVE_TEST) || defined(CHECK_BINSEARCH) || defined(EXTENTS_STATS)
34                 printk(KERN_INFO "EXT4-fs: file extents enabled");
35  #ifdef AGGRESSIVE_TEST
36 @@ -2760,7 +2760,7 @@
37   */
38  void ext4_ext_release(struct super_block *sb)
39  {
40 -       if (!EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_EXTENTS))
41 +       if (!test_opt(sb, EXTENTS))
42                 return;
43
44  #ifdef EXTENTS_STATS
45 diff -u -r linux-stage.orig/fs/ext4/ialloc.c linux-stage/fs/ext4/ialloc.c
46 --- linux-stage.orig/fs/ext4/ialloc.c   2012-12-31 15:07:27.000000000 -0500
47 +++ linux-stage/fs/ext4/ialloc.c        2012-12-31 15:07:34.000000000 -0500
48 @@ -1057,7 +1057,7 @@
49         if (err)
50                 goto fail_free_drop;
51
52 -       if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_EXTENTS)) {
53 +       if (test_opt(sb, EXTENTS)) {
54                 /* set extent flag only for directory, file and normal symlink*/
55                 if (S_ISDIR(mode) || S_ISREG(mode) || S_ISLNK(mode)) {
56                         ext4_set_inode_flag(inode, EXT4_INODE_EXTENTS);
57 diff -u -r linux-stage.orig/fs/ext4/migrate.c linux-stage/fs/ext4/migrate.c
58 --- linux-stage.orig/fs/ext4/migrate.c  2012-12-31 15:07:27.000000000 -0500
59 +++ linux-stage/fs/ext4/migrate.c       2012-12-31 15:07:34.000000000 -0500
60 @@ -469,13 +469,10 @@
61         unsigned long max_entries;
62         __u32 goal;
63
64 -       /*
65 -        * If the filesystem does not support extents, or the inode
66 -        * already is extent-based, error out.
67 -        */
68 -       if (!EXT4_HAS_INCOMPAT_FEATURE(inode->i_sb,
69 -                                      EXT4_FEATURE_INCOMPAT_EXTENTS) ||
70 -           (ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS)))
71 +       if (!test_opt(inode->i_sb, EXTENTS))
72 +               /*
73 +                * if mounted with noextents we don't allow the migrate
74 +                */
75                 return -EINVAL;
76
77         if (S_ISLNK(inode->i_mode) && inode->i_blocks == 0)
78 diff -u -r linux-stage.orig/fs/ext4/super.c linux-stage/fs/ext4/super.c
79 --- linux-stage.orig/fs/ext4/super.c    2012-12-31 15:07:27.000000000 -0500
80 +++ linux-stage/fs/ext4/super.c 2012-12-31 15:15:49.000000000 -0500
81 @@ -1078,6 +1078,8 @@
82                 seq_puts(seq, ",journal_async_commit");
83         else if (test_opt(sb, JOURNAL_CHECKSUM))
84                 seq_puts(seq, ",journal_checksum");
85 +       if (!test_opt(sb, EXTENTS))
86 +               seq_puts(seq, ",noextents");
87         if (test_opt(sb, I_VERSION))
88                 seq_puts(seq, ",i_version");
89         if (!test_opt(sb, DELALLOC) &&
90 @@ -1303,6 +1305,7 @@
91         Opt_inode_readahead_blks, Opt_journal_ioprio,
92         Opt_dioread_nolock, Opt_dioread_lock,
93         Opt_mballoc, Opt_bigendian_extents, Opt_force_over_128tb,
94 +       Opt_extents, Opt_noextents,
95         Opt_discard, Opt_nodiscard, Opt_init_itable, Opt_noinit_itable,
96  };
97
98 @@ -1380,6 +1383,8 @@
99         {Opt_bigendian_extents, "bigendian_extents"},
100         {Opt_force_over_128tb, "force_over_128tb"},
101         {Opt_mballoc, "mballoc"},
102 +       {Opt_extents, "extents"},
103 +       {Opt_noextents, "noextents"},
104         {Opt_discard, "discard"},
105         {Opt_nodiscard, "nodiscard"},
106         {Opt_init_itable, "init_itable=%u"},
107 @@ -1472,6 +1477,7 @@
108         return 1;
109  }
110  #endif
111 +       ext4_fsblk_t last_block;
112
113  static int parse_options(char *options, struct super_block *sb,
114                          unsigned long *journal_devnum,
115 @@ -1887,6 +1893,32 @@
116                 case Opt_force_over_128tb:
117                         force_over_128tb = 1;
118                         break;
119 +               case Opt_extents:
120 +                       if (!EXT4_HAS_INCOMPAT_FEATURE(sb,
121 +                                       EXT4_FEATURE_INCOMPAT_EXTENTS)) {
122 +                               ext4_warning(sb, "extents feature not enabled "
123 +                                                "on this filesystem, use tune2fs");
124 +                               return 0;
125 +                       }
126 +                       set_opt(sb, EXTENTS);
127 +                       break;
128 +               case Opt_noextents:
129 +                       /*
130 +                        * When e2fsprogs support resizing an already existing
131 +                        * ext4 file system to greater than 2**32 we need to
132 +                        * add support to block allocator to handle growing
133 +                        * already existing block  mapped inode so that blocks
134 +                        * allocated for them fall within 2**32
135 +                        */
136 +                       last_block = ext4_blocks_count(sbi->s_es) - 1;
137 +                       if (last_block  > 0xffffffffULL) {
138 +                               printk(KERN_ERR "EXT4-fs: Filesystem too "
139 +                                               "large to mount with "
140 +                                               "-o noextents options\n");
141 +                               return 0;
142 +                       }
143 +                       clear_opt(sb, EXTENTS);
144 +                       break;
145                 default:
146                         ext4_msg(sb, KERN_ERR,
147                                "Unrecognized mount option \"%s\" "
148 @@ -3206,6 +3238,14 @@
149                 set_opt(sb, BARRIER);
150
151         /*
152 +        * turn on extents feature by default in ext4 filesystem
153 +        * only if feature flag already set by mkfs or tune2fs.
154 +        * Use -o noextents to turn it off
155 +        */
156 +       if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_EXTENTS))
157 +               set_opt(sb, EXTENTS);
158 +
159 +       /*
160          * enable delayed allocation by default
161          * Use -o nodelalloc to turn it off
162          */