1 diff -urpN linux-stage.orig/fs/ext4/balloc.c linux-stage/fs/ext4/balloc.c
2 --- linux-stage.orig/fs/ext4/balloc.c 2012-07-02 12:07:23.000000000 -0400
3 +++ linux-stage/fs/ext4/balloc.c 2012-07-02 12:07:57.000000000 -0400
4 @@ -97,7 +97,7 @@ unsigned ext4_init_block_bitmap(struct s
5 /* If checksum is bad mark all blocks used to prevent allocation
6 * essentially implementing a per-group read-only flag. */
7 if (!ext4_group_desc_csum_verify(sbi, block_group, gdp)) {
8 - ext4_error(sb, __func__,
10 "Checksum bad for group %u", block_group);
11 ext4_free_blks_set(sb, gdp, 0);
12 ext4_free_inodes_set(sb, gdp, 0);
13 @@ -207,10 +207,8 @@ struct ext4_group_desc * ext4_get_group_
14 struct ext4_sb_info *sbi = EXT4_SB(sb);
16 if (block_group >= ngroups) {
17 - ext4_error(sb, "ext4_get_group_desc",
18 - "block_group >= groups_count - "
19 - "block_group = %u, groups_count = %u",
20 - block_group, ngroups);
21 + ext4_error(sb, "block_group >= groups_count - block_group = %u,"
22 + " groups_count = %u", block_group, ngroups);
26 @@ -218,8 +216,7 @@ struct ext4_group_desc * ext4_get_group_
27 group_desc = block_group >> EXT4_DESC_PER_BLOCK_BITS(sb);
28 offset = block_group & (EXT4_DESC_PER_BLOCK(sb) - 1);
29 if (!sbi->s_group_desc[group_desc]) {
30 - ext4_error(sb, "ext4_get_group_desc",
31 - "Group descriptor not loaded - "
32 + ext4_error(sb, "Group descriptor not loaded - "
33 "block_group = %u, group_desc = %u, desc = %u",
34 block_group, group_desc, offset);
36 @@ -280,7 +277,7 @@ static int ext4_valid_block_bitmap(struc
40 - ext4_error(sb, __func__,
42 "Invalid block bitmap - "
43 "block_group = %d, block = %llu",
44 block_group, bitmap_blk);
45 @@ -309,7 +306,7 @@ ext4_read_block_bitmap(struct super_bloc
46 bitmap_blk = ext4_block_bitmap(sb, desc);
47 bh = sb_getblk(sb, bitmap_blk);
49 - ext4_error(sb, __func__,
51 "Cannot read block bitmap - "
52 "block_group = %u, block_bitmap = %llu",
53 block_group, bitmap_blk);
54 @@ -352,7 +349,7 @@ ext4_read_block_bitmap(struct super_bloc
55 set_bitmap_uptodate(bh);
56 if (bh_submit_read(bh) < 0) {
58 - ext4_error(sb, __func__,
60 "Cannot read block bitmap - "
61 "block_group = %u, block_bitmap = %llu",
62 block_group, bitmap_blk);
63 @@ -417,7 +414,7 @@ void ext4_add_groupblocks(handle_t *hand
64 in_range(block, ext4_inode_table(sb, desc), sbi->s_itb_per_group) ||
65 in_range(block + count - 1, ext4_inode_table(sb, desc),
66 sbi->s_itb_per_group)) {
67 - ext4_error(sb, __func__,
69 "Adding blocks in system zones - "
70 "Block = %llu, count = %lu",
72 @@ -451,7 +448,7 @@ void ext4_add_groupblocks(handle_t *hand
73 BUFFER_TRACE(bitmap_bh, "clear bit");
74 if (!ext4_clear_bit_atomic(ext4_group_lock_ptr(sb, block_group),
75 bit + i, bitmap_bh->b_data)) {
76 - ext4_error(sb, __func__,
78 "bit already cleared for block %llu",
79 (ext4_fsblk_t)(block + i));
80 BUFFER_TRACE(bitmap_bh, "bit already cleared");
81 diff -urpN linux-stage.orig/fs/ext4/dir.c linux-stage/fs/ext4/dir.c
82 --- linux-stage.orig/fs/ext4/dir.c 2012-07-02 12:07:23.000000000 -0400
83 +++ linux-stage/fs/ext4/dir.c 2012-07-02 12:07:57.000000000 -0400
84 @@ -70,28 +70,29 @@ int ext4_check_dir_entry(const char *fun
85 const int rlen = ext4_rec_len_from_disk(de->rec_len,
86 dir->i_sb->s_blocksize);
88 - if (rlen < EXT4_DIR_REC_LEN(1))
89 + if (unlikely(rlen < EXT4_DIR_REC_LEN(1)))
90 error_msg = "rec_len is smaller than minimal";
91 - else if (rlen % 4 != 0)
92 + else if (unlikely(rlen % 4 != 0))
93 error_msg = "rec_len % 4 != 0";
94 - else if (rlen < EXT4_DIR_REC_LEN(de->name_len))
95 + else if (unlikely(rlen < EXT4_DIR_REC_LEN(de->name_len)))
96 error_msg = "rec_len is too small for name_len";
97 - else if (((char *) de - bh->b_data) + rlen > dir->i_sb->s_blocksize)
98 + else if (unlikely(((char *) de - bh->b_data) + rlen > dir->i_sb->s_blocksize))
99 error_msg = "directory entry across blocks";
100 - else if (le32_to_cpu(de->inode) >
101 - le32_to_cpu(EXT4_SB(dir->i_sb)->s_es->s_inodes_count))
102 + else if (unlikely(le32_to_cpu(de->inode) >
103 + le32_to_cpu(EXT4_SB(dir->i_sb)->s_es->s_inodes_count)))
104 error_msg = "inode out of bounds";
108 - if (error_msg != NULL)
109 - ext4_error(dir->i_sb, function,
110 - "bad entry in directory #%lu: %s - block=%llu"
111 - "offset=%u(%u), inode=%u, rec_len=%d, name_len=%d",
112 - dir->i_ino, error_msg,
113 - (unsigned long long) bh->b_blocknr,
114 - (unsigned) (offset%bh->b_size), offset,
115 - le32_to_cpu(de->inode),
116 - rlen, de->name_len);
117 - return error_msg == NULL ? 1 : 0;
118 + ext4_error(dir->i_sb,
119 + "bad entry in directory #%lu: %s - block=%llu"
120 + "offset=%u(%u), inode=%u, rec_len=%d, name_len=%d",
121 + dir->i_ino, error_msg,
122 + (unsigned long long) bh->b_blocknr,
123 + (unsigned) (offset%bh->b_size), offset,
124 + le32_to_cpu(de->inode),
125 + rlen, de->name_len);
129 static int ext4_readdir(struct file *filp,
130 @@ -152,7 +153,7 @@ static int ext4_readdir(struct file *fil
133 if (!dir_has_error) {
134 - ext4_error(sb, __func__, "directory #%lu "
135 + ext4_error(sb, "directory #%lu "
136 "contains a hole at offset %Lu",
138 (unsigned long long) filp->f_pos);
139 diff -urpN linux-stage.orig/fs/ext4/ext4_extents.h linux-stage/fs/ext4/ext4_extents.h
140 --- linux-stage.orig/fs/ext4/ext4_extents.h 2012-07-02 12:07:23.000000000 -0400
141 +++ linux-stage/fs/ext4/ext4_extents.h 2012-07-02 12:07:57.000000000 -0400
142 @@ -138,7 +138,7 @@ typedef int (*ext_prepare_callback)(stru
145 /* Maximum logical block in a file; ext4_extent's ee_block is __le32 */
146 -#define EXT_MAX_BLOCK 0xffffffff
147 +#define EXT_MAX_BLOCKS 0xffffffff
150 * EXT_INIT_MAX_LEN is the maximum number of blocks we can have in an
151 diff -urpN linux-stage.orig/fs/ext4/ext4.h linux-stage/fs/ext4/ext4.h
152 --- linux-stage.orig/fs/ext4/ext4.h 2012-07-02 12:07:23.000000000 -0400
153 +++ linux-stage/fs/ext4/ext4.h 2012-07-02 12:10:15.000000000 -0400
155 #include <linux/quota.h>
156 #include <linux/rwsem.h>
157 #include <linux/rbtree.h>
158 +#include <linux/kernel.h>
159 #include <linux/seqlock.h>
160 #include <linux/mutex.h>
161 #include <linux/timer.h>
163 #define ext4_debug(f, a...) do {} while (0)
166 +#define EXT4_ERROR_INODE(inode, fmt, a...) \
167 + ext4_error_inode(__func__, (inode), (fmt), ## a);
169 +#define EXT4_ERROR_FILE(file, fmt, a...) \
170 + ext4_error_file(__func__, (file), (fmt), ## a);
172 /* data type for block offset of block group */
173 typedef int ext4_grpblk_t;
175 @@ -970,7 +977,27 @@ struct ext4_super_block {
176 __u8 s_reserved_char_pad2;
177 __le16 s_reserved_pad;
178 __le64 s_kbytes_written; /* nr of lifetime kilobytes written */
179 - __u32 s_reserved[160]; /* Padding to the end of the block */
180 + __le32 s_snapshot_inum; /* Inode number of active snapshot */
181 + __le32 s_snapshot_id; /* sequential ID of active snapshot */
182 + __le64 s_snapshot_r_blocks_count; /* reserved blocks for active
183 + snapshot's future use */
184 + __le32 s_snapshot_list; /* inode number of the head of the
185 + on-disk snapshot list */
186 +#define EXT4_S_ERR_START offsetof(struct ext4_super_block, s_error_count)
187 + __le32 s_error_count; /* number of fs errors */
188 + __le32 s_first_error_time; /* first time an error happened */
189 + __le32 s_first_error_ino; /* inode involved in first error */
190 + __le64 s_first_error_block; /* block involved of first error */
191 + __u8 s_first_error_func[32]; /* function where the error happened */
192 + __le32 s_first_error_line; /* line number where error happened */
193 + __le32 s_last_error_time; /* most recent time of an error */
194 + __le32 s_last_error_ino; /* inode involved in last error */
195 + __le32 s_last_error_line; /* line number where error happened */
196 + __le64 s_last_error_block; /* block involved of last error */
197 + __u8 s_last_error_func[32]; /* function where the error happened */
198 +#define EXT4_S_ERR_END offsetof(struct ext4_super_block, s_mount_opts)
199 + __u8 s_mount_opts[64];
200 + __le32 s_reserved[112]; /* Padding to the end of the block */
204 @@ -1110,6 +1137,9 @@ struct ext4_sb_info {
206 /* workqueue for dio unwritten */
207 struct workqueue_struct *dio_unwritten_wq;
209 + /* Lazy inode table initialization info */
210 + struct ext4_li_request *s_li_request;
213 static inline struct ext4_sb_info *EXT4_SB(struct super_block *sb)
214 @@ -1431,6 +1461,23 @@ void ext4_get_group_no_and_offset(struct
215 extern struct proc_dir_entry *ext4_proc_root;
218 + * Timeout and state flag for lazy initialization inode thread.
220 +#define EXT4_DEF_LI_WAIT_MULT 10
221 +#define EXT4_DEF_LI_MAX_START_DELAY 5
222 +#define EXT4_LAZYINIT_QUIT 0x0001
223 +#define EXT4_LAZYINIT_RUNNING 0x0002
226 + * Lazy inode table initialization info
228 +struct ext4_lazy_init {
229 + unsigned long li_state;
230 + struct list_head li_request_list;
231 + struct mutex li_list_mtx;
235 * Function prototypes
238 @@ -1509,6 +1556,7 @@ extern struct buffer_head *ext4_read_ino
239 extern void mark_bitmap_end(int start_bit, int end_bit, char *bitmap);
242 +struct fstrim_range;
243 extern long ext4_mb_stats;
244 extern long ext4_mb_max_to_scan;
245 extern int ext4_mb_init(struct super_block *, int);
246 @@ -1526,6 +1574,8 @@ extern int ext4_mb_add_groupinfo(struct
247 extern int ext4_mb_get_buddy_cache_lock(struct super_block *, ext4_group_t);
248 extern void ext4_mb_put_buddy_cache_lock(struct super_block *,
250 +extern int ext4_trim_fs(struct super_block *, struct fstrim_range *);
253 int ext4_forget(handle_t *handle, int is_metadata, struct inode *inode,
254 struct buffer_head *bh, ext4_fsblk_t blocknr);
255 @@ -1586,13 +1636,17 @@ extern int ext4_group_extend(struct supe
256 ext4_fsblk_t n_blocks_count);
259 -extern void ext4_error(struct super_block *, const char *, const char *, ...)
260 +extern void __ext4_error(struct super_block *, const char *, const char *, ...)
261 + __attribute__ ((format (printf, 3, 4)));
262 +#define ext4_error(sb, message...) __ext4_error(sb, __func__, ## message)
263 +extern void ext4_error_inode(const char *, struct inode *, const char *, ...)
264 __attribute__ ((format (printf, 3, 4)));
265 extern void __ext4_std_error(struct super_block *, const char *, int);
266 extern void ext4_abort(struct super_block *, const char *, const char *, ...)
267 __attribute__ ((format (printf, 3, 4)));
268 -extern void ext4_warning(struct super_block *, const char *, const char *, ...)
269 +extern void __ext4_warning(struct super_block *, const char *, const char *, ...)
270 __attribute__ ((format (printf, 3, 4)));
271 +#define ext4_warning(sb, message...) __ext4_warning(sb, __func__, ## message)
272 extern void ext4_msg(struct super_block *, const char *, const char *, ...)
273 __attribute__ ((format (printf, 3, 4)));
274 extern void ext4_grp_locked_error(struct super_block *, ext4_group_t,
275 @@ -1774,11 +1828,19 @@ struct ext4_group_info {
276 * 5 free 8-block regions. */
279 -#define EXT4_GROUP_INFO_NEED_INIT_BIT 0
280 +#define EXT4_GROUP_INFO_NEED_INIT_BIT 0
281 +#define EXT4_GROUP_INFO_WAS_TRIMMED_BIT 1
283 #define EXT4_MB_GRP_NEED_INIT(grp) \
284 (test_bit(EXT4_GROUP_INFO_NEED_INIT_BIT, &((grp)->bb_state)))
286 +#define EXT4_MB_GRP_WAS_TRIMMED(grp) \
287 + (test_bit(EXT4_GROUP_INFO_WAS_TRIMMED_BIT, &((grp)->bb_state)))
288 +#define EXT4_MB_GRP_SET_TRIMMED(grp) \
289 + (set_bit(EXT4_GROUP_INFO_WAS_TRIMMED_BIT, &((grp)->bb_state)))
290 +#define EXT4_MB_GRP_CLEAR_TRIMMED(grp) \
291 + (clear_bit(EXT4_GROUP_INFO_WAS_TRIMMED_BIT, &((grp)->bb_state)))
293 #define EXT4_MAX_CONTENTION 8
294 #define EXT4_CONTENTION_THRESHOLD 2
296 diff -urpN linux-stage.orig/fs/ext4/ext4_jbd2.c linux-stage/fs/ext4/ext4_jbd2.c
297 --- linux-stage.orig/fs/ext4/ext4_jbd2.c 2012-07-02 12:07:23.000000000 -0400
298 +++ linux-stage/fs/ext4/ext4_jbd2.c 2012-07-02 12:07:57.000000000 -0400
299 @@ -96,7 +96,7 @@ int __ext4_handle_dirty_metadata(const c
300 if (inode && inode_needs_sync(inode)) {
301 sync_dirty_buffer(bh);
302 if (buffer_req(bh) && !buffer_uptodate(bh)) {
303 - ext4_error(inode->i_sb, __func__,
304 + ext4_error(inode->i_sb,
305 "IO error syncing inode, "
306 "inode=%lu, block=%llu",
308 diff -urpN linux-stage.orig/fs/ext4/extents.c linux-stage/fs/ext4/extents.c
309 --- linux-stage.orig/fs/ext4/extents.c 2012-07-02 12:07:23.000000000 -0400
310 +++ linux-stage/fs/ext4/extents.c 2012-07-02 12:07:57.000000000 -0400
311 @@ -437,7 +437,7 @@ static int __ext4_ext_check(const char *
315 - ext4_error(inode->i_sb, function,
316 + ext4_error(inode->i_sb,
317 "bad header/extent in inode #%lu: %s - magic %x, "
318 "entries %u, max %u(%u), depth %u(%u)",
319 inode->i_ino, error_msg, le16_to_cpu(eh->eh_magic),
320 @@ -1329,7 +1329,7 @@ got_index:
323 * ext4_ext_next_allocated_block:
324 - * returns allocated block in subsequent extent or EXT_MAX_BLOCK.
325 + * returns allocated block in subsequent extent or EXT_MAX_BLOCKS.
326 * NOTE: it considers block number from index entry as
327 * allocated block. Thus, index entries have to be consistent
329 @@ -1343,7 +1343,7 @@ ext4_ext_next_allocated_block(struct ext
330 depth = path->p_depth;
332 if (depth == 0 && path->p_ext == NULL)
333 - return EXT_MAX_BLOCK;
334 + return EXT_MAX_BLOCKS;
337 if (depth == path->p_depth) {
338 @@ -1360,12 +1360,12 @@ ext4_ext_next_allocated_block(struct ext
342 - return EXT_MAX_BLOCK;
343 + return EXT_MAX_BLOCKS;
347 * ext4_ext_next_leaf_block:
348 - * returns first allocated block from next leaf or EXT_MAX_BLOCK
349 + * returns first allocated block from next leaf or EXT_MAX_BLOCKS
351 static ext4_lblk_t ext4_ext_next_leaf_block(struct inode *inode,
352 struct ext4_ext_path *path)
353 @@ -1377,7 +1377,7 @@ static ext4_lblk_t ext4_ext_next_leaf_bl
355 /* zero-tree has no leaf blocks at all */
357 - return EXT_MAX_BLOCK;
358 + return EXT_MAX_BLOCKS;
360 /* go to index block */
362 @@ -1390,7 +1390,7 @@ static ext4_lblk_t ext4_ext_next_leaf_bl
366 - return EXT_MAX_BLOCK;
367 + return EXT_MAX_BLOCKS;
371 @@ -1534,7 +1534,7 @@ int ext4_ext_try_to_merge(struct inode *
373 WARN_ON(eh->eh_entries == 0);
375 - ext4_error(inode->i_sb, "ext4_ext_try_to_merge",
376 + ext4_error(inode->i_sb,
377 "inode#%lu, eh->eh_entries = 0!", inode->i_ino);
380 @@ -1570,13 +1570,13 @@ unsigned int ext4_ext_check_overlap(stru
383 b2 = ext4_ext_next_allocated_block(path);
384 - if (b2 == EXT_MAX_BLOCK)
385 + if (b2 == EXT_MAX_BLOCKS)
389 /* check for wrap through zero on extent logical start block*/
390 if (b1 + len1 < b1) {
391 - len1 = EXT_MAX_BLOCK - b1;
392 + len1 = EXT_MAX_BLOCKS - b1;
393 newext->ee_len = cpu_to_le16(len1);
396 @@ -1652,7 +1652,7 @@ repeat:
397 fex = EXT_LAST_EXTENT(eh);
398 next = ext4_ext_next_leaf_block(inode, path);
399 if (le32_to_cpu(newext->ee_block) > le32_to_cpu(fex->ee_block)
400 - && next != EXT_MAX_BLOCK) {
401 + && next != EXT_MAX_BLOCKS) {
402 ext_debug("next leaf block - %d\n", next);
403 BUG_ON(npath != NULL);
404 npath = ext4_ext_find_extent(inode, next, NULL);
405 @@ -1771,7 +1771,7 @@ int ext4_ext_walk_space(struct inode *in
406 BUG_ON(func == NULL);
407 BUG_ON(inode == NULL);
409 - while (block < last && block != EXT_MAX_BLOCK) {
410 + while (block < last && block != EXT_MAX_BLOCKS) {
412 /* find extent for this block */
413 down_read(&EXT4_I(inode)->i_data_sem);
414 @@ -1784,7 +1784,11 @@ int ext4_ext_walk_space(struct inode *in
417 depth = ext_depth(inode);
418 - BUG_ON(path[depth].p_hdr == NULL);
419 + if (unlikely(path[depth].p_hdr == NULL)) {
420 + EXT4_ERROR_INODE(inode, "path[%d].p_hdr == NULL", depth);
424 ex = path[depth].p_ext;
425 next = ext4_ext_next_allocated_block(path);
427 @@ -1835,7 +1839,11 @@ int ext4_ext_walk_space(struct inode *in
428 cbex.ec_type = EXT4_EXT_CACHE_EXTENT;
431 - BUG_ON(cbex.ec_len == 0);
432 + if (unlikely(cbex.ec_len == 0)) {
433 + EXT4_ERROR_INODE(inode, "cbex.ec_len == 0");
437 err = func(inode, path, &cbex, ex, cbdata);
438 ext4_ext_drop_refs(path);
440 @@ -1899,7 +1907,7 @@ ext4_ext_put_gap_in_cache(struct inode *
442 /* there is no extent yet, so gap is [0;-] */
444 - len = EXT_MAX_BLOCK;
445 + len = EXT_MAX_BLOCKS;
446 ext_debug("cache gap(whole file):");
447 } else if (block < le32_to_cpu(ex->ee_block)) {
449 @@ -2144,8 +2152,8 @@ ext4_ext_rm_leaf(handle_t *handle, struc
450 path[depth].p_ext = ex;
452 a = ex_ee_block > start ? ex_ee_block : start;
453 - b = ex_ee_block + ex_ee_len - 1 < EXT_MAX_BLOCK ?
454 - ex_ee_block + ex_ee_len - 1 : EXT_MAX_BLOCK;
455 + b = ex_ee_block + ex_ee_len - 1 < EXT_MAX_BLOCKS ?
456 + ex_ee_block + ex_ee_len - 1 : EXT_MAX_BLOCKS;
458 ext_debug(" border %u:%u\n", a, b);
460 @@ -3284,7 +3292,7 @@ int ext4_ext_get_blocks(handle_t *handle
461 * this is why assert can't be put in ext4_ext_find_extent()
463 if (path[depth].p_ext == NULL && depth != 0) {
464 - ext4_error(inode->i_sb, __func__, "bad extent address "
465 + ext4_error(inode->i_sb, "bad extent address "
466 "inode: %lu, iblock: %lu, depth: %d",
467 inode->i_ino, (unsigned long) iblock, depth);
469 @@ -3415,7 +3423,7 @@ int ext4_ext_get_blocks(handle_t *handle
471 if (unlikely(ext4_test_inode_flag(inode, EXT4_INODE_EOFBLOCKS))) {
472 if (unlikely(!eh->eh_entries)) {
473 - ext4_error(inode->i_sb, __func__,
474 + ext4_error(inode->i_sb,
475 "inode#%lu, eh->eh_entries = 0 and "
476 "EOFBLOCKS_FL set", inode->i_ino);
478 @@ -3782,15 +3790,15 @@ static int ext4_ext_fiemap_cb(struct ino
479 flags |= FIEMAP_EXTENT_UNWRITTEN;
482 - * If this extent reaches EXT_MAX_BLOCK, it must be last.
483 + * If this extent reaches EXT_MAX_BLOCKS, it must be last.
485 - * Or if ext4_ext_next_allocated_block is EXT_MAX_BLOCK,
486 + * Or if ext4_ext_next_allocated_block is EXT_MAX_BLOCKS,
487 * this also indicates no more allocated blocks.
489 - * XXX this might miss a single-block extent at EXT_MAX_BLOCK
490 + * XXX this might miss a single-block extent at EXT_MAX_BLOCKS
492 - if (ext4_ext_next_allocated_block(path) == EXT_MAX_BLOCK ||
493 - newex->ec_block + newex->ec_len - 1 == EXT_MAX_BLOCK) {
494 + if (ext4_ext_next_allocated_block(path) == EXT_MAX_BLOCKS ||
495 + newex->ec_block + newex->ec_len - 1 == EXT_MAX_BLOCKS) {
496 loff_t size = i_size_read(inode);
497 loff_t bs = EXT4_BLOCK_SIZE(inode->i_sb);
499 @@ -3870,8 +3878,8 @@ int ext4_fiemap(struct inode *inode, str
501 start_blk = start >> inode->i_sb->s_blocksize_bits;
502 last_blk = (start + len - 1) >> inode->i_sb->s_blocksize_bits;
503 - if (last_blk >= EXT_MAX_BLOCK)
504 - last_blk = EXT_MAX_BLOCK-1;
505 + if (last_blk >= EXT_MAX_BLOCKS)
506 + last_blk = EXT_MAX_BLOCKS-1;
507 len_blks = ((ext4_lblk_t) last_blk) - start_blk + 1;
510 diff -urpN linux-stage.orig/fs/ext4/ialloc.c linux-stage/fs/ext4/ialloc.c
511 --- linux-stage.orig/fs/ext4/ialloc.c 2012-07-02 12:07:23.000000000 -0400
512 +++ linux-stage/fs/ext4/ialloc.c 2012-07-02 12:07:57.000000000 -0400
513 @@ -76,7 +76,7 @@ unsigned ext4_init_inode_bitmap(struct s
514 /* If checksum is bad mark all blocks and inodes use to prevent
515 * allocation, essentially implementing a per-group read-only flag. */
516 if (!ext4_group_desc_csum_verify(sbi, block_group, gdp)) {
517 - ext4_error(sb, __func__, "Checksum bad for group %u",
518 + ext4_error(sb, "Checksum bad for group %u",
520 ext4_free_blks_set(sb, gdp, 0);
521 ext4_free_inodes_set(sb, gdp, 0);
522 @@ -111,7 +111,7 @@ ext4_read_inode_bitmap(struct super_bloc
523 bitmap_blk = ext4_inode_bitmap(sb, desc);
524 bh = sb_getblk(sb, bitmap_blk);
526 - ext4_error(sb, __func__,
528 "Cannot read inode bitmap - "
529 "block_group = %u, inode_bitmap = %llu",
530 block_group, bitmap_blk);
531 @@ -153,7 +153,7 @@ ext4_read_inode_bitmap(struct super_bloc
532 set_bitmap_uptodate(bh);
533 if (bh_submit_read(bh) < 0) {
535 - ext4_error(sb, __func__,
537 "Cannot read inode bitmap - "
538 "block_group = %u, inode_bitmap = %llu",
539 block_group, bitmap_blk);
540 @@ -230,8 +230,7 @@ void ext4_free_inode(handle_t *handle, s
542 es = EXT4_SB(sb)->s_es;
543 if (ino < EXT4_FIRST_INO(sb) || ino > le32_to_cpu(es->s_inodes_count)) {
544 - ext4_error(sb, "ext4_free_inode",
545 - "reserved or nonexistent inode %lu", ino);
546 + ext4_error(sb, "reserved or nonexistent inode %lu", ino);
549 block_group = (ino - 1) / EXT4_INODES_PER_GROUP(sb);
550 @@ -286,11 +285,10 @@ out:
554 - ext4_error(sb, "ext4_free_inode",
555 - "bit already cleared for inode %lu", ino);
556 + ext4_error(sb, "bit already cleared for inode %lu", ino);
561 ext4_std_error(sb, fatal);
564 @@ -730,7 +728,7 @@ static int ext4_claim_inode(struct super
565 if ((group == 0 && ino < EXT4_FIRST_INO(sb)) ||
566 ino > EXT4_INODES_PER_GROUP(sb)) {
567 ext4_unlock_group(sb, group);
568 - ext4_error(sb, __func__,
570 "reserved inode or inode > inodes count - "
571 "block_group = %u, inode=%lu", group,
572 ino + group * EXT4_INODES_PER_GROUP(sb));
573 @@ -1094,7 +1092,7 @@ struct inode *ext4_orphan_get(struct sup
575 /* Error cases - e2fsck has already cleaned up for us */
577 - ext4_warning(sb, __func__,
579 "bad orphan ino %lu! e2fsck was run?", ino);
582 @@ -1103,7 +1101,7 @@ struct inode *ext4_orphan_get(struct sup
583 bit = (ino - 1) % EXT4_INODES_PER_GROUP(sb);
584 bitmap_bh = ext4_read_inode_bitmap(sb, block_group);
586 - ext4_warning(sb, __func__,
588 "inode bitmap error for orphan %lu", ino);
591 @@ -1136,7 +1134,7 @@ iget_failed:
592 err = PTR_ERR(inode);
595 - ext4_warning(sb, __func__,
597 "bad orphan inode %lu! e2fsck was run?", ino);
598 printk(KERN_NOTICE "ext4_test_bit(bit=%d, block=%llu) = %d\n",
599 bit, (unsigned long long)bitmap_bh->b_blocknr,
600 diff -urpN linux-stage.orig/fs/ext4/inode.c linux-stage/fs/ext4/inode.c
601 --- linux-stage.orig/fs/ext4/inode.c 2012-07-02 12:07:23.000000000 -0400
602 +++ linux-stage/fs/ext4/inode.c 2012-07-02 12:07:57.000000000 -0400
603 @@ -246,7 +246,7 @@ void ext4_delete_inode(struct inode *ino
605 err = ext4_mark_inode_dirty(handle, inode);
607 - ext4_warning(inode->i_sb, __func__,
608 + ext4_warning(inode->i_sb,
609 "couldn't mark inode dirty (err %d)", err);
612 @@ -264,7 +264,7 @@ void ext4_delete_inode(struct inode *ino
614 err = ext4_journal_restart(handle, 3);
616 - ext4_warning(inode->i_sb, __func__,
617 + ext4_warning(inode->i_sb,
618 "couldn't extend journal (err %d)", err);
620 ext4_journal_stop(handle);
621 @@ -375,8 +375,7 @@ static int ext4_block_to_path(struct ino
622 offsets[n++] = i_block & (ptrs - 1);
625 - ext4_warning(inode->i_sb, "ext4_block_to_path",
626 - "block %lu > max in inode %lu",
627 + ext4_warning(inode->i_sb, "block %lu > max in inode %lu",
628 i_block + direct_blocks +
629 indirect_blocks + double_blocks, inode->i_ino);
631 @@ -396,7 +395,7 @@ static int __ext4_check_blockref(const c
633 unlikely(!ext4_data_block_valid(EXT4_SB(inode->i_sb),
635 - ext4_error(inode->i_sb, function,
636 + ext4_error(inode->i_sb,
637 "invalid block reference %u "
638 "in inode #%lu", blk, inode->i_ino);
640 @@ -1167,7 +1166,7 @@ static int check_block_validity(struct i
641 sector_t logical, sector_t phys, int len)
643 if (!ext4_data_block_valid(EXT4_SB(inode->i_sb), phys, len)) {
644 - ext4_error(inode->i_sb, msg,
645 + ext4_error(inode->i_sb,
646 "inode #%lu logical block %llu mapped to %llu "
647 "(size %d)", inode->i_ino,
648 (unsigned long long) logical,
649 @@ -4316,7 +4315,7 @@ static void ext4_free_data(handle_t *han
650 if ((EXT4_JOURNAL(inode) == NULL) || bh2jh(this_bh))
651 ext4_handle_dirty_metadata(handle, inode, this_bh);
653 - ext4_error(inode->i_sb, __func__,
654 + ext4_error(inode->i_sb,
655 "circular indirect block detected, "
656 "inode=%lu, block=%llu",
658 @@ -4364,7 +4363,7 @@ static void ext4_free_branches(handle_t
662 - ext4_error(inode->i_sb, "ext4_free_branches",
663 + ext4_error(inode->i_sb,
664 "Read failure, inode=%lu, block=%llu",
667 @@ -4680,9 +4679,8 @@ static int __ext4_get_inode_loc(struct i
669 bh = sb_getblk(sb, block);
671 - ext4_error(sb, "ext4_get_inode_loc", "unable to read "
672 - "inode block - inode=%lu, block=%llu",
673 - inode->i_ino, block);
674 + ext4_error(sb, "unable to read inode block - "
675 + "inode=%lu, block=%llu", inode->i_ino, block);
678 if (!buffer_uptodate(bh)) {
679 @@ -4780,7 +4778,7 @@ make_io:
680 submit_bh(READ_META, bh);
682 if (!buffer_uptodate(bh)) {
683 - ext4_error(sb, __func__,
685 "unable to read inode block - inode=%lu, "
686 "block=%llu", inode->i_ino, block);
688 @@ -4999,7 +4997,7 @@ struct inode *ext4_iget(struct super_blo
690 if (ei->i_file_acl &&
691 !ext4_data_block_valid(EXT4_SB(sb), ei->i_file_acl, 1)) {
692 - ext4_error(sb, __func__,
694 "bad extended attribute block %llu in inode #%lu",
695 ei->i_file_acl, inode->i_ino);
697 @@ -5046,7 +5044,7 @@ struct inode *ext4_iget(struct super_blo
698 new_decode_dev(le32_to_cpu(raw_inode->i_block[1])));
701 - ext4_error(inode->i_sb, __func__,
702 + ext4_error(inode->i_sb,
703 "bogus i_mode (%o) for inode=%lu",
704 inode->i_mode, inode->i_ino);
706 @@ -5286,7 +5284,7 @@ int ext4_write_inode(struct inode *inode
708 sync_dirty_buffer(iloc.bh);
709 if (buffer_req(iloc.bh) && !buffer_uptodate(iloc.bh)) {
710 - ext4_error(inode->i_sb, __func__,
711 + ext4_error(inode->i_sb,
712 "IO error syncing inode, "
713 "inode=%lu, block=%llu",
715 @@ -5707,7 +5705,7 @@ int ext4_mark_inode_dirty(handle_t *hand
716 EXT4_STATE_NO_EXPAND);
718 le16_to_cpu(sbi->s_es->s_mnt_count)) {
719 - ext4_warning(inode->i_sb, __func__,
720 + ext4_warning(inode->i_sb,
721 "Unable to expand inode %lu. Delete"
722 " some EAs or run e2fsck.",
724 diff -urpN linux-stage.orig/fs/ext4/mballoc.c linux-stage/fs/ext4/mballoc.c
725 --- linux-stage.orig/fs/ext4/mballoc.c 2012-07-02 12:07:23.000000000 -0400
726 +++ linux-stage/fs/ext4/mballoc.c 2012-07-02 12:07:57.000000000 -0400
727 @@ -862,8 +862,6 @@ static int ext4_mb_init_cache(struct pag
730 first_block = page->index * blocks_per_page;
731 - /* init the page */
732 - memset(page_address(page), 0xff, PAGE_CACHE_SIZE);
733 for (i = 0; i < blocks_per_page; i++) {
735 struct ext4_group_info *grinfo;
736 @@ -899,6 +897,8 @@ static int ext4_mb_init_cache(struct pag
737 * incore got set to the group block bitmap below
739 ext4_lock_group(sb, group);
740 + /* init the page */
741 + memset(data, 0xff, blocksize);
742 ext4_mb_generate_buddy(sb, data, incore, group);
743 ext4_unlock_group(sb, group);
745 @@ -1862,7 +1862,6 @@ void ext4_mb_scan_aligned(struct ext4_al
749 -/* This is now called BEFORE we load the buddy bitmap. */
750 static int ext4_mb_good_group(struct ext4_allocation_context *ac,
751 ext4_group_t group, int cr)
753 @@ -2162,6 +2161,11 @@ static void *ext4_mb_seq_groups_next(str
754 return (void *) ((unsigned long) group);
757 +static inline void ext4_mb_release_desc(struct ext4_buddy *e4b)
759 + ext4_mb_unload_buddy(e4b);
762 static int ext4_mb_seq_groups_show(struct seq_file *seq, void *v)
764 struct super_block *sb = seq->private;
765 @@ -2193,7 +2197,7 @@ static int ext4_mb_seq_groups_show(struc
766 ext4_lock_group(sb, group);
767 memcpy(&sg, ext4_get_group_info(sb, group), i);
768 ext4_unlock_group(sb, group);
769 - ext4_mb_unload_buddy(&e4b);
770 + ext4_mb_release_desc(&e4b);
772 seq_printf(seq, "#%-5u: %-5u %-5u %-5u [", group, sg.info.bb_free,
773 sg.info.bb_fragments, sg.info.bb_first_free);
774 @@ -2562,6 +2566,17 @@ int ext4_mb_release(struct super_block *
778 +static inline int ext4_issue_discard(struct super_block *sb,
779 + ext4_group_t block_group, ext4_grpblk_t block, int count)
781 + ext4_fsblk_t discard_block;
783 + discard_block = block + ext4_group_first_block_no(sb, block_group);
784 + trace_ext4_discard_blocks(sb,
785 + (unsigned long long) discard_block, count);
786 + return sb_issue_discard(sb, discard_block, count);
790 * This function is called by the jbd2 layer once the commit has finished,
791 * so we know we can free the blocks that were released with that commit.
792 @@ -2581,22 +2596,9 @@ static void release_blocks_on_commit(jou
793 mb_debug(1, "gonna free %u blocks in group %u (0x%p):",
794 entry->count, entry->group, entry);
796 - if (test_opt(sb, DISCARD)) {
798 - ext4_fsblk_t discard_block;
800 - discard_block = entry->start_blk +
801 - ext4_group_first_block_no(sb, entry->group);
802 - trace_ext4_discard_blocks(sb,
803 - (unsigned long long)discard_block,
805 - ret = sb_issue_discard(sb, discard_block, entry->count);
806 - if (ret == EOPNOTSUPP) {
807 - ext4_warning(sb, __func__,
808 - "discard not supported, disabling");
809 - clear_opt(EXT4_SB(sb)->s_mount_opt, DISCARD);
812 + if (test_opt(sb, DISCARD))
813 + ext4_issue_discard(sb, entry->group,
814 + entry->start_blk, entry->count);
816 err = ext4_mb_load_buddy(sb, entry->group, &e4b);
817 /* we expect to find existing buddy because it's pinned */
818 @@ -2611,6 +2613,15 @@ static void release_blocks_on_commit(jou
819 rb_erase(&entry->node, &(db->bb_free_root));
820 mb_free_blocks(NULL, &e4b, entry->start_blk, entry->count);
823 + * Clear the trimmed flag for the group so that the next
824 + * ext4_trim_fs can trim it.
825 + * If the volume is mounted with -o discard, online discard
826 + * is supported and the free blocks will be trimmed online.
828 + if (!test_opt(sb, DISCARD))
829 + EXT4_MB_GRP_CLEAR_TRIMMED(db);
831 if (!db->bb_free_root.rb_node) {
832 /* No more items in the per group rb tree
833 * balance refcounts from ext4_mb_free_metadata()
834 @@ -2620,7 +2631,7 @@ static void release_blocks_on_commit(jou
836 ext4_unlock_group(sb, entry->group);
837 kmem_cache_free(ext4_free_ext_cachep, entry);
838 - ext4_mb_unload_buddy(&e4b);
839 + ext4_mb_release_desc(&e4b);
842 mb_debug(1, "freed %u blocks in %u structures\n", count, count2);
843 @@ -2757,7 +2768,7 @@ ext4_mb_mark_diskspace_used(struct ext4_
845 len = ac->ac_b_ex.fe_len;
846 if (!ext4_data_block_valid(sbi, block, len)) {
847 - ext4_error(sb, __func__,
849 "Allocating blocks %llu-%llu which overlap "
850 "fs metadata\n", block, block+len);
851 /* File system mounted not to panic on error
852 @@ -3671,14 +3682,14 @@ ext4_mb_discard_group_preallocations(str
854 bitmap_bh = ext4_read_block_bitmap(sb, group);
855 if (bitmap_bh == NULL) {
856 - ext4_error(sb, __func__, "Error in reading block "
857 + ext4_error(sb, "Error in reading block "
858 "bitmap for %u", group);
862 err = ext4_mb_load_buddy(sb, group, &e4b);
864 - ext4_error(sb, __func__, "Error in loading buddy "
865 + ext4_error(sb, "Error in loading buddy "
866 "information for %u", group);
869 @@ -3852,14 +3863,14 @@ repeat:
871 err = ext4_mb_load_buddy(sb, group, &e4b);
873 - ext4_error(sb, __func__, "Error in loading buddy "
874 - "information for %u", group);
875 + ext4_error(sb, "Error in loading buddy information for %u",
880 bitmap_bh = ext4_read_block_bitmap(sb, group);
881 if (bitmap_bh == NULL) {
882 - ext4_error(sb, __func__, "Error in reading block "
883 + ext4_error(sb, "Error in reading block "
884 "bitmap for %u", group);
885 ext4_mb_unload_buddy(&e4b);
887 @@ -4125,7 +4136,7 @@ ext4_mb_discard_lg_preallocations(struct
889 ext4_get_group_no_and_offset(sb, pa->pa_pstart, &group, NULL);
890 if (ext4_mb_load_buddy(sb, group, &e4b)) {
891 - ext4_error(sb, __func__, "Error in loading buddy "
892 + ext4_error(sb, "Error in loading buddy "
893 "information for %u", group);
896 @@ -4516,7 +4527,7 @@ void ext4_mb_free_blocks(handle_t *handl
897 if (block < le32_to_cpu(es->s_first_data_block) ||
898 block + count < block ||
899 block + count > ext4_blocks_count(es)) {
900 - ext4_error(sb, __func__,
902 "Freeing blocks not in datazone - "
903 "block = %llu, count = %lu", block, count);
905 @@ -4561,7 +4572,7 @@ do_more:
906 in_range(block + count - 1, ext4_inode_table(sb, gdp),
907 EXT4_SB(sb)->s_itb_per_group)) {
909 - ext4_error(sb, __func__,
911 "Freeing blocks in system zone - "
912 "Block = %llu, count = %lu", block, count);
913 /* err = 0. ext4_std_error should be a no op */
914 diff -urpN linux-stage.orig/fs/ext4/move_extent.c linux-stage/fs/ext4/move_extent.c
915 --- linux-stage.orig/fs/ext4/move_extent.c 2012-07-02 12:07:23.000000000 -0400
916 +++ linux-stage/fs/ext4/move_extent.c 2012-07-02 12:07:57.000000000 -0400
917 @@ -152,12 +152,12 @@ mext_check_null_inode(struct inode *inod
920 if (inode1 == NULL) {
921 - ext4_error(inode2->i_sb, function,
922 + ext4_error(inode2->i_sb,
923 "Both inodes should not be NULL: "
924 "inode1 NULL inode2 %lu", inode2->i_ino);
926 } else if (inode2 == NULL) {
927 - ext4_error(inode1->i_sb, function,
928 + ext4_error(inode1->i_sb,
929 "Both inodes should not be NULL: "
930 "inode1 %lu inode2 NULL", inode1->i_ino);
932 @@ -483,7 +483,7 @@ mext_leaf_block(handle_t *handle, struct
934 o_start = o_end = oext = orig_path[depth].p_ext;
935 oext_alen = ext4_ext_get_actual_len(oext);
936 - start_ext.ee_len = end_ext.ee_len = 0;
937 + start_ext.ee_block = start_ext.ee_len = end_ext.ee_len = 0;
939 new_ext.ee_block = cpu_to_le32(*from);
940 ext4_ext_store_pblock(&new_ext, ext_pblock(dext));
941 @@ -528,7 +528,7 @@ mext_leaf_block(handle_t *handle, struct
944 if (le32_to_cpu(oext->ee_block) + oext_alen - 1 < new_ext_end) {
945 - ext4_error(orig_inode->i_sb, __func__,
946 + ext4_error(orig_inode->i_sb,
947 "new_ext_end(%u) should be less than or equal to "
948 "oext->ee_block(%u) + oext_alen(%d) - 1",
949 new_ext_end, le32_to_cpu(oext->ee_block),
950 @@ -691,12 +691,12 @@ mext_replace_branches(handle_t *handle,
952 /* The extent for donor must be found. */
954 - ext4_error(donor_inode->i_sb, __func__,
955 + ext4_error(donor_inode->i_sb,
956 "The extent for donor must be found");
959 } else if (donor_off != le32_to_cpu(tmp_dext.ee_block)) {
960 - ext4_error(donor_inode->i_sb, __func__,
961 + ext4_error(donor_inode->i_sb,
962 "Donor offset(%u) and the first block of donor "
963 "extent(%u) should be equal",
965 @@ -1001,12 +1001,12 @@ mext_check_arguments(struct inode *orig_
969 - if ((orig_start > EXT_MAX_BLOCK) ||
970 - (donor_start > EXT_MAX_BLOCK) ||
971 - (*len > EXT_MAX_BLOCK) ||
972 - (orig_start + *len > EXT_MAX_BLOCK)) {
973 + if ((orig_start > EXT_MAX_BLOCKS) ||
974 + (donor_start > EXT_MAX_BLOCKS) ||
975 + (*len > EXT_MAX_BLOCKS) ||
976 + (orig_start + *len > EXT_MAX_BLOCKS)) {
977 ext4_debug("ext4 move extent: Can't handle over [%u] blocks "
978 - "[ino:orig %lu, donor %lu]\n", EXT_MAX_BLOCK,
979 + "[ino:orig %lu, donor %lu]\n", EXT_MAX_BLOCKS,
980 orig_inode->i_ino, donor_inode->i_ino);
983 @@ -1356,7 +1356,7 @@ ext4_move_extents(struct file *o_filp, s
986 if (*moved_len > len) {
987 - ext4_error(orig_inode->i_sb, __func__,
988 + ext4_error(orig_inode->i_sb,
989 "We replaced blocks too much! "
990 "sum of replaced: %llu requested: %llu",
992 diff -urpN linux-stage.orig/fs/ext4/namei.c linux-stage/fs/ext4/namei.c
993 --- linux-stage.orig/fs/ext4/namei.c 2012-07-02 12:07:23.000000000 -0400
994 +++ linux-stage/fs/ext4/namei.c 2012-07-02 12:07:57.000000000 -0400
995 @@ -394,8 +394,7 @@ dx_probe(const struct qstr *d_name, stru
996 if (root->info.hash_version != DX_HASH_TEA &&
997 root->info.hash_version != DX_HASH_HALF_MD4 &&
998 root->info.hash_version != DX_HASH_LEGACY) {
999 - ext4_warning(dir->i_sb, __func__,
1000 - "Unrecognised inode hash code %d",
1001 + ext4_warning(dir->i_sb, "Unrecognised inode hash code %d",
1002 root->info.hash_version);
1004 *err = ERR_BAD_DX_DIR;
1005 @@ -410,8 +409,7 @@ dx_probe(const struct qstr *d_name, stru
1008 if (root->info.unused_flags & 1) {
1009 - ext4_warning(dir->i_sb, __func__,
1010 - "Unimplemented inode hash flags: %#06x",
1011 + ext4_warning(dir->i_sb, "Unimplemented inode hash flags: %#06x",
1012 root->info.unused_flags);
1014 *err = ERR_BAD_DX_DIR;
1015 @@ -419,8 +417,7 @@ dx_probe(const struct qstr *d_name, stru
1018 if ((indirect = root->info.indirect_levels) > 1) {
1019 - ext4_warning(dir->i_sb, __func__,
1020 - "Unimplemented inode hash depth: %#06x",
1021 + ext4_warning(dir->i_sb, "Unimplemented inode hash depth: %#06x",
1022 root->info.indirect_levels);
1024 *err = ERR_BAD_DX_DIR;
1025 @@ -432,8 +429,7 @@ dx_probe(const struct qstr *d_name, stru
1027 if (dx_get_limit(entries) != dx_root_limit(dir,
1028 root->info.info_length)) {
1029 - ext4_warning(dir->i_sb, __func__,
1030 - "dx entry: limit != root limit");
1031 + ext4_warning(dir->i_sb, "dx entry: limit != root limit");
1033 *err = ERR_BAD_DX_DIR;
1035 @@ -444,7 +440,7 @@ dx_probe(const struct qstr *d_name, stru
1037 count = dx_get_count(entries);
1038 if (!count || count > dx_get_limit(entries)) {
1039 - ext4_warning(dir->i_sb, __func__,
1040 + ext4_warning(dir->i_sb,
1041 "dx entry: no count or count > limit");
1043 *err = ERR_BAD_DX_DIR;
1044 @@ -489,7 +485,7 @@ dx_probe(const struct qstr *d_name, stru
1046 at = entries = ((struct dx_node *) bh->b_data)->entries;
1047 if (dx_get_limit(entries) != dx_node_limit (dir)) {
1048 - ext4_warning(dir->i_sb, __func__,
1049 + ext4_warning(dir->i_sb,
1050 "dx entry: limit != node limit");
1052 *err = ERR_BAD_DX_DIR;
1053 @@ -505,7 +501,7 @@ fail2:
1056 if (*err == ERR_BAD_DX_DIR)
1057 - ext4_warning(dir->i_sb, __func__,
1058 + ext4_warning(dir->i_sb,
1059 "Corrupt dir inode %ld, running e2fsck is "
1060 "recommended.", dir->i_ino);
1062 @@ -969,7 +965,7 @@ restart:
1064 if (!buffer_uptodate(bh)) {
1065 /* read error, skip block & hope for the best */
1066 - ext4_error(sb, __func__, "reading directory #%lu "
1067 + ext4_error(sb, "reading directory #%lu "
1068 "offset %lu", dir->i_ino,
1069 (unsigned long)block);
1071 @@ -1012,8 +1008,9 @@ cleanup_and_exit:
1072 static struct buffer_head * ext4_dx_find_entry(struct inode *dir, const struct qstr *d_name,
1073 struct ext4_dir_entry_2 **res_dir, int *err)
1075 - struct super_block * sb = dir->i_sb;
1076 + struct super_block * sb;
1077 struct dx_hash_info hinfo;
1079 struct dx_frame frames[2], *frame;
1080 struct ext4_dir_entry_2 *de, *top;
1081 struct buffer_head *bh;
1082 @@ -1022,8 +1019,18 @@ static struct buffer_head * ext4_dx_find
1083 int namelen = d_name->len;
1084 const u8 *name = d_name->name;
1086 - if (!(frame = dx_probe(d_name, dir, &hinfo, frames, err)))
1089 + /* NFS may look up ".." - look at dx_root directory block */
1090 + if (namelen > 2 || name[0] != '.'||(name[1] != '.' && name[1] != '\0')){
1091 + if (!(frame = dx_probe(d_name, dir, &hinfo, frames, err)))
1095 + frame->bh = NULL; /* for dx_release() */
1096 + frame->at = (struct dx_entry *)frames; /* hack for zero entry*/
1097 + dx_set_block(frame->at, 0); /* dx_root block is 0 */
1099 + hash = hinfo.hash;
1101 block = dx_get_block(frame->at);
1102 if (!(bh = ext4_bread (NULL,dir, block, 0, err)))
1103 @@ -1049,10 +1056,10 @@ static struct buffer_head * ext4_dx_find
1106 /* Check to see if we should continue to search */
1107 - retval = ext4_htree_next_block(dir, hinfo.hash, frame,
1108 + retval = ext4_htree_next_block(dir, hash, frame,
1111 - ext4_warning(sb, __func__,
1113 "error reading index page in directory #%lu",
1116 @@ -1082,14 +1089,13 @@ static struct dentry *ext4_lookup(struct
1117 __u32 ino = le32_to_cpu(de->inode);
1119 if (!ext4_valid_inum(dir->i_sb, ino)) {
1120 - ext4_error(dir->i_sb, "ext4_lookup",
1121 - "bad inode number: %u", ino);
1122 + ext4_error(dir->i_sb, "bad inode number: %u", ino);
1123 return ERR_PTR(-EIO);
1125 inode = ext4_iget(dir->i_sb, ino);
1126 if (unlikely(IS_ERR(inode))) {
1127 if (PTR_ERR(inode) == -ESTALE) {
1128 - ext4_error(dir->i_sb, __func__,
1129 + ext4_error(dir->i_sb,
1130 "deleted inode referenced: %u",
1132 return ERR_PTR(-EIO);
1133 @@ -1121,7 +1127,7 @@ struct dentry *ext4_get_parent(struct de
1136 if (!ext4_valid_inum(child->d_inode->i_sb, ino)) {
1137 - ext4_error(child->d_inode->i_sb, "ext4_get_parent",
1138 + ext4_error(child->d_inode->i_sb,
1139 "bad inode number: %u", ino);
1140 return ERR_PTR(-EIO);
1142 @@ -1421,7 +1427,7 @@ static int make_indexed_dir(handle_t *ha
1143 de = (struct ext4_dir_entry_2 *)((char *)fde +
1144 ext4_rec_len_from_disk(fde->rec_len, blocksize));
1145 if ((char *) de >= (((char *) root) + blocksize)) {
1146 - ext4_error(dir->i_sb, __func__,
1147 + ext4_error(dir->i_sb,
1148 "invalid rec_len for '..' in inode %lu",
1151 @@ -1468,10 +1474,22 @@ static int make_indexed_dir(handle_t *ha
1152 frame->at = entries;
1156 + ext4_handle_dirty_metadata(handle, dir, frame->bh);
1157 + ext4_handle_dirty_metadata(handle, dir, bh);
1159 de = do_split(handle,dir, &bh, frame, &hinfo, &retval);
1160 - dx_release (frames);
1164 + * Even if the block split failed, we have to properly write
1165 + * out all the changes we did so far. Otherwise we can end up
1166 + * with corrupted filesystem.
1168 + ext4_mark_inode_dirty(handle, dir);
1169 + dx_release(frames);
1172 + dx_release(frames);
1174 retval = add_dirent_to_buf(handle, dentry, inode, de, bh);
1176 @@ -1588,8 +1606,7 @@ static int ext4_dx_add_entry(handle_t *h
1178 if (levels && (dx_get_count(frames->entries) ==
1179 dx_get_limit(frames->entries))) {
1180 - ext4_warning(sb, __func__,
1181 - "Directory index full!");
1182 + ext4_warning(sb, "Directory index full!");
1186 @@ -1943,11 +1960,11 @@ static int empty_dir(struct inode *inode
1187 if (inode->i_size < EXT4_DIR_REC_LEN(1) + EXT4_DIR_REC_LEN(2) ||
1188 !(bh = ext4_bread(NULL, inode, 0, 0, &err))) {
1190 - ext4_error(inode->i_sb, __func__,
1191 + ext4_error(inode->i_sb,
1192 "error %d reading directory #%lu offset 0",
1195 - ext4_warning(inode->i_sb, __func__,
1196 + ext4_warning(inode->i_sb,
1197 "bad directory (dir #%lu) - no data block",
1200 @@ -1958,7 +1975,7 @@ static int empty_dir(struct inode *inode
1201 !le32_to_cpu(de1->inode) ||
1202 strcmp(".", de->name) ||
1203 strcmp("..", de1->name)) {
1204 - ext4_warning(inode->i_sb, "empty_dir",
1205 + ext4_warning(inode->i_sb,
1206 "bad directory (dir #%lu) - no `.' or `..'",
1209 @@ -1976,7 +1993,7 @@ static int empty_dir(struct inode *inode
1210 offset >> EXT4_BLOCK_SIZE_BITS(sb), 0, &err);
1213 - ext4_error(sb, __func__,
1215 "error %d reading directory"
1217 err, inode->i_ino, offset);
1218 @@ -2198,7 +2215,7 @@ static int ext4_rmdir(struct inode *dir,
1221 if (!EXT4_DIR_LINK_EMPTY(inode))
1222 - ext4_warning(inode->i_sb, "ext4_rmdir",
1223 + ext4_warning(inode->i_sb,
1224 "empty directory has too many links (%d)",
1227 @@ -2250,7 +2267,7 @@ static int ext4_unlink(struct inode *dir
1230 if (!inode->i_nlink) {
1231 - ext4_warning(inode->i_sb, "ext4_unlink",
1232 + ext4_warning(inode->i_sb,
1233 "Deleting nonexistent file (%lu), %d",
1234 inode->i_ino, inode->i_nlink);
1236 @@ -2497,7 +2514,7 @@ static int ext4_rename(struct inode *old
1240 - ext4_warning(old_dir->i_sb, "ext4_rename",
1241 + ext4_warning(old_dir->i_sb,
1242 "Deleting old file (%lu), %d, error=%d",
1243 old_dir->i_ino, old_dir->i_nlink, retval);
1245 diff -urpN linux-stage.orig/fs/ext4/resize.c linux-stage/fs/ext4/resize.c
1246 --- linux-stage.orig/fs/ext4/resize.c 2012-07-02 12:07:23.000000000 -0400
1247 +++ linux-stage/fs/ext4/resize.c 2012-07-02 12:07:57.000000000 -0400
1248 @@ -48,63 +48,63 @@ static int verify_group_input(struct sup
1250 ext4_get_group_no_and_offset(sb, start, NULL, &offset);
1251 if (group != sbi->s_groups_count)
1252 - ext4_warning(sb, __func__,
1254 "Cannot add at group %u (only %u groups)",
1255 input->group, sbi->s_groups_count);
1256 else if (offset != 0)
1257 - ext4_warning(sb, __func__, "Last group not full");
1258 + ext4_warning(sb, "Last group not full");
1259 else if (input->reserved_blocks > input->blocks_count / 5)
1260 - ext4_warning(sb, __func__, "Reserved blocks too high (%u)",
1261 + ext4_warning(sb, "Reserved blocks too high (%u)",
1262 input->reserved_blocks);
1263 else if (free_blocks_count < 0)
1264 - ext4_warning(sb, __func__, "Bad blocks count %u",
1265 + ext4_warning(sb, "Bad blocks count %u",
1266 input->blocks_count);
1267 else if (!(bh = sb_bread(sb, end - 1)))
1268 - ext4_warning(sb, __func__,
1270 "Cannot read last block (%llu)",
1272 else if (outside(input->block_bitmap, start, end))
1273 - ext4_warning(sb, __func__,
1275 "Block bitmap not in group (block %llu)",
1276 (unsigned long long)input->block_bitmap);
1277 else if (outside(input->inode_bitmap, start, end))
1278 - ext4_warning(sb, __func__,
1280 "Inode bitmap not in group (block %llu)",
1281 (unsigned long long)input->inode_bitmap);
1282 else if (outside(input->inode_table, start, end) ||
1283 outside(itend - 1, start, end))
1284 - ext4_warning(sb, __func__,
1286 "Inode table not in group (blocks %llu-%llu)",
1287 (unsigned long long)input->inode_table, itend - 1);
1288 else if (input->inode_bitmap == input->block_bitmap)
1289 - ext4_warning(sb, __func__,
1291 "Block bitmap same as inode bitmap (%llu)",
1292 (unsigned long long)input->block_bitmap);
1293 else if (inside(input->block_bitmap, input->inode_table, itend))
1294 - ext4_warning(sb, __func__,
1296 "Block bitmap (%llu) in inode table (%llu-%llu)",
1297 (unsigned long long)input->block_bitmap,
1298 (unsigned long long)input->inode_table, itend - 1);
1299 else if (inside(input->inode_bitmap, input->inode_table, itend))
1300 - ext4_warning(sb, __func__,
1302 "Inode bitmap (%llu) in inode table (%llu-%llu)",
1303 (unsigned long long)input->inode_bitmap,
1304 (unsigned long long)input->inode_table, itend - 1);
1305 else if (inside(input->block_bitmap, start, metaend))
1306 - ext4_warning(sb, __func__,
1308 "Block bitmap (%llu) in GDT table"
1310 (unsigned long long)input->block_bitmap,
1311 start, metaend - 1);
1312 else if (inside(input->inode_bitmap, start, metaend))
1313 - ext4_warning(sb, __func__,
1315 "Inode bitmap (%llu) in GDT table"
1317 (unsigned long long)input->inode_bitmap,
1318 start, metaend - 1);
1319 else if (inside(input->inode_table, start, metaend) ||
1320 inside(itend - 1, start, metaend))
1321 - ext4_warning(sb, __func__,
1323 "Inode table (%llu-%llu) overlaps"
1324 "GDT table (%llu-%llu)",
1325 (unsigned long long)input->inode_table,
1326 @@ -364,7 +364,7 @@ static int verify_reserved_gdb(struct su
1327 while ((grp = ext4_list_backups(sb, &three, &five, &seven)) < end) {
1328 if (le32_to_cpu(*p++) !=
1329 grp * EXT4_BLOCKS_PER_GROUP(sb) + blk){
1330 - ext4_warning(sb, __func__,
1333 " missing grp %d (%llu)",
1335 @@ -420,7 +420,7 @@ static int add_new_gdb(handle_t *handle,
1337 if (EXT4_SB(sb)->s_sbh->b_blocknr !=
1338 le32_to_cpu(EXT4_SB(sb)->s_es->s_first_data_block)) {
1339 - ext4_warning(sb, __func__,
1341 "won't resize using backup superblock at %llu",
1342 (unsigned long long)EXT4_SB(sb)->s_sbh->b_blocknr);
1344 @@ -444,7 +444,7 @@ static int add_new_gdb(handle_t *handle,
1346 data = (__le32 *)dind->b_data;
1347 if (le32_to_cpu(data[gdb_num % EXT4_ADDR_PER_BLOCK(sb)]) != gdblock) {
1348 - ext4_warning(sb, __func__,
1350 "new group %u GDT block %llu not reserved",
1351 input->group, gdblock);
1353 @@ -468,7 +468,7 @@ static int add_new_gdb(handle_t *handle,
1355 if (!n_group_desc) {
1357 - ext4_warning(sb, __func__,
1359 "not enough memory for %lu groups", gdb_num + 1);
1362 @@ -567,7 +567,7 @@ static int reserve_backup_gdb(handle_t *
1363 /* Get each reserved primary GDT block and verify it holds backups */
1364 for (res = 0; res < reserved_gdb; res++, blk++) {
1365 if (le32_to_cpu(*data) != blk) {
1366 - ext4_warning(sb, __func__,
1368 "reserved block %llu"
1369 " not at offset %ld",
1371 @@ -713,7 +713,7 @@ static void update_backups(struct super_
1375 - ext4_warning(sb, __func__,
1377 "can't update backup for group %u (err %d), "
1378 "forcing fsck on next reboot", group, err);
1379 sbi->s_mount_state &= ~EXT4_VALID_FS;
1380 @@ -753,20 +753,20 @@ int ext4_group_add(struct super_block *s
1382 if (gdb_off == 0 && !EXT4_HAS_RO_COMPAT_FEATURE(sb,
1383 EXT4_FEATURE_RO_COMPAT_SPARSE_SUPER)) {
1384 - ext4_warning(sb, __func__,
1386 "Can't resize non-sparse filesystem further");
1390 if (ext4_blocks_count(es) + input->blocks_count <
1391 ext4_blocks_count(es)) {
1392 - ext4_warning(sb, __func__, "blocks_count overflow");
1393 + ext4_warning(sb, "blocks_count overflow");
1397 if (le32_to_cpu(es->s_inodes_count) + EXT4_INODES_PER_GROUP(sb) <
1398 le32_to_cpu(es->s_inodes_count)) {
1399 - ext4_warning(sb, __func__, "inodes_count overflow");
1400 + ext4_warning(sb, "inodes_count overflow");
1404 @@ -774,13 +774,13 @@ int ext4_group_add(struct super_block *s
1405 if (!EXT4_HAS_COMPAT_FEATURE(sb,
1406 EXT4_FEATURE_COMPAT_RESIZE_INODE)
1407 || !le16_to_cpu(es->s_reserved_gdt_blocks)) {
1408 - ext4_warning(sb, __func__,
1410 "No reserved GDT blocks, can't resize");
1413 inode = ext4_iget(sb, EXT4_RESIZE_INO);
1414 if (IS_ERR(inode)) {
1415 - ext4_warning(sb, __func__,
1417 "Error opening resize inode");
1418 return PTR_ERR(inode);
1420 @@ -810,7 +810,7 @@ int ext4_group_add(struct super_block *s
1422 mutex_lock(&sbi->s_resize_lock);
1423 if (input->group != sbi->s_groups_count) {
1424 - ext4_warning(sb, __func__,
1426 "multiple resizers run on filesystem!");
1429 @@ -998,12 +998,12 @@ int ext4_group_extend(struct super_block
1430 " too large to resize to %llu blocks safely\n",
1431 sb->s_id, n_blocks_count);
1432 if (sizeof(sector_t) < 8)
1433 - ext4_warning(sb, __func__, "CONFIG_LBDAF not enabled");
1434 + ext4_warning(sb, "CONFIG_LBDAF not enabled");
1438 if (n_blocks_count < o_blocks_count) {
1439 - ext4_warning(sb, __func__,
1441 "can't shrink FS - resize aborted");
1444 @@ -1012,7 +1012,7 @@ int ext4_group_extend(struct super_block
1445 ext4_get_group_no_and_offset(sb, o_blocks_count, &group, &last);
1448 - ext4_warning(sb, __func__,
1450 "need to use ext2online to resize further");
1453 @@ -1020,7 +1020,7 @@ int ext4_group_extend(struct super_block
1454 add = EXT4_BLOCKS_PER_GROUP(sb) - last;
1456 if (o_blocks_count + add < o_blocks_count) {
1457 - ext4_warning(sb, __func__, "blocks_count overflow");
1458 + ext4_warning(sb, "blocks_count overflow");
1462 @@ -1028,7 +1028,7 @@ int ext4_group_extend(struct super_block
1463 add = n_blocks_count - o_blocks_count;
1465 if (o_blocks_count + add < n_blocks_count)
1466 - ext4_warning(sb, __func__,
1468 "will only finish group (%llu"
1470 o_blocks_count + add, add);
1471 @@ -1036,7 +1036,7 @@ int ext4_group_extend(struct super_block
1472 /* See if the device is actually as big as what was requested */
1473 bh = sb_bread(sb, o_blocks_count + add - 1);
1475 - ext4_warning(sb, __func__,
1477 "can't read last block, resize aborted");
1480 @@ -1048,13 +1048,13 @@ int ext4_group_extend(struct super_block
1481 handle = ext4_journal_start_sb(sb, 3);
1482 if (IS_ERR(handle)) {
1483 err = PTR_ERR(handle);
1484 - ext4_warning(sb, __func__, "error %d on journal start", err);
1485 + ext4_warning(sb, "error %d on journal start", err);
1489 mutex_lock(&EXT4_SB(sb)->s_resize_lock);
1490 if (o_blocks_count != ext4_blocks_count(es)) {
1491 - ext4_warning(sb, __func__,
1493 "multiple resizers run on filesystem!");
1494 mutex_unlock(&EXT4_SB(sb)->s_resize_lock);
1495 ext4_journal_stop(handle);
1496 @@ -1064,7 +1064,7 @@ int ext4_group_extend(struct super_block
1498 if ((err = ext4_journal_get_write_access(handle,
1499 EXT4_SB(sb)->s_sbh))) {
1500 - ext4_warning(sb, __func__,
1502 "error %d on journal write access", err);
1503 mutex_unlock(&EXT4_SB(sb)->s_resize_lock);
1504 ext4_journal_stop(handle);
1505 diff -urpN linux-stage.orig/fs/ext4/super.c linux-stage/fs/ext4/super.c
1506 --- linux-stage.orig/fs/ext4/super.c 2012-07-02 12:07:23.000000000 -0400
1507 +++ linux-stage/fs/ext4/super.c 2012-07-02 12:07:57.000000000 -0400
1510 #include "mballoc.h"
1512 +#define QFMT_OCFS2 3
1513 +#define QFMT_VFS_V1 4
1515 #define CREATE_TRACE_POINTS
1516 #include <trace/events/ext4.h>
1518 struct proc_dir_entry *ext4_proc_root;
1519 static struct kset *ext4_kset;
1520 +static struct ext4_lazy_init *ext4_li_info;
1521 +static struct mutex ext4_li_mtx;
1523 static int ext4_load_journal(struct super_block *, struct ext4_super_block *,
1524 unsigned long journal_devnum);
1525 @@ -337,7 +342,7 @@ static void ext4_handle_error(struct sup
1529 -void ext4_error(struct super_block *sb, const char *function,
1530 +void __ext4_error(struct super_block *sb, const char *function,
1531 const char *fmt, ...)
1534 @@ -351,6 +356,42 @@ void ext4_error(struct super_block *sb,
1535 ext4_handle_error(sb);
1538 +void ext4_error_inode(const char *function, struct inode *inode,
1539 + const char *fmt, ...)
1543 + va_start(args, fmt);
1544 + printk(KERN_CRIT "EXT4-fs error (device %s): %s: inode #%lu: (comm %s) ",
1545 + inode->i_sb->s_id, function, inode->i_ino, current->comm);
1546 + vprintk(fmt, args);
1550 + ext4_handle_error(inode->i_sb);
1553 +void ext4_error_file(const char *function, struct file *file,
1554 + const char *fmt, ...)
1557 + struct inode *inode = file->f_dentry->d_inode;
1558 + char pathname[80], *path;
1560 + va_start(args, fmt);
1561 + path = d_path(&(file->f_path), pathname, sizeof(pathname));
1563 + path = "(unknown)";
1565 + "EXT4-fs error (device %s): %s: inode #%lu (comm %s path %s): ",
1566 + inode->i_sb->s_id, function, inode->i_ino, current->comm, path);
1567 + vprintk(fmt, args);
1571 + ext4_handle_error(inode->i_sb);
1574 static const char *ext4_decode_error(struct super_block *sb, int errno,
1577 @@ -454,7 +495,7 @@ void ext4_msg (struct super_block * sb,
1581 -void ext4_warning(struct super_block *sb, const char *function,
1582 +void __ext4_warning(struct super_block *sb, const char *function,
1583 const char *fmt, ...)
1586 @@ -511,7 +552,7 @@ void ext4_update_dynamic_rev(struct supe
1587 if (le32_to_cpu(es->s_rev_level) > EXT4_GOOD_OLD_REV)
1590 - ext4_warning(sb, __func__,
1592 "updating to rev %d because of new feature flag, "
1593 "running e2fsck is recommended",
1595 @@ -777,9 +818,22 @@ static inline void ext4_show_quota_optio
1596 #if defined(CONFIG_QUOTA)
1597 struct ext4_sb_info *sbi = EXT4_SB(sb);
1599 - if (sbi->s_jquota_fmt)
1600 - seq_printf(seq, ",jqfmt=%s",
1601 - (sbi->s_jquota_fmt == QFMT_VFS_OLD) ? "vfsold" : "vfsv0");
1602 + if (sbi->s_jquota_fmt) {
1603 + char *fmtname = "";
1605 + switch (sbi->s_jquota_fmt) {
1606 + case QFMT_VFS_OLD:
1607 + fmtname = "vfsold";
1610 + fmtname = "vfsv0";
1613 + fmtname = "vfsv1";
1616 + seq_printf(seq, ",jqfmt=%s", fmtname);
1619 if (sbi->s_qf_names[USRQUOTA])
1620 seq_printf(seq, ",usrjquota=%s", sbi->s_qf_names[USRQUOTA]);
1621 @@ -1096,13 +1150,14 @@ enum {
1622 Opt_abort, Opt_data_journal, Opt_data_ordered, Opt_data_writeback,
1623 Opt_data_err_abort, Opt_data_err_ignore,
1624 Opt_usrjquota, Opt_grpjquota, Opt_offusrjquota, Opt_offgrpjquota,
1625 - Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_quota, Opt_noquota,
1626 - Opt_ignore, Opt_barrier, Opt_nobarrier, Opt_err, Opt_resize,
1627 - Opt_usrquota, Opt_grpquota, Opt_i_version,
1628 + Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_jqfmt_vfsv1, Opt_quota,
1629 + Opt_noquota, Opt_ignore, Opt_barrier, Opt_nobarrier, Opt_err,
1630 + Opt_resize, Opt_usrquota, Opt_grpquota, Opt_i_version,
1631 Opt_stripe, Opt_delalloc, Opt_nodelalloc,
1632 Opt_block_validity, Opt_noblock_validity,
1633 Opt_inode_readahead_blks, Opt_journal_ioprio,
1634 Opt_discard, Opt_nodiscard,
1635 + Opt_init_inode_table, Opt_noinit_inode_table,
1638 static const match_table_t tokens = {
1639 @@ -2709,6 +2764,21 @@ static int ext4_fill_super(struct super_
1640 get_random_bytes(&sbi->s_next_generation, sizeof(u32));
1641 spin_lock_init(&sbi->s_next_gen_lock);
1643 + err = percpu_counter_init(&sbi->s_freeblocks_counter,
1644 + ext4_count_free_blocks(sb));
1646 + err = percpu_counter_init(&sbi->s_freeinodes_counter,
1647 + ext4_count_free_inodes(sb));
1649 + err = percpu_counter_init(&sbi->s_dirs_counter,
1650 + ext4_count_dirs(sb));
1652 + err = percpu_counter_init(&sbi->s_dirtyblocks_counter, 0);
1654 + ext4_msg(sb, KERN_ERR, "insufficient memory");
1655 + goto failed_mount3;
1658 sbi->s_stripe = ext4_get_stripe_size(sbi);
1659 sbi->s_max_writeback_mb_bump = 128;
1661 @@ -2828,20 +2898,6 @@ static int ext4_fill_super(struct super_
1662 set_task_ioprio(sbi->s_journal->j_task, journal_ioprio);
1665 - err = percpu_counter_init(&sbi->s_freeblocks_counter,
1666 - ext4_count_free_blocks(sb));
1668 - err = percpu_counter_init(&sbi->s_freeinodes_counter,
1669 - ext4_count_free_inodes(sb));
1671 - err = percpu_counter_init(&sbi->s_dirs_counter,
1672 - ext4_count_dirs(sb));
1674 - err = percpu_counter_init(&sbi->s_dirtyblocks_counter, 0);
1676 - ext4_msg(sb, KERN_ERR, "insufficient memory");
1677 - goto failed_mount_wq;
1679 if (test_opt(sb, NOBH)) {
1680 if (!(test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_WRITEBACK_DATA)) {
1681 ext4_msg(sb, KERN_WARNING, "Ignoring nobh option - "
1682 @@ -2955,7 +3011,9 @@ no_journal:
1684 descr = "out journal";
1686 - ext4_msg(sb, KERN_INFO, "mounted filesystem with%s", descr);
1687 + ext4_msg(sb, KERN_INFO, "mounted filesystem with%s. "
1688 + "Opts: %s%s", descr, sbi->s_es->s_mount_opts,
1689 + *sbi->s_es->s_mount_opts ? "; " : "");
1693 @@ -2974,10 +3032,6 @@ failed_mount_wq:
1694 jbd2_journal_destroy(sbi->s_journal);
1695 sbi->s_journal = NULL;
1697 - percpu_counter_destroy(&sbi->s_freeblocks_counter);
1698 - percpu_counter_destroy(&sbi->s_freeinodes_counter);
1699 - percpu_counter_destroy(&sbi->s_dirs_counter);
1700 - percpu_counter_destroy(&sbi->s_dirtyblocks_counter);
1702 if (sbi->s_flex_groups) {
1703 if (is_vmalloc_addr(sbi->s_flex_groups))
1704 @@ -2985,6 +3039,10 @@ failed_mount3:
1706 kfree(sbi->s_flex_groups);
1708 + percpu_counter_destroy(&sbi->s_freeblocks_counter);
1709 + percpu_counter_destroy(&sbi->s_freeinodes_counter);
1710 + percpu_counter_destroy(&sbi->s_dirs_counter);
1711 + percpu_counter_destroy(&sbi->s_dirtyblocks_counter);
1713 for (i = 0; i < db_count; i++)
1714 brelse(sbi->s_group_desc[i]);
1715 @@ -3377,9 +3435,9 @@ static void ext4_clear_journal_err(struc
1718 errstr = ext4_decode_error(sb, j_errno, nbuf);
1719 - ext4_warning(sb, __func__, "Filesystem error recorded "
1720 + ext4_warning(sb, "Filesystem error recorded "
1721 "from previous mount: %s", errstr);
1722 - ext4_warning(sb, __func__, "Marking fs in need of "
1723 + ext4_warning(sb, "Marking fs in need of "
1724 "filesystem check.");
1726 EXT4_SB(sb)->s_mount_state |= EXT4_ERROR_FS;
1727 @@ -4007,11 +4065,21 @@ static struct file_system_type ext4_fs_t
1728 .fs_flags = FS_REQUIRES_DEV,
1731 +static int __init ext4_init_feat_adverts(void)
1736 +static void ext4_exit_feat_adverts(void)
1740 static int __init init_ext4_fs(void)
1744 ext4_check_flag_values();
1746 err = init_ext4_system_zone();
1749 @@ -4019,6 +4087,9 @@ static int __init init_ext4_fs(void)
1752 ext4_proc_root = proc_mkdir("fs/ext4", NULL);
1754 + err = ext4_init_feat_adverts();
1756 err = init_ext4_mballoc();
1759 @@ -4032,6 +4103,9 @@ static int __init init_ext4_fs(void)
1760 err = register_filesystem(&ext4_fs_type);
1764 + ext4_li_info = NULL;
1765 + mutex_init(&ext4_li_mtx);
1768 destroy_inodecache();
1769 @@ -4040,6 +4114,7 @@ out1:
1771 exit_ext4_mballoc();
1773 + ext4_exit_feat_adverts();
1774 remove_proc_entry("fs/ext4", NULL);
1775 kset_unregister(ext4_kset);
1777 @@ -4053,6 +4128,7 @@ static void __exit exit_ext4_fs(void)
1778 destroy_inodecache();
1780 exit_ext4_mballoc();
1781 + ext4_exit_feat_adverts();
1782 remove_proc_entry("fs/ext4", NULL);
1783 kset_unregister(ext4_kset);
1784 exit_ext4_system_zone();
1785 diff -urpN linux-stage.orig/fs/ext4/xattr.c linux-stage/fs/ext4/xattr.c
1786 --- linux-stage.orig/fs/ext4/xattr.c 2012-07-02 12:07:23.000000000 -0400
1787 +++ linux-stage/fs/ext4/xattr.c 2012-07-02 12:07:57.000000000 -0400
1788 @@ -227,7 +227,7 @@ ext4_xattr_block_get(struct inode *inode
1789 ea_bdebug(bh, "b_count=%d, refcount=%d",
1790 atomic_read(&(bh->b_count)), le32_to_cpu(BHDR(bh)->h_refcount));
1791 if (ext4_xattr_check_block(bh)) {
1792 -bad_block: ext4_error(inode->i_sb, __func__,
1793 +bad_block: ext4_error(inode->i_sb,
1794 "inode %lu: bad block %llu", inode->i_ino,
1795 EXT4_I(inode)->i_file_acl);
1797 @@ -369,7 +369,7 @@ ext4_xattr_block_list(struct inode *inod
1798 ea_bdebug(bh, "b_count=%d, refcount=%d",
1799 atomic_read(&(bh->b_count)), le32_to_cpu(BHDR(bh)->h_refcount));
1800 if (ext4_xattr_check_block(bh)) {
1801 - ext4_error(inode->i_sb, __func__,
1802 + ext4_error(inode->i_sb,
1803 "inode %lu: bad block %llu", inode->i_ino,
1804 EXT4_I(inode)->i_file_acl);
1806 @@ -661,7 +661,7 @@ ext4_xattr_block_find(struct inode *inod
1807 atomic_read(&(bs->bh->b_count)),
1808 le32_to_cpu(BHDR(bs->bh)->h_refcount));
1809 if (ext4_xattr_check_block(bs->bh)) {
1810 - ext4_error(sb, __func__,
1812 "inode %lu: bad block %llu", inode->i_ino,
1813 EXT4_I(inode)->i_file_acl);
1815 @@ -875,7 +875,7 @@ cleanup_dquot:
1819 - ext4_error(inode->i_sb, __func__,
1820 + ext4_error(inode->i_sb,
1821 "inode %lu: bad block %llu", inode->i_ino,
1822 EXT4_I(inode)->i_file_acl);
1824 @@ -1190,7 +1190,7 @@ retry:
1827 if (ext4_xattr_check_block(bh)) {
1828 - ext4_error(inode->i_sb, __func__,
1829 + ext4_error(inode->i_sb,
1830 "inode %lu: bad block %llu", inode->i_ino,
1831 EXT4_I(inode)->i_file_acl);
1833 @@ -1367,14 +1367,14 @@ ext4_xattr_delete_inode(handle_t *handle
1835 bh = sb_bread(inode->i_sb, EXT4_I(inode)->i_file_acl);
1837 - ext4_error(inode->i_sb, __func__,
1838 + ext4_error(inode->i_sb,
1839 "inode %lu: block %llu read error", inode->i_ino,
1840 EXT4_I(inode)->i_file_acl);
1843 if (BHDR(bh)->h_magic != cpu_to_le32(EXT4_XATTR_MAGIC) ||
1844 BHDR(bh)->h_blocks != cpu_to_le32(1)) {
1845 - ext4_error(inode->i_sb, __func__,
1846 + ext4_error(inode->i_sb,
1847 "inode %lu: bad block %llu", inode->i_ino,
1848 EXT4_I(inode)->i_file_acl);
1850 @@ -1501,7 +1501,7 @@ again:
1852 bh = sb_bread(inode->i_sb, ce->e_block);
1854 - ext4_error(inode->i_sb, __func__,
1855 + ext4_error(inode->i_sb,
1856 "inode %lu: block %lu read error",
1857 inode->i_ino, (unsigned long) ce->e_block);
1858 } else if (le32_to_cpu(BHDR(bh)->h_refcount) >=