Whamcloud - gitweb
LU-2473 ldiskfs: Add ldiskfs support for RHEL 6.4
[fs/lustre-release.git] / ldiskfs / kernel_patches / patches / rhel6.4 / ext4-misc.patch
1 Index: linux-stage/fs/ext4/ext4.h
2 ===================================================================
3 --- linux-stage.orig/fs/ext4/ext4.h
4 +++ linux-stage/fs/ext4/ext4.h
5 @@ -1256,6 +1256,9 @@ EXT4_INODE_BIT_FNS(state, state_flags)
6  
7  #define NEXT_ORPHAN(inode) EXT4_I(inode)->i_dtime
8  
9 +/* Has been moved to linux/magic.h but we need it for Lustre */
10 +#define EXT4_SUPER_MAGIC       0xEF53
11 +
12  /*
13   * Codes for operating systems
14   */
15 @@ -1757,6 +1760,9 @@ extern void ext4_add_groupblocks(handle_
16                                 ext4_fsblk_t block, unsigned long count);
17  extern int ext4_trim_fs(struct super_block *, struct fstrim_range *);
18  
19 +extern void ext4_mb_discard_inode_preallocations(struct inode *);
20 +
21 +
22  /* inode.c */
23  int ext4_forget(handle_t *handle, int is_metadata, struct inode *inode,
24                 struct buffer_head *bh, ext4_fsblk_t blocknr);
25 Index: linux-stage/fs/ext4/ext4_extents.h
26 ===================================================================
27 --- linux-stage.orig/fs/ext4/ext4_extents.h
28 +++ linux-stage/fs/ext4/ext4_extents.h
29 @@ -58,6 +58,12 @@
30   */
31  #define EXT_STATS_
32  
33 +/*
34 + * define EXT4_ALLOC_NEEDED to 0 since block bitmap, group desc. and sb
35 + * are now accounted in ext4_ext_calc_credits_for_insert()
36 + */
37 +#define EXT4_ALLOC_NEEDED 0
38 +#define HAVE_EXT_PREPARE_CB_EXTENT
39  
40  /*
41   * ext4_inode has i_block array (60 bytes total).
42 @@ -291,6 +297,8 @@ extern int ext4_extent_tree_init(handle_
43  extern int ext4_ext_calc_credits_for_single_extent(struct inode *inode,
44                                                    int num,
45                                                    struct ext4_ext_path *path);
46 +extern int ext4_ext_calc_credits_for_insert(struct inode *,
47 +                                           struct ext4_ext_path *);
48  extern int ext4_can_extents_be_merged(struct inode *inode,
49                                       struct ext4_extent *ex1,
50                                       struct ext4_extent *ex2);
51 Index: linux-stage/fs/ext4/ext4_jbd2.c
52 ===================================================================
53 --- linux-stage.orig/fs/ext4/ext4_jbd2.c
54 +++ linux-stage/fs/ext4/ext4_jbd2.c
55 @@ -31,6 +31,7 @@ int __ext4_journal_get_write_access(cons
56         }
57         return err;
58  }
59 +EXPORT_SYMBOL(__ext4_journal_get_write_access);
60  
61  int __ext4_journal_forget(const char *where, handle_t *handle,
62                                 struct buffer_head *bh)
63 @@ -107,3 +108,4 @@ int __ext4_handle_dirty_metadata(const c
64         }
65         return err;
66  }
67 +EXPORT_SYMBOL(__ext4_handle_dirty_metadata);
68 Index: linux-stage/fs/ext4/ext4_jbd2.h
69 ===================================================================
70 --- linux-stage.orig/fs/ext4/ext4_jbd2.h
71 +++ linux-stage/fs/ext4/ext4_jbd2.h
72 @@ -35,6 +35,8 @@
73         (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_EXTENTS)   \
74          ? 27U : 8U)
75  
76 +#define ext4_journal_dirty_metadata(handle, bh)  \
77 +               ext4_handle_dirty_metadata(handle, NULL, bh)
78  /* Extended attribute operations touch at most two data buffers,
79   * two bitmap buffers, and two group summaries, in addition to the inode
80   * and the superblock, which are already accounted for. */
81 Index: linux-stage/fs/ext4/extents.c
82 ===================================================================
83 --- linux-stage.orig/fs/ext4/extents.c
84 +++ linux-stage/fs/ext4/extents.c
85 @@ -2200,6 +2200,55 @@ int ext4_ext_calc_credits_for_single_ext
86  }
87  
88  /*
89 + * This routine returns max. credits extent tree can consume.
90 + * It should be OK for low-performance paths like ->writepage()
91 + * To allow many writing process to fit a single transaction,
92 + * caller should calculate credits under truncate_mutex and
93 + * pass actual path.
94 + */
95 +int ext4_ext_calc_credits_for_insert(struct inode *inode,
96 +                                    struct ext4_ext_path *path)
97 +{
98 +       int depth, needed;
99 +
100 +       if (path) {
101 +               /* probably there is space in leaf? */
102 +               depth = path->p_depth;
103 +               if (le16_to_cpu(path[depth].p_hdr->eh_entries)
104 +                               < le16_to_cpu(path[depth].p_hdr->eh_max))
105 +                       return 1;
106 +       }
107 +
108 +       /*
109 +        * given 32bit logical block (4294967296 blocks), max. tree
110 +        * can be 4 levels in depth -- 4 * 340^4 == 53453440000.
111 +        * let's also add one more level for imbalance.
112 +        */
113 +       depth = 5;
114 +
115 +       /* allocation of new data block(s) */
116 +       needed = 2;
117 +
118 +       /*
119 +        * tree can be full, so it'd need to grow in depth:
120 +        * we need one credit to modify old root, credits for
121 +        * new root will be added in split accounting
122 +        */
123 +       needed += 1;
124 +       /*
125 +        * Index split can happen, we'd need:
126 +        *    allocate intermediate indexes (bitmap + group)
127 +        *  + change two blocks at each level, but root (already included)
128 +        */
129 +       needed += (depth * 2) + (depth * 2);
130 +
131 +       /* any allocation modifies superblock */
132 +       needed += 1;
133 +
134 +       return needed;
135 +}
136 +
137 +/*
138   * How many index/leaf blocks need to change/allocate to modify nrblocks?
139   *
140   * if nrblocks are fit in a single extent (chunk flag is 1), then
141 @@ -4488,3 +4537,14 @@ int ext4_fiemap(struct inode *inode, str
142         return error;
143  }
144  
145 +EXPORT_SYMBOL(ext4_ext_store_pblock);
146 +EXPORT_SYMBOL(ext4_ext_search_right);
147 +EXPORT_SYMBOL(ext4_ext_search_left);
148 +EXPORT_SYMBOL(ext4_ext_pblock);
149 +EXPORT_SYMBOL(ext4_ext_insert_extent);
150 +EXPORT_SYMBOL(ext4_mb_new_blocks);
151 +EXPORT_SYMBOL(ext4_ext_calc_credits_for_insert);
152 +EXPORT_SYMBOL(ext4_mark_inode_dirty);
153 +EXPORT_SYMBOL(ext4_ext_walk_space);
154 +EXPORT_SYMBOL(ext4_ext_find_extent);
155 +EXPORT_SYMBOL(ext4_ext_drop_refs);
156 Index: linux-stage/fs/ext4/inode.c
157 ===================================================================
158 --- linux-stage.orig/fs/ext4/inode.c
159 +++ linux-stage/fs/ext4/inode.c
160 @@ -5549,6 +5549,7 @@ bad_inode:
161         iget_failed(inode);
162         return ERR_PTR(ret);
163  }
164 +EXPORT_SYMBOL(ext4_iget);
165  
166  static int ext4_inode_blocks_set(handle_t *handle,
167                                 struct ext4_inode *raw_inode,
168 Index: linux-stage/fs/ext4/mballoc.c
169 ===================================================================
170 --- linux-stage.orig/fs/ext4/mballoc.c
171 +++ linux-stage/fs/ext4/mballoc.c
172 @@ -4031,6 +4031,7 @@ repeat:
173         if (ac)
174                 kmem_cache_free(ext4_ac_cachep, ac);
175  }
176 +EXPORT_SYMBOL(ext4_discard_preallocations);
177  
178  /*
179   * finds all preallocated spaces and return blocks being freed to them
180 @@ -5189,3 +5190,6 @@ out:
181         range->len = trimmed * sb->s_blocksize;
182         return ret;
183  }
184 +
185 +EXPORT_SYMBOL(ext4_free_blocks);
186 +
187 Index: linux-stage/fs/ext4/super.c
188 ===================================================================
189 --- linux-stage.orig/fs/ext4/super.c
190 +++ linux-stage/fs/ext4/super.c
191 @@ -137,6 +137,7 @@ __u32 ext4_itable_unused_count(struct su
192                 (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT ?
193                  (__u32)le16_to_cpu(bg->bg_itable_unused_hi) << 16 : 0);
194  }
195 +EXPORT_SYMBOL(ext4_itable_unused_count);
196  
197  void ext4_block_bitmap_set(struct super_block *sb,
198                            struct ext4_group_desc *bg, ext4_fsblk_t blk)
199 @@ -1176,11 +1177,14 @@ enum {
200         Opt_usrjquota, Opt_grpjquota, Opt_offusrjquota, Opt_offgrpjquota,
201         Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_jqfmt_vfsv1, Opt_quota,
202         Opt_noquota, Opt_ignore, Opt_barrier, Opt_nobarrier, Opt_err,
203 +       Opt_iopen, Opt_noiopen, Opt_iopen_nopriv,
204         Opt_resize, Opt_usrquota, Opt_grpquota, Opt_i_version,
205         Opt_stripe, Opt_delalloc, Opt_nodelalloc,
206         Opt_block_validity, Opt_noblock_validity,
207         Opt_inode_readahead_blks, Opt_journal_ioprio,
208 -       Opt_discard, Opt_nodiscard, Opt_init_itable, Opt_noinit_itable,
209 +       Opt_mballoc,
210 +       Opt_discard, Opt_nodiscard,
211 +       Opt_init_itable, Opt_noinit_itable,
212  };
213  
214  static const match_table_t tokens = {
215 @@ -1232,6 +1236,9 @@ static const match_table_t tokens = {
216         {Opt_noquota, "noquota"},
217         {Opt_quota, "quota"},
218         {Opt_usrquota, "usrquota"},
219 +       {Opt_iopen, "iopen"},
220 +       {Opt_noiopen, "noiopen"},
221 +       {Opt_iopen_nopriv, "iopen_nopriv"},
222         {Opt_barrier, "barrier=%u"},
223         {Opt_barrier, "barrier"},
224         {Opt_nobarrier, "nobarrier"},
225 @@ -1247,6 +1254,7 @@ static const match_table_t tokens = {
226         {Opt_auto_da_alloc, "auto_da_alloc=%u"},
227         {Opt_auto_da_alloc, "auto_da_alloc"},
228         {Opt_noauto_da_alloc, "noauto_da_alloc"},
229 +       {Opt_mballoc, "mballoc"},
230         {Opt_discard, "discard"},
231         {Opt_nodiscard, "nodiscard"},
232         {Opt_init_itable, "init_itable=%u"},
233 @@ -1607,6 +1615,10 @@ set_qf_format:
234                         else
235                                 clear_opt(sbi->s_mount_opt, BARRIER);
236                         break;
237 +               case Opt_iopen:
238 +               case Opt_noiopen:
239 +               case Opt_iopen_nopriv:
240 +                       break;
241                 case Opt_ignore:
242                         break;
243                 case Opt_resize:
244 @@ -1704,6 +1716,8 @@ set_qf_format:
245                 case Opt_noinit_itable:
246                         clear_opt(sbi->s_mount_opt, INIT_INODE_TABLE);
247                         break;
248 +               case Opt_mballoc:
249 +                       break;
250                 default:
251                         ext4_msg(sb, KERN_ERR,
252                                "Unrecognized mount option \"%s\" "