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.h linux-stage/fs/ext4/ext4.h
140 --- linux-stage.orig/fs/ext4/ext4.h 2012-07-02 12:07:23.000000000 -0400
141 +++ linux-stage/fs/ext4/ext4.h 2012-07-02 12:10:15.000000000 -0400
143 #include <linux/quota.h>
144 #include <linux/rwsem.h>
145 #include <linux/rbtree.h>
146 +#include <linux/kernel.h>
147 #include <linux/seqlock.h>
148 #include <linux/mutex.h>
149 #include <linux/timer.h>
151 #define ext4_debug(f, a...) do {} while (0)
154 +#define EXT4_ERROR_INODE(inode, fmt, a...) \
155 + ext4_error_inode(__func__, (inode), (fmt), ## a);
157 +#define EXT4_ERROR_FILE(file, fmt, a...) \
158 + ext4_error_file(__func__, (file), (fmt), ## a);
160 /* data type for block offset of block group */
161 typedef int ext4_grpblk_t;
163 @@ -970,7 +977,27 @@ struct ext4_super_block {
164 __u8 s_reserved_char_pad2;
165 __le16 s_reserved_pad;
166 __le64 s_kbytes_written; /* nr of lifetime kilobytes written */
167 - __u32 s_reserved[160]; /* Padding to the end of the block */
168 + __le32 s_snapshot_inum; /* Inode number of active snapshot */
169 + __le32 s_snapshot_id; /* sequential ID of active snapshot */
170 + __le64 s_snapshot_r_blocks_count; /* reserved blocks for active
171 + snapshot's future use */
172 + __le32 s_snapshot_list; /* inode number of the head of the
173 + on-disk snapshot list */
174 +#define EXT4_S_ERR_START offsetof(struct ext4_super_block, s_error_count)
175 + __le32 s_error_count; /* number of fs errors */
176 + __le32 s_first_error_time; /* first time an error happened */
177 + __le32 s_first_error_ino; /* inode involved in first error */
178 + __le64 s_first_error_block; /* block involved of first error */
179 + __u8 s_first_error_func[32]; /* function where the error happened */
180 + __le32 s_first_error_line; /* line number where error happened */
181 + __le32 s_last_error_time; /* most recent time of an error */
182 + __le32 s_last_error_ino; /* inode involved in last error */
183 + __le32 s_last_error_line; /* line number where error happened */
184 + __le64 s_last_error_block; /* block involved of last error */
185 + __u8 s_last_error_func[32]; /* function where the error happened */
186 +#define EXT4_S_ERR_END offsetof(struct ext4_super_block, s_mount_opts)
187 + __u8 s_mount_opts[64];
188 + __le32 s_reserved[112]; /* Padding to the end of the block */
192 @@ -1110,6 +1137,9 @@ struct ext4_sb_info {
194 /* workqueue for dio unwritten */
195 struct workqueue_struct *dio_unwritten_wq;
197 + /* Lazy inode table initialization info */
198 + struct ext4_li_request *s_li_request;
201 static inline struct ext4_sb_info *EXT4_SB(struct super_block *sb)
202 @@ -1431,6 +1461,23 @@ void ext4_get_group_no_and_offset(struct
203 extern struct proc_dir_entry *ext4_proc_root;
206 + * Timeout and state flag for lazy initialization inode thread.
208 +#define EXT4_DEF_LI_WAIT_MULT 10
209 +#define EXT4_DEF_LI_MAX_START_DELAY 5
210 +#define EXT4_LAZYINIT_QUIT 0x0001
211 +#define EXT4_LAZYINIT_RUNNING 0x0002
214 + * Lazy inode table initialization info
216 +struct ext4_lazy_init {
217 + unsigned long li_state;
218 + struct list_head li_request_list;
219 + struct mutex li_list_mtx;
223 * Function prototypes
226 @@ -1509,6 +1556,7 @@ extern struct buffer_head *ext4_read_ino
227 extern void mark_bitmap_end(int start_bit, int end_bit, char *bitmap);
230 +struct fstrim_range;
231 extern long ext4_mb_stats;
232 extern long ext4_mb_max_to_scan;
233 extern int ext4_mb_init(struct super_block *, int);
234 @@ -1526,6 +1574,8 @@ extern int ext4_mb_add_groupinfo(struct
235 extern int ext4_mb_get_buddy_cache_lock(struct super_block *, ext4_group_t);
236 extern void ext4_mb_put_buddy_cache_lock(struct super_block *,
238 +extern int ext4_trim_fs(struct super_block *, struct fstrim_range *);
241 int ext4_forget(handle_t *handle, int is_metadata, struct inode *inode,
242 struct buffer_head *bh, ext4_fsblk_t blocknr);
243 @@ -1586,13 +1636,17 @@ extern int ext4_group_extend(struct supe
244 ext4_fsblk_t n_blocks_count);
247 -extern void ext4_error(struct super_block *, const char *, const char *, ...)
248 +extern void __ext4_error(struct super_block *, const char *, const char *, ...)
249 + __attribute__ ((format (printf, 3, 4)));
250 +#define ext4_error(sb, message...) __ext4_error(sb, __func__, ## message)
251 +extern void ext4_error_inode(const char *, struct inode *, const char *, ...)
252 __attribute__ ((format (printf, 3, 4)));
253 extern void __ext4_std_error(struct super_block *, const char *, int);
254 extern void ext4_abort(struct super_block *, const char *, const char *, ...)
255 __attribute__ ((format (printf, 3, 4)));
256 -extern void ext4_warning(struct super_block *, const char *, const char *, ...)
257 +extern void __ext4_warning(struct super_block *, const char *, const char *, ...)
258 __attribute__ ((format (printf, 3, 4)));
259 +#define ext4_warning(sb, message...) __ext4_warning(sb, __func__, ## message)
260 extern void ext4_msg(struct super_block *, const char *, const char *, ...)
261 __attribute__ ((format (printf, 3, 4)));
262 extern void ext4_grp_locked_error(struct super_block *, ext4_group_t,
263 @@ -1774,11 +1828,19 @@ struct ext4_group_info {
264 * 5 free 8-block regions. */
267 -#define EXT4_GROUP_INFO_NEED_INIT_BIT 0
268 +#define EXT4_GROUP_INFO_NEED_INIT_BIT 0
269 +#define EXT4_GROUP_INFO_WAS_TRIMMED_BIT 1
271 #define EXT4_MB_GRP_NEED_INIT(grp) \
272 (test_bit(EXT4_GROUP_INFO_NEED_INIT_BIT, &((grp)->bb_state)))
274 +#define EXT4_MB_GRP_WAS_TRIMMED(grp) \
275 + (test_bit(EXT4_GROUP_INFO_WAS_TRIMMED_BIT, &((grp)->bb_state)))
276 +#define EXT4_MB_GRP_SET_TRIMMED(grp) \
277 + (set_bit(EXT4_GROUP_INFO_WAS_TRIMMED_BIT, &((grp)->bb_state)))
278 +#define EXT4_MB_GRP_CLEAR_TRIMMED(grp) \
279 + (clear_bit(EXT4_GROUP_INFO_WAS_TRIMMED_BIT, &((grp)->bb_state)))
281 #define EXT4_MAX_CONTENTION 8
282 #define EXT4_CONTENTION_THRESHOLD 2
284 diff -urpN linux-stage.orig/fs/ext4/ext4_jbd2.c linux-stage/fs/ext4/ext4_jbd2.c
285 --- linux-stage.orig/fs/ext4/ext4_jbd2.c 2012-07-02 12:07:23.000000000 -0400
286 +++ linux-stage/fs/ext4/ext4_jbd2.c 2012-07-02 12:07:57.000000000 -0400
287 @@ -96,7 +96,7 @@ int __ext4_handle_dirty_metadata(const c
288 if (inode && inode_needs_sync(inode)) {
289 sync_dirty_buffer(bh);
290 if (buffer_req(bh) && !buffer_uptodate(bh)) {
291 - ext4_error(inode->i_sb, __func__,
292 + ext4_error(inode->i_sb,
293 "IO error syncing inode, "
294 "inode=%lu, block=%llu",
296 diff -urpN linux-stage.orig/fs/ext4/extents.c linux-stage/fs/ext4/extents.c
297 --- linux-stage.orig/fs/ext4/extents.c 2012-07-02 12:07:23.000000000 -0400
298 +++ linux-stage/fs/ext4/extents.c 2012-07-02 12:07:57.000000000 -0400
299 @@ -437,7 +437,7 @@ static int __ext4_ext_check(const char *
303 - ext4_error(inode->i_sb, function,
304 + ext4_error(inode->i_sb,
305 "bad header/extent in inode #%lu: %s - magic %x, "
306 "entries %u, max %u(%u), depth %u(%u)",
307 inode->i_ino, error_msg, le16_to_cpu(eh->eh_magic),
308 @@ -1534,7 +1534,7 @@ int ext4_ext_try_to_merge(struct inode *
310 WARN_ON(eh->eh_entries == 0);
312 - ext4_error(inode->i_sb, "ext4_ext_try_to_merge",
313 + ext4_error(inode->i_sb,
314 "inode#%lu, eh->eh_entries = 0!", inode->i_ino);
317 @@ -1784,7 +1784,11 @@ int ext4_ext_walk_space(struct inode *in
320 depth = ext_depth(inode);
321 - BUG_ON(path[depth].p_hdr == NULL);
322 + if (unlikely(path[depth].p_hdr == NULL)) {
323 + EXT4_ERROR_INODE(inode, "path[%d].p_hdr == NULL", depth);
327 ex = path[depth].p_ext;
328 next = ext4_ext_next_allocated_block(path);
330 @@ -1835,7 +1839,11 @@ int ext4_ext_walk_space(struct inode *in
331 cbex.ec_type = EXT4_EXT_CACHE_EXTENT;
334 - BUG_ON(cbex.ec_len == 0);
335 + if (unlikely(cbex.ec_len == 0)) {
336 + EXT4_ERROR_INODE(inode, "cbex.ec_len == 0");
340 err = func(inode, path, &cbex, ex, cbdata);
341 ext4_ext_drop_refs(path);
343 @@ -3284,7 +3292,7 @@ int ext4_ext_get_blocks(handle_t *handle
344 * this is why assert can't be put in ext4_ext_find_extent()
346 if (path[depth].p_ext == NULL && depth != 0) {
347 - ext4_error(inode->i_sb, __func__, "bad extent address "
348 + ext4_error(inode->i_sb, "bad extent address "
349 "inode: %lu, iblock: %lu, depth: %d",
350 inode->i_ino, (unsigned long) iblock, depth);
352 @@ -3415,7 +3423,7 @@ int ext4_ext_get_blocks(handle_t *handle
354 if (unlikely(ext4_test_inode_flag(inode, EXT4_INODE_EOFBLOCKS))) {
355 if (unlikely(!eh->eh_entries)) {
356 - ext4_error(inode->i_sb, __func__,
357 + ext4_error(inode->i_sb,
358 "inode#%lu, eh->eh_entries = 0 and "
359 "EOFBLOCKS_FL set", inode->i_ino);
361 diff -urpN linux-stage.orig/fs/ext4/ialloc.c linux-stage/fs/ext4/ialloc.c
362 --- linux-stage.orig/fs/ext4/ialloc.c 2012-07-02 12:07:23.000000000 -0400
363 +++ linux-stage/fs/ext4/ialloc.c 2012-07-02 12:07:57.000000000 -0400
364 @@ -76,7 +76,7 @@ unsigned ext4_init_inode_bitmap(struct s
365 /* If checksum is bad mark all blocks and inodes use to prevent
366 * allocation, essentially implementing a per-group read-only flag. */
367 if (!ext4_group_desc_csum_verify(sbi, block_group, gdp)) {
368 - ext4_error(sb, __func__, "Checksum bad for group %u",
369 + ext4_error(sb, "Checksum bad for group %u",
371 ext4_free_blks_set(sb, gdp, 0);
372 ext4_free_inodes_set(sb, gdp, 0);
373 @@ -111,7 +111,7 @@ ext4_read_inode_bitmap(struct super_bloc
374 bitmap_blk = ext4_inode_bitmap(sb, desc);
375 bh = sb_getblk(sb, bitmap_blk);
377 - ext4_error(sb, __func__,
379 "Cannot read inode bitmap - "
380 "block_group = %u, inode_bitmap = %llu",
381 block_group, bitmap_blk);
382 @@ -153,7 +153,7 @@ ext4_read_inode_bitmap(struct super_bloc
383 set_bitmap_uptodate(bh);
384 if (bh_submit_read(bh) < 0) {
386 - ext4_error(sb, __func__,
388 "Cannot read inode bitmap - "
389 "block_group = %u, inode_bitmap = %llu",
390 block_group, bitmap_blk);
391 @@ -230,8 +230,7 @@ void ext4_free_inode(handle_t *handle, s
393 es = EXT4_SB(sb)->s_es;
394 if (ino < EXT4_FIRST_INO(sb) || ino > le32_to_cpu(es->s_inodes_count)) {
395 - ext4_error(sb, "ext4_free_inode",
396 - "reserved or nonexistent inode %lu", ino);
397 + ext4_error(sb, "reserved or nonexistent inode %lu", ino);
400 block_group = (ino - 1) / EXT4_INODES_PER_GROUP(sb);
401 @@ -286,11 +285,10 @@ out:
405 - ext4_error(sb, "ext4_free_inode",
406 - "bit already cleared for inode %lu", ino);
407 + ext4_error(sb, "bit already cleared for inode %lu", ino);
412 ext4_std_error(sb, fatal);
415 @@ -730,7 +728,7 @@ static int ext4_claim_inode(struct super
416 if ((group == 0 && ino < EXT4_FIRST_INO(sb)) ||
417 ino > EXT4_INODES_PER_GROUP(sb)) {
418 ext4_unlock_group(sb, group);
419 - ext4_error(sb, __func__,
421 "reserved inode or inode > inodes count - "
422 "block_group = %u, inode=%lu", group,
423 ino + group * EXT4_INODES_PER_GROUP(sb));
424 @@ -1094,7 +1092,7 @@ struct inode *ext4_orphan_get(struct sup
426 /* Error cases - e2fsck has already cleaned up for us */
428 - ext4_warning(sb, __func__,
430 "bad orphan ino %lu! e2fsck was run?", ino);
433 @@ -1103,7 +1101,7 @@ struct inode *ext4_orphan_get(struct sup
434 bit = (ino - 1) % EXT4_INODES_PER_GROUP(sb);
435 bitmap_bh = ext4_read_inode_bitmap(sb, block_group);
437 - ext4_warning(sb, __func__,
439 "inode bitmap error for orphan %lu", ino);
442 @@ -1136,7 +1134,7 @@ iget_failed:
443 err = PTR_ERR(inode);
446 - ext4_warning(sb, __func__,
448 "bad orphan inode %lu! e2fsck was run?", ino);
449 printk(KERN_NOTICE "ext4_test_bit(bit=%d, block=%llu) = %d\n",
450 bit, (unsigned long long)bitmap_bh->b_blocknr,
451 diff -urpN linux-stage.orig/fs/ext4/inode.c linux-stage/fs/ext4/inode.c
452 --- linux-stage.orig/fs/ext4/inode.c 2012-07-02 12:07:23.000000000 -0400
453 +++ linux-stage/fs/ext4/inode.c 2012-07-02 12:07:57.000000000 -0400
454 @@ -246,7 +246,7 @@ void ext4_delete_inode(struct inode *ino
456 err = ext4_mark_inode_dirty(handle, inode);
458 - ext4_warning(inode->i_sb, __func__,
459 + ext4_warning(inode->i_sb,
460 "couldn't mark inode dirty (err %d)", err);
463 @@ -264,7 +264,7 @@ void ext4_delete_inode(struct inode *ino
465 err = ext4_journal_restart(handle, 3);
467 - ext4_warning(inode->i_sb, __func__,
468 + ext4_warning(inode->i_sb,
469 "couldn't extend journal (err %d)", err);
471 ext4_journal_stop(handle);
472 @@ -375,8 +375,7 @@ static int ext4_block_to_path(struct ino
473 offsets[n++] = i_block & (ptrs - 1);
476 - ext4_warning(inode->i_sb, "ext4_block_to_path",
477 - "block %lu > max in inode %lu",
478 + ext4_warning(inode->i_sb, "block %lu > max in inode %lu",
479 i_block + direct_blocks +
480 indirect_blocks + double_blocks, inode->i_ino);
482 @@ -396,7 +395,7 @@ static int __ext4_check_blockref(const c
484 unlikely(!ext4_data_block_valid(EXT4_SB(inode->i_sb),
486 - ext4_error(inode->i_sb, function,
487 + ext4_error(inode->i_sb,
488 "invalid block reference %u "
489 "in inode #%lu", blk, inode->i_ino);
491 @@ -1167,7 +1166,7 @@ static int check_block_validity(struct i
492 sector_t logical, sector_t phys, int len)
494 if (!ext4_data_block_valid(EXT4_SB(inode->i_sb), phys, len)) {
495 - ext4_error(inode->i_sb, msg,
496 + ext4_error(inode->i_sb,
497 "inode #%lu logical block %llu mapped to %llu "
498 "(size %d)", inode->i_ino,
499 (unsigned long long) logical,
500 @@ -4316,7 +4315,7 @@ static void ext4_free_data(handle_t *han
501 if ((EXT4_JOURNAL(inode) == NULL) || bh2jh(this_bh))
502 ext4_handle_dirty_metadata(handle, inode, this_bh);
504 - ext4_error(inode->i_sb, __func__,
505 + ext4_error(inode->i_sb,
506 "circular indirect block detected, "
507 "inode=%lu, block=%llu",
509 @@ -4364,7 +4363,7 @@ static void ext4_free_branches(handle_t
513 - ext4_error(inode->i_sb, "ext4_free_branches",
514 + ext4_error(inode->i_sb,
515 "Read failure, inode=%lu, block=%llu",
518 @@ -4680,9 +4679,8 @@ static int __ext4_get_inode_loc(struct i
520 bh = sb_getblk(sb, block);
522 - ext4_error(sb, "ext4_get_inode_loc", "unable to read "
523 - "inode block - inode=%lu, block=%llu",
524 - inode->i_ino, block);
525 + ext4_error(sb, "unable to read inode block - "
526 + "inode=%lu, block=%llu", inode->i_ino, block);
529 if (!buffer_uptodate(bh)) {
530 @@ -4780,7 +4778,7 @@ make_io:
531 submit_bh(READ_META, bh);
533 if (!buffer_uptodate(bh)) {
534 - ext4_error(sb, __func__,
536 "unable to read inode block - inode=%lu, "
537 "block=%llu", inode->i_ino, block);
539 @@ -4999,7 +4997,7 @@ struct inode *ext4_iget(struct super_blo
541 if (ei->i_file_acl &&
542 !ext4_data_block_valid(EXT4_SB(sb), ei->i_file_acl, 1)) {
543 - ext4_error(sb, __func__,
545 "bad extended attribute block %llu in inode #%lu",
546 ei->i_file_acl, inode->i_ino);
548 @@ -5046,7 +5044,7 @@ struct inode *ext4_iget(struct super_blo
549 new_decode_dev(le32_to_cpu(raw_inode->i_block[1])));
552 - ext4_error(inode->i_sb, __func__,
553 + ext4_error(inode->i_sb,
554 "bogus i_mode (%o) for inode=%lu",
555 inode->i_mode, inode->i_ino);
557 @@ -5286,7 +5284,7 @@ int ext4_write_inode(struct inode *inode
559 sync_dirty_buffer(iloc.bh);
560 if (buffer_req(iloc.bh) && !buffer_uptodate(iloc.bh)) {
561 - ext4_error(inode->i_sb, __func__,
562 + ext4_error(inode->i_sb,
563 "IO error syncing inode, "
564 "inode=%lu, block=%llu",
566 @@ -5707,7 +5705,7 @@ int ext4_mark_inode_dirty(handle_t *hand
567 EXT4_STATE_NO_EXPAND);
569 le16_to_cpu(sbi->s_es->s_mnt_count)) {
570 - ext4_warning(inode->i_sb, __func__,
571 + ext4_warning(inode->i_sb,
572 "Unable to expand inode %lu. Delete"
573 " some EAs or run e2fsck.",
575 diff -urpN linux-stage.orig/fs/ext4/mballoc.c linux-stage/fs/ext4/mballoc.c
576 --- linux-stage.orig/fs/ext4/mballoc.c 2012-07-02 12:07:23.000000000 -0400
577 +++ linux-stage/fs/ext4/mballoc.c 2012-07-02 12:07:57.000000000 -0400
578 @@ -862,8 +862,6 @@ static int ext4_mb_init_cache(struct pag
581 first_block = page->index * blocks_per_page;
582 - /* init the page */
583 - memset(page_address(page), 0xff, PAGE_CACHE_SIZE);
584 for (i = 0; i < blocks_per_page; i++) {
586 struct ext4_group_info *grinfo;
587 @@ -899,6 +897,8 @@ static int ext4_mb_init_cache(struct pag
588 * incore got set to the group block bitmap below
590 ext4_lock_group(sb, group);
591 + /* init the page */
592 + memset(data, 0xff, blocksize);
593 ext4_mb_generate_buddy(sb, data, incore, group);
594 ext4_unlock_group(sb, group);
596 @@ -1862,7 +1862,6 @@ void ext4_mb_scan_aligned(struct ext4_al
600 -/* This is now called BEFORE we load the buddy bitmap. */
601 static int ext4_mb_good_group(struct ext4_allocation_context *ac,
602 ext4_group_t group, int cr)
604 @@ -2162,6 +2161,11 @@ static void *ext4_mb_seq_groups_next(str
605 return (void *) ((unsigned long) group);
608 +static inline void ext4_mb_release_desc(struct ext4_buddy *e4b)
610 + ext4_mb_unload_buddy(e4b);
613 static int ext4_mb_seq_groups_show(struct seq_file *seq, void *v)
615 struct super_block *sb = seq->private;
616 @@ -2193,7 +2197,7 @@ static int ext4_mb_seq_groups_show(struc
617 ext4_lock_group(sb, group);
618 memcpy(&sg, ext4_get_group_info(sb, group), i);
619 ext4_unlock_group(sb, group);
620 - ext4_mb_unload_buddy(&e4b);
621 + ext4_mb_release_desc(&e4b);
623 seq_printf(seq, "#%-5u: %-5u %-5u %-5u [", group, sg.info.bb_free,
624 sg.info.bb_fragments, sg.info.bb_first_free);
625 @@ -2562,6 +2566,17 @@ int ext4_mb_release(struct super_block *
629 +static inline int ext4_issue_discard(struct super_block *sb,
630 + ext4_group_t block_group, ext4_grpblk_t block, int count)
632 + ext4_fsblk_t discard_block;
634 + discard_block = block + ext4_group_first_block_no(sb, block_group);
635 + trace_ext4_discard_blocks(sb,
636 + (unsigned long long) discard_block, count);
637 + return sb_issue_discard(sb, discard_block, count);
641 * This function is called by the jbd2 layer once the commit has finished,
642 * so we know we can free the blocks that were released with that commit.
643 @@ -2581,22 +2596,9 @@ static void release_blocks_on_commit(jou
644 mb_debug(1, "gonna free %u blocks in group %u (0x%p):",
645 entry->count, entry->group, entry);
647 - if (test_opt(sb, DISCARD)) {
649 - ext4_fsblk_t discard_block;
651 - discard_block = entry->start_blk +
652 - ext4_group_first_block_no(sb, entry->group);
653 - trace_ext4_discard_blocks(sb,
654 - (unsigned long long)discard_block,
656 - ret = sb_issue_discard(sb, discard_block, entry->count);
657 - if (ret == EOPNOTSUPP) {
658 - ext4_warning(sb, __func__,
659 - "discard not supported, disabling");
660 - clear_opt(EXT4_SB(sb)->s_mount_opt, DISCARD);
663 + if (test_opt(sb, DISCARD))
664 + ext4_issue_discard(sb, entry->group,
665 + entry->start_blk, entry->count);
667 err = ext4_mb_load_buddy(sb, entry->group, &e4b);
668 /* we expect to find existing buddy because it's pinned */
669 @@ -2611,6 +2613,15 @@ static void release_blocks_on_commit(jou
670 rb_erase(&entry->node, &(db->bb_free_root));
671 mb_free_blocks(NULL, &e4b, entry->start_blk, entry->count);
674 + * Clear the trimmed flag for the group so that the next
675 + * ext4_trim_fs can trim it.
676 + * If the volume is mounted with -o discard, online discard
677 + * is supported and the free blocks will be trimmed online.
679 + if (!test_opt(sb, DISCARD))
680 + EXT4_MB_GRP_CLEAR_TRIMMED(db);
682 if (!db->bb_free_root.rb_node) {
683 /* No more items in the per group rb tree
684 * balance refcounts from ext4_mb_free_metadata()
685 @@ -2620,7 +2631,7 @@ static void release_blocks_on_commit(jou
687 ext4_unlock_group(sb, entry->group);
688 kmem_cache_free(ext4_free_ext_cachep, entry);
689 - ext4_mb_unload_buddy(&e4b);
690 + ext4_mb_release_desc(&e4b);
693 mb_debug(1, "freed %u blocks in %u structures\n", count, count2);
694 @@ -2757,7 +2768,7 @@ ext4_mb_mark_diskspace_used(struct ext4_
696 len = ac->ac_b_ex.fe_len;
697 if (!ext4_data_block_valid(sbi, block, len)) {
698 - ext4_error(sb, __func__,
700 "Allocating blocks %llu-%llu which overlap "
701 "fs metadata\n", block, block+len);
702 /* File system mounted not to panic on error
703 @@ -3671,14 +3682,14 @@ ext4_mb_discard_group_preallocations(str
705 bitmap_bh = ext4_read_block_bitmap(sb, group);
706 if (bitmap_bh == NULL) {
707 - ext4_error(sb, __func__, "Error in reading block "
708 + ext4_error(sb, "Error in reading block "
709 "bitmap for %u", group);
713 err = ext4_mb_load_buddy(sb, group, &e4b);
715 - ext4_error(sb, __func__, "Error in loading buddy "
716 + ext4_error(sb, "Error in loading buddy "
717 "information for %u", group);
720 @@ -3852,14 +3863,14 @@ repeat:
722 err = ext4_mb_load_buddy(sb, group, &e4b);
724 - ext4_error(sb, __func__, "Error in loading buddy "
725 - "information for %u", group);
726 + ext4_error(sb, "Error in loading buddy information for %u",
731 bitmap_bh = ext4_read_block_bitmap(sb, group);
732 if (bitmap_bh == NULL) {
733 - ext4_error(sb, __func__, "Error in reading block "
734 + ext4_error(sb, "Error in reading block "
735 "bitmap for %u", group);
736 ext4_mb_unload_buddy(&e4b);
738 @@ -4125,7 +4136,7 @@ ext4_mb_discard_lg_preallocations(struct
740 ext4_get_group_no_and_offset(sb, pa->pa_pstart, &group, NULL);
741 if (ext4_mb_load_buddy(sb, group, &e4b)) {
742 - ext4_error(sb, __func__, "Error in loading buddy "
743 + ext4_error(sb, "Error in loading buddy "
744 "information for %u", group);
747 @@ -4516,7 +4527,7 @@ void ext4_mb_free_blocks(handle_t *handl
748 if (block < le32_to_cpu(es->s_first_data_block) ||
749 block + count < block ||
750 block + count > ext4_blocks_count(es)) {
751 - ext4_error(sb, __func__,
753 "Freeing blocks not in datazone - "
754 "block = %llu, count = %lu", block, count);
756 @@ -4561,7 +4572,7 @@ do_more:
757 in_range(block + count - 1, ext4_inode_table(sb, gdp),
758 EXT4_SB(sb)->s_itb_per_group)) {
760 - ext4_error(sb, __func__,
762 "Freeing blocks in system zone - "
763 "Block = %llu, count = %lu", block, count);
764 /* err = 0. ext4_std_error should be a no op */
765 diff -urpN linux-stage.orig/fs/ext4/move_extent.c linux-stage/fs/ext4/move_extent.c
766 --- linux-stage.orig/fs/ext4/move_extent.c 2012-07-02 12:07:23.000000000 -0400
767 +++ linux-stage/fs/ext4/move_extent.c 2012-07-02 12:07:57.000000000 -0400
768 @@ -152,12 +152,12 @@ mext_check_null_inode(struct inode *inod
771 if (inode1 == NULL) {
772 - ext4_error(inode2->i_sb, function,
773 + ext4_error(inode2->i_sb,
774 "Both inodes should not be NULL: "
775 "inode1 NULL inode2 %lu", inode2->i_ino);
777 } else if (inode2 == NULL) {
778 - ext4_error(inode1->i_sb, function,
779 + ext4_error(inode1->i_sb,
780 "Both inodes should not be NULL: "
781 "inode1 %lu inode2 NULL", inode1->i_ino);
783 @@ -483,7 +483,7 @@ mext_leaf_block(handle_t *handle, struct
785 o_start = o_end = oext = orig_path[depth].p_ext;
786 oext_alen = ext4_ext_get_actual_len(oext);
787 - start_ext.ee_len = end_ext.ee_len = 0;
788 + start_ext.ee_block = start_ext.ee_len = end_ext.ee_len = 0;
790 new_ext.ee_block = cpu_to_le32(*from);
791 ext4_ext_store_pblock(&new_ext, ext_pblock(dext));
792 @@ -528,7 +528,7 @@ mext_leaf_block(handle_t *handle, struct
795 if (le32_to_cpu(oext->ee_block) + oext_alen - 1 < new_ext_end) {
796 - ext4_error(orig_inode->i_sb, __func__,
797 + ext4_error(orig_inode->i_sb,
798 "new_ext_end(%u) should be less than or equal to "
799 "oext->ee_block(%u) + oext_alen(%d) - 1",
800 new_ext_end, le32_to_cpu(oext->ee_block),
801 @@ -691,12 +691,12 @@ mext_replace_branches(handle_t *handle,
803 /* The extent for donor must be found. */
805 - ext4_error(donor_inode->i_sb, __func__,
806 + ext4_error(donor_inode->i_sb,
807 "The extent for donor must be found");
810 } else if (donor_off != le32_to_cpu(tmp_dext.ee_block)) {
811 - ext4_error(donor_inode->i_sb, __func__,
812 + ext4_error(donor_inode->i_sb,
813 "Donor offset(%u) and the first block of donor "
814 "extent(%u) should be equal",
816 @@ -1356,7 +1356,7 @@ ext4_move_extents(struct file *o_filp, s
819 if (*moved_len > len) {
820 - ext4_error(orig_inode->i_sb, __func__,
821 + ext4_error(orig_inode->i_sb,
822 "We replaced blocks too much! "
823 "sum of replaced: %llu requested: %llu",
825 diff -urpN linux-stage.orig/fs/ext4/namei.c linux-stage/fs/ext4/namei.c
826 --- linux-stage.orig/fs/ext4/namei.c 2012-07-02 12:07:23.000000000 -0400
827 +++ linux-stage/fs/ext4/namei.c 2012-07-02 12:07:57.000000000 -0400
828 @@ -394,8 +394,7 @@ dx_probe(const struct qstr *d_name, stru
829 if (root->info.hash_version != DX_HASH_TEA &&
830 root->info.hash_version != DX_HASH_HALF_MD4 &&
831 root->info.hash_version != DX_HASH_LEGACY) {
832 - ext4_warning(dir->i_sb, __func__,
833 - "Unrecognised inode hash code %d",
834 + ext4_warning(dir->i_sb, "Unrecognised inode hash code %d",
835 root->info.hash_version);
837 *err = ERR_BAD_DX_DIR;
838 @@ -410,8 +409,7 @@ dx_probe(const struct qstr *d_name, stru
841 if (root->info.unused_flags & 1) {
842 - ext4_warning(dir->i_sb, __func__,
843 - "Unimplemented inode hash flags: %#06x",
844 + ext4_warning(dir->i_sb, "Unimplemented inode hash flags: %#06x",
845 root->info.unused_flags);
847 *err = ERR_BAD_DX_DIR;
848 @@ -419,8 +417,7 @@ dx_probe(const struct qstr *d_name, stru
851 if ((indirect = root->info.indirect_levels) > 1) {
852 - ext4_warning(dir->i_sb, __func__,
853 - "Unimplemented inode hash depth: %#06x",
854 + ext4_warning(dir->i_sb, "Unimplemented inode hash depth: %#06x",
855 root->info.indirect_levels);
857 *err = ERR_BAD_DX_DIR;
858 @@ -432,8 +429,7 @@ dx_probe(const struct qstr *d_name, stru
860 if (dx_get_limit(entries) != dx_root_limit(dir,
861 root->info.info_length)) {
862 - ext4_warning(dir->i_sb, __func__,
863 - "dx entry: limit != root limit");
864 + ext4_warning(dir->i_sb, "dx entry: limit != root limit");
866 *err = ERR_BAD_DX_DIR;
868 @@ -444,7 +440,7 @@ dx_probe(const struct qstr *d_name, stru
870 count = dx_get_count(entries);
871 if (!count || count > dx_get_limit(entries)) {
872 - ext4_warning(dir->i_sb, __func__,
873 + ext4_warning(dir->i_sb,
874 "dx entry: no count or count > limit");
876 *err = ERR_BAD_DX_DIR;
877 @@ -489,7 +485,7 @@ dx_probe(const struct qstr *d_name, stru
879 at = entries = ((struct dx_node *) bh->b_data)->entries;
880 if (dx_get_limit(entries) != dx_node_limit (dir)) {
881 - ext4_warning(dir->i_sb, __func__,
882 + ext4_warning(dir->i_sb,
883 "dx entry: limit != node limit");
885 *err = ERR_BAD_DX_DIR;
886 @@ -505,7 +501,7 @@ fail2:
889 if (*err == ERR_BAD_DX_DIR)
890 - ext4_warning(dir->i_sb, __func__,
891 + ext4_warning(dir->i_sb,
892 "Corrupt dir inode %ld, running e2fsck is "
893 "recommended.", dir->i_ino);
895 @@ -969,7 +965,7 @@ restart:
897 if (!buffer_uptodate(bh)) {
898 /* read error, skip block & hope for the best */
899 - ext4_error(sb, __func__, "reading directory #%lu "
900 + ext4_error(sb, "reading directory #%lu "
901 "offset %lu", dir->i_ino,
902 (unsigned long)block);
904 @@ -1012,8 +1008,9 @@ cleanup_and_exit:
905 static struct buffer_head * ext4_dx_find_entry(struct inode *dir, const struct qstr *d_name,
906 struct ext4_dir_entry_2 **res_dir, int *err)
908 - struct super_block * sb = dir->i_sb;
909 + struct super_block * sb;
910 struct dx_hash_info hinfo;
912 struct dx_frame frames[2], *frame;
913 struct ext4_dir_entry_2 *de, *top;
914 struct buffer_head *bh;
915 @@ -1022,8 +1019,18 @@ static struct buffer_head * ext4_dx_find
916 int namelen = d_name->len;
917 const u8 *name = d_name->name;
919 - if (!(frame = dx_probe(d_name, dir, &hinfo, frames, err)))
922 + /* NFS may look up ".." - look at dx_root directory block */
923 + if (namelen > 2 || name[0] != '.'||(name[1] != '.' && name[1] != '\0')){
924 + if (!(frame = dx_probe(d_name, dir, &hinfo, frames, err)))
928 + frame->bh = NULL; /* for dx_release() */
929 + frame->at = (struct dx_entry *)frames; /* hack for zero entry*/
930 + dx_set_block(frame->at, 0); /* dx_root block is 0 */
934 block = dx_get_block(frame->at);
935 if (!(bh = ext4_bread (NULL,dir, block, 0, err)))
936 @@ -1049,10 +1056,10 @@ static struct buffer_head * ext4_dx_find
939 /* Check to see if we should continue to search */
940 - retval = ext4_htree_next_block(dir, hinfo.hash, frame,
941 + retval = ext4_htree_next_block(dir, hash, frame,
944 - ext4_warning(sb, __func__,
946 "error reading index page in directory #%lu",
949 @@ -1082,14 +1089,13 @@ static struct dentry *ext4_lookup(struct
950 __u32 ino = le32_to_cpu(de->inode);
952 if (!ext4_valid_inum(dir->i_sb, ino)) {
953 - ext4_error(dir->i_sb, "ext4_lookup",
954 - "bad inode number: %u", ino);
955 + ext4_error(dir->i_sb, "bad inode number: %u", ino);
956 return ERR_PTR(-EIO);
958 inode = ext4_iget(dir->i_sb, ino);
959 if (unlikely(IS_ERR(inode))) {
960 if (PTR_ERR(inode) == -ESTALE) {
961 - ext4_error(dir->i_sb, __func__,
962 + ext4_error(dir->i_sb,
963 "deleted inode referenced: %u",
965 return ERR_PTR(-EIO);
966 @@ -1121,7 +1127,7 @@ struct dentry *ext4_get_parent(struct de
969 if (!ext4_valid_inum(child->d_inode->i_sb, ino)) {
970 - ext4_error(child->d_inode->i_sb, "ext4_get_parent",
971 + ext4_error(child->d_inode->i_sb,
972 "bad inode number: %u", ino);
973 return ERR_PTR(-EIO);
975 @@ -1421,7 +1427,7 @@ static int make_indexed_dir(handle_t *ha
976 de = (struct ext4_dir_entry_2 *)((char *)fde +
977 ext4_rec_len_from_disk(fde->rec_len, blocksize));
978 if ((char *) de >= (((char *) root) + blocksize)) {
979 - ext4_error(dir->i_sb, __func__,
980 + ext4_error(dir->i_sb,
981 "invalid rec_len for '..' in inode %lu",
984 @@ -1468,10 +1474,22 @@ static int make_indexed_dir(handle_t *ha
989 + ext4_handle_dirty_metadata(handle, dir, frame->bh);
990 + ext4_handle_dirty_metadata(handle, dir, bh);
992 de = do_split(handle,dir, &bh, frame, &hinfo, &retval);
993 - dx_release (frames);
997 + * Even if the block split failed, we have to properly write
998 + * out all the changes we did so far. Otherwise we can end up
999 + * with corrupted filesystem.
1001 + ext4_mark_inode_dirty(handle, dir);
1002 + dx_release(frames);
1005 + dx_release(frames);
1007 retval = add_dirent_to_buf(handle, dentry, inode, de, bh);
1009 @@ -1588,8 +1606,7 @@ static int ext4_dx_add_entry(handle_t *h
1011 if (levels && (dx_get_count(frames->entries) ==
1012 dx_get_limit(frames->entries))) {
1013 - ext4_warning(sb, __func__,
1014 - "Directory index full!");
1015 + ext4_warning(sb, "Directory index full!");
1019 @@ -1943,11 +1960,11 @@ static int empty_dir(struct inode *inode
1020 if (inode->i_size < EXT4_DIR_REC_LEN(1) + EXT4_DIR_REC_LEN(2) ||
1021 !(bh = ext4_bread(NULL, inode, 0, 0, &err))) {
1023 - ext4_error(inode->i_sb, __func__,
1024 + ext4_error(inode->i_sb,
1025 "error %d reading directory #%lu offset 0",
1028 - ext4_warning(inode->i_sb, __func__,
1029 + ext4_warning(inode->i_sb,
1030 "bad directory (dir #%lu) - no data block",
1033 @@ -1958,7 +1975,7 @@ static int empty_dir(struct inode *inode
1034 !le32_to_cpu(de1->inode) ||
1035 strcmp(".", de->name) ||
1036 strcmp("..", de1->name)) {
1037 - ext4_warning(inode->i_sb, "empty_dir",
1038 + ext4_warning(inode->i_sb,
1039 "bad directory (dir #%lu) - no `.' or `..'",
1042 @@ -1976,7 +1993,7 @@ static int empty_dir(struct inode *inode
1043 offset >> EXT4_BLOCK_SIZE_BITS(sb), 0, &err);
1046 - ext4_error(sb, __func__,
1048 "error %d reading directory"
1050 err, inode->i_ino, offset);
1051 @@ -2198,7 +2215,7 @@ static int ext4_rmdir(struct inode *dir,
1054 if (!EXT4_DIR_LINK_EMPTY(inode))
1055 - ext4_warning(inode->i_sb, "ext4_rmdir",
1056 + ext4_warning(inode->i_sb,
1057 "empty directory has too many links (%d)",
1060 @@ -2250,7 +2267,7 @@ static int ext4_unlink(struct inode *dir
1063 if (!inode->i_nlink) {
1064 - ext4_warning(inode->i_sb, "ext4_unlink",
1065 + ext4_warning(inode->i_sb,
1066 "Deleting nonexistent file (%lu), %d",
1067 inode->i_ino, inode->i_nlink);
1069 @@ -2497,7 +2514,7 @@ static int ext4_rename(struct inode *old
1073 - ext4_warning(old_dir->i_sb, "ext4_rename",
1074 + ext4_warning(old_dir->i_sb,
1075 "Deleting old file (%lu), %d, error=%d",
1076 old_dir->i_ino, old_dir->i_nlink, retval);
1078 diff -urpN linux-stage.orig/fs/ext4/resize.c linux-stage/fs/ext4/resize.c
1079 --- linux-stage.orig/fs/ext4/resize.c 2012-07-02 12:07:23.000000000 -0400
1080 +++ linux-stage/fs/ext4/resize.c 2012-07-02 12:07:57.000000000 -0400
1081 @@ -48,63 +48,63 @@ static int verify_group_input(struct sup
1083 ext4_get_group_no_and_offset(sb, start, NULL, &offset);
1084 if (group != sbi->s_groups_count)
1085 - ext4_warning(sb, __func__,
1087 "Cannot add at group %u (only %u groups)",
1088 input->group, sbi->s_groups_count);
1089 else if (offset != 0)
1090 - ext4_warning(sb, __func__, "Last group not full");
1091 + ext4_warning(sb, "Last group not full");
1092 else if (input->reserved_blocks > input->blocks_count / 5)
1093 - ext4_warning(sb, __func__, "Reserved blocks too high (%u)",
1094 + ext4_warning(sb, "Reserved blocks too high (%u)",
1095 input->reserved_blocks);
1096 else if (free_blocks_count < 0)
1097 - ext4_warning(sb, __func__, "Bad blocks count %u",
1098 + ext4_warning(sb, "Bad blocks count %u",
1099 input->blocks_count);
1100 else if (!(bh = sb_bread(sb, end - 1)))
1101 - ext4_warning(sb, __func__,
1103 "Cannot read last block (%llu)",
1105 else if (outside(input->block_bitmap, start, end))
1106 - ext4_warning(sb, __func__,
1108 "Block bitmap not in group (block %llu)",
1109 (unsigned long long)input->block_bitmap);
1110 else if (outside(input->inode_bitmap, start, end))
1111 - ext4_warning(sb, __func__,
1113 "Inode bitmap not in group (block %llu)",
1114 (unsigned long long)input->inode_bitmap);
1115 else if (outside(input->inode_table, start, end) ||
1116 outside(itend - 1, start, end))
1117 - ext4_warning(sb, __func__,
1119 "Inode table not in group (blocks %llu-%llu)",
1120 (unsigned long long)input->inode_table, itend - 1);
1121 else if (input->inode_bitmap == input->block_bitmap)
1122 - ext4_warning(sb, __func__,
1124 "Block bitmap same as inode bitmap (%llu)",
1125 (unsigned long long)input->block_bitmap);
1126 else if (inside(input->block_bitmap, input->inode_table, itend))
1127 - ext4_warning(sb, __func__,
1129 "Block bitmap (%llu) in inode table (%llu-%llu)",
1130 (unsigned long long)input->block_bitmap,
1131 (unsigned long long)input->inode_table, itend - 1);
1132 else if (inside(input->inode_bitmap, input->inode_table, itend))
1133 - ext4_warning(sb, __func__,
1135 "Inode bitmap (%llu) in inode table (%llu-%llu)",
1136 (unsigned long long)input->inode_bitmap,
1137 (unsigned long long)input->inode_table, itend - 1);
1138 else if (inside(input->block_bitmap, start, metaend))
1139 - ext4_warning(sb, __func__,
1141 "Block bitmap (%llu) in GDT table"
1143 (unsigned long long)input->block_bitmap,
1144 start, metaend - 1);
1145 else if (inside(input->inode_bitmap, start, metaend))
1146 - ext4_warning(sb, __func__,
1148 "Inode bitmap (%llu) in GDT table"
1150 (unsigned long long)input->inode_bitmap,
1151 start, metaend - 1);
1152 else if (inside(input->inode_table, start, metaend) ||
1153 inside(itend - 1, start, metaend))
1154 - ext4_warning(sb, __func__,
1156 "Inode table (%llu-%llu) overlaps"
1157 "GDT table (%llu-%llu)",
1158 (unsigned long long)input->inode_table,
1159 @@ -364,7 +364,7 @@ static int verify_reserved_gdb(struct su
1160 while ((grp = ext4_list_backups(sb, &three, &five, &seven)) < end) {
1161 if (le32_to_cpu(*p++) !=
1162 grp * EXT4_BLOCKS_PER_GROUP(sb) + blk){
1163 - ext4_warning(sb, __func__,
1166 " missing grp %d (%llu)",
1168 @@ -420,7 +420,7 @@ static int add_new_gdb(handle_t *handle,
1170 if (EXT4_SB(sb)->s_sbh->b_blocknr !=
1171 le32_to_cpu(EXT4_SB(sb)->s_es->s_first_data_block)) {
1172 - ext4_warning(sb, __func__,
1174 "won't resize using backup superblock at %llu",
1175 (unsigned long long)EXT4_SB(sb)->s_sbh->b_blocknr);
1177 @@ -444,7 +444,7 @@ static int add_new_gdb(handle_t *handle,
1179 data = (__le32 *)dind->b_data;
1180 if (le32_to_cpu(data[gdb_num % EXT4_ADDR_PER_BLOCK(sb)]) != gdblock) {
1181 - ext4_warning(sb, __func__,
1183 "new group %u GDT block %llu not reserved",
1184 input->group, gdblock);
1186 @@ -468,7 +468,7 @@ static int add_new_gdb(handle_t *handle,
1188 if (!n_group_desc) {
1190 - ext4_warning(sb, __func__,
1192 "not enough memory for %lu groups", gdb_num + 1);
1195 @@ -567,7 +567,7 @@ static int reserve_backup_gdb(handle_t *
1196 /* Get each reserved primary GDT block and verify it holds backups */
1197 for (res = 0; res < reserved_gdb; res++, blk++) {
1198 if (le32_to_cpu(*data) != blk) {
1199 - ext4_warning(sb, __func__,
1201 "reserved block %llu"
1202 " not at offset %ld",
1204 @@ -713,7 +713,7 @@ static void update_backups(struct super_
1208 - ext4_warning(sb, __func__,
1210 "can't update backup for group %u (err %d), "
1211 "forcing fsck on next reboot", group, err);
1212 sbi->s_mount_state &= ~EXT4_VALID_FS;
1213 @@ -753,20 +753,20 @@ int ext4_group_add(struct super_block *s
1215 if (gdb_off == 0 && !EXT4_HAS_RO_COMPAT_FEATURE(sb,
1216 EXT4_FEATURE_RO_COMPAT_SPARSE_SUPER)) {
1217 - ext4_warning(sb, __func__,
1219 "Can't resize non-sparse filesystem further");
1223 if (ext4_blocks_count(es) + input->blocks_count <
1224 ext4_blocks_count(es)) {
1225 - ext4_warning(sb, __func__, "blocks_count overflow");
1226 + ext4_warning(sb, "blocks_count overflow");
1230 if (le32_to_cpu(es->s_inodes_count) + EXT4_INODES_PER_GROUP(sb) <
1231 le32_to_cpu(es->s_inodes_count)) {
1232 - ext4_warning(sb, __func__, "inodes_count overflow");
1233 + ext4_warning(sb, "inodes_count overflow");
1237 @@ -774,13 +774,13 @@ int ext4_group_add(struct super_block *s
1238 if (!EXT4_HAS_COMPAT_FEATURE(sb,
1239 EXT4_FEATURE_COMPAT_RESIZE_INODE)
1240 || !le16_to_cpu(es->s_reserved_gdt_blocks)) {
1241 - ext4_warning(sb, __func__,
1243 "No reserved GDT blocks, can't resize");
1246 inode = ext4_iget(sb, EXT4_RESIZE_INO);
1247 if (IS_ERR(inode)) {
1248 - ext4_warning(sb, __func__,
1250 "Error opening resize inode");
1251 return PTR_ERR(inode);
1253 @@ -810,7 +810,7 @@ int ext4_group_add(struct super_block *s
1255 mutex_lock(&sbi->s_resize_lock);
1256 if (input->group != sbi->s_groups_count) {
1257 - ext4_warning(sb, __func__,
1259 "multiple resizers run on filesystem!");
1262 @@ -998,12 +998,12 @@ int ext4_group_extend(struct super_block
1263 " too large to resize to %llu blocks safely\n",
1264 sb->s_id, n_blocks_count);
1265 if (sizeof(sector_t) < 8)
1266 - ext4_warning(sb, __func__, "CONFIG_LBDAF not enabled");
1267 + ext4_warning(sb, "CONFIG_LBDAF not enabled");
1271 if (n_blocks_count < o_blocks_count) {
1272 - ext4_warning(sb, __func__,
1274 "can't shrink FS - resize aborted");
1277 @@ -1012,7 +1012,7 @@ int ext4_group_extend(struct super_block
1278 ext4_get_group_no_and_offset(sb, o_blocks_count, &group, &last);
1281 - ext4_warning(sb, __func__,
1283 "need to use ext2online to resize further");
1286 @@ -1020,7 +1020,7 @@ int ext4_group_extend(struct super_block
1287 add = EXT4_BLOCKS_PER_GROUP(sb) - last;
1289 if (o_blocks_count + add < o_blocks_count) {
1290 - ext4_warning(sb, __func__, "blocks_count overflow");
1291 + ext4_warning(sb, "blocks_count overflow");
1295 @@ -1028,7 +1028,7 @@ int ext4_group_extend(struct super_block
1296 add = n_blocks_count - o_blocks_count;
1298 if (o_blocks_count + add < n_blocks_count)
1299 - ext4_warning(sb, __func__,
1301 "will only finish group (%llu"
1303 o_blocks_count + add, add);
1304 @@ -1036,7 +1036,7 @@ int ext4_group_extend(struct super_block
1305 /* See if the device is actually as big as what was requested */
1306 bh = sb_bread(sb, o_blocks_count + add - 1);
1308 - ext4_warning(sb, __func__,
1310 "can't read last block, resize aborted");
1313 @@ -1048,13 +1048,13 @@ int ext4_group_extend(struct super_block
1314 handle = ext4_journal_start_sb(sb, 3);
1315 if (IS_ERR(handle)) {
1316 err = PTR_ERR(handle);
1317 - ext4_warning(sb, __func__, "error %d on journal start", err);
1318 + ext4_warning(sb, "error %d on journal start", err);
1322 mutex_lock(&EXT4_SB(sb)->s_resize_lock);
1323 if (o_blocks_count != ext4_blocks_count(es)) {
1324 - ext4_warning(sb, __func__,
1326 "multiple resizers run on filesystem!");
1327 mutex_unlock(&EXT4_SB(sb)->s_resize_lock);
1328 ext4_journal_stop(handle);
1329 @@ -1064,7 +1064,7 @@ int ext4_group_extend(struct super_block
1331 if ((err = ext4_journal_get_write_access(handle,
1332 EXT4_SB(sb)->s_sbh))) {
1333 - ext4_warning(sb, __func__,
1335 "error %d on journal write access", err);
1336 mutex_unlock(&EXT4_SB(sb)->s_resize_lock);
1337 ext4_journal_stop(handle);
1338 diff -urpN linux-stage.orig/fs/ext4/super.c linux-stage/fs/ext4/super.c
1339 --- linux-stage.orig/fs/ext4/super.c 2012-07-02 12:07:23.000000000 -0400
1340 +++ linux-stage/fs/ext4/super.c 2012-07-02 12:07:57.000000000 -0400
1343 #include "mballoc.h"
1345 +#define QFMT_OCFS2 3
1346 +#define QFMT_VFS_V1 4
1348 #define CREATE_TRACE_POINTS
1349 #include <trace/events/ext4.h>
1351 struct proc_dir_entry *ext4_proc_root;
1352 static struct kset *ext4_kset;
1353 +static struct ext4_lazy_init *ext4_li_info;
1354 +static struct mutex ext4_li_mtx;
1356 static int ext4_load_journal(struct super_block *, struct ext4_super_block *,
1357 unsigned long journal_devnum);
1358 @@ -337,7 +342,7 @@ static void ext4_handle_error(struct sup
1362 -void ext4_error(struct super_block *sb, const char *function,
1363 +void __ext4_error(struct super_block *sb, const char *function,
1364 const char *fmt, ...)
1367 @@ -351,6 +356,42 @@ void ext4_error(struct super_block *sb,
1368 ext4_handle_error(sb);
1371 +void ext4_error_inode(const char *function, struct inode *inode,
1372 + const char *fmt, ...)
1376 + va_start(args, fmt);
1377 + printk(KERN_CRIT "EXT4-fs error (device %s): %s: inode #%lu: (comm %s) ",
1378 + inode->i_sb->s_id, function, inode->i_ino, current->comm);
1379 + vprintk(fmt, args);
1383 + ext4_handle_error(inode->i_sb);
1386 +void ext4_error_file(const char *function, struct file *file,
1387 + const char *fmt, ...)
1390 + struct inode *inode = file->f_dentry->d_inode;
1391 + char pathname[80], *path;
1393 + va_start(args, fmt);
1394 + path = d_path(&(file->f_path), pathname, sizeof(pathname));
1396 + path = "(unknown)";
1398 + "EXT4-fs error (device %s): %s: inode #%lu (comm %s path %s): ",
1399 + inode->i_sb->s_id, function, inode->i_ino, current->comm, path);
1400 + vprintk(fmt, args);
1404 + ext4_handle_error(inode->i_sb);
1407 static const char *ext4_decode_error(struct super_block *sb, int errno,
1410 @@ -454,7 +495,7 @@ void ext4_msg (struct super_block * sb,
1414 -void ext4_warning(struct super_block *sb, const char *function,
1415 +void __ext4_warning(struct super_block *sb, const char *function,
1416 const char *fmt, ...)
1419 @@ -511,7 +552,7 @@ void ext4_update_dynamic_rev(struct supe
1420 if (le32_to_cpu(es->s_rev_level) > EXT4_GOOD_OLD_REV)
1423 - ext4_warning(sb, __func__,
1425 "updating to rev %d because of new feature flag, "
1426 "running e2fsck is recommended",
1428 @@ -777,9 +818,22 @@ static inline void ext4_show_quota_optio
1429 #if defined(CONFIG_QUOTA)
1430 struct ext4_sb_info *sbi = EXT4_SB(sb);
1432 - if (sbi->s_jquota_fmt)
1433 - seq_printf(seq, ",jqfmt=%s",
1434 - (sbi->s_jquota_fmt == QFMT_VFS_OLD) ? "vfsold" : "vfsv0");
1435 + if (sbi->s_jquota_fmt) {
1436 + char *fmtname = "";
1438 + switch (sbi->s_jquota_fmt) {
1439 + case QFMT_VFS_OLD:
1440 + fmtname = "vfsold";
1443 + fmtname = "vfsv0";
1446 + fmtname = "vfsv1";
1449 + seq_printf(seq, ",jqfmt=%s", fmtname);
1452 if (sbi->s_qf_names[USRQUOTA])
1453 seq_printf(seq, ",usrjquota=%s", sbi->s_qf_names[USRQUOTA]);
1454 @@ -1096,13 +1150,14 @@ enum {
1455 Opt_abort, Opt_data_journal, Opt_data_ordered, Opt_data_writeback,
1456 Opt_data_err_abort, Opt_data_err_ignore,
1457 Opt_usrjquota, Opt_grpjquota, Opt_offusrjquota, Opt_offgrpjquota,
1458 - Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_quota, Opt_noquota,
1459 - Opt_ignore, Opt_barrier, Opt_nobarrier, Opt_err, Opt_resize,
1460 - Opt_usrquota, Opt_grpquota, Opt_i_version,
1461 + Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_jqfmt_vfsv1, Opt_quota,
1462 + Opt_noquota, Opt_ignore, Opt_barrier, Opt_nobarrier, Opt_err,
1463 + Opt_resize, Opt_usrquota, Opt_grpquota, Opt_i_version,
1464 Opt_stripe, Opt_delalloc, Opt_nodelalloc,
1465 Opt_block_validity, Opt_noblock_validity,
1466 Opt_inode_readahead_blks, Opt_journal_ioprio,
1467 Opt_discard, Opt_nodiscard,
1468 + Opt_init_inode_table, Opt_noinit_inode_table,
1471 static const match_table_t tokens = {
1472 @@ -2709,6 +2764,21 @@ static int ext4_fill_super(struct super_
1473 get_random_bytes(&sbi->s_next_generation, sizeof(u32));
1474 spin_lock_init(&sbi->s_next_gen_lock);
1476 + err = percpu_counter_init(&sbi->s_freeblocks_counter,
1477 + ext4_count_free_blocks(sb));
1479 + err = percpu_counter_init(&sbi->s_freeinodes_counter,
1480 + ext4_count_free_inodes(sb));
1482 + err = percpu_counter_init(&sbi->s_dirs_counter,
1483 + ext4_count_dirs(sb));
1485 + err = percpu_counter_init(&sbi->s_dirtyblocks_counter, 0);
1487 + ext4_msg(sb, KERN_ERR, "insufficient memory");
1488 + goto failed_mount3;
1491 sbi->s_stripe = ext4_get_stripe_size(sbi);
1492 sbi->s_max_writeback_mb_bump = 128;
1494 @@ -2828,20 +2898,6 @@ static int ext4_fill_super(struct super_
1495 set_task_ioprio(sbi->s_journal->j_task, journal_ioprio);
1498 - err = percpu_counter_init(&sbi->s_freeblocks_counter,
1499 - ext4_count_free_blocks(sb));
1501 - err = percpu_counter_init(&sbi->s_freeinodes_counter,
1502 - ext4_count_free_inodes(sb));
1504 - err = percpu_counter_init(&sbi->s_dirs_counter,
1505 - ext4_count_dirs(sb));
1507 - err = percpu_counter_init(&sbi->s_dirtyblocks_counter, 0);
1509 - ext4_msg(sb, KERN_ERR, "insufficient memory");
1510 - goto failed_mount_wq;
1512 if (test_opt(sb, NOBH)) {
1513 if (!(test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_WRITEBACK_DATA)) {
1514 ext4_msg(sb, KERN_WARNING, "Ignoring nobh option - "
1515 @@ -2955,7 +3011,9 @@ no_journal:
1517 descr = "out journal";
1519 - ext4_msg(sb, KERN_INFO, "mounted filesystem with%s", descr);
1520 + ext4_msg(sb, KERN_INFO, "mounted filesystem with%s. "
1521 + "Opts: %s%s", descr, sbi->s_es->s_mount_opts,
1522 + *sbi->s_es->s_mount_opts ? "; " : "");
1526 @@ -2974,10 +3032,6 @@ failed_mount_wq:
1527 jbd2_journal_destroy(sbi->s_journal);
1528 sbi->s_journal = NULL;
1530 - percpu_counter_destroy(&sbi->s_freeblocks_counter);
1531 - percpu_counter_destroy(&sbi->s_freeinodes_counter);
1532 - percpu_counter_destroy(&sbi->s_dirs_counter);
1533 - percpu_counter_destroy(&sbi->s_dirtyblocks_counter);
1535 if (sbi->s_flex_groups) {
1536 if (is_vmalloc_addr(sbi->s_flex_groups))
1537 @@ -2985,6 +3039,10 @@ failed_mount3:
1539 kfree(sbi->s_flex_groups);
1541 + percpu_counter_destroy(&sbi->s_freeblocks_counter);
1542 + percpu_counter_destroy(&sbi->s_freeinodes_counter);
1543 + percpu_counter_destroy(&sbi->s_dirs_counter);
1544 + percpu_counter_destroy(&sbi->s_dirtyblocks_counter);
1546 for (i = 0; i < db_count; i++)
1547 brelse(sbi->s_group_desc[i]);
1548 @@ -3377,9 +3435,9 @@ static void ext4_clear_journal_err(struc
1551 errstr = ext4_decode_error(sb, j_errno, nbuf);
1552 - ext4_warning(sb, __func__, "Filesystem error recorded "
1553 + ext4_warning(sb, "Filesystem error recorded "
1554 "from previous mount: %s", errstr);
1555 - ext4_warning(sb, __func__, "Marking fs in need of "
1556 + ext4_warning(sb, "Marking fs in need of "
1557 "filesystem check.");
1559 EXT4_SB(sb)->s_mount_state |= EXT4_ERROR_FS;
1560 @@ -4007,11 +4065,21 @@ static struct file_system_type ext4_fs_t
1561 .fs_flags = FS_REQUIRES_DEV,
1564 +static int __init ext4_init_feat_adverts(void)
1569 +static void ext4_exit_feat_adverts(void)
1573 static int __init init_ext4_fs(void)
1577 ext4_check_flag_values();
1579 err = init_ext4_system_zone();
1582 @@ -4019,6 +4087,9 @@ static int __init init_ext4_fs(void)
1585 ext4_proc_root = proc_mkdir("fs/ext4", NULL);
1587 + err = ext4_init_feat_adverts();
1589 err = init_ext4_mballoc();
1592 @@ -4032,6 +4103,9 @@ static int __init init_ext4_fs(void)
1593 err = register_filesystem(&ext4_fs_type);
1597 + ext4_li_info = NULL;
1598 + mutex_init(&ext4_li_mtx);
1601 destroy_inodecache();
1602 @@ -4040,6 +4114,7 @@ out1:
1604 exit_ext4_mballoc();
1606 + ext4_exit_feat_adverts();
1607 remove_proc_entry("fs/ext4", NULL);
1608 kset_unregister(ext4_kset);
1610 @@ -4053,6 +4128,7 @@ static void __exit exit_ext4_fs(void)
1611 destroy_inodecache();
1613 exit_ext4_mballoc();
1614 + ext4_exit_feat_adverts();
1615 remove_proc_entry("fs/ext4", NULL);
1616 kset_unregister(ext4_kset);
1617 exit_ext4_system_zone();
1618 diff -urpN linux-stage.orig/fs/ext4/xattr.c linux-stage/fs/ext4/xattr.c
1619 --- linux-stage.orig/fs/ext4/xattr.c 2012-07-02 12:07:23.000000000 -0400
1620 +++ linux-stage/fs/ext4/xattr.c 2012-07-02 12:07:57.000000000 -0400
1621 @@ -227,7 +227,7 @@ ext4_xattr_block_get(struct inode *inode
1622 ea_bdebug(bh, "b_count=%d, refcount=%d",
1623 atomic_read(&(bh->b_count)), le32_to_cpu(BHDR(bh)->h_refcount));
1624 if (ext4_xattr_check_block(bh)) {
1625 -bad_block: ext4_error(inode->i_sb, __func__,
1626 +bad_block: ext4_error(inode->i_sb,
1627 "inode %lu: bad block %llu", inode->i_ino,
1628 EXT4_I(inode)->i_file_acl);
1630 @@ -369,7 +369,7 @@ ext4_xattr_block_list(struct inode *inod
1631 ea_bdebug(bh, "b_count=%d, refcount=%d",
1632 atomic_read(&(bh->b_count)), le32_to_cpu(BHDR(bh)->h_refcount));
1633 if (ext4_xattr_check_block(bh)) {
1634 - ext4_error(inode->i_sb, __func__,
1635 + ext4_error(inode->i_sb,
1636 "inode %lu: bad block %llu", inode->i_ino,
1637 EXT4_I(inode)->i_file_acl);
1639 @@ -661,7 +661,7 @@ ext4_xattr_block_find(struct inode *inod
1640 atomic_read(&(bs->bh->b_count)),
1641 le32_to_cpu(BHDR(bs->bh)->h_refcount));
1642 if (ext4_xattr_check_block(bs->bh)) {
1643 - ext4_error(sb, __func__,
1645 "inode %lu: bad block %llu", inode->i_ino,
1646 EXT4_I(inode)->i_file_acl);
1648 @@ -875,7 +875,7 @@ cleanup_dquot:
1652 - ext4_error(inode->i_sb, __func__,
1653 + ext4_error(inode->i_sb,
1654 "inode %lu: bad block %llu", inode->i_ino,
1655 EXT4_I(inode)->i_file_acl);
1657 @@ -1190,7 +1190,7 @@ retry:
1660 if (ext4_xattr_check_block(bh)) {
1661 - ext4_error(inode->i_sb, __func__,
1662 + ext4_error(inode->i_sb,
1663 "inode %lu: bad block %llu", inode->i_ino,
1664 EXT4_I(inode)->i_file_acl);
1666 @@ -1367,14 +1367,14 @@ ext4_xattr_delete_inode(handle_t *handle
1668 bh = sb_bread(inode->i_sb, EXT4_I(inode)->i_file_acl);
1670 - ext4_error(inode->i_sb, __func__,
1671 + ext4_error(inode->i_sb,
1672 "inode %lu: block %llu read error", inode->i_ino,
1673 EXT4_I(inode)->i_file_acl);
1676 if (BHDR(bh)->h_magic != cpu_to_le32(EXT4_XATTR_MAGIC) ||
1677 BHDR(bh)->h_blocks != cpu_to_le32(1)) {
1678 - ext4_error(inode->i_sb, __func__,
1679 + ext4_error(inode->i_sb,
1680 "inode %lu: bad block %llu", inode->i_ino,
1681 EXT4_I(inode)->i_file_acl);
1683 @@ -1501,7 +1501,7 @@ again:
1685 bh = sb_bread(inode->i_sb, ce->e_block);
1687 - ext4_error(inode->i_sb, __func__,
1688 + ext4_error(inode->i_sb,
1689 "inode %lu: block %lu read error",
1690 inode->i_ino, (unsigned long) ce->e_block);
1691 } else if (le32_to_cpu(BHDR(bh)->h_refcount) >=