Whamcloud - gitweb
Branch b1_8
[fs/lustre-release.git] / ldiskfs / kernel_patches / patches / ext4-misc-rhel5.patch
1 Index: linux-2.6.18.i386/fs/ext4/ext4_jbd2.h
2 ===================================================================
3 --- linux-2.6.18.i386.orig/fs/ext4/ext4_jbd2.h
4 +++ linux-2.6.18.i386/fs/ext4/ext4_jbd2.h
5 @@ -35,6 +35,9 @@
6         (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_EXTENTS)   \
7                 || test_opt(sb, EXTENTS) ? 27U : 8U)
8  
9 +/* Indicate that EXT4_SINGLEDATA_TRANS_BLOCKS takes the sb as argument */
10 +#define EXT4_SINGLEDATA_TRANS_BLOCKS_HAS_SB
11 +
12  /* Extended attribute operations touch at most two data buffers,
13   * two bitmap buffers, and two group summaries, in addition to the inode
14   * and the superblock, which are already accounted for. */
15 Index: linux-2.6.18.i386/fs/ext4/extents.c
16 ===================================================================
17 --- linux-2.6.18.i386.orig/fs/ext4/extents.c
18 +++ linux-2.6.18.i386/fs/ext4/extents.c
19 @@ -50,7 +50,7 @@
20   * ext_pblock:
21   * combine low and high parts of physical block number into ext4_fsblk_t
22   */
23 -static ext4_fsblk_t ext_pblock(struct ext4_extent *ex)
24 +ext4_fsblk_t ext_pblock(struct ext4_extent *ex)
25  {
26         ext4_fsblk_t block;
27  
28 @@ -60,6 +60,17 @@ static ext4_fsblk_t ext_pblock(struct ex
29  }
30  
31  /*
32 + * ext4_ext_store_pblock:
33 + * stores a large physical block number into an extent struct,
34 + * breaking it into parts
35 + */
36 +void ext4_ext_store_pblock(struct ext4_extent *ex, ext4_fsblk_t pb)
37 +{
38 +       ex->ee_start_lo = cpu_to_le32((unsigned long) (pb & 0xffffffff));
39 +       ex->ee_start_hi = cpu_to_le16((unsigned long) ((pb >> 31) >> 1) & 0xffff);
40 +}
41 +
42 +/*
43   * idx_pblock:
44   * combine low and high parts of a leaf physical block number into ext4_fsblk_t
45   */
46 @@ -73,17 +84,6 @@ ext4_fsblk_t idx_pblock(struct ext4_exte
47  }
48  
49  /*
50 - * ext4_ext_store_pblock:
51 - * stores a large physical block number into an extent struct,
52 - * breaking it into parts
53 - */
54 -void ext4_ext_store_pblock(struct ext4_extent *ex, ext4_fsblk_t pb)
55 -{
56 -       ex->ee_start_lo = cpu_to_le32((unsigned long) (pb & 0xffffffff));
57 -       ex->ee_start_hi = cpu_to_le16((unsigned long) ((pb >> 31) >> 1) & 0xffff);
58 -}
59 -
60 -/*
61   * ext4_idx_store_pblock:
62   * stores a large physical block number into an index struct,
63   * breaking it into parts
64 @@ -1826,6 +1826,56 @@ static int ext4_ext_rm_idx(handle_t *han
65  }
66  
67  /*
68 + * This routine returns max. credits extent tree can consume.
69 + * It should be OK for low-performance paths like ->writepage()
70 + * To allow many writing process to fit a single transaction,
71 + * caller should calculate credits under truncate_mutex and
72 + * pass actual path.
73 + */
74 +int ext4_ext_calc_credits_for_insert(struct inode *inode,
75 +                                   struct ext4_ext_path *path)
76 +{
77 +       int depth, needed;
78 +
79 +       if (path) {
80 +               /* probably there is space in leaf? */
81 +               depth = ext_depth(inode);
82 +               if (le16_to_cpu(path[depth].p_hdr->eh_entries)
83 +                               < le16_to_cpu(path[depth].p_hdr->eh_max))
84 +                       return 1;
85 +       }
86 +
87 +       /*
88 +        * given 32bit logical block (4294967296 blocks), max. tree
89 +        * can be 4 levels in depth -- 4 * 340^4 == 53453440000.
90 +        * let's also add one more level for imbalance.
91 +        */
92 +       depth = 5;
93 +
94 +       /* allocation of new data block(s) */
95 +       needed = 2;
96 +
97 +       /*
98 +        * tree can be full, so it'd need to grow in depth:
99 +        * we need one credit to modify old root, credits for
100 +        * new root will be added in split accounting
101 +        */
102 +       needed += 1;
103 +
104 +       /*
105 +        * Index split can happen, we'd need:
106 +        *    allocate intermediate indexes (bitmap + group)
107 +        *  + change two blocks at each level, but root (already included)
108 +        */
109 +       needed += (depth * 2) + (depth * 2);
110 +
111 +       /* any allocation modifies superblock */
112 +       needed += 1;
113 +
114 +       return needed;
115 +}
116 +
117 +/*
118   * ext4_ext_calc_credits_for_single_extent:
119   * This routine returns max. credits that needed to insert an extent
120   * to the extent tree.
121 @@ -3157,3 +3207,14 @@ int ext4_fiemap(struct inode *inode, str
122  
123         return error;
124  }
125 +
126 +EXPORT_SYMBOL(ext4_ext_store_pblock);
127 +EXPORT_SYMBOL(ext4_ext_search_right);
128 +EXPORT_SYMBOL(ext4_ext_search_left);
129 +EXPORT_SYMBOL(ext_pblock);
130 +EXPORT_SYMBOL(ext4_ext_insert_extent);
131 +EXPORT_SYMBOL(ext4_mb_new_blocks);
132 +EXPORT_SYMBOL(ext4_ext_walk_space);
133 +EXPORT_SYMBOL(ext4_ext_calc_credits_for_insert);
134 +EXPORT_SYMBOL(ext4_mark_inode_dirty);
135 +
136 Index: linux-2.6.18.i386/fs/ext4/ext4_extents.h
137 ===================================================================
138 --- linux-2.6.18.i386.orig/fs/ext4/ext4_extents.h
139 +++ linux-2.6.18.i386/fs/ext4/ext4_extents.h
140 @@ -59,6 +59,11 @@
141   */
142  #define EXT_STATS_
143  
144 +/*
145 + * define EXT4_ALLOC_NEEDED to 0 since block bitmap, group desc. and sb
146 + * are now accounted in ext4_ext_calc_credits_for_insert()
147 + */
148 +#define EXT4_ALLOC_NEEDED 0
149  
150  /*
151   * ext4_inode has i_block array (60 bytes total).
152 @@ -124,6 +129,7 @@ struct ext4_ext_path {
153  #define EXT4_EXT_CACHE_GAP     1
154  #define EXT4_EXT_CACHE_EXTENT  2
155  
156 +#define EXT4_EXT_HAS_NO_TREE  /* ext4_extents_tree struct is not used*/
157  
158  #define EXT_MAX_BLOCK  0xffffffff
159  
160 @@ -228,9 +234,13 @@ static inline int ext4_ext_get_actual_le
161                 (le16_to_cpu(ext->ee_len) - EXT_INIT_MAX_LEN));
162  }
163  
164 +extern ext4_fsblk_t ext_pblock(struct ext4_extent *ex);
165 +extern void ext4_ext_store_pblock(struct ext4_extent *ex, ext4_fsblk_t pb);
166  extern ext4_fsblk_t idx_pblock(struct ext4_extent_idx *);
167  extern void ext4_ext_store_pblock(struct ext4_extent *, ext4_fsblk_t);
168  extern int ext4_extent_tree_init(handle_t *, struct inode *);
169 +extern int ext4_ext_calc_credits_for_insert(struct inode *,
170 +                                           struct ext4_ext_path *);
171  extern int ext4_ext_calc_credits_for_single_extent(struct inode *inode,
172                                                    int num,
173                                                    struct ext4_ext_path *path);
174 Index: linux-2.6.18.i386/fs/ext4/mballoc.c
175 ===================================================================
176 --- linux-2.6.18.i386.orig/fs/ext4/mballoc.c
177 +++ linux-2.6.18.i386/fs/ext4/mballoc.c
178 @@ -4965,3 +4965,7 @@ error_return:
179                 kmem_cache_free(ext4_ac_cachep, ac);
180         return;
181  }
182 +
183 +EXPORT_SYMBOL(ext4_free_blocks);
184 +EXPORT_SYMBOL(ext4_mb_discard_inode_preallocations);
185 +
186 Index: linux-2.6.18.i386/fs/ext4/super.c
187 ===================================================================
188 --- linux-2.6.18.i386.orig/fs/ext4/super.c
189 +++ linux-2.6.18.i386/fs/ext4/super.c
190 @@ -91,6 +91,7 @@ ext4_fsblk_t ext4_inode_bitmap(struct su
191                 (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT ?
192                 (ext4_fsblk_t)le32_to_cpu(bg->bg_inode_bitmap_hi) << 32 : 0);
193  }
194 +EXPORT_SYMBOL(ext4_inode_bitmap);
195  
196  ext4_fsblk_t ext4_inode_table(struct super_block *sb,
197                               struct ext4_group_desc *bg)
198 @@ -513,7 +514,8 @@ static void ext4_put_super(struct super_
199         struct ext4_super_block *es = sbi->s_es;
200         int i;
201  
202 -       ext4_mb_release(sb);
203 +       if (test_opt(sb, MBALLOC))
204 +               ext4_mb_release(sb);
205         ext4_ext_release(sb);
206         ext4_xattr_put_super(sb);
207         jbd2_journal_destroy(sbi->s_journal);
208 @@ -2373,16 +2375,6 @@ static int ext4_fill_super(struct super_
209                        "running e2fsck is recommended\n");
210  
211         /*
212 -        * Since ext4 is still considered development code, we require
213 -        * that the TEST_FILESYS flag in s->flags be set.
214 -        */
215 -       if (!(le32_to_cpu(es->s_flags) & EXT2_FLAGS_TEST_FILESYS)) {
216 -               printk(KERN_WARNING "EXT4-fs: %s: not marked "
217 -                      "OK to use with test code.\n", sb->s_id);
218 -               goto failed_mount;
219 -       }
220 -
221 -       /*
222          * Check feature flags regardless of the revision level, since we
223          * previously didn't change the revision level when setting the flags,
224          * so there is a chance incompat flags are set on a rev 0 filesystem.
225 @@ -3835,9 +3827,9 @@ static int ext4_get_sb(struct file_syste
226         return get_sb_bdev(fs_type, flags, dev_name, data, ext4_fill_super, mnt);
227  }
228  
229 -static struct file_system_type ext4dev_fs_type = {
230 +static struct file_system_type ext4_fs_type = {
231         .owner          = THIS_MODULE,
232 -       .name           = "ext4dev",
233 +       .name           = "ext4",
234         .get_sb         = ext4_get_sb,
235         .kill_sb        = kill_block_super,
236  #ifdef HAVE_FALLOCATE
237 @@ -3867,7 +3859,7 @@ static int __init init_ext4_fs(void)
238         err = init_inodecache();
239         if (err)
240                 goto out1;
241 -       err = register_filesystem(&ext4dev_fs_type);
242 +       err = register_filesystem(&ext4_fs_type);
243         if (err)
244                 goto out;
245         return 0;
246 @@ -3884,7 +3876,7 @@ out3:
247  
248  static void __exit exit_ext4_fs(void)
249  {
250 -       unregister_filesystem(&ext4dev_fs_type);
251 +       unregister_filesystem(&ext4_fs_type);
252         destroy_inodecache();
253         exit_ext4_xattr();
254         exit_ext4_mballoc();
255 Index: linux-2.6.18.i386/fs/ext4/ext4_jbd2.c
256 ===================================================================
257 --- linux-2.6.18.i386.orig/fs/ext4/ext4_jbd2.c
258 +++ linux-2.6.18.i386/fs/ext4/ext4_jbd2.c
259 @@ -21,6 +21,7 @@ int __ext4_journal_get_write_access(cons
260                 ext4_journal_abort_handle(where, __func__, bh, handle, err);
261         return err;
262  }
263 +EXPORT_SYMBOL(__ext4_journal_get_write_access);
264  
265  int __ext4_journal_forget(const char *where, handle_t *handle,
266                                 struct buffer_head *bh)
267 @@ -57,3 +58,4 @@ int __ext4_journal_dirty_metadata(const 
268                 ext4_journal_abort_handle(where, __func__, bh, handle, err);
269         return err;
270  }
271 +EXPORT_SYMBOL(__ext4_journal_dirty_metadata);