Whamcloud - gitweb
LU-2760 ldiskfs: update rhel6.3 series to handle mkdir errors
[fs/lustre-release.git] / ldiskfs / kernel_patches / patches / sles11sp1 / ext4-update-sles11-rhel6.patch
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__,
9 +                       ext4_error(sb,
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);
15  
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);
23  
24                 return NULL;
25         }
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);
35                 return NULL;
36 @@ -280,7 +277,7 @@ static int ext4_valid_block_bitmap(struc
37                 return 1;
38  
39  err_out:
40 -       ext4_error(sb, __func__,
41 +       ext4_error(sb,
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);
48         if (unlikely(!bh)) {
49 -               ext4_error(sb, __func__,
50 +               ext4_error(sb,
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) {
57                 put_bh(bh);
58 -               ext4_error(sb, __func__,
59 +               ext4_error(sb,
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__,
68 +               ext4_error(sb,
69                            "Adding blocks in system zones - "
70                            "Block = %llu, count = %lu",
71                            block, count);
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__,
77 +                       ext4_error(sb,
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);
87  
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";
105 +       else
106 +               return 1;
107  
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);
126 +       return 0;
127  }
128  
129  static int ext4_readdir(struct file *filp,
130 @@ -152,7 +153,7 @@ static int ext4_readdir(struct file *fil
131                  */
132                 if (!bh) {
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",
137                                            inode->i_ino,
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
142 @@ -23,6 +23,7 @@
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>
150 @@ -56,6 +57,12 @@
151  #define ext4_debug(f, a...)    do {} while (0)
152  #endif
153  
154 +#define EXT4_ERROR_INODE(inode, fmt, a...) \
155 +       ext4_error_inode(__func__, (inode), (fmt), ## a);
156 +
157 +#define EXT4_ERROR_FILE(file, fmt, a...)        \
158 +       ext4_error_file(__func__, (file), (fmt), ## a);
159 +
160  /* data type for block offset of block group */
161  typedef int ext4_grpblk_t;
162  
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 */
189  };
190  
191  #ifdef __KERNEL__
192 @@ -1110,6 +1137,9 @@ struct ext4_sb_info {
193  
194         /* workqueue for dio unwritten */
195         struct workqueue_struct *dio_unwritten_wq;
196 +
197 +       /* Lazy inode table initialization info */
198 +       struct ext4_li_request *s_li_request;
199  };
200  
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;
204  
205  /*
206 + * Timeout and state flag for lazy initialization inode thread.
207 + */
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
212 +
213 +/*
214 + * Lazy inode table initialization info
215 + */
216 +struct ext4_lazy_init {
217 +       unsigned long           li_state;
218 +       struct list_head        li_request_list;
219 +       struct mutex            li_list_mtx;
220 +};
221 +
222 +/*
223   * Function prototypes
224   */
225  
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);
228  
229  /* mballoc.c */
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 *,
237                                                 ext4_group_t, int);
238 +extern int ext4_trim_fs(struct super_block *, struct fstrim_range *);
239 +
240  /* inode.c */
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);
245  
246  /* super.c */
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. */
265  };
266  
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
270  
271  #define EXT4_MB_GRP_NEED_INIT(grp)     \
272         (test_bit(EXT4_GROUP_INFO_NEED_INIT_BIT, &((grp)->bb_state)))
273  
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)))
280 +
281  #define EXT4_MAX_CONTENTION            8
282  #define EXT4_CONTENTION_THRESHOLD      2
283  
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",
295                                            inode->i_ino,
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 *
300         return 0;
301  
302  corrupted:
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 *
309                 merge_done = 1;
310                 WARN_ON(eh->eh_entries == 0);
311                 if (!eh->eh_entries)
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);
315         }
316  
317 @@ -1784,7 +1784,11 @@ int ext4_ext_walk_space(struct inode *in
318                 }
319  
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);
324 +                       err = -EIO;
325 +                       break;
326 +               }
327                 ex = path[depth].p_ext;
328                 next = ext4_ext_next_allocated_block(path);
329  
330 @@ -1835,7 +1839,11 @@ int ext4_ext_walk_space(struct inode *in
331                         cbex.ec_type = EXT4_EXT_CACHE_EXTENT;
332                 }
333  
334 -               BUG_ON(cbex.ec_len == 0);
335 +               if (unlikely(cbex.ec_len == 0)) {
336 +                       EXT4_ERROR_INODE(inode, "cbex.ec_len == 0");
337 +                       err = -EIO;
338 +                       break;
339 +               }
340                 err = func(inode, path, &cbex, ex, cbdata);
341                 ext4_ext_drop_refs(path);
342  
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()
345          */
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);
351                 err = -EIO;
352 @@ -3415,7 +3423,7 @@ int ext4_ext_get_blocks(handle_t *handle
353  
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);
360                         err = -EIO;
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",
370                            block_group);
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);
376         if (unlikely(!bh)) {
377 -               ext4_error(sb, __func__,
378 +               ext4_error(sb,
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) {
385                 put_bh(bh);
386 -               ext4_error(sb, __func__,
387 +               ext4_error(sb,
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
392  
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);
398                 goto error_return;
399         }
400         block_group = (ino - 1) / EXT4_INODES_PER_GROUP(sb);
401 @@ -286,11 +285,10 @@ out:
402                         fatal = err;
403                 sb->s_dirt = 1;
404         } else
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);
408  
409  error_return:
410 -       brelse(bitmap_bh);
411 +       brelse(bitmap_bh); 
412         ext4_std_error(sb, fatal);
413  }
414  
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__,
420 +               ext4_error(sb,
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
425  
426         /* Error cases - e2fsck has already cleaned up for us */
427         if (ino > max_ino) {
428 -               ext4_warning(sb, __func__,
429 +               ext4_warning(sb,
430                              "bad orphan ino %lu!  e2fsck was run?", ino);
431                 goto error;
432         }
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);
436         if (!bitmap_bh) {
437 -               ext4_warning(sb, __func__,
438 +               ext4_warning(sb,
439                              "inode bitmap error for orphan %lu", ino);
440                 goto error;
441         }
442 @@ -1136,7 +1134,7 @@ iget_failed:
443         err = PTR_ERR(inode);
444         inode = NULL;
445  bad_orphan:
446 -       ext4_warning(sb, __func__,
447 +       ext4_warning(sb,
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
455         inode->i_size = 0;
456         err = ext4_mark_inode_dirty(handle, inode);
457         if (err) {
458 -               ext4_warning(inode->i_sb, __func__,
459 +               ext4_warning(inode->i_sb,
460                              "couldn't mark inode dirty (err %d)", err);
461                 goto stop_handle;
462         }
463 @@ -264,7 +264,7 @@ void ext4_delete_inode(struct inode *ino
464                 if (err > 0)
465                         err = ext4_journal_restart(handle, 3);
466                 if (err != 0) {
467 -                       ext4_warning(inode->i_sb, __func__,
468 +                       ext4_warning(inode->i_sb,
469                                      "couldn't extend journal (err %d)", err);
470                 stop_handle:
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);
474                 final = ptrs;
475         } else {
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);
481         }
482 @@ -396,7 +395,7 @@ static int __ext4_check_blockref(const c
483                 if (blk &&
484                     unlikely(!ext4_data_block_valid(EXT4_SB(inode->i_sb),
485                                                     blk, 1))) {
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);
490                         return -EIO;
491 @@ -1167,7 +1166,7 @@ static int check_block_validity(struct i
492                                 sector_t logical, sector_t phys, int len)
493  {
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);
503                 else
504 -                       ext4_error(inode->i_sb, __func__,
505 +                       ext4_error(inode->i_sb,
506                                    "circular indirect block detected, "
507                                    "inode=%lu, block=%llu",
508                                    inode->i_ino,
509 @@ -4364,7 +4363,7 @@ static void ext4_free_branches(handle_t 
510                          * (should be rare).
511                          */
512                         if (!bh) {
513 -                               ext4_error(inode->i_sb, "ext4_free_branches",
514 +                               ext4_error(inode->i_sb,
515                                            "Read failure, inode=%lu, block=%llu",
516                                            inode->i_ino, nr);
517                                 continue;
518 @@ -4680,9 +4679,8 @@ static int __ext4_get_inode_loc(struct i
519  
520         bh = sb_getblk(sb, block);
521         if (!bh) {
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);
527                 return -EIO;
528         }
529         if (!buffer_uptodate(bh)) {
530 @@ -4780,7 +4778,7 @@ make_io:
531                 submit_bh(READ_META, bh);
532                 wait_on_buffer(bh);
533                 if (!buffer_uptodate(bh)) {
534 -                       ext4_error(sb, __func__,
535 +                       ext4_error(sb,
536                                    "unable to read inode block - inode=%lu, "
537                                    "block=%llu", inode->i_ino, block);
538                         brelse(bh);
539 @@ -4999,7 +4997,7 @@ struct inode *ext4_iget(struct super_blo
540         ret = 0;
541         if (ei->i_file_acl &&
542             !ext4_data_block_valid(EXT4_SB(sb), ei->i_file_acl, 1)) {
543 -               ext4_error(sb, __func__,
544 +               ext4_error(sb,
545                            "bad extended attribute block %llu in inode #%lu",
546                            ei->i_file_acl, inode->i_ino);
547                 ret = -EIO;
548 @@ -5046,7 +5044,7 @@ struct inode *ext4_iget(struct super_blo
549                            new_decode_dev(le32_to_cpu(raw_inode->i_block[1])));
550         } else {
551                 ret = -EIO;
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);
556                 goto bad_inode;
557 @@ -5286,7 +5284,7 @@ int ext4_write_inode(struct inode *inode
558                 if (wait)
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",
565                                    inode->i_ino,
566 @@ -5707,7 +5705,7 @@ int ext4_mark_inode_dirty(handle_t *hand
567                                                      EXT4_STATE_NO_EXPAND);
568                                 if (mnt_count !=
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.",
574                                         inode->i_ino);
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
579  
580         err = 0;
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++) {
585                 int group;
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
589                          */
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);
595                         incore = NULL;
596 @@ -1862,7 +1862,6 @@ void ext4_mb_scan_aligned(struct ext4_al
597         }
598  }
599  
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)
603  {
604 @@ -2162,6 +2161,11 @@ static void *ext4_mb_seq_groups_next(str
605         return (void *) ((unsigned long) group);
606  }
607  
608 +static inline void ext4_mb_release_desc(struct ext4_buddy *e4b)
609 +{
610 +       ext4_mb_unload_buddy(e4b);
611 +}
612 +
613  static int ext4_mb_seq_groups_show(struct seq_file *seq, void *v)
614  {
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);
622  
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 *
626         return 0;
627  }
628  
629 +static inline int ext4_issue_discard(struct super_block *sb,
630 +               ext4_group_t block_group, ext4_grpblk_t block, int count)
631 +{
632 +       ext4_fsblk_t discard_block;
633 +
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);
638 +}
639 +
640  /*
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);
646  
647 -               if (test_opt(sb, DISCARD)) {
648 -                       int ret;
649 -                       ext4_fsblk_t discard_block;
650 -
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,
655 -                                       entry->count);
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);
661 -                       }
662 -               }
663 +               if (test_opt(sb, DISCARD))
664 +                       ext4_issue_discard(sb, entry->group,
665 +                                          entry->start_blk, entry->count);
666  
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);
672  
673 +               /*
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.
678 +                */
679 +               if (!test_opt(sb, DISCARD))
680 +                       EXT4_MB_GRP_CLEAR_TRIMMED(db);
681 +
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
686                 }
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);
691         }
692  
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_
695  
696         len = ac->ac_b_ex.fe_len;
697         if (!ext4_data_block_valid(sbi, block, len)) {
698 -               ext4_error(sb, __func__,
699 +               ext4_error(sb,
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
704  
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);
710                 return 0;
711         }
712  
713         err = ext4_mb_load_buddy(sb, group, &e4b);
714         if (err) {
715 -               ext4_error(sb, __func__, "Error in loading buddy "
716 +               ext4_error(sb, "Error in loading buddy "
717                                 "information for %u", group);
718                 put_bh(bitmap_bh);
719                 return 0;
720 @@ -3852,14 +3863,14 @@ repeat:
721  
722                 err = ext4_mb_load_buddy(sb, group, &e4b);
723                 if (err) {
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",
727 +                                       group);
728                         continue;
729                 }
730  
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);
737                         continue;
738 @@ -4125,7 +4136,7 @@ ext4_mb_discard_lg_preallocations(struct
739  
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);
745                         continue;
746                 }
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__,
752 +               ext4_error(sb,
753                             "Freeing blocks not in datazone - "
754                             "block = %llu, count = %lu", block, count);
755                 goto error_return;
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)) {
759  
760 -               ext4_error(sb, __func__,
761 +               ext4_error(sb,
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
769         int ret = 0;
770  
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);
776                 ret = -EIO;
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);
782                 ret = -EIO;
783 @@ -483,7 +483,7 @@ mext_leaf_block(handle_t *handle, struct
784  
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;
789  
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
793          * new_ext       |-------|
794          */
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, 
802         while (1) {
803                 /* The extent for donor must be found. */
804                 if (!dext) {
805 -                       ext4_error(donor_inode->i_sb, __func__,
806 +                       ext4_error(donor_inode->i_sb,
807                                    "The extent for donor must be found");
808                         *err = -EIO;
809                         goto out;
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",
815                                 donor_off,
816 @@ -1356,7 +1356,7 @@ ext4_move_extents(struct file *o_filp, s
817                         if (ret1 < 0)
818                                 break;
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",
824                                         *moved_len, len);
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);
836                 brelse(bh);
837                 *err = ERR_BAD_DX_DIR;
838 @@ -410,8 +409,7 @@ dx_probe(const struct qstr *d_name, stru
839         hash = hinfo->hash;
840  
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);
846                 brelse(bh);
847                 *err = ERR_BAD_DX_DIR;
848 @@ -419,8 +417,7 @@ dx_probe(const struct qstr *d_name, stru
849         }
850  
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);
856                 brelse(bh);
857                 *err = ERR_BAD_DX_DIR;
858 @@ -432,8 +429,7 @@ dx_probe(const struct qstr *d_name, stru
859  
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");
865                 brelse(bh);
866                 *err = ERR_BAD_DX_DIR;
867                 goto fail;
868 @@ -444,7 +440,7 @@ dx_probe(const struct qstr *d_name, stru
869         {
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");
875                         brelse(bh);
876                         *err = ERR_BAD_DX_DIR;
877 @@ -489,7 +485,7 @@ dx_probe(const struct qstr *d_name, stru
878                         goto fail2;
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");
884                         brelse(bh);
885                         *err = ERR_BAD_DX_DIR;
886 @@ -505,7 +501,7 @@ fail2:
887         }
888  fail:
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);
894         return NULL;
895 @@ -969,7 +965,7 @@ restart:
896                 wait_on_buffer(bh);
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);
903                         brelse(bh);
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)
907  {
908 -       struct super_block * sb = dir->i_sb;
909 +       struct super_block * sb;
910         struct dx_hash_info     hinfo;
911 +       u32 hash;
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;
918  
919 -       if (!(frame = dx_probe(d_name, dir, &hinfo, frames, err)))
920 -               return NULL;
921 +       sb = dir->i_sb;
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)))
925 +                       return NULL;
926 +       } else {
927 +               frame = frames;
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 */
931 +       }
932 +       hash = hinfo.hash;
933         do {
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
937                 }
938                 brelse(bh);
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,
942                                                frames, NULL);
943                 if (retval < 0) {
944 -                       ext4_warning(sb, __func__,
945 +                       ext4_warning(sb,
946                              "error reading index page in directory #%lu",
947                              dir->i_ino);
948                         *err = retval;
949 @@ -1082,14 +1089,13 @@ static struct dentry *ext4_lookup(struct
950                 __u32 ino = le32_to_cpu(de->inode);
951                 brelse(bh);
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);
957                 }
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",
964                                                 ino);
965                                 return ERR_PTR(-EIO);
966 @@ -1121,7 +1127,7 @@ struct dentry *ext4_get_parent(struct de
967         brelse(bh);
968  
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);
974         }
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",
982                            dir->i_ino);
983                 brelse(bh);
984 @@ -1468,10 +1474,22 @@ static int make_indexed_dir(handle_t *ha
985         frame->at = entries;
986         frame->bh = bh;
987         bh = bh2;
988 +
989 +       ext4_handle_dirty_metadata(handle, dir, frame->bh);
990 +       ext4_handle_dirty_metadata(handle, dir, bh);
991 +
992         de = do_split(handle,dir, &bh, frame, &hinfo, &retval);
993 -       dx_release (frames);
994 -       if (!(de))
995 +       if (!de) {
996 +               /*
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.
1000 +                */
1001 +               ext4_mark_inode_dirty(handle, dir);
1002 +               dx_release(frames);
1003                 return retval;
1004 +       }
1005 +       dx_release(frames);
1006  
1007         retval = add_dirent_to_buf(handle, dentry, inode, de, bh);
1008         brelse(bh);
1009 @@ -1588,8 +1606,7 @@ static int ext4_dx_add_entry(handle_t *h
1010  
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!");
1016                         err = -ENOSPC;
1017                         goto cleanup;
1018                 }
1019 @@ -1904,7 +1921,7 @@
1020         ext4_set_de_type(dir->i_sb, de, S_IFDIR);
1021         inode->i_nlink = 2;
1022         BUFFER_TRACE(dir_block, "call ext4_handle_dirty_metadata");
1023 -       ext4_handle_dirty_metadata(handle, dir, dir_block);
1024 +       ext4_handle_dirty_metadata(handle, inode, dir_block);
1025         brelse(dir_block);
1026         ext4_mark_inode_dirty(handle, inode);
1027         err = ext4_add_entry(handle, dentry, inode);
1028 @@ -1943,11 +1960,11 @@ static int empty_dir(struct inode *inode
1029         if (inode->i_size < EXT4_DIR_REC_LEN(1) + EXT4_DIR_REC_LEN(2) ||
1030             !(bh = ext4_bread(NULL, inode, 0, 0, &err))) {
1031                 if (err)
1032 -                       ext4_error(inode->i_sb, __func__,
1033 +                       ext4_error(inode->i_sb,
1034                                    "error %d reading directory #%lu offset 0",
1035                                    err, inode->i_ino);
1036                 else
1037 -                       ext4_warning(inode->i_sb, __func__,
1038 +                       ext4_warning(inode->i_sb,
1039                                      "bad directory (dir #%lu) - no data block",
1040                                      inode->i_ino);
1041                 return 1;
1042 @@ -1958,7 +1975,7 @@ static int empty_dir(struct inode *inode
1043                         !le32_to_cpu(de1->inode) ||
1044                         strcmp(".", de->name) ||
1045                         strcmp("..", de1->name)) {
1046 -               ext4_warning(inode->i_sb, "empty_dir",
1047 +               ext4_warning(inode->i_sb,
1048                              "bad directory (dir #%lu) - no `.' or `..'",
1049                              inode->i_ino);
1050                 brelse(bh);
1051 @@ -1976,7 +1993,7 @@ static int empty_dir(struct inode *inode
1052                                 offset >> EXT4_BLOCK_SIZE_BITS(sb), 0, &err);
1053                         if (!bh) {
1054                                 if (err)
1055 -                                       ext4_error(sb, __func__,
1056 +                                       ext4_error(sb,
1057                                                    "error %d reading directory"
1058                                                    " #%lu offset %u",
1059                                                    err, inode->i_ino, offset);
1060 @@ -2198,7 +2215,7 @@ static int ext4_rmdir(struct inode *dir,
1061         if (retval)
1062                 goto end_rmdir;
1063         if (!EXT4_DIR_LINK_EMPTY(inode))
1064 -               ext4_warning(inode->i_sb, "ext4_rmdir",
1065 +               ext4_warning(inode->i_sb,
1066                              "empty directory has too many links (%d)",
1067                              inode->i_nlink);
1068         inode->i_version++;
1069 @@ -2250,7 +2267,7 @@ static int ext4_unlink(struct inode *dir
1070                 goto end_unlink;
1071  
1072         if (!inode->i_nlink) {
1073 -               ext4_warning(inode->i_sb, "ext4_unlink",
1074 +               ext4_warning(inode->i_sb,
1075                              "Deleting nonexistent file (%lu), %d",
1076                              inode->i_ino, inode->i_nlink);
1077                 inode->i_nlink = 1;
1078 @@ -2497,7 +2514,7 @@ static int ext4_rename(struct inode *old
1079                 }
1080         }
1081         if (retval) {
1082 -               ext4_warning(old_dir->i_sb, "ext4_rename",
1083 +               ext4_warning(old_dir->i_sb,
1084                                 "Deleting old file (%lu), %d, error=%d",
1085                                 old_dir->i_ino, old_dir->i_nlink, retval);
1086         }
1087 diff -urpN linux-stage.orig/fs/ext4/resize.c linux-stage/fs/ext4/resize.c
1088 --- linux-stage.orig/fs/ext4/resize.c   2012-07-02 12:07:23.000000000 -0400
1089 +++ linux-stage/fs/ext4/resize.c        2012-07-02 12:07:57.000000000 -0400
1090 @@ -48,63 +48,63 @@ static int verify_group_input(struct sup
1091  
1092         ext4_get_group_no_and_offset(sb, start, NULL, &offset);
1093         if (group != sbi->s_groups_count)
1094 -               ext4_warning(sb, __func__,
1095 +               ext4_warning(sb,
1096                              "Cannot add at group %u (only %u groups)",
1097                              input->group, sbi->s_groups_count);
1098         else if (offset != 0)
1099 -                       ext4_warning(sb, __func__, "Last group not full");
1100 +                       ext4_warning(sb, "Last group not full");
1101         else if (input->reserved_blocks > input->blocks_count / 5)
1102 -               ext4_warning(sb, __func__, "Reserved blocks too high (%u)",
1103 +               ext4_warning(sb, "Reserved blocks too high (%u)",
1104                              input->reserved_blocks);
1105         else if (free_blocks_count < 0)
1106 -               ext4_warning(sb, __func__, "Bad blocks count %u",
1107 +               ext4_warning(sb, "Bad blocks count %u",
1108                              input->blocks_count);
1109         else if (!(bh = sb_bread(sb, end - 1)))
1110 -               ext4_warning(sb, __func__,
1111 +               ext4_warning(sb,
1112                              "Cannot read last block (%llu)",
1113                              end - 1);
1114         else if (outside(input->block_bitmap, start, end))
1115 -               ext4_warning(sb, __func__,
1116 +               ext4_warning(sb,
1117                              "Block bitmap not in group (block %llu)",
1118                              (unsigned long long)input->block_bitmap);
1119         else if (outside(input->inode_bitmap, start, end))
1120 -               ext4_warning(sb, __func__,
1121 +               ext4_warning(sb,
1122                              "Inode bitmap not in group (block %llu)",
1123                              (unsigned long long)input->inode_bitmap);
1124         else if (outside(input->inode_table, start, end) ||
1125                  outside(itend - 1, start, end))
1126 -               ext4_warning(sb, __func__,
1127 +               ext4_warning(sb,
1128                              "Inode table not in group (blocks %llu-%llu)",
1129                              (unsigned long long)input->inode_table, itend - 1);
1130         else if (input->inode_bitmap == input->block_bitmap)
1131 -               ext4_warning(sb, __func__,
1132 +               ext4_warning(sb,
1133                              "Block bitmap same as inode bitmap (%llu)",
1134                              (unsigned long long)input->block_bitmap);
1135         else if (inside(input->block_bitmap, input->inode_table, itend))
1136 -               ext4_warning(sb, __func__,
1137 +               ext4_warning(sb,
1138                              "Block bitmap (%llu) in inode table (%llu-%llu)",
1139                              (unsigned long long)input->block_bitmap,
1140                              (unsigned long long)input->inode_table, itend - 1);
1141         else if (inside(input->inode_bitmap, input->inode_table, itend))
1142 -               ext4_warning(sb, __func__,
1143 +               ext4_warning(sb,
1144                              "Inode bitmap (%llu) in inode table (%llu-%llu)",
1145                              (unsigned long long)input->inode_bitmap,
1146                              (unsigned long long)input->inode_table, itend - 1);
1147         else if (inside(input->block_bitmap, start, metaend))
1148 -               ext4_warning(sb, __func__,
1149 +               ext4_warning(sb,
1150                              "Block bitmap (%llu) in GDT table"
1151                              " (%llu-%llu)",
1152                              (unsigned long long)input->block_bitmap,
1153                              start, metaend - 1);
1154         else if (inside(input->inode_bitmap, start, metaend))
1155 -               ext4_warning(sb, __func__,
1156 +               ext4_warning(sb,
1157                              "Inode bitmap (%llu) in GDT table"
1158                              " (%llu-%llu)",
1159                              (unsigned long long)input->inode_bitmap,
1160                              start, metaend - 1);
1161         else if (inside(input->inode_table, start, metaend) ||
1162                  inside(itend - 1, start, metaend))
1163 -               ext4_warning(sb, __func__,
1164 +               ext4_warning(sb,
1165                              "Inode table (%llu-%llu) overlaps"
1166                              "GDT table (%llu-%llu)",
1167                              (unsigned long long)input->inode_table,
1168 @@ -364,7 +364,7 @@ static int verify_reserved_gdb(struct su
1169         while ((grp = ext4_list_backups(sb, &three, &five, &seven)) < end) {
1170                 if (le32_to_cpu(*p++) !=
1171                     grp * EXT4_BLOCKS_PER_GROUP(sb) + blk){
1172 -                       ext4_warning(sb, __func__,
1173 +                       ext4_warning(sb,
1174                                      "reserved GDT %llu"
1175                                      " missing grp %d (%llu)",
1176                                      blk, grp,
1177 @@ -420,7 +420,7 @@ static int add_new_gdb(handle_t *handle,
1178           */
1179         if (EXT4_SB(sb)->s_sbh->b_blocknr !=
1180             le32_to_cpu(EXT4_SB(sb)->s_es->s_first_data_block)) {
1181 -               ext4_warning(sb, __func__,
1182 +               ext4_warning(sb,
1183                         "won't resize using backup superblock at %llu",
1184                         (unsigned long long)EXT4_SB(sb)->s_sbh->b_blocknr);
1185                 return -EPERM;
1186 @@ -444,7 +444,7 @@ static int add_new_gdb(handle_t *handle,
1187  
1188         data = (__le32 *)dind->b_data;
1189         if (le32_to_cpu(data[gdb_num % EXT4_ADDR_PER_BLOCK(sb)]) != gdblock) {
1190 -               ext4_warning(sb, __func__,
1191 +               ext4_warning(sb,
1192                              "new group %u GDT block %llu not reserved",
1193                              input->group, gdblock);
1194                 err = -EINVAL;
1195 @@ -468,7 +468,7 @@ static int add_new_gdb(handle_t *handle,
1196                         GFP_NOFS);
1197         if (!n_group_desc) {
1198                 err = -ENOMEM;
1199 -               ext4_warning(sb, __func__,
1200 +               ext4_warning(sb,
1201                               "not enough memory for %lu groups", gdb_num + 1);
1202                 goto exit_inode;
1203         }
1204 @@ -567,7 +567,7 @@ static int reserve_backup_gdb(handle_t *
1205         /* Get each reserved primary GDT block and verify it holds backups */
1206         for (res = 0; res < reserved_gdb; res++, blk++) {
1207                 if (le32_to_cpu(*data) != blk) {
1208 -                       ext4_warning(sb, __func__,
1209 +                       ext4_warning(sb,
1210                                      "reserved block %llu"
1211                                      " not at offset %ld",
1212                                      blk,
1213 @@ -713,7 +713,7 @@ static void update_backups(struct super_
1214          */
1215  exit_err:
1216         if (err) {
1217 -               ext4_warning(sb, __func__,
1218 +               ext4_warning(sb,
1219                              "can't update backup for group %u (err %d), "
1220                              "forcing fsck on next reboot", group, err);
1221                 sbi->s_mount_state &= ~EXT4_VALID_FS;
1222 @@ -753,20 +753,20 @@ int ext4_group_add(struct super_block *s
1223  
1224         if (gdb_off == 0 && !EXT4_HAS_RO_COMPAT_FEATURE(sb,
1225                                         EXT4_FEATURE_RO_COMPAT_SPARSE_SUPER)) {
1226 -               ext4_warning(sb, __func__,
1227 +               ext4_warning(sb,
1228                              "Can't resize non-sparse filesystem further");
1229                 return -EPERM;
1230         }
1231  
1232         if (ext4_blocks_count(es) + input->blocks_count <
1233             ext4_blocks_count(es)) {
1234 -               ext4_warning(sb, __func__, "blocks_count overflow");
1235 +               ext4_warning(sb, "blocks_count overflow");
1236                 return -EINVAL;
1237         }
1238  
1239         if (le32_to_cpu(es->s_inodes_count) + EXT4_INODES_PER_GROUP(sb) <
1240             le32_to_cpu(es->s_inodes_count)) {
1241 -               ext4_warning(sb, __func__, "inodes_count overflow");
1242 +               ext4_warning(sb, "inodes_count overflow");
1243                 return -EINVAL;
1244         }
1245  
1246 @@ -774,13 +774,13 @@ int ext4_group_add(struct super_block *s
1247                 if (!EXT4_HAS_COMPAT_FEATURE(sb,
1248                                              EXT4_FEATURE_COMPAT_RESIZE_INODE)
1249                     || !le16_to_cpu(es->s_reserved_gdt_blocks)) {
1250 -                       ext4_warning(sb, __func__,
1251 +                       ext4_warning(sb,
1252                                      "No reserved GDT blocks, can't resize");
1253                         return -EPERM;
1254                 }
1255                 inode = ext4_iget(sb, EXT4_RESIZE_INO);
1256                 if (IS_ERR(inode)) {
1257 -                       ext4_warning(sb, __func__,
1258 +                       ext4_warning(sb,
1259                                      "Error opening resize inode");
1260                         return PTR_ERR(inode);
1261                 }
1262 @@ -810,7 +810,7 @@ int ext4_group_add(struct super_block *s
1263  
1264         mutex_lock(&sbi->s_resize_lock);
1265         if (input->group != sbi->s_groups_count) {
1266 -               ext4_warning(sb, __func__,
1267 +               ext4_warning(sb,
1268                              "multiple resizers run on filesystem!");
1269                 err = -EBUSY;
1270                 goto exit_journal;
1271 @@ -998,12 +998,12 @@ int ext4_group_extend(struct super_block
1272                         " too large to resize to %llu blocks safely\n",
1273                         sb->s_id, n_blocks_count);
1274                 if (sizeof(sector_t) < 8)
1275 -                       ext4_warning(sb, __func__, "CONFIG_LBDAF not enabled");
1276 +                       ext4_warning(sb, "CONFIG_LBDAF not enabled");
1277                 return -EINVAL;
1278         }
1279  
1280         if (n_blocks_count < o_blocks_count) {
1281 -               ext4_warning(sb, __func__,
1282 +               ext4_warning(sb,
1283                              "can't shrink FS - resize aborted");
1284                 return -EBUSY;
1285         }
1286 @@ -1012,7 +1012,7 @@ int ext4_group_extend(struct super_block
1287         ext4_get_group_no_and_offset(sb, o_blocks_count, &group, &last);
1288  
1289         if (last == 0) {
1290 -               ext4_warning(sb, __func__,
1291 +               ext4_warning(sb,
1292                              "need to use ext2online to resize further");
1293                 return -EPERM;
1294         }
1295 @@ -1020,7 +1020,7 @@ int ext4_group_extend(struct super_block
1296         add = EXT4_BLOCKS_PER_GROUP(sb) - last;
1297  
1298         if (o_blocks_count + add < o_blocks_count) {
1299 -               ext4_warning(sb, __func__, "blocks_count overflow");
1300 +               ext4_warning(sb, "blocks_count overflow");
1301                 return -EINVAL;
1302         }
1303  
1304 @@ -1028,7 +1028,7 @@ int ext4_group_extend(struct super_block
1305                 add = n_blocks_count - o_blocks_count;
1306  
1307         if (o_blocks_count + add < n_blocks_count)
1308 -               ext4_warning(sb, __func__,
1309 +               ext4_warning(sb,
1310                              "will only finish group (%llu"
1311                              " blocks, %u new)",
1312                              o_blocks_count + add, add);
1313 @@ -1036,7 +1036,7 @@ int ext4_group_extend(struct super_block
1314         /* See if the device is actually as big as what was requested */
1315         bh = sb_bread(sb, o_blocks_count + add - 1);
1316         if (!bh) {
1317 -               ext4_warning(sb, __func__,
1318 +               ext4_warning(sb,
1319                              "can't read last block, resize aborted");
1320                 return -ENOSPC;
1321         }
1322 @@ -1048,13 +1048,13 @@ int ext4_group_extend(struct super_block
1323         handle = ext4_journal_start_sb(sb, 3);
1324         if (IS_ERR(handle)) {
1325                 err = PTR_ERR(handle);
1326 -               ext4_warning(sb, __func__, "error %d on journal start", err);
1327 +               ext4_warning(sb, "error %d on journal start", err);
1328                 goto exit_put;
1329         }
1330  
1331         mutex_lock(&EXT4_SB(sb)->s_resize_lock);
1332         if (o_blocks_count != ext4_blocks_count(es)) {
1333 -               ext4_warning(sb, __func__,
1334 +               ext4_warning(sb,
1335                              "multiple resizers run on filesystem!");
1336                 mutex_unlock(&EXT4_SB(sb)->s_resize_lock);
1337                 ext4_journal_stop(handle);
1338 @@ -1064,7 +1064,7 @@ int ext4_group_extend(struct super_block
1339  
1340         if ((err = ext4_journal_get_write_access(handle,
1341                                                  EXT4_SB(sb)->s_sbh))) {
1342 -               ext4_warning(sb, __func__,
1343 +               ext4_warning(sb,
1344                              "error %d on journal write access", err);
1345                 mutex_unlock(&EXT4_SB(sb)->s_resize_lock);
1346                 ext4_journal_stop(handle);
1347 diff -urpN linux-stage.orig/fs/ext4/super.c linux-stage/fs/ext4/super.c
1348 --- linux-stage.orig/fs/ext4/super.c    2012-07-02 12:07:23.000000000 -0400
1349 +++ linux-stage/fs/ext4/super.c 2012-07-02 12:07:57.000000000 -0400
1350 @@ -48,11 +48,16 @@
1351  #include "acl.h"
1352  #include "mballoc.h"
1353  
1354 +#define QFMT_OCFS2 3
1355 +#define QFMT_VFS_V1 4
1356 +
1357  #define CREATE_TRACE_POINTS
1358  #include <trace/events/ext4.h>
1359  
1360  struct proc_dir_entry *ext4_proc_root;
1361  static struct kset *ext4_kset;
1362 +static struct ext4_lazy_init *ext4_li_info;
1363 +static struct mutex ext4_li_mtx;
1364  
1365  static int ext4_load_journal(struct super_block *, struct ext4_super_block *,
1366                              unsigned long journal_devnum);
1367 @@ -337,7 +342,7 @@ static void ext4_handle_error(struct sup
1368                         sb->s_id);
1369  }
1370  
1371 -void ext4_error(struct super_block *sb, const char *function,
1372 +void __ext4_error(struct super_block *sb, const char *function,
1373                 const char *fmt, ...)
1374  {
1375         va_list args;
1376 @@ -351,6 +356,42 @@ void ext4_error(struct super_block *sb, 
1377         ext4_handle_error(sb);
1378  }
1379  
1380 +void ext4_error_inode(const char *function, struct inode *inode,
1381 +                      const char *fmt, ...)
1382 +{
1383 +       va_list args;
1384 +
1385 +       va_start(args, fmt);
1386 +       printk(KERN_CRIT "EXT4-fs error (device %s): %s: inode #%lu: (comm %s) ",
1387 +              inode->i_sb->s_id, function, inode->i_ino, current->comm);
1388 +       vprintk(fmt, args);
1389 +       printk("\n");
1390 +       va_end(args);
1391 +
1392 +       ext4_handle_error(inode->i_sb);
1393 +}
1394 +
1395 +void ext4_error_file(const char *function, struct file *file,
1396 +                     const char *fmt, ...)
1397 +{
1398 +       va_list args;
1399 +       struct inode *inode = file->f_dentry->d_inode;
1400 +       char pathname[80], *path;
1401 +
1402 +       va_start(args, fmt);
1403 +       path = d_path(&(file->f_path), pathname, sizeof(pathname));
1404 +       if (!path)
1405 +               path = "(unknown)";
1406 +       printk(KERN_CRIT
1407 +              "EXT4-fs error (device %s): %s: inode #%lu (comm %s path %s): ",
1408 +              inode->i_sb->s_id, function, inode->i_ino, current->comm, path);
1409 +       vprintk(fmt, args);
1410 +       printk("\n");
1411 +       va_end(args);
1412 +
1413 +       ext4_handle_error(inode->i_sb);
1414 +}
1415 +
1416  static const char *ext4_decode_error(struct super_block *sb, int errno,
1417                                      char nbuf[16])
1418  {
1419 @@ -454,7 +495,7 @@ void ext4_msg (struct super_block * sb, 
1420         va_end(args);
1421  }
1422  
1423 -void ext4_warning(struct super_block *sb, const char *function,
1424 +void __ext4_warning(struct super_block *sb, const char *function,
1425                   const char *fmt, ...)
1426  {
1427         va_list args;
1428 @@ -511,7 +552,7 @@ void ext4_update_dynamic_rev(struct supe
1429         if (le32_to_cpu(es->s_rev_level) > EXT4_GOOD_OLD_REV)
1430                 return;
1431  
1432 -       ext4_warning(sb, __func__,
1433 +       ext4_warning(sb,
1434                      "updating to rev %d because of new feature flag, "
1435                      "running e2fsck is recommended",
1436                      EXT4_DYNAMIC_REV);
1437 @@ -777,9 +818,22 @@ static inline void ext4_show_quota_optio
1438  #if defined(CONFIG_QUOTA)
1439         struct ext4_sb_info *sbi = EXT4_SB(sb);
1440  
1441 -       if (sbi->s_jquota_fmt)
1442 -               seq_printf(seq, ",jqfmt=%s",
1443 -               (sbi->s_jquota_fmt == QFMT_VFS_OLD) ? "vfsold" : "vfsv0");
1444 +       if (sbi->s_jquota_fmt) {
1445 +               char *fmtname = "";
1446 +
1447 +               switch (sbi->s_jquota_fmt) {
1448 +               case QFMT_VFS_OLD:
1449 +                       fmtname = "vfsold";
1450 +                       break;
1451 +               case QFMT_VFS_V0:
1452 +                       fmtname = "vfsv0";
1453 +                       break;
1454 +               case QFMT_VFS_V1:
1455 +                       fmtname = "vfsv1";
1456 +                       break;
1457 +               }
1458 +               seq_printf(seq, ",jqfmt=%s", fmtname);
1459 +       }
1460  
1461         if (sbi->s_qf_names[USRQUOTA])
1462                 seq_printf(seq, ",usrjquota=%s", sbi->s_qf_names[USRQUOTA]);
1463 @@ -1096,13 +1150,14 @@ enum {
1464         Opt_abort, Opt_data_journal, Opt_data_ordered, Opt_data_writeback,
1465         Opt_data_err_abort, Opt_data_err_ignore,
1466         Opt_usrjquota, Opt_grpjquota, Opt_offusrjquota, Opt_offgrpjquota,
1467 -       Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_quota, Opt_noquota,
1468 -       Opt_ignore, Opt_barrier, Opt_nobarrier, Opt_err, Opt_resize,
1469 -       Opt_usrquota, Opt_grpquota, Opt_i_version,
1470 +       Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_jqfmt_vfsv1, Opt_quota,
1471 +       Opt_noquota, Opt_ignore, Opt_barrier, Opt_nobarrier, Opt_err,
1472 +       Opt_resize, Opt_usrquota, Opt_grpquota, Opt_i_version,
1473         Opt_stripe, Opt_delalloc, Opt_nodelalloc,
1474         Opt_block_validity, Opt_noblock_validity,
1475         Opt_inode_readahead_blks, Opt_journal_ioprio,
1476         Opt_discard, Opt_nodiscard,
1477 +       Opt_init_inode_table, Opt_noinit_inode_table,
1478  };
1479  
1480  static const match_table_t tokens = {
1481 @@ -2709,6 +2764,21 @@ static int ext4_fill_super(struct super_
1482         get_random_bytes(&sbi->s_next_generation, sizeof(u32));
1483         spin_lock_init(&sbi->s_next_gen_lock);
1484  
1485 +       err = percpu_counter_init(&sbi->s_freeblocks_counter,
1486 +                                 ext4_count_free_blocks(sb));
1487 +       if (!err)
1488 +               err = percpu_counter_init(&sbi->s_freeinodes_counter,
1489 +                                         ext4_count_free_inodes(sb));
1490 +       if (!err)
1491 +               err = percpu_counter_init(&sbi->s_dirs_counter,
1492 +                                         ext4_count_dirs(sb));
1493 +       if (!err)
1494 +               err = percpu_counter_init(&sbi->s_dirtyblocks_counter, 0);
1495 +       if (err) {
1496 +               ext4_msg(sb, KERN_ERR, "insufficient memory");
1497 +               goto failed_mount3;
1498 +       }
1499 +
1500         sbi->s_stripe = ext4_get_stripe_size(sbi);
1501         sbi->s_max_writeback_mb_bump = 128;
1502  
1503 @@ -2828,20 +2898,6 @@ static int ext4_fill_super(struct super_
1504         set_task_ioprio(sbi->s_journal->j_task, journal_ioprio);
1505  
1506  no_journal:
1507 -       err = percpu_counter_init(&sbi->s_freeblocks_counter,
1508 -                                 ext4_count_free_blocks(sb));
1509 -       if (!err)
1510 -               err = percpu_counter_init(&sbi->s_freeinodes_counter,
1511 -                                         ext4_count_free_inodes(sb));
1512 -       if (!err)
1513 -               err = percpu_counter_init(&sbi->s_dirs_counter,
1514 -                                         ext4_count_dirs(sb));
1515 -       if (!err)
1516 -               err = percpu_counter_init(&sbi->s_dirtyblocks_counter, 0);
1517 -       if (err) {
1518 -               ext4_msg(sb, KERN_ERR, "insufficient memory");
1519 -               goto failed_mount_wq;
1520 -       }
1521         if (test_opt(sb, NOBH)) {
1522                 if (!(test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_WRITEBACK_DATA)) {
1523                         ext4_msg(sb, KERN_WARNING, "Ignoring nobh option - "
1524 @@ -2955,7 +3011,9 @@ no_journal:
1525         } else
1526                 descr = "out journal";
1527  
1528 -       ext4_msg(sb, KERN_INFO, "mounted filesystem with%s", descr);
1529 +       ext4_msg(sb, KERN_INFO, "mounted filesystem with%s. "
1530 +                "Opts: %s%s", descr, sbi->s_es->s_mount_opts,
1531 +                *sbi->s_es->s_mount_opts ? "; " : "");
1532  
1533         lock_kernel();
1534         return 0;
1535 @@ -2974,10 +3032,6 @@ failed_mount_wq:
1536                 jbd2_journal_destroy(sbi->s_journal);
1537                 sbi->s_journal = NULL;
1538         }
1539 -       percpu_counter_destroy(&sbi->s_freeblocks_counter);
1540 -       percpu_counter_destroy(&sbi->s_freeinodes_counter);
1541 -       percpu_counter_destroy(&sbi->s_dirs_counter);
1542 -       percpu_counter_destroy(&sbi->s_dirtyblocks_counter);
1543  failed_mount3:
1544         if (sbi->s_flex_groups) {
1545                 if (is_vmalloc_addr(sbi->s_flex_groups))
1546 @@ -2985,6 +3039,10 @@ failed_mount3:
1547                 else
1548                         kfree(sbi->s_flex_groups);
1549         }
1550 +       percpu_counter_destroy(&sbi->s_freeblocks_counter);
1551 +       percpu_counter_destroy(&sbi->s_freeinodes_counter);
1552 +       percpu_counter_destroy(&sbi->s_dirs_counter);
1553 +       percpu_counter_destroy(&sbi->s_dirtyblocks_counter);
1554  failed_mount2:
1555         for (i = 0; i < db_count; i++)
1556                 brelse(sbi->s_group_desc[i]);
1557 @@ -3377,9 +3435,9 @@ static void ext4_clear_journal_err(struc
1558                 char nbuf[16];
1559  
1560                 errstr = ext4_decode_error(sb, j_errno, nbuf);
1561 -               ext4_warning(sb, __func__, "Filesystem error recorded "
1562 +               ext4_warning(sb, "Filesystem error recorded "
1563                              "from previous mount: %s", errstr);
1564 -               ext4_warning(sb, __func__, "Marking fs in need of "
1565 +               ext4_warning(sb, "Marking fs in need of "
1566                              "filesystem check.");
1567  
1568                 EXT4_SB(sb)->s_mount_state |= EXT4_ERROR_FS;
1569 @@ -4007,11 +4065,21 @@ static struct file_system_type ext4_fs_t
1570         .fs_flags       = FS_REQUIRES_DEV,
1571  };
1572  
1573 +static int __init ext4_init_feat_adverts(void)
1574 +{
1575 +       return 0;
1576 +}
1577 +
1578 +static void ext4_exit_feat_adverts(void)
1579 +{
1580 +}
1581 +
1582  static int __init init_ext4_fs(void)
1583  {
1584         int err;
1585  
1586         ext4_check_flag_values();
1587 +
1588         err = init_ext4_system_zone();
1589         if (err)
1590                 return err;
1591 @@ -4019,6 +4087,9 @@ static int __init init_ext4_fs(void)
1592         if (!ext4_kset)
1593                 goto out4;
1594         ext4_proc_root = proc_mkdir("fs/ext4", NULL);
1595 +
1596 +       err = ext4_init_feat_adverts();
1597 +
1598         err = init_ext4_mballoc();
1599         if (err)
1600                 goto out3;
1601 @@ -4032,6 +4103,9 @@ static int __init init_ext4_fs(void)
1602         err = register_filesystem(&ext4_fs_type);
1603         if (err)
1604                 goto out;
1605 +
1606 +       ext4_li_info = NULL;
1607 +       mutex_init(&ext4_li_mtx);
1608         return 0;
1609  out:
1610         destroy_inodecache();
1611 @@ -4040,6 +4114,7 @@ out1:
1612  out2:
1613         exit_ext4_mballoc();
1614  out3:
1615 +       ext4_exit_feat_adverts();
1616         remove_proc_entry("fs/ext4", NULL);
1617         kset_unregister(ext4_kset);
1618  out4:
1619 @@ -4053,6 +4128,7 @@ static void __exit exit_ext4_fs(void)
1620         destroy_inodecache();
1621         exit_ext4_xattr();
1622         exit_ext4_mballoc();
1623 +       ext4_exit_feat_adverts();
1624         remove_proc_entry("fs/ext4", NULL);
1625         kset_unregister(ext4_kset);
1626         exit_ext4_system_zone();
1627 diff -urpN linux-stage.orig/fs/ext4/xattr.c linux-stage/fs/ext4/xattr.c
1628 --- linux-stage.orig/fs/ext4/xattr.c    2012-07-02 12:07:23.000000000 -0400
1629 +++ linux-stage/fs/ext4/xattr.c 2012-07-02 12:07:57.000000000 -0400
1630 @@ -227,7 +227,7 @@ ext4_xattr_block_get(struct inode *inode
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 -bad_block:     ext4_error(inode->i_sb, __func__,
1635 +bad_block:     ext4_error(inode->i_sb,
1636                            "inode %lu: bad block %llu", inode->i_ino,
1637                            EXT4_I(inode)->i_file_acl);
1638                 error = -EIO;
1639 @@ -369,7 +369,7 @@ ext4_xattr_block_list(struct inode *inod
1640         ea_bdebug(bh, "b_count=%d, refcount=%d",
1641                 atomic_read(&(bh->b_count)), le32_to_cpu(BHDR(bh)->h_refcount));
1642         if (ext4_xattr_check_block(bh)) {
1643 -               ext4_error(inode->i_sb, __func__,
1644 +               ext4_error(inode->i_sb,
1645                            "inode %lu: bad block %llu", inode->i_ino,
1646                            EXT4_I(inode)->i_file_acl);
1647                 error = -EIO;
1648 @@ -661,7 +661,7 @@ ext4_xattr_block_find(struct inode *inod
1649                         atomic_read(&(bs->bh->b_count)),
1650                         le32_to_cpu(BHDR(bs->bh)->h_refcount));
1651                 if (ext4_xattr_check_block(bs->bh)) {
1652 -                       ext4_error(sb, __func__,
1653 +                       ext4_error(sb,
1654                                 "inode %lu: bad block %llu", inode->i_ino,
1655                                 EXT4_I(inode)->i_file_acl);
1656                         error = -EIO;
1657 @@ -875,7 +875,7 @@ cleanup_dquot:
1658         goto cleanup;
1659  
1660  bad_block:
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);
1665         goto cleanup;
1666 @@ -1190,7 +1190,7 @@ retry:
1667                 if (!bh)
1668                         goto cleanup;
1669                 if (ext4_xattr_check_block(bh)) {
1670 -                       ext4_error(inode->i_sb, __func__,
1671 +                       ext4_error(inode->i_sb,
1672                                 "inode %lu: bad block %llu", inode->i_ino,
1673                                 EXT4_I(inode)->i_file_acl);
1674                         error = -EIO;
1675 @@ -1367,14 +1367,14 @@ ext4_xattr_delete_inode(handle_t *handle
1676                 goto cleanup;
1677         bh = sb_bread(inode->i_sb, EXT4_I(inode)->i_file_acl);
1678         if (!bh) {
1679 -               ext4_error(inode->i_sb, __func__,
1680 +               ext4_error(inode->i_sb,
1681                         "inode %lu: block %llu read error", inode->i_ino,
1682                         EXT4_I(inode)->i_file_acl);
1683                 goto cleanup;
1684         }
1685         if (BHDR(bh)->h_magic != cpu_to_le32(EXT4_XATTR_MAGIC) ||
1686             BHDR(bh)->h_blocks != cpu_to_le32(1)) {
1687 -               ext4_error(inode->i_sb, __func__,
1688 +               ext4_error(inode->i_sb,
1689                         "inode %lu: bad block %llu", inode->i_ino,
1690                         EXT4_I(inode)->i_file_acl);
1691                 goto cleanup;
1692 @@ -1501,7 +1501,7 @@ again:
1693                 }
1694                 bh = sb_bread(inode->i_sb, ce->e_block);
1695                 if (!bh) {
1696 -                       ext4_error(inode->i_sb, __func__,
1697 +                       ext4_error(inode->i_sb,
1698                                 "inode %lu: block %lu read error",
1699                                 inode->i_ino, (unsigned long) ce->e_block);
1700                 } else if (le32_to_cpu(BHDR(bh)->h_refcount) >=