aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2013-02-08 21:59:22 -0500
committerTheodore Ts'o <tytso@mit.edu>2013-02-08 21:59:22 -0500
commit9924a92a8c217576bd2a2b1bbbb854462f1a00ae (patch)
tree5c4eaee350e38cd2854fd6029da9f2a822ee184e
parent722887ddc8982ff40e40b650fbca9ae1e56259bc (diff)
ext4: pass context information to jbd2__journal_start()
So we can better understand what bits of ext4 are responsible for long-running jbd2 handles, use jbd2__journal_start() so we can pass context information for logging purposes. The recommended way for finding the longer-running handles is: T=/sys/kernel/debug/tracing EVENT=$T/events/jbd2/jbd2_handle_stats echo "interval > 5" > $EVENT/filter echo 1 > $EVENT/enable ./run-my-fs-benchmark cat $T/trace > /tmp/problem-handles This will list handles that were active for longer than 20ms. Having longer-running handles is bad, because a commit started at the wrong time could stall for those 20+ milliseconds, which could delay an fsync() or an O_SYNC operation. Here is an example line from the trace file describing a handle which lived on for 311 jiffies, or over 1.2 seconds: postmark-2917 [000] .... 196.435786: jbd2_handle_stats: dev 254,32 tid 570 type 2 line_no 2541 interval 311 sync 0 requested_blocks 1 dirtied_blocks 0 Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
-rw-r--r--fs/ext4/acl.c5
-rw-r--r--fs/ext4/ext4_jbd2.c5
-rw-r--r--fs/ext4/ext4_jbd2.h31
-rw-r--r--fs/ext4/extents.c11
-rw-r--r--fs/ext4/file.c2
-rw-r--r--fs/ext4/ialloc.c2
-rw-r--r--fs/ext4/indirect.c7
-rw-r--r--fs/ext4/inline.c10
-rw-r--r--fs/ext4/inode.c33
-rw-r--r--fs/ext4/ioctl.c4
-rw-r--r--fs/ext4/migrate.c4
-rw-r--r--fs/ext4/move_extent.c2
-rw-r--r--fs/ext4/namei.c42
-rw-r--r--fs/ext4/resize.c10
-rw-r--r--fs/ext4/super.c10
-rw-r--r--fs/ext4/xattr.c2
16 files changed, 111 insertions, 69 deletions
diff --git a/fs/ext4/acl.c b/fs/ext4/acl.c
index e6e0d988439b..406cf8bb12d5 100644
--- a/fs/ext4/acl.c
+++ b/fs/ext4/acl.c
@@ -324,7 +324,7 @@ ext4_acl_chmod(struct inode *inode)
324 if (error) 324 if (error)
325 return error; 325 return error;
326retry: 326retry:
327 handle = ext4_journal_start(inode, 327 handle = ext4_journal_start(inode, EXT4_HT_XATTR,
328 EXT4_DATA_TRANS_BLOCKS(inode->i_sb)); 328 EXT4_DATA_TRANS_BLOCKS(inode->i_sb));
329 if (IS_ERR(handle)) { 329 if (IS_ERR(handle)) {
330 error = PTR_ERR(handle); 330 error = PTR_ERR(handle);
@@ -422,7 +422,8 @@ ext4_xattr_set_acl(struct dentry *dentry, const char *name, const void *value,
422 acl = NULL; 422 acl = NULL;
423 423
424retry: 424retry:
425 handle = ext4_journal_start(inode, EXT4_DATA_TRANS_BLOCKS(inode->i_sb)); 425 handle = ext4_journal_start(inode, EXT4_HT_XATTR,
426 EXT4_DATA_TRANS_BLOCKS(inode->i_sb));
426 if (IS_ERR(handle)) { 427 if (IS_ERR(handle)) {
427 error = PTR_ERR(handle); 428 error = PTR_ERR(handle);
428 goto release_and_out; 429 goto release_and_out;
diff --git a/fs/ext4/ext4_jbd2.c b/fs/ext4/ext4_jbd2.c
index 6f6114525535..7058975e3a55 100644
--- a/fs/ext4/ext4_jbd2.c
+++ b/fs/ext4/ext4_jbd2.c
@@ -38,7 +38,8 @@ static void ext4_put_nojournal(handle_t *handle)
38/* 38/*
39 * Wrappers for jbd2_journal_start/end. 39 * Wrappers for jbd2_journal_start/end.
40 */ 40 */
41handle_t *ext4_journal_start_sb(struct super_block *sb, int nblocks) 41handle_t *__ext4_journal_start_sb(struct super_block *sb, unsigned int line,
42 int type, int nblocks)
42{ 43{
43 journal_t *journal; 44 journal_t *journal;
44 45
@@ -59,7 +60,7 @@ handle_t *ext4_journal_start_sb(struct super_block *sb, int nblocks)
59 ext4_abort(sb, "Detected aborted journal"); 60 ext4_abort(sb, "Detected aborted journal");
60 return ERR_PTR(-EROFS); 61 return ERR_PTR(-EROFS);
61 } 62 }
62 return jbd2_journal_start(journal, nblocks); 63 return jbd2__journal_start(journal, nblocks, GFP_NOFS, type, line);
63} 64}
64 65
65int __ext4_journal_stop(const char *where, unsigned int line, handle_t *handle) 66int __ext4_journal_stop(const char *where, unsigned int line, handle_t *handle)
diff --git a/fs/ext4/ext4_jbd2.h b/fs/ext4/ext4_jbd2.h
index 7177f9b21cb2..302814b85945 100644
--- a/fs/ext4/ext4_jbd2.h
+++ b/fs/ext4/ext4_jbd2.h
@@ -110,6 +110,22 @@
110#define EXT4_MAXQUOTAS_INIT_BLOCKS(sb) (MAXQUOTAS*EXT4_QUOTA_INIT_BLOCKS(sb)) 110#define EXT4_MAXQUOTAS_INIT_BLOCKS(sb) (MAXQUOTAS*EXT4_QUOTA_INIT_BLOCKS(sb))
111#define EXT4_MAXQUOTAS_DEL_BLOCKS(sb) (MAXQUOTAS*EXT4_QUOTA_DEL_BLOCKS(sb)) 111#define EXT4_MAXQUOTAS_DEL_BLOCKS(sb) (MAXQUOTAS*EXT4_QUOTA_DEL_BLOCKS(sb))
112 112
113/*
114 * Ext4 handle operation types -- for logging purposes
115 */
116#define EXT4_HT_MISC 0
117#define EXT4_HT_INODE 1
118#define EXT4_HT_WRITE_PAGE 2
119#define EXT4_HT_MAP_BLOCKS 3
120#define EXT4_HT_DIR 4
121#define EXT4_HT_TRUNCATE 5
122#define EXT4_HT_QUOTA 6
123#define EXT4_HT_RESIZE 7
124#define EXT4_HT_MIGRATE 8
125#define EXT4_HT_MOVE_EXTENTS 9
126#define EXT4_HT_XATTR 10
127#define EXT4_HT_MAX 11
128
113/** 129/**
114 * struct ext4_journal_cb_entry - Base structure for callback information. 130 * struct ext4_journal_cb_entry - Base structure for callback information.
115 * 131 *
@@ -234,7 +250,8 @@ int __ext4_handle_dirty_super(const char *where, unsigned int line,
234#define ext4_handle_dirty_super(handle, sb) \ 250#define ext4_handle_dirty_super(handle, sb) \
235 __ext4_handle_dirty_super(__func__, __LINE__, (handle), (sb)) 251 __ext4_handle_dirty_super(__func__, __LINE__, (handle), (sb))
236 252
237handle_t *ext4_journal_start_sb(struct super_block *sb, int nblocks); 253handle_t *__ext4_journal_start_sb(struct super_block *sb, unsigned int line,
254 int type, int nblocks);
238int __ext4_journal_stop(const char *where, unsigned int line, handle_t *handle); 255int __ext4_journal_stop(const char *where, unsigned int line, handle_t *handle);
239 256
240#define EXT4_NOJOURNAL_MAX_REF_COUNT ((unsigned long) 4096) 257#define EXT4_NOJOURNAL_MAX_REF_COUNT ((unsigned long) 4096)
@@ -268,9 +285,17 @@ static inline int ext4_handle_has_enough_credits(handle_t *handle, int needed)
268 return 1; 285 return 1;
269} 286}
270 287
271static inline handle_t *ext4_journal_start(struct inode *inode, int nblocks) 288#define ext4_journal_start_sb(sb, type, nblocks) \
289 __ext4_journal_start_sb((sb), __LINE__, (type), (nblocks))
290
291#define ext4_journal_start(inode, type, nblocks) \
292 __ext4_journal_start((inode), __LINE__, (type), (nblocks))
293
294static inline handle_t *__ext4_journal_start(struct inode *inode,
295 unsigned int line, int type,
296 int nblocks)
272{ 297{
273 return ext4_journal_start_sb(inode->i_sb, nblocks); 298 return __ext4_journal_start_sb(inode->i_sb, line, type, nblocks);
274} 299}
275 300
276#define ext4_journal_stop(handle) \ 301#define ext4_journal_stop(handle) \
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index db55c62e1f01..b6b54d658dc2 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -2656,7 +2656,7 @@ static int ext4_ext_remove_space(struct inode *inode, ext4_lblk_t start,
2656 ext_debug("truncate since %u to %u\n", start, end); 2656 ext_debug("truncate since %u to %u\n", start, end);
2657 2657
2658 /* probably first extent we're gonna free will be last in block */ 2658 /* probably first extent we're gonna free will be last in block */
2659 handle = ext4_journal_start(inode, depth + 1); 2659 handle = ext4_journal_start(inode, EXT4_HT_TRUNCATE, depth + 1);
2660 if (IS_ERR(handle)) 2660 if (IS_ERR(handle))
2661 return PTR_ERR(handle); 2661 return PTR_ERR(handle);
2662 2662
@@ -4287,7 +4287,7 @@ void ext4_ext_truncate(struct inode *inode)
4287 * probably first extent we're gonna free will be last in block 4287 * probably first extent we're gonna free will be last in block
4288 */ 4288 */
4289 err = ext4_writepage_trans_blocks(inode); 4289 err = ext4_writepage_trans_blocks(inode);
4290 handle = ext4_journal_start(inode, err); 4290 handle = ext4_journal_start(inode, EXT4_HT_TRUNCATE, err);
4291 if (IS_ERR(handle)) 4291 if (IS_ERR(handle))
4292 return; 4292 return;
4293 4293
@@ -4454,7 +4454,8 @@ retry:
4454 while (ret >= 0 && ret < max_blocks) { 4454 while (ret >= 0 && ret < max_blocks) {
4455 map.m_lblk = map.m_lblk + ret; 4455 map.m_lblk = map.m_lblk + ret;
4456 map.m_len = max_blocks = max_blocks - ret; 4456 map.m_len = max_blocks = max_blocks - ret;
4457 handle = ext4_journal_start(inode, credits); 4457 handle = ext4_journal_start(inode, EXT4_HT_MAP_BLOCKS,
4458 credits);
4458 if (IS_ERR(handle)) { 4459 if (IS_ERR(handle)) {
4459 ret = PTR_ERR(handle); 4460 ret = PTR_ERR(handle);
4460 break; 4461 break;
@@ -4532,7 +4533,7 @@ int ext4_convert_unwritten_extents(struct inode *inode, loff_t offset,
4532 while (ret >= 0 && ret < max_blocks) { 4533 while (ret >= 0 && ret < max_blocks) {
4533 map.m_lblk += ret; 4534 map.m_lblk += ret;
4534 map.m_len = (max_blocks -= ret); 4535 map.m_len = (max_blocks -= ret);
4535 handle = ext4_journal_start(inode, credits); 4536 handle = ext4_journal_start(inode, EXT4_HT_MAP_BLOCKS, credits);
4536 if (IS_ERR(handle)) { 4537 if (IS_ERR(handle)) {
4537 ret = PTR_ERR(handle); 4538 ret = PTR_ERR(handle);
4538 break; 4539 break;
@@ -4710,7 +4711,7 @@ int ext4_ext_punch_hole(struct file *file, loff_t offset, loff_t length)
4710 inode_dio_wait(inode); 4711 inode_dio_wait(inode);
4711 4712
4712 credits = ext4_writepage_trans_blocks(inode); 4713 credits = ext4_writepage_trans_blocks(inode);
4713 handle = ext4_journal_start(inode, credits); 4714 handle = ext4_journal_start(inode, EXT4_HT_TRUNCATE, credits);
4714 if (IS_ERR(handle)) { 4715 if (IS_ERR(handle)) {
4715 err = PTR_ERR(handle); 4716 err = PTR_ERR(handle);
4716 goto out_dio; 4717 goto out_dio;
diff --git a/fs/ext4/file.c b/fs/ext4/file.c
index 405565a62277..2cf8ab810687 100644
--- a/fs/ext4/file.c
+++ b/fs/ext4/file.c
@@ -240,7 +240,7 @@ static int ext4_file_open(struct inode * inode, struct file * filp)
240 handle_t *handle; 240 handle_t *handle;
241 int err; 241 int err;
242 242
243 handle = ext4_journal_start_sb(sb, 1); 243 handle = ext4_journal_start_sb(sb, EXT4_HT_MISC, 1);
244 if (IS_ERR(handle)) 244 if (IS_ERR(handle))
245 return PTR_ERR(handle); 245 return PTR_ERR(handle);
246 err = ext4_journal_get_write_access(handle, sbi->s_sbh); 246 err = ext4_journal_get_write_access(handle, sbi->s_sbh);
diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c
index 3f32c8012447..10bd6fecc9ff 100644
--- a/fs/ext4/ialloc.c
+++ b/fs/ext4/ialloc.c
@@ -1137,7 +1137,7 @@ int ext4_init_inode_table(struct super_block *sb, ext4_group_t group,
1137 if (gdp->bg_flags & cpu_to_le16(EXT4_BG_INODE_ZEROED)) 1137 if (gdp->bg_flags & cpu_to_le16(EXT4_BG_INODE_ZEROED))
1138 goto out; 1138 goto out;
1139 1139
1140 handle = ext4_journal_start_sb(sb, 1); 1140 handle = ext4_journal_start_sb(sb, EXT4_HT_MISC, 1);
1141 if (IS_ERR(handle)) { 1141 if (IS_ERR(handle)) {
1142 ret = PTR_ERR(handle); 1142 ret = PTR_ERR(handle);
1143 goto out; 1143 goto out;
diff --git a/fs/ext4/indirect.c b/fs/ext4/indirect.c
index 193281098fb6..c541ab8b64dd 100644
--- a/fs/ext4/indirect.c
+++ b/fs/ext4/indirect.c
@@ -791,7 +791,7 @@ ssize_t ext4_ind_direct_IO(int rw, struct kiocb *iocb,
791 791
792 if (final_size > inode->i_size) { 792 if (final_size > inode->i_size) {
793 /* Credits for sb + inode write */ 793 /* Credits for sb + inode write */
794 handle = ext4_journal_start(inode, 2); 794 handle = ext4_journal_start(inode, EXT4_HT_INODE, 2);
795 if (IS_ERR(handle)) { 795 if (IS_ERR(handle)) {
796 ret = PTR_ERR(handle); 796 ret = PTR_ERR(handle);
797 goto out; 797 goto out;
@@ -851,7 +851,7 @@ locked:
851 int err; 851 int err;
852 852
853 /* Credits for sb + inode write */ 853 /* Credits for sb + inode write */
854 handle = ext4_journal_start(inode, 2); 854 handle = ext4_journal_start(inode, EXT4_HT_INODE, 2);
855 if (IS_ERR(handle)) { 855 if (IS_ERR(handle)) {
856 /* This is really bad luck. We've written the data 856 /* This is really bad luck. We've written the data
857 * but cannot extend i_size. Bail out and pretend 857 * but cannot extend i_size. Bail out and pretend
@@ -950,7 +950,8 @@ static handle_t *start_transaction(struct inode *inode)
950{ 950{
951 handle_t *result; 951 handle_t *result;
952 952
953 result = ext4_journal_start(inode, ext4_blocks_for_truncate(inode)); 953 result = ext4_journal_start(inode, EXT4_HT_TRUNCATE,
954 ext4_blocks_for_truncate(inode));
954 if (!IS_ERR(result)) 955 if (!IS_ERR(result))
955 return result; 956 return result;
956 957
diff --git a/fs/ext4/inline.c b/fs/ext4/inline.c
index 93a3408fc89b..bc5f871f0893 100644
--- a/fs/ext4/inline.c
+++ b/fs/ext4/inline.c
@@ -545,7 +545,7 @@ static int ext4_convert_inline_data_to_extent(struct address_space *mapping,
545 return ret; 545 return ret;
546 546
547retry: 547retry:
548 handle = ext4_journal_start(inode, needed_blocks); 548 handle = ext4_journal_start(inode, EXT4_HT_WRITE_PAGE, needed_blocks);
549 if (IS_ERR(handle)) { 549 if (IS_ERR(handle)) {
550 ret = PTR_ERR(handle); 550 ret = PTR_ERR(handle);
551 handle = NULL; 551 handle = NULL;
@@ -657,7 +657,7 @@ int ext4_try_to_write_inline_data(struct address_space *mapping,
657 * The possible write could happen in the inode, 657 * The possible write could happen in the inode,
658 * so try to reserve the space in inode first. 658 * so try to reserve the space in inode first.
659 */ 659 */
660 handle = ext4_journal_start(inode, 1); 660 handle = ext4_journal_start(inode, EXT4_HT_INODE, 1);
661 if (IS_ERR(handle)) { 661 if (IS_ERR(handle)) {
662 ret = PTR_ERR(handle); 662 ret = PTR_ERR(handle);
663 handle = NULL; 663 handle = NULL;
@@ -853,7 +853,7 @@ int ext4_da_write_inline_data_begin(struct address_space *mapping,
853 if (ret) 853 if (ret)
854 return ret; 854 return ret;
855 855
856 handle = ext4_journal_start(inode, 1); 856 handle = ext4_journal_start(inode, EXT4_HT_INODE, 1);
857 if (IS_ERR(handle)) { 857 if (IS_ERR(handle)) {
858 ret = PTR_ERR(handle); 858 ret = PTR_ERR(handle);
859 handle = NULL; 859 handle = NULL;
@@ -1770,7 +1770,7 @@ void ext4_inline_data_truncate(struct inode *inode, int *has_inline)
1770 1770
1771 1771
1772 needed_blocks = ext4_writepage_trans_blocks(inode); 1772 needed_blocks = ext4_writepage_trans_blocks(inode);
1773 handle = ext4_journal_start(inode, needed_blocks); 1773 handle = ext4_journal_start(inode, EXT4_HT_INODE, needed_blocks);
1774 if (IS_ERR(handle)) 1774 if (IS_ERR(handle))
1775 return; 1775 return;
1776 1776
@@ -1862,7 +1862,7 @@ int ext4_convert_inline_data(struct inode *inode)
1862 if (error) 1862 if (error)
1863 return error; 1863 return error;
1864 1864
1865 handle = ext4_journal_start(inode, needed_blocks); 1865 handle = ext4_journal_start(inode, EXT4_HT_WRITE_PAGE, needed_blocks);
1866 if (IS_ERR(handle)) { 1866 if (IS_ERR(handle)) {
1867 error = PTR_ERR(handle); 1867 error = PTR_ERR(handle);
1868 goto out_free; 1868 goto out_free;
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 07d9defeaf8c..5042c8773ad7 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -234,7 +234,8 @@ void ext4_evict_inode(struct inode *inode)
234 * protection against it 234 * protection against it
235 */ 235 */
236 sb_start_intwrite(inode->i_sb); 236 sb_start_intwrite(inode->i_sb);
237 handle = ext4_journal_start(inode, ext4_blocks_for_truncate(inode)+3); 237 handle = ext4_journal_start(inode, EXT4_HT_TRUNCATE,
238 ext4_blocks_for_truncate(inode)+3);
238 if (IS_ERR(handle)) { 239 if (IS_ERR(handle)) {
239 ext4_std_error(inode->i_sb, PTR_ERR(handle)); 240 ext4_std_error(inode->i_sb, PTR_ERR(handle));
240 /* 241 /*
@@ -656,7 +657,8 @@ static int _ext4_get_block(struct inode *inode, sector_t iblock,
656 if (map.m_len > DIO_MAX_BLOCKS) 657 if (map.m_len > DIO_MAX_BLOCKS)
657 map.m_len = DIO_MAX_BLOCKS; 658 map.m_len = DIO_MAX_BLOCKS;
658 dio_credits = ext4_chunk_trans_blocks(inode, map.m_len); 659 dio_credits = ext4_chunk_trans_blocks(inode, map.m_len);
659 handle = ext4_journal_start(inode, dio_credits); 660 handle = ext4_journal_start(inode, EXT4_HT_MAP_BLOCKS,
661 dio_credits);
660 if (IS_ERR(handle)) { 662 if (IS_ERR(handle)) {
661 ret = PTR_ERR(handle); 663 ret = PTR_ERR(handle);
662 return ret; 664 return ret;
@@ -881,7 +883,7 @@ static int ext4_write_begin(struct file *file, struct address_space *mapping,
881 } 883 }
882 884
883retry: 885retry:
884 handle = ext4_journal_start(inode, needed_blocks); 886 handle = ext4_journal_start(inode, EXT4_HT_WRITE_PAGE, needed_blocks);
885 if (IS_ERR(handle)) { 887 if (IS_ERR(handle)) {
886 ret = PTR_ERR(handle); 888 ret = PTR_ERR(handle);
887 goto out; 889 goto out;
@@ -1881,7 +1883,8 @@ static int __ext4_journalled_writepage(struct page *page,
1881 * references to buffers so we are safe */ 1883 * references to buffers so we are safe */
1882 unlock_page(page); 1884 unlock_page(page);
1883 1885
1884 handle = ext4_journal_start(inode, ext4_writepage_trans_blocks(inode)); 1886 handle = ext4_journal_start(inode, EXT4_HT_WRITE_PAGE,
1887 ext4_writepage_trans_blocks(inode));
1885 if (IS_ERR(handle)) { 1888 if (IS_ERR(handle)) {
1886 ret = PTR_ERR(handle); 1889 ret = PTR_ERR(handle);
1887 goto out; 1890 goto out;
@@ -2312,7 +2315,8 @@ retry:
2312 needed_blocks = ext4_da_writepages_trans_blocks(inode); 2315 needed_blocks = ext4_da_writepages_trans_blocks(inode);
2313 2316
2314 /* start a new transaction*/ 2317 /* start a new transaction*/
2315 handle = ext4_journal_start(inode, needed_blocks); 2318 handle = ext4_journal_start(inode, EXT4_HT_WRITE_PAGE,
2319 needed_blocks);
2316 if (IS_ERR(handle)) { 2320 if (IS_ERR(handle)) {
2317 ret = PTR_ERR(handle); 2321 ret = PTR_ERR(handle);
2318 ext4_msg(inode->i_sb, KERN_CRIT, "%s: jbd2_start: " 2322 ext4_msg(inode->i_sb, KERN_CRIT, "%s: jbd2_start: "
@@ -2468,7 +2472,7 @@ retry:
2468 * to journalling the i_disksize update if writes to the end 2472 * to journalling the i_disksize update if writes to the end
2469 * of file which has an already mapped buffer. 2473 * of file which has an already mapped buffer.
2470 */ 2474 */
2471 handle = ext4_journal_start(inode, 1); 2475 handle = ext4_journal_start(inode, EXT4_HT_WRITE_PAGE, 1);
2472 if (IS_ERR(handle)) { 2476 if (IS_ERR(handle)) {
2473 ret = PTR_ERR(handle); 2477 ret = PTR_ERR(handle);
2474 goto out; 2478 goto out;
@@ -4215,8 +4219,9 @@ int ext4_setattr(struct dentry *dentry, struct iattr *attr)
4215 4219
4216 /* (user+group)*(old+new) structure, inode write (sb, 4220 /* (user+group)*(old+new) structure, inode write (sb,
4217 * inode block, ? - but truncate inode update has it) */ 4221 * inode block, ? - but truncate inode update has it) */
4218 handle = ext4_journal_start(inode, (EXT4_MAXQUOTAS_INIT_BLOCKS(inode->i_sb)+ 4222 handle = ext4_journal_start(inode, EXT4_HT_QUOTA,
4219 EXT4_MAXQUOTAS_DEL_BLOCKS(inode->i_sb))+3); 4223 (EXT4_MAXQUOTAS_INIT_BLOCKS(inode->i_sb) +
4224 EXT4_MAXQUOTAS_DEL_BLOCKS(inode->i_sb)) + 3);
4220 if (IS_ERR(handle)) { 4225 if (IS_ERR(handle)) {
4221 error = PTR_ERR(handle); 4226 error = PTR_ERR(handle);
4222 goto err_out; 4227 goto err_out;
@@ -4251,7 +4256,7 @@ int ext4_setattr(struct dentry *dentry, struct iattr *attr)
4251 (attr->ia_size < inode->i_size)) { 4256 (attr->ia_size < inode->i_size)) {
4252 handle_t *handle; 4257 handle_t *handle;
4253 4258
4254 handle = ext4_journal_start(inode, 3); 4259 handle = ext4_journal_start(inode, EXT4_HT_INODE, 3);
4255 if (IS_ERR(handle)) { 4260 if (IS_ERR(handle)) {
4256 error = PTR_ERR(handle); 4261 error = PTR_ERR(handle);
4257 goto err_out; 4262 goto err_out;
@@ -4271,7 +4276,8 @@ int ext4_setattr(struct dentry *dentry, struct iattr *attr)
4271 attr->ia_size); 4276 attr->ia_size);
4272 if (error) { 4277 if (error) {
4273 /* Do as much error cleanup as possible */ 4278 /* Do as much error cleanup as possible */
4274 handle = ext4_journal_start(inode, 3); 4279 handle = ext4_journal_start(inode,
4280 EXT4_HT_INODE, 3);
4275 if (IS_ERR(handle)) { 4281 if (IS_ERR(handle)) {
4276 ext4_orphan_del(NULL, inode); 4282 ext4_orphan_del(NULL, inode);
4277 goto err_out; 4283 goto err_out;
@@ -4612,7 +4618,7 @@ void ext4_dirty_inode(struct inode *inode, int flags)
4612{ 4618{
4613 handle_t *handle; 4619 handle_t *handle;
4614 4620
4615 handle = ext4_journal_start(inode, 2); 4621 handle = ext4_journal_start(inode, EXT4_HT_INODE, 2);
4616 if (IS_ERR(handle)) 4622 if (IS_ERR(handle))
4617 goto out; 4623 goto out;
4618 4624
@@ -4713,7 +4719,7 @@ int ext4_change_inode_journal_flag(struct inode *inode, int val)
4713 4719
4714 /* Finally we can mark the inode as dirty. */ 4720 /* Finally we can mark the inode as dirty. */
4715 4721
4716 handle = ext4_journal_start(inode, 1); 4722 handle = ext4_journal_start(inode, EXT4_HT_INODE, 1);
4717 if (IS_ERR(handle)) 4723 if (IS_ERR(handle))
4718 return PTR_ERR(handle); 4724 return PTR_ERR(handle);
4719 4725
@@ -4791,7 +4797,8 @@ int ext4_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
4791 else 4797 else
4792 get_block = ext4_get_block; 4798 get_block = ext4_get_block;
4793retry_alloc: 4799retry_alloc:
4794 handle = ext4_journal_start(inode, ext4_writepage_trans_blocks(inode)); 4800 handle = ext4_journal_start(inode, EXT4_HT_WRITE_PAGE,
4801 ext4_writepage_trans_blocks(inode));
4795 if (IS_ERR(handle)) { 4802 if (IS_ERR(handle)) {
4796 ret = VM_FAULT_SIGBUS; 4803 ret = VM_FAULT_SIGBUS;
4797 goto out; 4804 goto out;
diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c
index 4784ac244fc6..31f4f56a32d6 100644
--- a/fs/ext4/ioctl.c
+++ b/fs/ext4/ioctl.c
@@ -104,7 +104,7 @@ long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
104 } else if (oldflags & EXT4_EOFBLOCKS_FL) 104 } else if (oldflags & EXT4_EOFBLOCKS_FL)
105 ext4_truncate(inode); 105 ext4_truncate(inode);
106 106
107 handle = ext4_journal_start(inode, 1); 107 handle = ext4_journal_start(inode, EXT4_HT_INODE, 1);
108 if (IS_ERR(handle)) { 108 if (IS_ERR(handle)) {
109 err = PTR_ERR(handle); 109 err = PTR_ERR(handle);
110 goto flags_out; 110 goto flags_out;
@@ -173,7 +173,7 @@ flags_out:
173 } 173 }
174 174
175 mutex_lock(&inode->i_mutex); 175 mutex_lock(&inode->i_mutex);
176 handle = ext4_journal_start(inode, 1); 176 handle = ext4_journal_start(inode, EXT4_HT_INODE, 1);
177 if (IS_ERR(handle)) { 177 if (IS_ERR(handle)) {
178 err = PTR_ERR(handle); 178 err = PTR_ERR(handle);
179 goto unlock_out; 179 goto unlock_out;
diff --git a/fs/ext4/migrate.c b/fs/ext4/migrate.c
index db8226d595fa..4e4fcfd342f8 100644
--- a/fs/ext4/migrate.c
+++ b/fs/ext4/migrate.c
@@ -456,7 +456,7 @@ int ext4_ext_migrate(struct inode *inode)
456 */ 456 */
457 return retval; 457 return retval;
458 458
459 handle = ext4_journal_start(inode, 459 handle = ext4_journal_start(inode, EXT4_HT_MIGRATE,
460 EXT4_DATA_TRANS_BLOCKS(inode->i_sb) + 460 EXT4_DATA_TRANS_BLOCKS(inode->i_sb) +
461 EXT4_INDEX_EXTRA_TRANS_BLOCKS + 3 + 461 EXT4_INDEX_EXTRA_TRANS_BLOCKS + 3 +
462 EXT4_MAXQUOTAS_INIT_BLOCKS(inode->i_sb) 462 EXT4_MAXQUOTAS_INIT_BLOCKS(inode->i_sb)
@@ -507,7 +507,7 @@ int ext4_ext_migrate(struct inode *inode)
507 ext4_set_inode_state(inode, EXT4_STATE_EXT_MIGRATE); 507 ext4_set_inode_state(inode, EXT4_STATE_EXT_MIGRATE);
508 up_read((&EXT4_I(inode)->i_data_sem)); 508 up_read((&EXT4_I(inode)->i_data_sem));
509 509
510 handle = ext4_journal_start(inode, 1); 510 handle = ext4_journal_start(inode, EXT4_HT_MIGRATE, 1);
511 if (IS_ERR(handle)) { 511 if (IS_ERR(handle)) {
512 /* 512 /*
513 * It is impossible to update on-disk structures without 513 * It is impossible to update on-disk structures without
diff --git a/fs/ext4/move_extent.c b/fs/ext4/move_extent.c
index e4cdb5188f34..0d6734394eac 100644
--- a/fs/ext4/move_extent.c
+++ b/fs/ext4/move_extent.c
@@ -923,7 +923,7 @@ move_extent_per_page(struct file *o_filp, struct inode *donor_inode,
923again: 923again:
924 *err = 0; 924 *err = 0;
925 jblocks = ext4_writepage_trans_blocks(orig_inode) * 2; 925 jblocks = ext4_writepage_trans_blocks(orig_inode) * 2;
926 handle = ext4_journal_start(orig_inode, jblocks); 926 handle = ext4_journal_start(orig_inode, EXT4_HT_MOVE_EXTENTS, jblocks);
927 if (IS_ERR(handle)) { 927 if (IS_ERR(handle)) {
928 *err = PTR_ERR(handle); 928 *err = PTR_ERR(handle);
929 return 0; 929 return 0;
diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
index 34ed624d2c56..51841032ca03 100644
--- a/fs/ext4/namei.c
+++ b/fs/ext4/namei.c
@@ -2262,9 +2262,10 @@ static int ext4_create(struct inode *dir, struct dentry *dentry, umode_t mode,
2262 dquot_initialize(dir); 2262 dquot_initialize(dir);
2263 2263
2264retry: 2264retry:
2265 handle = ext4_journal_start(dir, EXT4_DATA_TRANS_BLOCKS(dir->i_sb) + 2265 handle = ext4_journal_start(dir, EXT4_HT_DIR,
2266 EXT4_INDEX_EXTRA_TRANS_BLOCKS + 3 + 2266 (EXT4_DATA_TRANS_BLOCKS(dir->i_sb) +
2267 EXT4_MAXQUOTAS_INIT_BLOCKS(dir->i_sb)); 2267 EXT4_INDEX_EXTRA_TRANS_BLOCKS + 3 +
2268 EXT4_MAXQUOTAS_INIT_BLOCKS(dir->i_sb)));
2268 if (IS_ERR(handle)) 2269 if (IS_ERR(handle))
2269 return PTR_ERR(handle); 2270 return PTR_ERR(handle);
2270 2271
@@ -2298,9 +2299,10 @@ static int ext4_mknod(struct inode *dir, struct dentry *dentry,
2298 dquot_initialize(dir); 2299 dquot_initialize(dir);
2299 2300
2300retry: 2301retry:
2301 handle = ext4_journal_start(dir, EXT4_DATA_TRANS_BLOCKS(dir->i_sb) + 2302 handle = ext4_journal_start(dir, EXT4_HT_DIR,
2302 EXT4_INDEX_EXTRA_TRANS_BLOCKS + 3 + 2303 (EXT4_DATA_TRANS_BLOCKS(dir->i_sb) +
2303 EXT4_MAXQUOTAS_INIT_BLOCKS(dir->i_sb)); 2304 EXT4_INDEX_EXTRA_TRANS_BLOCKS + 3 +
2305 EXT4_MAXQUOTAS_INIT_BLOCKS(dir->i_sb)));
2304 if (IS_ERR(handle)) 2306 if (IS_ERR(handle))
2305 return PTR_ERR(handle); 2307 return PTR_ERR(handle);
2306 2308
@@ -2414,9 +2416,10 @@ static int ext4_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
2414 dquot_initialize(dir); 2416 dquot_initialize(dir);
2415 2417
2416retry: 2418retry:
2417 handle = ext4_journal_start(dir, EXT4_DATA_TRANS_BLOCKS(dir->i_sb) + 2419 handle = ext4_journal_start(dir, EXT4_HT_DIR,
2418 EXT4_INDEX_EXTRA_TRANS_BLOCKS + 3 + 2420 (EXT4_DATA_TRANS_BLOCKS(dir->i_sb) +
2419 EXT4_MAXQUOTAS_INIT_BLOCKS(dir->i_sb)); 2421 EXT4_INDEX_EXTRA_TRANS_BLOCKS + 3 +
2422 EXT4_MAXQUOTAS_INIT_BLOCKS(dir->i_sb)));
2420 if (IS_ERR(handle)) 2423 if (IS_ERR(handle))
2421 return PTR_ERR(handle); 2424 return PTR_ERR(handle);
2422 2425
@@ -2729,7 +2732,8 @@ static int ext4_rmdir(struct inode *dir, struct dentry *dentry)
2729 dquot_initialize(dir); 2732 dquot_initialize(dir);
2730 dquot_initialize(dentry->d_inode); 2733 dquot_initialize(dentry->d_inode);
2731 2734
2732 handle = ext4_journal_start(dir, EXT4_DELETE_TRANS_BLOCKS(dir->i_sb)); 2735 handle = ext4_journal_start(dir, EXT4_HT_DIR,
2736 EXT4_DELETE_TRANS_BLOCKS(dir->i_sb));
2733 if (IS_ERR(handle)) 2737 if (IS_ERR(handle))
2734 return PTR_ERR(handle); 2738 return PTR_ERR(handle);
2735 2739
@@ -2791,7 +2795,8 @@ static int ext4_unlink(struct inode *dir, struct dentry *dentry)
2791 dquot_initialize(dir); 2795 dquot_initialize(dir);
2792 dquot_initialize(dentry->d_inode); 2796 dquot_initialize(dentry->d_inode);
2793 2797
2794 handle = ext4_journal_start(dir, EXT4_DELETE_TRANS_BLOCKS(dir->i_sb)); 2798 handle = ext4_journal_start(dir, EXT4_HT_DIR,
2799 EXT4_DELETE_TRANS_BLOCKS(dir->i_sb));
2795 if (IS_ERR(handle)) 2800 if (IS_ERR(handle))
2796 return PTR_ERR(handle); 2801 return PTR_ERR(handle);
2797 2802
@@ -2870,7 +2875,7 @@ static int ext4_symlink(struct inode *dir,
2870 EXT4_MAXQUOTAS_INIT_BLOCKS(dir->i_sb); 2875 EXT4_MAXQUOTAS_INIT_BLOCKS(dir->i_sb);
2871 } 2876 }
2872retry: 2877retry:
2873 handle = ext4_journal_start(dir, credits); 2878 handle = ext4_journal_start(dir, EXT4_HT_DIR, credits);
2874 if (IS_ERR(handle)) 2879 if (IS_ERR(handle))
2875 return PTR_ERR(handle); 2880 return PTR_ERR(handle);
2876 2881
@@ -2908,7 +2913,7 @@ retry:
2908 * Now inode is being linked into dir (EXT4_DATA_TRANS_BLOCKS 2913 * Now inode is being linked into dir (EXT4_DATA_TRANS_BLOCKS
2909 * + EXT4_INDEX_EXTRA_TRANS_BLOCKS), inode is also modified 2914 * + EXT4_INDEX_EXTRA_TRANS_BLOCKS), inode is also modified
2910 */ 2915 */
2911 handle = ext4_journal_start(dir, 2916 handle = ext4_journal_start(dir, EXT4_HT_DIR,
2912 EXT4_DATA_TRANS_BLOCKS(dir->i_sb) + 2917 EXT4_DATA_TRANS_BLOCKS(dir->i_sb) +
2913 EXT4_INDEX_EXTRA_TRANS_BLOCKS + 1); 2918 EXT4_INDEX_EXTRA_TRANS_BLOCKS + 1);
2914 if (IS_ERR(handle)) { 2919 if (IS_ERR(handle)) {
@@ -2955,8 +2960,9 @@ static int ext4_link(struct dentry *old_dentry,
2955 dquot_initialize(dir); 2960 dquot_initialize(dir);
2956 2961
2957retry: 2962retry:
2958 handle = ext4_journal_start(dir, EXT4_DATA_TRANS_BLOCKS(dir->i_sb) + 2963 handle = ext4_journal_start(dir, EXT4_HT_DIR,
2959 EXT4_INDEX_EXTRA_TRANS_BLOCKS); 2964 (EXT4_DATA_TRANS_BLOCKS(dir->i_sb) +
2965 EXT4_INDEX_EXTRA_TRANS_BLOCKS));
2960 if (IS_ERR(handle)) 2966 if (IS_ERR(handle))
2961 return PTR_ERR(handle); 2967 return PTR_ERR(handle);
2962 2968
@@ -3039,9 +3045,9 @@ static int ext4_rename(struct inode *old_dir, struct dentry *old_dentry,
3039 * in separate transaction */ 3045 * in separate transaction */
3040 if (new_dentry->d_inode) 3046 if (new_dentry->d_inode)
3041 dquot_initialize(new_dentry->d_inode); 3047 dquot_initialize(new_dentry->d_inode);
3042 handle = ext4_journal_start(old_dir, 2 * 3048 handle = ext4_journal_start(old_dir, EXT4_HT_DIR,
3043 EXT4_DATA_TRANS_BLOCKS(old_dir->i_sb) + 3049 (2 * EXT4_DATA_TRANS_BLOCKS(old_dir->i_sb) +
3044 EXT4_INDEX_EXTRA_TRANS_BLOCKS + 2); 3050 EXT4_INDEX_EXTRA_TRANS_BLOCKS + 2));
3045 if (IS_ERR(handle)) 3051 if (IS_ERR(handle))
3046 return PTR_ERR(handle); 3052 return PTR_ERR(handle);
3047 3053
diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c
index 8eefb636beb8..c7f4d7584669 100644
--- a/fs/ext4/resize.c
+++ b/fs/ext4/resize.c
@@ -466,7 +466,7 @@ static int setup_new_flex_group_blocks(struct super_block *sb,
466 meta_bg = EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_META_BG); 466 meta_bg = EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_META_BG);
467 467
468 /* This transaction may be extended/restarted along the way */ 468 /* This transaction may be extended/restarted along the way */
469 handle = ext4_journal_start_sb(sb, EXT4_MAX_TRANS_DATA); 469 handle = ext4_journal_start_sb(sb, EXT4_HT_RESIZE, EXT4_MAX_TRANS_DATA);
470 if (IS_ERR(handle)) 470 if (IS_ERR(handle))
471 return PTR_ERR(handle); 471 return PTR_ERR(handle);
472 472
@@ -1031,7 +1031,7 @@ static void update_backups(struct super_block *sb, int blk_off, char *data,
1031 handle_t *handle; 1031 handle_t *handle;
1032 int err = 0, err2; 1032 int err = 0, err2;
1033 1033
1034 handle = ext4_journal_start_sb(sb, EXT4_MAX_TRANS_DATA); 1034 handle = ext4_journal_start_sb(sb, EXT4_HT_RESIZE, EXT4_MAX_TRANS_DATA);
1035 if (IS_ERR(handle)) { 1035 if (IS_ERR(handle)) {
1036 group = 1; 1036 group = 1;
1037 err = PTR_ERR(handle); 1037 err = PTR_ERR(handle);
@@ -1412,7 +1412,7 @@ static int ext4_flex_group_add(struct super_block *sb,
1412 * modify each of the reserved GDT dindirect blocks. 1412 * modify each of the reserved GDT dindirect blocks.
1413 */ 1413 */
1414 credit = flex_gd->count * 4 + reserved_gdb; 1414 credit = flex_gd->count * 4 + reserved_gdb;
1415 handle = ext4_journal_start_sb(sb, credit); 1415 handle = ext4_journal_start_sb(sb, EXT4_HT_RESIZE, credit);
1416 if (IS_ERR(handle)) { 1416 if (IS_ERR(handle)) {
1417 err = PTR_ERR(handle); 1417 err = PTR_ERR(handle);
1418 goto exit; 1418 goto exit;
@@ -1624,7 +1624,7 @@ static int ext4_group_extend_no_check(struct super_block *sb,
1624 /* We will update the superblock, one block bitmap, and 1624 /* We will update the superblock, one block bitmap, and
1625 * one group descriptor via ext4_group_add_blocks(). 1625 * one group descriptor via ext4_group_add_blocks().
1626 */ 1626 */
1627 handle = ext4_journal_start_sb(sb, 3); 1627 handle = ext4_journal_start_sb(sb, EXT4_HT_RESIZE, 3);
1628 if (IS_ERR(handle)) { 1628 if (IS_ERR(handle)) {
1629 err = PTR_ERR(handle); 1629 err = PTR_ERR(handle);
1630 ext4_warning(sb, "error %d on journal start", err); 1630 ext4_warning(sb, "error %d on journal start", err);
@@ -1788,7 +1788,7 @@ static int ext4_convert_meta_bg(struct super_block *sb, struct inode *inode)
1788 credits += 3; /* block bitmap, bg descriptor, resize inode */ 1788 credits += 3; /* block bitmap, bg descriptor, resize inode */
1789 } 1789 }
1790 1790
1791 handle = ext4_journal_start_sb(sb, credits); 1791 handle = ext4_journal_start_sb(sb, EXT4_HT_RESIZE, credits);
1792 if (IS_ERR(handle)) 1792 if (IS_ERR(handle))
1793 return PTR_ERR(handle); 1793 return PTR_ERR(handle);
1794 1794
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index cb9d67fbc8f0..ef6ac59e4961 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -4762,7 +4762,7 @@ static int ext4_write_dquot(struct dquot *dquot)
4762 struct inode *inode; 4762 struct inode *inode;
4763 4763
4764 inode = dquot_to_inode(dquot); 4764 inode = dquot_to_inode(dquot);
4765 handle = ext4_journal_start(inode, 4765 handle = ext4_journal_start(inode, EXT4_HT_QUOTA,
4766 EXT4_QUOTA_TRANS_BLOCKS(dquot->dq_sb)); 4766 EXT4_QUOTA_TRANS_BLOCKS(dquot->dq_sb));
4767 if (IS_ERR(handle)) 4767 if (IS_ERR(handle))
4768 return PTR_ERR(handle); 4768 return PTR_ERR(handle);
@@ -4778,7 +4778,7 @@ static int ext4_acquire_dquot(struct dquot *dquot)
4778 int ret, err; 4778 int ret, err;
4779 handle_t *handle; 4779 handle_t *handle;
4780 4780
4781 handle = ext4_journal_start(dquot_to_inode(dquot), 4781 handle = ext4_journal_start(dquot_to_inode(dquot), EXT4_HT_QUOTA,
4782 EXT4_QUOTA_INIT_BLOCKS(dquot->dq_sb)); 4782 EXT4_QUOTA_INIT_BLOCKS(dquot->dq_sb));
4783 if (IS_ERR(handle)) 4783 if (IS_ERR(handle))
4784 return PTR_ERR(handle); 4784 return PTR_ERR(handle);
@@ -4794,7 +4794,7 @@ static int ext4_release_dquot(struct dquot *dquot)
4794 int ret, err; 4794 int ret, err;
4795 handle_t *handle; 4795 handle_t *handle;
4796 4796
4797 handle = ext4_journal_start(dquot_to_inode(dquot), 4797 handle = ext4_journal_start(dquot_to_inode(dquot), EXT4_HT_QUOTA,
4798 EXT4_QUOTA_DEL_BLOCKS(dquot->dq_sb)); 4798 EXT4_QUOTA_DEL_BLOCKS(dquot->dq_sb));
4799 if (IS_ERR(handle)) { 4799 if (IS_ERR(handle)) {
4800 /* Release dquot anyway to avoid endless cycle in dqput() */ 4800 /* Release dquot anyway to avoid endless cycle in dqput() */
@@ -4826,7 +4826,7 @@ static int ext4_write_info(struct super_block *sb, int type)
4826 handle_t *handle; 4826 handle_t *handle;
4827 4827
4828 /* Data block + inode block */ 4828 /* Data block + inode block */
4829 handle = ext4_journal_start(sb->s_root->d_inode, 2); 4829 handle = ext4_journal_start(sb->s_root->d_inode, EXT4_HT_QUOTA, 2);
4830 if (IS_ERR(handle)) 4830 if (IS_ERR(handle))
4831 return PTR_ERR(handle); 4831 return PTR_ERR(handle);
4832 ret = dquot_commit_info(sb, type); 4832 ret = dquot_commit_info(sb, type);
@@ -4972,7 +4972,7 @@ static int ext4_quota_off(struct super_block *sb, int type)
4972 4972
4973 /* Update modification times of quota files when userspace can 4973 /* Update modification times of quota files when userspace can
4974 * start looking at them */ 4974 * start looking at them */
4975 handle = ext4_journal_start(inode, 1); 4975 handle = ext4_journal_start(inode, EXT4_HT_QUOTA, 1);
4976 if (IS_ERR(handle)) 4976 if (IS_ERR(handle))
4977 goto out; 4977 goto out;
4978 inode->i_mtime = inode->i_ctime = CURRENT_TIME; 4978 inode->i_mtime = inode->i_ctime = CURRENT_TIME;
diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c
index c68990c392c7..2efc5600b03b 100644
--- a/fs/ext4/xattr.c
+++ b/fs/ext4/xattr.c
@@ -1175,7 +1175,7 @@ retry:
1175 if (ext4_has_inline_data(inode)) 1175 if (ext4_has_inline_data(inode))
1176 credits += ext4_writepage_trans_blocks(inode) + 1; 1176 credits += ext4_writepage_trans_blocks(inode) + 1;
1177 1177
1178 handle = ext4_journal_start(inode, credits); 1178 handle = ext4_journal_start(inode, EXT4_HT_XATTR, credits);
1179 if (IS_ERR(handle)) { 1179 if (IS_ERR(handle)) {
1180 error = PTR_ERR(handle); 1180 error = PTR_ERR(handle);
1181 } else { 1181 } else {