提交 9924a92a 编写于 作者: T Theodore Ts'o

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: N"Theodore Ts'o" <tytso@mit.edu>
上级 722887dd
...@@ -324,7 +324,7 @@ ext4_acl_chmod(struct inode *inode) ...@@ -324,7 +324,7 @@ ext4_acl_chmod(struct inode *inode)
if (error) if (error)
return error; return error;
retry: retry:
handle = ext4_journal_start(inode, handle = ext4_journal_start(inode, EXT4_HT_XATTR,
EXT4_DATA_TRANS_BLOCKS(inode->i_sb)); EXT4_DATA_TRANS_BLOCKS(inode->i_sb));
if (IS_ERR(handle)) { if (IS_ERR(handle)) {
error = PTR_ERR(handle); error = PTR_ERR(handle);
...@@ -422,7 +422,8 @@ ext4_xattr_set_acl(struct dentry *dentry, const char *name, const void *value, ...@@ -422,7 +422,8 @@ ext4_xattr_set_acl(struct dentry *dentry, const char *name, const void *value,
acl = NULL; acl = NULL;
retry: retry:
handle = ext4_journal_start(inode, EXT4_DATA_TRANS_BLOCKS(inode->i_sb)); handle = ext4_journal_start(inode, EXT4_HT_XATTR,
EXT4_DATA_TRANS_BLOCKS(inode->i_sb));
if (IS_ERR(handle)) { if (IS_ERR(handle)) {
error = PTR_ERR(handle); error = PTR_ERR(handle);
goto release_and_out; goto release_and_out;
......
...@@ -38,7 +38,8 @@ static void ext4_put_nojournal(handle_t *handle) ...@@ -38,7 +38,8 @@ static void ext4_put_nojournal(handle_t *handle)
/* /*
* Wrappers for jbd2_journal_start/end. * Wrappers for jbd2_journal_start/end.
*/ */
handle_t *ext4_journal_start_sb(struct super_block *sb, int nblocks) handle_t *__ext4_journal_start_sb(struct super_block *sb, unsigned int line,
int type, int nblocks)
{ {
journal_t *journal; journal_t *journal;
...@@ -59,7 +60,7 @@ handle_t *ext4_journal_start_sb(struct super_block *sb, int nblocks) ...@@ -59,7 +60,7 @@ handle_t *ext4_journal_start_sb(struct super_block *sb, int nblocks)
ext4_abort(sb, "Detected aborted journal"); ext4_abort(sb, "Detected aborted journal");
return ERR_PTR(-EROFS); return ERR_PTR(-EROFS);
} }
return jbd2_journal_start(journal, nblocks); return jbd2__journal_start(journal, nblocks, GFP_NOFS, type, line);
} }
int __ext4_journal_stop(const char *where, unsigned int line, handle_t *handle) int __ext4_journal_stop(const char *where, unsigned int line, handle_t *handle)
......
...@@ -110,6 +110,22 @@ ...@@ -110,6 +110,22 @@
#define EXT4_MAXQUOTAS_INIT_BLOCKS(sb) (MAXQUOTAS*EXT4_QUOTA_INIT_BLOCKS(sb)) #define EXT4_MAXQUOTAS_INIT_BLOCKS(sb) (MAXQUOTAS*EXT4_QUOTA_INIT_BLOCKS(sb))
#define EXT4_MAXQUOTAS_DEL_BLOCKS(sb) (MAXQUOTAS*EXT4_QUOTA_DEL_BLOCKS(sb)) #define EXT4_MAXQUOTAS_DEL_BLOCKS(sb) (MAXQUOTAS*EXT4_QUOTA_DEL_BLOCKS(sb))
/*
* Ext4 handle operation types -- for logging purposes
*/
#define EXT4_HT_MISC 0
#define EXT4_HT_INODE 1
#define EXT4_HT_WRITE_PAGE 2
#define EXT4_HT_MAP_BLOCKS 3
#define EXT4_HT_DIR 4
#define EXT4_HT_TRUNCATE 5
#define EXT4_HT_QUOTA 6
#define EXT4_HT_RESIZE 7
#define EXT4_HT_MIGRATE 8
#define EXT4_HT_MOVE_EXTENTS 9
#define EXT4_HT_XATTR 10
#define EXT4_HT_MAX 11
/** /**
* struct ext4_journal_cb_entry - Base structure for callback information. * struct ext4_journal_cb_entry - Base structure for callback information.
* *
...@@ -234,7 +250,8 @@ int __ext4_handle_dirty_super(const char *where, unsigned int line, ...@@ -234,7 +250,8 @@ int __ext4_handle_dirty_super(const char *where, unsigned int line,
#define ext4_handle_dirty_super(handle, sb) \ #define ext4_handle_dirty_super(handle, sb) \
__ext4_handle_dirty_super(__func__, __LINE__, (handle), (sb)) __ext4_handle_dirty_super(__func__, __LINE__, (handle), (sb))
handle_t *ext4_journal_start_sb(struct super_block *sb, int nblocks); handle_t *__ext4_journal_start_sb(struct super_block *sb, unsigned int line,
int type, int nblocks);
int __ext4_journal_stop(const char *where, unsigned int line, handle_t *handle); int __ext4_journal_stop(const char *where, unsigned int line, handle_t *handle);
#define EXT4_NOJOURNAL_MAX_REF_COUNT ((unsigned long) 4096) #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,9 +285,17 @@ static inline int ext4_handle_has_enough_credits(handle_t *handle, int needed)
return 1; return 1;
} }
static inline handle_t *ext4_journal_start(struct inode *inode, int nblocks) #define ext4_journal_start_sb(sb, type, nblocks) \
__ext4_journal_start_sb((sb), __LINE__, (type), (nblocks))
#define ext4_journal_start(inode, type, nblocks) \
__ext4_journal_start((inode), __LINE__, (type), (nblocks))
static inline handle_t *__ext4_journal_start(struct inode *inode,
unsigned int line, int type,
int nblocks)
{ {
return ext4_journal_start_sb(inode->i_sb, nblocks); return __ext4_journal_start_sb(inode->i_sb, line, type, nblocks);
} }
#define ext4_journal_stop(handle) \ #define ext4_journal_stop(handle) \
......
...@@ -2656,7 +2656,7 @@ static int ext4_ext_remove_space(struct inode *inode, ext4_lblk_t start, ...@@ -2656,7 +2656,7 @@ static int ext4_ext_remove_space(struct inode *inode, ext4_lblk_t start,
ext_debug("truncate since %u to %u\n", start, end); ext_debug("truncate since %u to %u\n", start, end);
/* probably first extent we're gonna free will be last in block */ /* probably first extent we're gonna free will be last in block */
handle = ext4_journal_start(inode, depth + 1); handle = ext4_journal_start(inode, EXT4_HT_TRUNCATE, depth + 1);
if (IS_ERR(handle)) if (IS_ERR(handle))
return PTR_ERR(handle); return PTR_ERR(handle);
...@@ -4287,7 +4287,7 @@ void ext4_ext_truncate(struct inode *inode) ...@@ -4287,7 +4287,7 @@ void ext4_ext_truncate(struct inode *inode)
* probably first extent we're gonna free will be last in block * probably first extent we're gonna free will be last in block
*/ */
err = ext4_writepage_trans_blocks(inode); err = ext4_writepage_trans_blocks(inode);
handle = ext4_journal_start(inode, err); handle = ext4_journal_start(inode, EXT4_HT_TRUNCATE, err);
if (IS_ERR(handle)) if (IS_ERR(handle))
return; return;
...@@ -4454,7 +4454,8 @@ long ext4_fallocate(struct file *file, int mode, loff_t offset, loff_t len) ...@@ -4454,7 +4454,8 @@ long ext4_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
while (ret >= 0 && ret < max_blocks) { while (ret >= 0 && ret < max_blocks) {
map.m_lblk = map.m_lblk + ret; map.m_lblk = map.m_lblk + ret;
map.m_len = max_blocks = max_blocks - ret; map.m_len = max_blocks = max_blocks - ret;
handle = ext4_journal_start(inode, credits); handle = ext4_journal_start(inode, EXT4_HT_MAP_BLOCKS,
credits);
if (IS_ERR(handle)) { if (IS_ERR(handle)) {
ret = PTR_ERR(handle); ret = PTR_ERR(handle);
break; break;
...@@ -4532,7 +4533,7 @@ int ext4_convert_unwritten_extents(struct inode *inode, loff_t offset, ...@@ -4532,7 +4533,7 @@ int ext4_convert_unwritten_extents(struct inode *inode, loff_t offset,
while (ret >= 0 && ret < max_blocks) { while (ret >= 0 && ret < max_blocks) {
map.m_lblk += ret; map.m_lblk += ret;
map.m_len = (max_blocks -= ret); map.m_len = (max_blocks -= ret);
handle = ext4_journal_start(inode, credits); handle = ext4_journal_start(inode, EXT4_HT_MAP_BLOCKS, credits);
if (IS_ERR(handle)) { if (IS_ERR(handle)) {
ret = PTR_ERR(handle); ret = PTR_ERR(handle);
break; break;
...@@ -4710,7 +4711,7 @@ int ext4_ext_punch_hole(struct file *file, loff_t offset, loff_t length) ...@@ -4710,7 +4711,7 @@ int ext4_ext_punch_hole(struct file *file, loff_t offset, loff_t length)
inode_dio_wait(inode); inode_dio_wait(inode);
credits = ext4_writepage_trans_blocks(inode); credits = ext4_writepage_trans_blocks(inode);
handle = ext4_journal_start(inode, credits); handle = ext4_journal_start(inode, EXT4_HT_TRUNCATE, credits);
if (IS_ERR(handle)) { if (IS_ERR(handle)) {
err = PTR_ERR(handle); err = PTR_ERR(handle);
goto out_dio; goto out_dio;
......
...@@ -240,7 +240,7 @@ static int ext4_file_open(struct inode * inode, struct file * filp) ...@@ -240,7 +240,7 @@ static int ext4_file_open(struct inode * inode, struct file * filp)
handle_t *handle; handle_t *handle;
int err; int err;
handle = ext4_journal_start_sb(sb, 1); handle = ext4_journal_start_sb(sb, EXT4_HT_MISC, 1);
if (IS_ERR(handle)) if (IS_ERR(handle))
return PTR_ERR(handle); return PTR_ERR(handle);
err = ext4_journal_get_write_access(handle, sbi->s_sbh); err = ext4_journal_get_write_access(handle, sbi->s_sbh);
......
...@@ -1137,7 +1137,7 @@ int ext4_init_inode_table(struct super_block *sb, ext4_group_t group, ...@@ -1137,7 +1137,7 @@ int ext4_init_inode_table(struct super_block *sb, ext4_group_t group,
if (gdp->bg_flags & cpu_to_le16(EXT4_BG_INODE_ZEROED)) if (gdp->bg_flags & cpu_to_le16(EXT4_BG_INODE_ZEROED))
goto out; goto out;
handle = ext4_journal_start_sb(sb, 1); handle = ext4_journal_start_sb(sb, EXT4_HT_MISC, 1);
if (IS_ERR(handle)) { if (IS_ERR(handle)) {
ret = PTR_ERR(handle); ret = PTR_ERR(handle);
goto out; goto out;
......
...@@ -791,7 +791,7 @@ ssize_t ext4_ind_direct_IO(int rw, struct kiocb *iocb, ...@@ -791,7 +791,7 @@ ssize_t ext4_ind_direct_IO(int rw, struct kiocb *iocb,
if (final_size > inode->i_size) { if (final_size > inode->i_size) {
/* Credits for sb + inode write */ /* Credits for sb + inode write */
handle = ext4_journal_start(inode, 2); handle = ext4_journal_start(inode, EXT4_HT_INODE, 2);
if (IS_ERR(handle)) { if (IS_ERR(handle)) {
ret = PTR_ERR(handle); ret = PTR_ERR(handle);
goto out; goto out;
...@@ -851,7 +851,7 @@ ssize_t ext4_ind_direct_IO(int rw, struct kiocb *iocb, ...@@ -851,7 +851,7 @@ ssize_t ext4_ind_direct_IO(int rw, struct kiocb *iocb,
int err; int err;
/* Credits for sb + inode write */ /* Credits for sb + inode write */
handle = ext4_journal_start(inode, 2); handle = ext4_journal_start(inode, EXT4_HT_INODE, 2);
if (IS_ERR(handle)) { if (IS_ERR(handle)) {
/* This is really bad luck. We've written the data /* This is really bad luck. We've written the data
* but cannot extend i_size. Bail out and pretend * but cannot extend i_size. Bail out and pretend
...@@ -950,7 +950,8 @@ static handle_t *start_transaction(struct inode *inode) ...@@ -950,7 +950,8 @@ static handle_t *start_transaction(struct inode *inode)
{ {
handle_t *result; handle_t *result;
result = ext4_journal_start(inode, ext4_blocks_for_truncate(inode)); result = ext4_journal_start(inode, EXT4_HT_TRUNCATE,
ext4_blocks_for_truncate(inode));
if (!IS_ERR(result)) if (!IS_ERR(result))
return result; return result;
......
...@@ -545,7 +545,7 @@ static int ext4_convert_inline_data_to_extent(struct address_space *mapping, ...@@ -545,7 +545,7 @@ static int ext4_convert_inline_data_to_extent(struct address_space *mapping,
return ret; return ret;
retry: retry:
handle = ext4_journal_start(inode, needed_blocks); handle = ext4_journal_start(inode, EXT4_HT_WRITE_PAGE, needed_blocks);
if (IS_ERR(handle)) { if (IS_ERR(handle)) {
ret = PTR_ERR(handle); ret = PTR_ERR(handle);
handle = NULL; handle = NULL;
...@@ -657,7 +657,7 @@ int ext4_try_to_write_inline_data(struct address_space *mapping, ...@@ -657,7 +657,7 @@ int ext4_try_to_write_inline_data(struct address_space *mapping,
* The possible write could happen in the inode, * The possible write could happen in the inode,
* so try to reserve the space in inode first. * so try to reserve the space in inode first.
*/ */
handle = ext4_journal_start(inode, 1); handle = ext4_journal_start(inode, EXT4_HT_INODE, 1);
if (IS_ERR(handle)) { if (IS_ERR(handle)) {
ret = PTR_ERR(handle); ret = PTR_ERR(handle);
handle = NULL; handle = NULL;
...@@ -853,7 +853,7 @@ int ext4_da_write_inline_data_begin(struct address_space *mapping, ...@@ -853,7 +853,7 @@ int ext4_da_write_inline_data_begin(struct address_space *mapping,
if (ret) if (ret)
return ret; return ret;
handle = ext4_journal_start(inode, 1); handle = ext4_journal_start(inode, EXT4_HT_INODE, 1);
if (IS_ERR(handle)) { if (IS_ERR(handle)) {
ret = PTR_ERR(handle); ret = PTR_ERR(handle);
handle = NULL; handle = NULL;
...@@ -1770,7 +1770,7 @@ void ext4_inline_data_truncate(struct inode *inode, int *has_inline) ...@@ -1770,7 +1770,7 @@ void ext4_inline_data_truncate(struct inode *inode, int *has_inline)
needed_blocks = ext4_writepage_trans_blocks(inode); needed_blocks = ext4_writepage_trans_blocks(inode);
handle = ext4_journal_start(inode, needed_blocks); handle = ext4_journal_start(inode, EXT4_HT_INODE, needed_blocks);
if (IS_ERR(handle)) if (IS_ERR(handle))
return; return;
...@@ -1862,7 +1862,7 @@ int ext4_convert_inline_data(struct inode *inode) ...@@ -1862,7 +1862,7 @@ int ext4_convert_inline_data(struct inode *inode)
if (error) if (error)
return error; return error;
handle = ext4_journal_start(inode, needed_blocks); handle = ext4_journal_start(inode, EXT4_HT_WRITE_PAGE, needed_blocks);
if (IS_ERR(handle)) { if (IS_ERR(handle)) {
error = PTR_ERR(handle); error = PTR_ERR(handle);
goto out_free; goto out_free;
......
...@@ -234,7 +234,8 @@ void ext4_evict_inode(struct inode *inode) ...@@ -234,7 +234,8 @@ void ext4_evict_inode(struct inode *inode)
* protection against it * protection against it
*/ */
sb_start_intwrite(inode->i_sb); sb_start_intwrite(inode->i_sb);
handle = ext4_journal_start(inode, ext4_blocks_for_truncate(inode)+3); handle = ext4_journal_start(inode, EXT4_HT_TRUNCATE,
ext4_blocks_for_truncate(inode)+3);
if (IS_ERR(handle)) { if (IS_ERR(handle)) {
ext4_std_error(inode->i_sb, PTR_ERR(handle)); ext4_std_error(inode->i_sb, PTR_ERR(handle));
/* /*
...@@ -656,7 +657,8 @@ static int _ext4_get_block(struct inode *inode, sector_t iblock, ...@@ -656,7 +657,8 @@ static int _ext4_get_block(struct inode *inode, sector_t iblock,
if (map.m_len > DIO_MAX_BLOCKS) if (map.m_len > DIO_MAX_BLOCKS)
map.m_len = DIO_MAX_BLOCKS; map.m_len = DIO_MAX_BLOCKS;
dio_credits = ext4_chunk_trans_blocks(inode, map.m_len); dio_credits = ext4_chunk_trans_blocks(inode, map.m_len);
handle = ext4_journal_start(inode, dio_credits); handle = ext4_journal_start(inode, EXT4_HT_MAP_BLOCKS,
dio_credits);
if (IS_ERR(handle)) { if (IS_ERR(handle)) {
ret = PTR_ERR(handle); ret = PTR_ERR(handle);
return ret; return ret;
...@@ -881,7 +883,7 @@ static int ext4_write_begin(struct file *file, struct address_space *mapping, ...@@ -881,7 +883,7 @@ static int ext4_write_begin(struct file *file, struct address_space *mapping,
} }
retry: retry:
handle = ext4_journal_start(inode, needed_blocks); handle = ext4_journal_start(inode, EXT4_HT_WRITE_PAGE, needed_blocks);
if (IS_ERR(handle)) { if (IS_ERR(handle)) {
ret = PTR_ERR(handle); ret = PTR_ERR(handle);
goto out; goto out;
...@@ -1881,7 +1883,8 @@ static int __ext4_journalled_writepage(struct page *page, ...@@ -1881,7 +1883,8 @@ static int __ext4_journalled_writepage(struct page *page,
* references to buffers so we are safe */ * references to buffers so we are safe */
unlock_page(page); unlock_page(page);
handle = ext4_journal_start(inode, ext4_writepage_trans_blocks(inode)); handle = ext4_journal_start(inode, EXT4_HT_WRITE_PAGE,
ext4_writepage_trans_blocks(inode));
if (IS_ERR(handle)) { if (IS_ERR(handle)) {
ret = PTR_ERR(handle); ret = PTR_ERR(handle);
goto out; goto out;
...@@ -2312,7 +2315,8 @@ static int ext4_da_writepages(struct address_space *mapping, ...@@ -2312,7 +2315,8 @@ static int ext4_da_writepages(struct address_space *mapping,
needed_blocks = ext4_da_writepages_trans_blocks(inode); needed_blocks = ext4_da_writepages_trans_blocks(inode);
/* start a new transaction*/ /* start a new transaction*/
handle = ext4_journal_start(inode, needed_blocks); handle = ext4_journal_start(inode, EXT4_HT_WRITE_PAGE,
needed_blocks);
if (IS_ERR(handle)) { if (IS_ERR(handle)) {
ret = PTR_ERR(handle); ret = PTR_ERR(handle);
ext4_msg(inode->i_sb, KERN_CRIT, "%s: jbd2_start: " ext4_msg(inode->i_sb, KERN_CRIT, "%s: jbd2_start: "
...@@ -2468,7 +2472,7 @@ static int ext4_da_write_begin(struct file *file, struct address_space *mapping, ...@@ -2468,7 +2472,7 @@ static int ext4_da_write_begin(struct file *file, struct address_space *mapping,
* to journalling the i_disksize update if writes to the end * to journalling the i_disksize update if writes to the end
* of file which has an already mapped buffer. * of file which has an already mapped buffer.
*/ */
handle = ext4_journal_start(inode, 1); handle = ext4_journal_start(inode, EXT4_HT_WRITE_PAGE, 1);
if (IS_ERR(handle)) { if (IS_ERR(handle)) {
ret = PTR_ERR(handle); ret = PTR_ERR(handle);
goto out; goto out;
...@@ -4215,8 +4219,9 @@ int ext4_setattr(struct dentry *dentry, struct iattr *attr) ...@@ -4215,8 +4219,9 @@ int ext4_setattr(struct dentry *dentry, struct iattr *attr)
/* (user+group)*(old+new) structure, inode write (sb, /* (user+group)*(old+new) structure, inode write (sb,
* inode block, ? - but truncate inode update has it) */ * inode block, ? - but truncate inode update has it) */
handle = ext4_journal_start(inode, (EXT4_MAXQUOTAS_INIT_BLOCKS(inode->i_sb)+ handle = ext4_journal_start(inode, EXT4_HT_QUOTA,
EXT4_MAXQUOTAS_DEL_BLOCKS(inode->i_sb))+3); (EXT4_MAXQUOTAS_INIT_BLOCKS(inode->i_sb) +
EXT4_MAXQUOTAS_DEL_BLOCKS(inode->i_sb)) + 3);
if (IS_ERR(handle)) { if (IS_ERR(handle)) {
error = PTR_ERR(handle); error = PTR_ERR(handle);
goto err_out; goto err_out;
...@@ -4251,7 +4256,7 @@ int ext4_setattr(struct dentry *dentry, struct iattr *attr) ...@@ -4251,7 +4256,7 @@ int ext4_setattr(struct dentry *dentry, struct iattr *attr)
(attr->ia_size < inode->i_size)) { (attr->ia_size < inode->i_size)) {
handle_t *handle; handle_t *handle;
handle = ext4_journal_start(inode, 3); handle = ext4_journal_start(inode, EXT4_HT_INODE, 3);
if (IS_ERR(handle)) { if (IS_ERR(handle)) {
error = PTR_ERR(handle); error = PTR_ERR(handle);
goto err_out; goto err_out;
...@@ -4271,7 +4276,8 @@ int ext4_setattr(struct dentry *dentry, struct iattr *attr) ...@@ -4271,7 +4276,8 @@ int ext4_setattr(struct dentry *dentry, struct iattr *attr)
attr->ia_size); attr->ia_size);
if (error) { if (error) {
/* Do as much error cleanup as possible */ /* Do as much error cleanup as possible */
handle = ext4_journal_start(inode, 3); handle = ext4_journal_start(inode,
EXT4_HT_INODE, 3);
if (IS_ERR(handle)) { if (IS_ERR(handle)) {
ext4_orphan_del(NULL, inode); ext4_orphan_del(NULL, inode);
goto err_out; goto err_out;
...@@ -4612,7 +4618,7 @@ void ext4_dirty_inode(struct inode *inode, int flags) ...@@ -4612,7 +4618,7 @@ void ext4_dirty_inode(struct inode *inode, int flags)
{ {
handle_t *handle; handle_t *handle;
handle = ext4_journal_start(inode, 2); handle = ext4_journal_start(inode, EXT4_HT_INODE, 2);
if (IS_ERR(handle)) if (IS_ERR(handle))
goto out; goto out;
...@@ -4713,7 +4719,7 @@ int ext4_change_inode_journal_flag(struct inode *inode, int val) ...@@ -4713,7 +4719,7 @@ int ext4_change_inode_journal_flag(struct inode *inode, int val)
/* Finally we can mark the inode as dirty. */ /* Finally we can mark the inode as dirty. */
handle = ext4_journal_start(inode, 1); handle = ext4_journal_start(inode, EXT4_HT_INODE, 1);
if (IS_ERR(handle)) if (IS_ERR(handle))
return PTR_ERR(handle); return PTR_ERR(handle);
...@@ -4791,7 +4797,8 @@ int ext4_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf) ...@@ -4791,7 +4797,8 @@ int ext4_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
else else
get_block = ext4_get_block; get_block = ext4_get_block;
retry_alloc: retry_alloc:
handle = ext4_journal_start(inode, ext4_writepage_trans_blocks(inode)); handle = ext4_journal_start(inode, EXT4_HT_WRITE_PAGE,
ext4_writepage_trans_blocks(inode));
if (IS_ERR(handle)) { if (IS_ERR(handle)) {
ret = VM_FAULT_SIGBUS; ret = VM_FAULT_SIGBUS;
goto out; goto out;
......
...@@ -104,7 +104,7 @@ long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) ...@@ -104,7 +104,7 @@ long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
} else if (oldflags & EXT4_EOFBLOCKS_FL) } else if (oldflags & EXT4_EOFBLOCKS_FL)
ext4_truncate(inode); ext4_truncate(inode);
handle = ext4_journal_start(inode, 1); handle = ext4_journal_start(inode, EXT4_HT_INODE, 1);
if (IS_ERR(handle)) { if (IS_ERR(handle)) {
err = PTR_ERR(handle); err = PTR_ERR(handle);
goto flags_out; goto flags_out;
...@@ -173,7 +173,7 @@ long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) ...@@ -173,7 +173,7 @@ long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
} }
mutex_lock(&inode->i_mutex); mutex_lock(&inode->i_mutex);
handle = ext4_journal_start(inode, 1); handle = ext4_journal_start(inode, EXT4_HT_INODE, 1);
if (IS_ERR(handle)) { if (IS_ERR(handle)) {
err = PTR_ERR(handle); err = PTR_ERR(handle);
goto unlock_out; goto unlock_out;
......
...@@ -456,7 +456,7 @@ int ext4_ext_migrate(struct inode *inode) ...@@ -456,7 +456,7 @@ int ext4_ext_migrate(struct inode *inode)
*/ */
return retval; return retval;
handle = ext4_journal_start(inode, handle = ext4_journal_start(inode, EXT4_HT_MIGRATE,
EXT4_DATA_TRANS_BLOCKS(inode->i_sb) + EXT4_DATA_TRANS_BLOCKS(inode->i_sb) +
EXT4_INDEX_EXTRA_TRANS_BLOCKS + 3 + EXT4_INDEX_EXTRA_TRANS_BLOCKS + 3 +
EXT4_MAXQUOTAS_INIT_BLOCKS(inode->i_sb) EXT4_MAXQUOTAS_INIT_BLOCKS(inode->i_sb)
...@@ -507,7 +507,7 @@ int ext4_ext_migrate(struct inode *inode) ...@@ -507,7 +507,7 @@ int ext4_ext_migrate(struct inode *inode)
ext4_set_inode_state(inode, EXT4_STATE_EXT_MIGRATE); ext4_set_inode_state(inode, EXT4_STATE_EXT_MIGRATE);
up_read((&EXT4_I(inode)->i_data_sem)); up_read((&EXT4_I(inode)->i_data_sem));
handle = ext4_journal_start(inode, 1); handle = ext4_journal_start(inode, EXT4_HT_MIGRATE, 1);
if (IS_ERR(handle)) { if (IS_ERR(handle)) {
/* /*
* It is impossible to update on-disk structures without * It is impossible to update on-disk structures without
......
...@@ -923,7 +923,7 @@ move_extent_per_page(struct file *o_filp, struct inode *donor_inode, ...@@ -923,7 +923,7 @@ move_extent_per_page(struct file *o_filp, struct inode *donor_inode,
again: again:
*err = 0; *err = 0;
jblocks = ext4_writepage_trans_blocks(orig_inode) * 2; jblocks = ext4_writepage_trans_blocks(orig_inode) * 2;
handle = ext4_journal_start(orig_inode, jblocks); handle = ext4_journal_start(orig_inode, EXT4_HT_MOVE_EXTENTS, jblocks);
if (IS_ERR(handle)) { if (IS_ERR(handle)) {
*err = PTR_ERR(handle); *err = PTR_ERR(handle);
return 0; return 0;
......
...@@ -2262,9 +2262,10 @@ static int ext4_create(struct inode *dir, struct dentry *dentry, umode_t mode, ...@@ -2262,9 +2262,10 @@ static int ext4_create(struct inode *dir, struct dentry *dentry, umode_t mode,
dquot_initialize(dir); dquot_initialize(dir);
retry: retry:
handle = ext4_journal_start(dir, EXT4_DATA_TRANS_BLOCKS(dir->i_sb) + handle = ext4_journal_start(dir, EXT4_HT_DIR,
EXT4_INDEX_EXTRA_TRANS_BLOCKS + 3 + (EXT4_DATA_TRANS_BLOCKS(dir->i_sb) +
EXT4_MAXQUOTAS_INIT_BLOCKS(dir->i_sb)); EXT4_INDEX_EXTRA_TRANS_BLOCKS + 3 +
EXT4_MAXQUOTAS_INIT_BLOCKS(dir->i_sb)));
if (IS_ERR(handle)) if (IS_ERR(handle))
return PTR_ERR(handle); return PTR_ERR(handle);
...@@ -2298,9 +2299,10 @@ static int ext4_mknod(struct inode *dir, struct dentry *dentry, ...@@ -2298,9 +2299,10 @@ static int ext4_mknod(struct inode *dir, struct dentry *dentry,
dquot_initialize(dir); dquot_initialize(dir);
retry: retry:
handle = ext4_journal_start(dir, EXT4_DATA_TRANS_BLOCKS(dir->i_sb) + handle = ext4_journal_start(dir, EXT4_HT_DIR,
EXT4_INDEX_EXTRA_TRANS_BLOCKS + 3 + (EXT4_DATA_TRANS_BLOCKS(dir->i_sb) +
EXT4_MAXQUOTAS_INIT_BLOCKS(dir->i_sb)); EXT4_INDEX_EXTRA_TRANS_BLOCKS + 3 +
EXT4_MAXQUOTAS_INIT_BLOCKS(dir->i_sb)));
if (IS_ERR(handle)) if (IS_ERR(handle))
return PTR_ERR(handle); return PTR_ERR(handle);
...@@ -2414,9 +2416,10 @@ static int ext4_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) ...@@ -2414,9 +2416,10 @@ static int ext4_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
dquot_initialize(dir); dquot_initialize(dir);
retry: retry:
handle = ext4_journal_start(dir, EXT4_DATA_TRANS_BLOCKS(dir->i_sb) + handle = ext4_journal_start(dir, EXT4_HT_DIR,
EXT4_INDEX_EXTRA_TRANS_BLOCKS + 3 + (EXT4_DATA_TRANS_BLOCKS(dir->i_sb) +
EXT4_MAXQUOTAS_INIT_BLOCKS(dir->i_sb)); EXT4_INDEX_EXTRA_TRANS_BLOCKS + 3 +
EXT4_MAXQUOTAS_INIT_BLOCKS(dir->i_sb)));
if (IS_ERR(handle)) if (IS_ERR(handle))
return PTR_ERR(handle); return PTR_ERR(handle);
...@@ -2729,7 +2732,8 @@ static int ext4_rmdir(struct inode *dir, struct dentry *dentry) ...@@ -2729,7 +2732,8 @@ static int ext4_rmdir(struct inode *dir, struct dentry *dentry)
dquot_initialize(dir); dquot_initialize(dir);
dquot_initialize(dentry->d_inode); dquot_initialize(dentry->d_inode);
handle = ext4_journal_start(dir, EXT4_DELETE_TRANS_BLOCKS(dir->i_sb)); handle = ext4_journal_start(dir, EXT4_HT_DIR,
EXT4_DELETE_TRANS_BLOCKS(dir->i_sb));
if (IS_ERR(handle)) if (IS_ERR(handle))
return PTR_ERR(handle); return PTR_ERR(handle);
...@@ -2791,7 +2795,8 @@ static int ext4_unlink(struct inode *dir, struct dentry *dentry) ...@@ -2791,7 +2795,8 @@ static int ext4_unlink(struct inode *dir, struct dentry *dentry)
dquot_initialize(dir); dquot_initialize(dir);
dquot_initialize(dentry->d_inode); dquot_initialize(dentry->d_inode);
handle = ext4_journal_start(dir, EXT4_DELETE_TRANS_BLOCKS(dir->i_sb)); handle = ext4_journal_start(dir, EXT4_HT_DIR,
EXT4_DELETE_TRANS_BLOCKS(dir->i_sb));
if (IS_ERR(handle)) if (IS_ERR(handle))
return PTR_ERR(handle); return PTR_ERR(handle);
...@@ -2870,7 +2875,7 @@ static int ext4_symlink(struct inode *dir, ...@@ -2870,7 +2875,7 @@ static int ext4_symlink(struct inode *dir,
EXT4_MAXQUOTAS_INIT_BLOCKS(dir->i_sb); EXT4_MAXQUOTAS_INIT_BLOCKS(dir->i_sb);
} }
retry: retry:
handle = ext4_journal_start(dir, credits); handle = ext4_journal_start(dir, EXT4_HT_DIR, credits);
if (IS_ERR(handle)) if (IS_ERR(handle))
return PTR_ERR(handle); return PTR_ERR(handle);
...@@ -2908,7 +2913,7 @@ static int ext4_symlink(struct inode *dir, ...@@ -2908,7 +2913,7 @@ static int ext4_symlink(struct inode *dir,
* Now inode is being linked into dir (EXT4_DATA_TRANS_BLOCKS * Now inode is being linked into dir (EXT4_DATA_TRANS_BLOCKS
* + EXT4_INDEX_EXTRA_TRANS_BLOCKS), inode is also modified * + EXT4_INDEX_EXTRA_TRANS_BLOCKS), inode is also modified
*/ */
handle = ext4_journal_start(dir, handle = ext4_journal_start(dir, EXT4_HT_DIR,
EXT4_DATA_TRANS_BLOCKS(dir->i_sb) + EXT4_DATA_TRANS_BLOCKS(dir->i_sb) +
EXT4_INDEX_EXTRA_TRANS_BLOCKS + 1); EXT4_INDEX_EXTRA_TRANS_BLOCKS + 1);
if (IS_ERR(handle)) { if (IS_ERR(handle)) {
...@@ -2955,8 +2960,9 @@ static int ext4_link(struct dentry *old_dentry, ...@@ -2955,8 +2960,9 @@ static int ext4_link(struct dentry *old_dentry,
dquot_initialize(dir); dquot_initialize(dir);
retry: retry:
handle = ext4_journal_start(dir, EXT4_DATA_TRANS_BLOCKS(dir->i_sb) + handle = ext4_journal_start(dir, EXT4_HT_DIR,
EXT4_INDEX_EXTRA_TRANS_BLOCKS); (EXT4_DATA_TRANS_BLOCKS(dir->i_sb) +
EXT4_INDEX_EXTRA_TRANS_BLOCKS));
if (IS_ERR(handle)) if (IS_ERR(handle))
return PTR_ERR(handle); return PTR_ERR(handle);
...@@ -3039,9 +3045,9 @@ static int ext4_rename(struct inode *old_dir, struct dentry *old_dentry, ...@@ -3039,9 +3045,9 @@ static int ext4_rename(struct inode *old_dir, struct dentry *old_dentry,
* in separate transaction */ * in separate transaction */
if (new_dentry->d_inode) if (new_dentry->d_inode)
dquot_initialize(new_dentry->d_inode); dquot_initialize(new_dentry->d_inode);
handle = ext4_journal_start(old_dir, 2 * handle = ext4_journal_start(old_dir, EXT4_HT_DIR,
EXT4_DATA_TRANS_BLOCKS(old_dir->i_sb) + (2 * EXT4_DATA_TRANS_BLOCKS(old_dir->i_sb) +
EXT4_INDEX_EXTRA_TRANS_BLOCKS + 2); EXT4_INDEX_EXTRA_TRANS_BLOCKS + 2));
if (IS_ERR(handle)) if (IS_ERR(handle))
return PTR_ERR(handle); return PTR_ERR(handle);
......
...@@ -466,7 +466,7 @@ static int setup_new_flex_group_blocks(struct super_block *sb, ...@@ -466,7 +466,7 @@ static int setup_new_flex_group_blocks(struct super_block *sb,
meta_bg = EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_META_BG); meta_bg = EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_META_BG);
/* This transaction may be extended/restarted along the way */ /* This transaction may be extended/restarted along the way */
handle = ext4_journal_start_sb(sb, EXT4_MAX_TRANS_DATA); handle = ext4_journal_start_sb(sb, EXT4_HT_RESIZE, EXT4_MAX_TRANS_DATA);
if (IS_ERR(handle)) if (IS_ERR(handle))
return PTR_ERR(handle); return PTR_ERR(handle);
...@@ -1031,7 +1031,7 @@ static void update_backups(struct super_block *sb, int blk_off, char *data, ...@@ -1031,7 +1031,7 @@ static void update_backups(struct super_block *sb, int blk_off, char *data,
handle_t *handle; handle_t *handle;
int err = 0, err2; int err = 0, err2;
handle = ext4_journal_start_sb(sb, EXT4_MAX_TRANS_DATA); handle = ext4_journal_start_sb(sb, EXT4_HT_RESIZE, EXT4_MAX_TRANS_DATA);
if (IS_ERR(handle)) { if (IS_ERR(handle)) {
group = 1; group = 1;
err = PTR_ERR(handle); err = PTR_ERR(handle);
...@@ -1412,7 +1412,7 @@ static int ext4_flex_group_add(struct super_block *sb, ...@@ -1412,7 +1412,7 @@ static int ext4_flex_group_add(struct super_block *sb,
* modify each of the reserved GDT dindirect blocks. * modify each of the reserved GDT dindirect blocks.
*/ */
credit = flex_gd->count * 4 + reserved_gdb; credit = flex_gd->count * 4 + reserved_gdb;
handle = ext4_journal_start_sb(sb, credit); handle = ext4_journal_start_sb(sb, EXT4_HT_RESIZE, credit);
if (IS_ERR(handle)) { if (IS_ERR(handle)) {
err = PTR_ERR(handle); err = PTR_ERR(handle);
goto exit; goto exit;
...@@ -1624,7 +1624,7 @@ static int ext4_group_extend_no_check(struct super_block *sb, ...@@ -1624,7 +1624,7 @@ static int ext4_group_extend_no_check(struct super_block *sb,
/* We will update the superblock, one block bitmap, and /* We will update the superblock, one block bitmap, and
* one group descriptor via ext4_group_add_blocks(). * one group descriptor via ext4_group_add_blocks().
*/ */
handle = ext4_journal_start_sb(sb, 3); handle = ext4_journal_start_sb(sb, EXT4_HT_RESIZE, 3);
if (IS_ERR(handle)) { if (IS_ERR(handle)) {
err = PTR_ERR(handle); err = PTR_ERR(handle);
ext4_warning(sb, "error %d on journal start", err); 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,7 +1788,7 @@ static int ext4_convert_meta_bg(struct super_block *sb, struct inode *inode)
credits += 3; /* block bitmap, bg descriptor, resize inode */ credits += 3; /* block bitmap, bg descriptor, resize inode */
} }
handle = ext4_journal_start_sb(sb, credits); handle = ext4_journal_start_sb(sb, EXT4_HT_RESIZE, credits);
if (IS_ERR(handle)) if (IS_ERR(handle))
return PTR_ERR(handle); return PTR_ERR(handle);
......
...@@ -4762,7 +4762,7 @@ static int ext4_write_dquot(struct dquot *dquot) ...@@ -4762,7 +4762,7 @@ static int ext4_write_dquot(struct dquot *dquot)
struct inode *inode; struct inode *inode;
inode = dquot_to_inode(dquot); inode = dquot_to_inode(dquot);
handle = ext4_journal_start(inode, handle = ext4_journal_start(inode, EXT4_HT_QUOTA,
EXT4_QUOTA_TRANS_BLOCKS(dquot->dq_sb)); EXT4_QUOTA_TRANS_BLOCKS(dquot->dq_sb));
if (IS_ERR(handle)) if (IS_ERR(handle))
return PTR_ERR(handle); return PTR_ERR(handle);
...@@ -4778,7 +4778,7 @@ static int ext4_acquire_dquot(struct dquot *dquot) ...@@ -4778,7 +4778,7 @@ static int ext4_acquire_dquot(struct dquot *dquot)
int ret, err; int ret, err;
handle_t *handle; handle_t *handle;
handle = ext4_journal_start(dquot_to_inode(dquot), handle = ext4_journal_start(dquot_to_inode(dquot), EXT4_HT_QUOTA,
EXT4_QUOTA_INIT_BLOCKS(dquot->dq_sb)); EXT4_QUOTA_INIT_BLOCKS(dquot->dq_sb));
if (IS_ERR(handle)) if (IS_ERR(handle))
return PTR_ERR(handle); return PTR_ERR(handle);
...@@ -4794,7 +4794,7 @@ static int ext4_release_dquot(struct dquot *dquot) ...@@ -4794,7 +4794,7 @@ static int ext4_release_dquot(struct dquot *dquot)
int ret, err; int ret, err;
handle_t *handle; handle_t *handle;
handle = ext4_journal_start(dquot_to_inode(dquot), handle = ext4_journal_start(dquot_to_inode(dquot), EXT4_HT_QUOTA,
EXT4_QUOTA_DEL_BLOCKS(dquot->dq_sb)); EXT4_QUOTA_DEL_BLOCKS(dquot->dq_sb));
if (IS_ERR(handle)) { if (IS_ERR(handle)) {
/* Release dquot anyway to avoid endless cycle in dqput() */ /* 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,7 +4826,7 @@ static int ext4_write_info(struct super_block *sb, int type)
handle_t *handle; handle_t *handle;
/* Data block + inode block */ /* Data block + inode block */
handle = ext4_journal_start(sb->s_root->d_inode, 2); handle = ext4_journal_start(sb->s_root->d_inode, EXT4_HT_QUOTA, 2);
if (IS_ERR(handle)) if (IS_ERR(handle))
return PTR_ERR(handle); return PTR_ERR(handle);
ret = dquot_commit_info(sb, type); ret = dquot_commit_info(sb, type);
...@@ -4972,7 +4972,7 @@ static int ext4_quota_off(struct super_block *sb, int type) ...@@ -4972,7 +4972,7 @@ static int ext4_quota_off(struct super_block *sb, int type)
/* Update modification times of quota files when userspace can /* Update modification times of quota files when userspace can
* start looking at them */ * start looking at them */
handle = ext4_journal_start(inode, 1); handle = ext4_journal_start(inode, EXT4_HT_QUOTA, 1);
if (IS_ERR(handle)) if (IS_ERR(handle))
goto out; goto out;
inode->i_mtime = inode->i_ctime = CURRENT_TIME; inode->i_mtime = inode->i_ctime = CURRENT_TIME;
......
...@@ -1175,7 +1175,7 @@ ext4_xattr_set(struct inode *inode, int name_index, const char *name, ...@@ -1175,7 +1175,7 @@ ext4_xattr_set(struct inode *inode, int name_index, const char *name,
if (ext4_has_inline_data(inode)) if (ext4_has_inline_data(inode))
credits += ext4_writepage_trans_blocks(inode) + 1; credits += ext4_writepage_trans_blocks(inode) + 1;
handle = ext4_journal_start(inode, credits); handle = ext4_journal_start(inode, EXT4_HT_XATTR, credits);
if (IS_ERR(handle)) { if (IS_ERR(handle)) {
error = PTR_ERR(handle); error = PTR_ERR(handle);
} else { } else {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册