Whamcloud - gitweb
5c1f182e70ee65c347d2ed5733098e886400726f
[fs/lustre-release.git] / ldiskfs / kernel_patches / patches / sles11sp2 / ext4-extents-mount-option.patch
1 Index: linux-3.0.101-0.5/fs/ext4/ext4.h
2 ===================================================================
3 --- linux-3.0.101-0.5.orig/fs/ext4/ext4.h
4 +++ linux-3.0.101-0.5/fs/ext4/ext4.h
5 @@ -911,6 +911,7 @@ struct ext4_inode_info {
6  #define EXT4_MOUNT_POSIX_ACL           0x08000 /* POSIX Access Control Lists */
7  #define EXT4_MOUNT_NO_AUTO_DA_ALLOC    0x10000 /* No auto delalloc mapping */
8  #define EXT4_MOUNT_BARRIER             0x20000 /* Use block barriers */
9 +#define EXT4_MOUNT_EXTENTS             0x40000 /* Extents support */
10  #define EXT4_MOUNT_QUOTA               0x80000 /* Some quota option set */
11  #define EXT4_MOUNT_USRQUOTA            0x100000 /* "old" user quota */
12  #define EXT4_MOUNT_GRPQUOTA            0x200000 /* "old" group quota */
13 Index: linux-3.0.101-0.5/fs/ext4/ext4_jbd2.h
14 ===================================================================
15 --- linux-3.0.101-0.5.orig/fs/ext4/ext4_jbd2.h
16 +++ linux-3.0.101-0.5/fs/ext4/ext4_jbd2.h
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  /* Extended attribute operations touch at most two data buffers,
25   * two bitmap buffers, and two group summaries, in addition to the inode
26 Index: linux-3.0.101-0.5/fs/ext4/extents.c
27 ===================================================================
28 --- linux-3.0.101-0.5.orig/fs/ext4/extents.c
29 +++ linux-3.0.101-0.5/fs/ext4/extents.c
30 @@ -2751,7 +2751,7 @@ void ext4_ext_init(struct super_block *s
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 @@ -2778,7 +2778,7 @@ void ext4_ext_init(struct super_block *s
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-3.0.101-0.5/fs/ext4/ialloc.c
49 ===================================================================
50 --- linux-3.0.101-0.5.orig/fs/ext4/ialloc.c
51 +++ linux-3.0.101-0.5/fs/ext4/ialloc.c
52 @@ -1054,7 +1054,7 @@ got:
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_set_inode_flag(inode, EXT4_INODE_EXTENTS);
61 Index: linux-3.0.101-0.5/fs/ext4/migrate.c
62 ===================================================================
63 --- linux-3.0.101-0.5.orig/fs/ext4/migrate.c
64 +++ linux-3.0.101-0.5/fs/ext4/migrate.c
65 @@ -469,13 +469,10 @@ int ext4_ext_migrate(struct inode *inode
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_test_inode_flag(inode, EXT4_INODE_EXTENTS)))
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 (S_ISLNK(inode->i_mode) && inode->i_blocks == 0)
83 Index: linux-3.0.101-0.5/fs/ext4/super.c
84 ===================================================================
85 --- linux-3.0.101-0.5.orig/fs/ext4/super.c
86 +++ linux-3.0.101-0.5/fs/ext4/super.c
87 @@ -1128,6 +1128,8 @@ static int ext4_show_options(struct seq_
88                 seq_puts(seq, ",journal_async_commit");
89         else if (test_opt(sb, JOURNAL_CHECKSUM))
90                 seq_puts(seq, ",journal_checksum");
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 @@ -1369,6 +1371,7 @@ enum {
97         Opt_inode_readahead_blks, Opt_journal_ioprio,
98         Opt_dioread_nolock, Opt_dioread_lock,
99         Opt_mballoc, Opt_bigendian_extents, Opt_force_over_128tb,
100 +       Opt_extents, Opt_noextents,
101         Opt_discard, Opt_nodiscard, Opt_init_itable, Opt_noinit_itable,
102  };
103  
104 @@ -1446,6 +1449,8 @@ static const match_table_t tokens = {
105         {Opt_bigendian_extents, "bigendian_extents"},
106         {Opt_force_over_128tb, "force_over_128tb"},
107         {Opt_mballoc, "mballoc"},
108 +       {Opt_extents, "extents"},
109 +       {Opt_noextents, "noextents"},
110         {Opt_discard, "discard"},
111         {Opt_nodiscard, "nodiscard"},
112         {Opt_init_itable, "init_itable=%u"},
113 @@ -1538,6 +1543,7 @@ static int clear_qf_name(struct super_bl
114         return 1;
115  }
116  #endif
117 +       ext4_fsblk_t last_block;
118  
119  static int parse_options(char *options, struct super_block *sb,
120                          unsigned long *journal_devnum,
121 @@ -1953,6 +1959,32 @@ set_qf_format:
122                 case Opt_force_over_128tb:
123                         force_over_128tb = 1;
124                         break;
125 +               case Opt_extents:
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");
130 +                               return 0;
131 +                       }
132 +                       set_opt(sb, EXTENTS);
133 +                       break;
134 +               case Opt_noextents:
135 +                       /*
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
141 +                        */
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");
147 +                               return 0;
148 +                       }
149 +                       clear_opt(sb, EXTENTS);
150 +                       break;
151                 default:
152                         ext4_msg(sb, KERN_ERR,
153                                "Unrecognized mount option \"%s\" "
154 @@ -3276,6 +3308,14 @@ static int ext4_fill_super(struct super_
155                 set_opt(sb, BARRIER);
156  
157         /*
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
161 +        */
162 +       if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_EXTENTS))
163 +               set_opt(sb, EXTENTS);
164 +
165 +       /*
166          * enable delayed allocation by default
167          * Use -o nodelalloc to turn it off
168          */