Whamcloud - gitweb
c4cc5317b17b3b2f9a462ec745e5a32a9c1a02d6
[fs/lustre-release.git] / ldiskfs / kernel_patches / patches / ext4-extents-mount-option-rhel6.patch
1 Index: linux-stage/fs/ext4/ext4.h
2 ===================================================================
3 --- linux-stage.orig/fs/ext4/ext4.h     2011-03-14 15:57:13.613674482 +0800
4 +++ linux-stage/fs/ext4/ext4.h  2011-03-14 15:57:22.031906980 +0800
5 @@ -780,6 +780,7 @@
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-03-14 15:57:12.000000000 +0800
16 +++ linux-stage/fs/ext4/ext4_jbd2.h     2011-03-14 15:58:55.957499110 +0800
17 @@ -33,7 +33,7 @@
18  
19  #define EXT4_SINGLEDATA_TRANS_BLOCKS(sb)                               \
20         (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_EXTENTS)   \
21 -        ? 27U : 8U)
22 +        || test_opt(sb, EXTENTS) ? 27U : 8U)
23  
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-03-14 15:57:12.000000000 +0800
29 +++ linux-stage/fs/ext4/extents.c       2011-03-14 16:14:14.246265207 +0800
30 @@ -2553,7 +2553,7 @@
31          * possible initialization would be here
32          */
33  
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 @@ -2580,7 +2580,7 @@
40   */
41  void ext4_ext_release(struct super_block *sb)
42  {
43 -       if (!EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_EXTENTS))
44 +       if (!test_opt(sb, EXTENTS))
45                 return;
46  
47  #ifdef EXTENTS_STATS
48 Index: linux-stage/fs/ext4/ialloc.c
49 ===================================================================
50 --- linux-stage.orig/fs/ext4/ialloc.c   2011-03-14 15:57:13.000000000 +0800
51 +++ linux-stage/fs/ext4/ialloc.c        2011-03-14 16:02:03.334308846 +0800
52 @@ -1049,7 +1049,7 @@
53         if (err)
54                 goto fail_free_drop;
55  
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_I(inode)->i_flags |= EXT4_EXTENTS_FL;
61 Index: linux-stage/fs/ext4/migrate.c
62 ===================================================================
63 --- linux-stage.orig/fs/ext4/migrate.c  2011-03-14 15:36:15.000000000 +0800
64 +++ linux-stage/fs/ext4/migrate.c       2011-03-14 16:05:39.083369164 +0800
65 @@ -459,13 +459,13 @@
66         unsigned long max_entries;
67         __u32 goal;
68  
69 -       /*
70 -        * If the filesystem does not support extents, or the inode
71 -        * already is extent-based, error out.
72 -        */
73 -       if (!EXT4_HAS_INCOMPAT_FEATURE(inode->i_sb,
74 -                                      EXT4_FEATURE_INCOMPAT_EXTENTS) ||
75 -           (EXT4_I(inode)->i_flags & EXT4_EXTENTS_FL))
76 +       if (!test_opt(inode->i_sb, EXTENTS))
77 +               /*
78 +                * if mounted with noextents we don't allow the migrate
79 +                */
80 +               return -EINVAL;
81 +
82 +       if ((EXT4_I(inode)->i_flags & EXT4_EXTENTS_FL))
83                 return -EINVAL;
84  
85         if (S_ISLNK(inode->i_mode) && inode->i_blocks == 0)
86 Index: linux-stage/fs/ext4/super.c
87 ===================================================================
88 --- linux-stage.orig/fs/ext4/super.c    2011-03-14 15:57:18.000000000 +0800
89 +++ linux-stage/fs/ext4/super.c 2011-03-14 16:11:58.234626200 +0800
90 @@ -942,6 +942,8 @@
91                 seq_puts(seq, ",journal_async_commit");
92         if (test_opt(sb, NOBH))
93                 seq_puts(seq, ",nobh");
94 +       if (!test_opt(sb, EXTENTS))
95 +               seq_puts(seq, ",noextents");
96         if (test_opt(sb, I_VERSION))
97                 seq_puts(seq, ",i_version");
98         if (!test_opt(sb, DELALLOC))
99 @@ -1500,6 +1502,7 @@
100         Opt_inode_readahead_blks, Opt_journal_ioprio,
101         Opt_discard, Opt_nodiscard,
102         Opt_mballoc, Opt_bigendian_extents, Opt_force_over_16tb,
103 +       Opt_extents, Opt_noextents,
104  };
105  
106  static const match_table_t tokens = {
107 @@ -1571,6 +1574,8 @@
108         {Opt_mballoc, "mballoc"},
109         {Opt_discard, "discard"},
110         {Opt_nodiscard, "nodiscard"},
111 +       {Opt_extents, "extents"},
112 +       {Opt_noextents, "noextents"},
113         {Opt_err, NULL},
114  };
115  
116 @@ -1613,6 +1618,7 @@
117         int qtype, qfmt;
118         char *qname;
119  #endif
120 +       ext4_fsblk_t last_block;
121  
122         if (!options)
123                 return 1;
124 @@ -2017,6 +2023,32 @@
125                 case Opt_force_over_16tb:
126                         force_over_16tb = 1;
127                         break;
128 +               case Opt_extents:
129 +                       if (!EXT4_HAS_INCOMPAT_FEATURE(sb,
130 +                                       EXT4_FEATURE_INCOMPAT_EXTENTS)) {
131 +                               ext4_warning(sb, "extents feature not enabled "
132 +                                                "on this filesystem, use tune2fs");
133 +                               return 0;
134 +                       }
135 +                       set_opt(sbi->s_mount_opt, EXTENTS);
136 +                       break;
137 +               case Opt_noextents:
138 +                       /*
139 +                        * When e2fsprogs support resizing an already existing
140 +                        * ext4 file system to greater than 2**32 we need to
141 +                        * add support to block allocator to handle growing
142 +                        * already existing block  mapped inode so that blocks
143 +                        * allocated for them fall within 2**32
144 +                        */
145 +                       last_block = ext4_blocks_count(sbi->s_es) - 1;
146 +                       if (last_block  > 0xffffffffULL) {
147 +                               printk(KERN_ERR "EXT4-fs: Filesystem too "
148 +                                               "large to mount with "
149 +                                               "-o noextents options\n");
150 +                               return 0;
151 +                       }
152 +                       clear_opt(sbi->s_mount_opt, EXTENTS);
153 +                       break;
154                 default:
155                         ext4_msg(sb, KERN_ERR,
156                                "Unrecognized mount option \"%s\" "
157 @@ -2879,6 +2911,17 @@
158         set_opt(sbi->s_mount_opt, BARRIER);
159  
160         /*
161 +        * turn on extents feature by default in ext4 filesystem
162 +        * only if feature flag already set by mkfs or tune2fs.
163 +        * Use -o noextents to turn it off
164 +        */
165 +       if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_EXTENTS))
166 +               set_opt(sbi->s_mount_opt, EXTENTS);
167 +       else
168 +               ext4_warning(sb, "extents feature not enabled on this filesystem, "
169 +                                "use tune2fs.");
170 +
171 +       /*
172          * enable delayed allocation by default
173          * Use -o nodelalloc to turn it off
174          */