ext4: Fix missing acl release in error path in acl.c
Subsystems (3)
PATCH v2 1/3 ext4: Fix missing acl release in error path in acl.c
a) Incase journal transaction allocation
fails due to ENOMEM don't call ext4_std_error() since it will remount the fs as readonly and logs the message in kernel log.
b) Call posix_acl_release() incase journal allocation fails in case of error paths.
--- fs/ext4/acl.c | 9 ++++++--- 1 files changed, 6 insertions(+), 3 deletions(-)
fs/ext4/acl.c +6 -3
@@ -354,7 +354,8 @@ ext4_acl_chmod(struct inode *inode) EXT4_DATA_TRANS_BLOCKS(inode->i_sb));if (IS_ERR (handle)) { error =PTR_ERR (handle); -ext4_std_error (inode->i_sb, error); +if (error != -ENOMEM ) +ext4_std_error (inode->i_sb, error); goto out; } error =ext4_set_acl (handle, inode,ACL_TYPE_ACCESS , clone);
@@ -450,8 +451,10 @@ ext4_xattr_set_acl(struct dentry *dentry, const char *name, const void *value, retry: handle =ext4_journal_start (inode,EXT4_DATA_TRANS_BLOCKS (inode->i_sb)); -if (IS_ERR (handle)) -return PTR_ERR (handle); +if (IS_ERR (handle)) { + error =PTR_ERR (handle); + goto release_and_out; + } error =ext4_set_acl (handle, inode, type, acl);ext4_journal_stop (handle);if (error == -ENOSPC &&ext4_should_retry_alloc (inode->i_sb, &retries))
Signature · 1 line
1.7.4.1
PATCH v2 2/3 jbd2: Add extra parameter in start_this_handle() to control allocation flags.
changes from v1 -> v2 :
*) Update start_this_handle to take extra parameter to specify whether
to retry the allocation or not.
*) Added jbd allocation flags for callers to control the transaction allocation behavior. Callers can pass JBD2_TOPLEVEL if allocation needs to be done using GFP_KERNEL.
Pass extra flags in journal routines to specify if its ok to
fail in the journal transaction allocation. Passing JBD2_FAIL_OK means caller is ok with journal start failures and can handle ENOMEM.
Update ocfs2 and ext4 routines to pass JBD2_NO_FAIL for the updated journal interface by default, to retain the existing behavior.
--- fs/ext4/ext4_jbd2.h | 2 +- fs/ext4/super.c | 2 +- fs/jbd2/transaction.c | 44 ++++++++++++++++---------------------------- fs/ocfs2/journal.c | 8 ++++---- include/linux/jbd2.h | 13 +++++++++---- 5 files changed, 31 insertions(+), 38 deletions(-)
fs/ext4/ext4_jbd2.h +1 -1
@@ -220,7 +220,7 @@ static inline int ext4_journal_extend(handle_t *handle, int nblocks)static inline int ext4_journal_restart (handle_t *handle,int nblocks) {if (ext4_handle_valid (handle)) -return jbd2_journal_restart (handle, nblocks); +return jbd2_journal_restart (handle, nblocks,JBD2_NO_FAIL );return 0 ; }
fs/ext4/super.c +1 -1
@@ -295,7 +295,7 @@ handle_t *ext4_journal_start_sb(struct super_block *sb, int nblocks)ext4_abort (sb,"Detected aborted journal" );return ERR_PTR (-EROFS ); } -return jbd2_journal_start (journal, nblocks); +return jbd2_journal_start (journal, nblocks,JBD2_NO_FAIL ); }/*
fs/jbd2/transaction.c +16 -28
112 lines not on this page · raw message
fs/ocfs2/journal.c +4 -4
@@ -353,11 +353,11 @@ handle_t *ocfs2_start_trans(struct ocfs2_super *osb, int max_buffs)/* Nested transaction? Just return the handle... */ if (journal_current_handle ()) -return jbd2_journal_start (journal, max_buffs); +return jbd2_journal_start (journal, max_buffs,JBD2_NO_FAIL );down_read (&osb->journal->j_trans_barrier); - handle =jbd2_journal_start (journal, max_buffs); + handle =jbd2_journal_start (journal, max_buffs,JBD2_NO_FAIL );if (IS_ERR (handle)) {up_read (&osb->journal->j_trans_barrier);
@@ -437,8 +437,8 @@ int ocfs2_extend_trans(handle_t *handle, int nblocks)if (status >0 ) {trace_ocfs2_extend_trans_restart (old_nblocks + nblocks); - status =jbd2_journal_restart (handle, - old_nblocks + nblocks); + status =jbd2_journal_restart (handle, old_nblocks + nblocks, +JBD2_NO_FAIL );if (status <0 ) {mlog_errno (status); goto bail;
include/linux/jbd2.h +9 -4
@@ -1106,10 +1106,10 @@ static inline handle_t *journal_current_handle(void)* Register buffer modifications against the current transaction. */ -extern handle_t *jbd2_journal_start (journal_t *,int nblocks); -extern handle_t *jbd2__journal_start (journal_t *,int nblocks,int gfp_mask); -extern int jbd2_journal_restart (handle_t *,int nblocks); -extern int jbd2__journal_restart (handle_t *,int nblocks,int gfp_mask); +extern handle_t *jbd2_journal_start (journal_t *, +int nblocks,int jbd_alloc_flags); +extern int jbd2_journal_restart (handle_t *, +int nblocks,int jbd_alloc_flags);extern int jbd2_journal_extend (handle_t *,int nblocks);extern int jbd2_journal_get_write_access (handle_t *,struct buffer_head *);extern int jbd2_journal_get_create_access (handle_t *,struct buffer_head *);
@@ -1322,6 +1322,11 @@ static inline int jbd_space_needed(journal_t *journal)extern int jbd_blocks_per_page (struct inode *inode); +/* JBD2 transaction allocation flags */ +#define JBD2_NO_FAIL 0x00000001 +#define JBD2_FAIL_OK 0x00000002 +#define JBD2_TOPLEVEL 0x00000004 +#ifdef __KERNEL__#define buffer_trace_init (bh) do {} while (0)
Signature · 1 line
1.7.4.1
PATCH v2 3/3 ext4: Fix ext4 to use pass jbd allocation flags if they can handle ENOMEM.
In reply to Manish KatiyarThis patch updates ext4 code to pass appropriate transaction allocation flags to callers who are safe to deal with ENOMEM. Pass JBD2_TOPLEVEL from the callers who are safe to do allocations with GFP_KERNEL instead of GFP_NOFS.
--- fs/ext4/acl.c | 6 ++++-- fs/ext4/ext4_jbd2.h | 8 +++++--- fs/ext4/extents.c | 11 ++++++----- fs/ext4/ialloc.c | 2 +- fs/ext4/inode.c | 40 ++++++++++++++++++++++++---------------- fs/ext4/ioctl.c | 6 ++++-- fs/ext4/migrate.c | 10 +++++----- fs/ext4/move_extent.c | 3 ++- fs/ext4/namei.c | 47 ++++++++++++++++++++++++++++++----------------- fs/ext4/resize.c | 8 ++++---- fs/ext4/super.c | 18 +++++++++++------- fs/ext4/xattr.c | 3 ++- 12 files changed, 98 insertions(+), 64 deletions(-)
fs/ext4/acl.c +4 -2
@@ -351,7 +351,8 @@ ext4_acl_chmod(struct inode *inode) retry: handle =ext4_journal_start (inode, -EXT4_DATA_TRANS_BLOCKS (inode->i_sb)); +EXT4_DATA_TRANS_BLOCKS (inode->i_sb), + (JBD2_FAIL_OK |JBD2_TOPLEVEL ));if (IS_ERR (handle)) { error =PTR_ERR (handle);if (error != -ENOMEM )
@@ -450,7 +451,8 @@ ext4_xattr_set_acl(struct dentry *dentry, const char *name, const void *value, acl =NULL ; retry: - handle =ext4_journal_start (inode,EXT4_DATA_TRANS_BLOCKS (inode->i_sb)); + handle =ext4_journal_start (inode,EXT4_DATA_TRANS_BLOCKS (inode->i_sb), + (JBD2_FAIL_OK |JBD2_TOPLEVEL ));if (IS_ERR (handle)) { error =PTR_ERR (handle); goto release_and_out;
fs/ext4/ext4_jbd2.h +5 -3
@@ -156,7 +156,8 @@ int __ext4_handle_dirty_super(const char *where, unsigned int line,#define ext4_handle_dirty_super (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, +int nblocks,int jbd_alloc_flags);int __ext4_journal_stop (const char *where,unsigned int line,handle_t *handle);#define EXT4_NOJOURNAL_MAX_REF_COUNT ((unsigned long) 4096)
@@ -197,9 +198,10 @@ static inline int ext4_handle_has_enough_credits(handle_t *handle, int needed)return 1 ; } -static inline handle_t *ext4_journal_start (struct inode *inode,int nblocks) +static inline handle_t *ext4_journal_start (struct inode *inode, +int nblocks,int jbd_alloc_flags) { -return ext4_journal_start_sb (inode->i_sb, nblocks); +return ext4_journal_start_sb (inode->i_sb, nblocks, jbd_alloc_flags); }#define ext4_journal_stop (handle) \
fs/ext4/extents.c +6 -5
@@ -2546,7 +2546,7 @@ static int ext4_ext_remove_space(struct inode *inode, ext4_lblk_t start,ext_debug ("truncate since %u\n" , start);/* probably first extent we're gonna free will be last in block */ - handle =ext4_journal_start (inode, depth +1 ); + handle =ext4_journal_start (inode, depth +1 ,JBD2_NO_FAIL );if (IS_ERR (handle))return PTR_ERR (handle);
@@ -3672,7 +3672,7 @@ void ext4_ext_truncate(struct inode *inode)* probably first extent we're gonna free will be last in block */ err =ext4_writepage_trans_blocks (inode); - handle =ext4_journal_start (inode, err); + handle =ext4_journal_start (inode, err,JBD2_NO_FAIL );if (IS_ERR (handle))return ;
@@ -3811,7 +3811,8 @@ retry:while (ret >=0 && ret < max_blocks) { map.m_lblk = map.m_lblk + ret; map.m_len = max_blocks = max_blocks - ret; - handle =ext4_journal_start (inode, credits); + handle =ext4_journal_start (inode, credits, + (JBD2_FAIL_OK |JBD2_TOPLEVEL ));if (IS_ERR (handle)) { ret =PTR_ERR (handle);break ;
@@ -3889,7 +3890,7 @@ int ext4_convert_unwritten_extents(struct inode *inode, loff_t offset,while (ret >=0 && ret < max_blocks) { map.m_lblk += ret; map.m_len = (max_blocks -= ret); - handle =ext4_journal_start (inode, credits); + handle =ext4_journal_start (inode, credits,JBD2_NO_FAIL );if (IS_ERR (handle)) { ret =PTR_ERR (handle);break ;
@@ -4215,7 +4216,7 @@ int ext4_ext_punch_hole(struct file *file, loff_t offset, loff_t length)ext4_flush_completed_IO (inode); credits =ext4_writepage_trans_blocks (inode); - handle =ext4_journal_start (inode, credits); + handle =ext4_journal_start (inode, credits,JBD2_NO_FAIL );if (IS_ERR (handle))return PTR_ERR (handle);
fs/ext4/ialloc.c +1 -1
@@ -1263,7 +1263,7 @@ extern int ext4_init_inode_table(struct super_block *sb, ext4_group_t group,if (gdp->bg_flags &cpu_to_le16 (EXT4_BG_INODE_ZEROED )) goto out; - handle =ext4_journal_start_sb (sb,1 ); + handle =ext4_journal_start_sb (sb,1 ,JBD2_NO_FAIL );if (IS_ERR (handle)) { ret =PTR_ERR (handle); goto out;
fs/ext4/inode.c +24 -16
@@ -129,7 +129,8 @@ static handle_t *start_transaction(struct inode *inode) {handle_t *result; - result =ext4_journal_start (inode,blocks_for_truncate (inode)); + result =ext4_journal_start (inode, +blocks_for_truncate (inode),JBD2_NO_FAIL );if (!IS_ERR (result))return result;
@@ -204,7 +205,8 @@ void ext4_evict_inode(struct inode *inode)if (is_bad_inode (inode)) goto no_delete; - handle =ext4_journal_start (inode,blocks_for_truncate (inode)+3 ); + handle =ext4_journal_start (inode, +blocks_for_truncate (inode)+3 ,JBD2_NO_FAIL );if (IS_ERR (handle)) {ext4_std_error (inode->i_sb,PTR_ERR (handle));/*
@@ -1401,7 +1403,7 @@ static int _ext4_get_block(struct inode *inode, sector_t iblock,if (map.m_len >DIO_MAX_BLOCKS ) map.m_len =DIO_MAX_BLOCKS ; dio_credits =ext4_chunk_trans_blocks (inode, map.m_len); - handle =ext4_journal_start (inode, dio_credits); + handle =ext4_journal_start (inode, dio_credits,JBD2_NO_FAIL );if (IS_ERR (handle)) { ret =PTR_ERR (handle);return ret;
@@ -1624,7 +1626,7 @@ static int ext4_write_begin(struct file *file, struct address_space *mapping, to = from + len; retry: - handle =ext4_journal_start (inode, needed_blocks); + handle =ext4_journal_start (inode, needed_blocks,JBD2_FAIL_OK );if (IS_ERR (handle)) { ret =PTR_ERR (handle); goto out;
@@ -2558,7 +2560,8 @@ static int __ext4_journalled_writepage(struct page *page,* references to buffers so we are safe */ unlock_page (page); - handle =ext4_journal_start (inode,ext4_writepage_trans_blocks (inode)); + handle =ext4_journal_start (inode,ext4_writepage_trans_blocks (inode), +JBD2_NO_FAIL );if (IS_ERR (handle)) { ret =PTR_ERR (handle); goto out;
@@ -2988,7 +2991,7 @@ retry: needed_blocks =ext4_da_writepages_trans_blocks (inode);/* start a new transaction*/ - handle =ext4_journal_start (inode, needed_blocks); + handle =ext4_journal_start (inode, needed_blocks,JBD2_NO_FAIL );if (IS_ERR (handle)) { ret =PTR_ERR (handle); ext4_msg(inode->i_sb, KERN_CRIT, "%s: jbd2_start: "
@@ -3124,7 +3127,7 @@ retry:* to journalling the i_disksize update if writes to the end * of file which has an already mapped buffer. */ - handle =ext4_journal_start (inode,1 ); + handle =ext4_journal_start (inode,1 ,JBD2_FAIL_OK );if (IS_ERR (handle)) { ret =PTR_ERR (handle); goto out;
@@ -3478,7 +3481,7 @@ static ssize_t ext4_ind_direct_IO(int rw, struct kiocb *iocb,if (final_size > inode->i_size) {/* Credits for sb + inode write */ - handle =ext4_journal_start (inode,2 ); + handle =ext4_journal_start (inode,2 ,JBD2_FAIL_OK );if (IS_ERR (handle)) { ret =PTR_ERR (handle); goto out;
@@ -3521,7 +3524,7 @@ retry:int err;/* Credits for sb + inode write */ - handle =ext4_journal_start (inode,2 ); + handle =ext4_journal_start (inode,2 ,JBD2_NO_FAIL );if (IS_ERR (handle)) {/* This is really bad luck. We've written the data * but cannot extend i_size. Bail out and pretend
@@ -5329,8 +5332,10 @@ int ext4_setattr(struct dentry *dentry, struct iattr *attr)/* (user+group)*(old+new) structure, inode write (sb, * inode block, ? - but truncate inode update has it) */ - handle =ext4_journal_start (inode, (EXT4_MAXQUOTAS_INIT_BLOCKS (inode->i_sb)+ -EXT4_MAXQUOTAS_DEL_BLOCKS (inode->i_sb))+3 ); + handle =ext4_journal_start (inode, + (EXT4_MAXQUOTAS_INIT_BLOCKS (inode->i_sb)+ +EXT4_MAXQUOTAS_DEL_BLOCKS (inode->i_sb))+3 , + (JBD2_FAIL_OK |JBD2_TOPLEVEL ));if (IS_ERR (handle)) { error =PTR_ERR (handle); goto err_out;
@@ -5364,7 +5369,8 @@ int ext4_setattr(struct dentry *dentry, struct iattr *attr) (attr->ia_size < inode->i_size)) {handle_t *handle; - handle =ext4_journal_start (inode,3 ); + handle =ext4_journal_start (inode,3 , + (JBD2_FAIL_OK |JBD2_TOPLEVEL ));if (IS_ERR (handle)) { error =PTR_ERR (handle); goto err_out;
@@ -5384,7 +5390,8 @@ int ext4_setattr(struct dentry *dentry, struct iattr *attr) attr->ia_size);if (error) {/* Do as much error cleanup as possible */ - handle =ext4_journal_start (inode,3 ); + handle =ext4_journal_start (inode,3 , +JBD2_NO_FAIL );if (IS_ERR (handle)) {ext4_orphan_del (NULL , inode); goto err_out;
@@ -5421,7 +5428,8 @@ int ext4_setattr(struct dentry *dentry, struct iattr *attr) rc =ext4_acl_chmod (inode); err_out: -ext4_std_error (inode->i_sb, error); +if (error != -ENOMEM ) +ext4_std_error (inode->i_sb, error);if (!error) error = rc;return error;
@@ -5737,7 +5745,7 @@ void ext4_dirty_inode(struct inode *inode) {handle_t *handle; - handle =ext4_journal_start (inode,2 ); + handle =ext4_journal_start (inode,2 ,JBD2_NO_FAIL );if (IS_ERR (handle)) goto out;
@@ -5821,7 +5829,7 @@ int ext4_change_inode_journal_flag(struct inode *inode, int val)/* Finally we can mark the inode as dirty. */ - handle =ext4_journal_start (inode,1 ); + handle =ext4_journal_start (inode,1 ,JBD2_NO_FAIL );if (IS_ERR (handle))return PTR_ERR (handle);
fs/ext4/ioctl.c +4 -2
@@ -101,7 +101,8 @@ long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) }else if (oldflags &EXT4_EOFBLOCKS_FL )ext4_truncate (inode); - handle =ext4_journal_start (inode,1 ); + handle =ext4_journal_start (inode,1 , + (JBD2_FAIL_OK |JBD2_TOPLEVEL ));if (IS_ERR (handle)) { err =PTR_ERR (handle); goto flags_out;
@@ -157,7 +158,8 @@ flags_out: goto setversion_out; } - handle =ext4_journal_start (inode,1 ); + handle =ext4_journal_start (inode,1 , + (JBD2_FAIL_OK |JBD2_TOPLEVEL ));if (IS_ERR (handle)) { err =PTR_ERR (handle); goto setversion_out;
fs/ext4/migrate.c +5 -5
@@ -485,10 +485,10 @@ int ext4_ext_migrate(struct inode *inode)return retval; handle =ext4_journal_start (inode, -EXT4_DATA_TRANS_BLOCKS (inode->i_sb) + -EXT4_INDEX_EXTRA_TRANS_BLOCKS +3 + -EXT4_MAXQUOTAS_INIT_BLOCKS (inode->i_sb) - +1 ); +EXT4_DATA_TRANS_BLOCKS (inode->i_sb) + +EXT4_INDEX_EXTRA_TRANS_BLOCKS +3 + +EXT4_MAXQUOTAS_INIT_BLOCKS (inode->i_sb) + +1 , (JBD2_FAIL_OK |JBD2_TOPLEVEL ));if (IS_ERR (handle)) { retval =PTR_ERR (handle);return retval;
@@ -533,7 +533,7 @@ int ext4_ext_migrate(struct inode *inode)ext4_set_inode_state (inode,EXT4_STATE_EXT_MIGRATE );up_read ((&EXT4_I (inode)->i_data_sem)); - handle =ext4_journal_start (inode,1 ); + handle =ext4_journal_start (inode,1 ,JBD2_NO_FAIL );if (IS_ERR (handle)) {/* * It is impossible to update on-disk structures without
fs/ext4/move_extent.c +2 -1
@@ -813,7 +813,8 @@ move_extent_per_page(struct file *o_filp, struct inode *donor_inode,* inode and donor_inode may change each different metadata blocks. */ jblocks =ext4_writepage_trans_blocks (orig_inode) *2 ; - handle =ext4_journal_start (orig_inode, jblocks); + handle =ext4_journal_start (orig_inode, jblocks, + (JBD2_FAIL_OK |JBD2_TOPLEVEL ));if (IS_ERR (handle)) { *err =PTR_ERR (handle);return 0 ;
fs/ext4/namei.c +30 -17
101 lines not on this page · raw message
fs/ext4/resize.c +4 -4
@@ -176,7 +176,7 @@ static int setup_new_group_blocks(struct super_block *sb,int err =0 , err2;/* 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_MAX_TRANS_DATA ,JBD2_NO_FAIL );if (IS_ERR (handle))return PTR_ERR (handle);
@@ -655,7 +655,7 @@ static void update_backups(struct super_block *sb,handle_t *handle;int err =0 , err2; - handle =ext4_journal_start_sb (sb,EXT4_MAX_TRANS_DATA ); + handle =ext4_journal_start_sb (sb,EXT4_MAX_TRANS_DATA ,JBD2_NO_FAIL );if (IS_ERR (handle)) { group =1 ; err =PTR_ERR (handle);
@@ -793,7 +793,7 @@ int ext4_group_add(struct super_block *sb, struct ext4_new_group_data *input)*/ handle =ext4_journal_start_sb (sb,ext4_bg_has_super (sb, input->group) ? -3 + reserved_gdb :4 ); +3 + reserved_gdb :4 ,JBD2_NO_FAIL );if (IS_ERR (handle)) { err =PTR_ERR (handle); goto exit_put;
@@ -1031,7 +1031,7 @@ int ext4_group_extend(struct super_block *sb, struct ext4_super_block *es,/* We will update the superblock, one block bitmap, and * one group descriptor via ext4_free_blocks(). */ - handle =ext4_journal_start_sb (sb,3 ); + handle =ext4_journal_start_sb (sb,3 ,JBD2_NO_FAIL );if (IS_ERR (handle)) { err =PTR_ERR (handle);ext4_warning (sb,"error %d on journal start" , err);
fs/ext4/super.c +11 -7
@@ -263,7 +263,8 @@ static void ext4_put_nojournal(handle_t *handle)* ext4 prevents a new handle from being started by s_frozen, which * is in an upper layer. */ -handle_t *ext4_journal_start_sb (struct super_block *sb,int nblocks) +handle_t *ext4_journal_start_sb (struct super_block *sb, +int nblocks,int jbd_alloc_flags) {journal_t *journal;handle_t *handle;
@@ -295,7 +296,7 @@ handle_t *ext4_journal_start_sb(struct super_block *sb, int nblocks)ext4_abort (sb,"Detected aborted journal" );return ERR_PTR (-EROFS ); } -return jbd2_journal_start (journal, nblocks,JBD2_NO_FAIL ); +return jbd2_journal_start (journal, nblocks, jbd_alloc_flags); }/*
@@ -4561,7 +4562,8 @@ static int ext4_write_dquot(struct dquot *dquot) inode =dquot_to_inode (dquot); handle =ext4_journal_start (inode, -EXT4_QUOTA_TRANS_BLOCKS (dquot->dq_sb)); +EXT4_QUOTA_TRANS_BLOCKS (dquot->dq_sb), +JBD2_NO_FAIL );if (IS_ERR (handle))return PTR_ERR (handle); ret =dquot_commit (dquot);
@@ -4577,7 +4579,8 @@ static int ext4_acquire_dquot(struct dquot *dquot)handle_t *handle; handle =ext4_journal_start (dquot_to_inode (dquot), -EXT4_QUOTA_INIT_BLOCKS (dquot->dq_sb)); +EXT4_QUOTA_INIT_BLOCKS (dquot->dq_sb), +JBD2_NO_FAIL );if (IS_ERR (handle))return PTR_ERR (handle); ret =dquot_acquire (dquot);
@@ -4593,7 +4596,8 @@ static int ext4_release_dquot(struct dquot *dquot)handle_t *handle; handle =ext4_journal_start (dquot_to_inode (dquot), -EXT4_QUOTA_DEL_BLOCKS (dquot->dq_sb)); +EXT4_QUOTA_DEL_BLOCKS (dquot->dq_sb), +JBD2_NO_FAIL );if (IS_ERR (handle)) {/* Release dquot anyway to avoid endless cycle in dqput() */ dquot_release (dquot);
@@ -4624,7 +4628,7 @@ static int ext4_write_info(struct super_block *sb, int type)handle_t *handle;/* Data block + inode block */ - handle =ext4_journal_start (sb->s_root->d_inode,2 ); + handle =ext4_journal_start (sb->s_root->d_inode,2 ,JBD2_NO_FAIL );if (IS_ERR (handle))return PTR_ERR (handle); ret =dquot_commit_info (sb, type);
@@ -4702,7 +4706,7 @@ static int ext4_quota_off(struct super_block *sb, int type)/* Update modification times of quota files when userspace can * start looking at them */ - handle =ext4_journal_start (inode,1 ); + handle =ext4_journal_start (inode,1 , (JBD2_FAIL_OK |JBD2_TOPLEVEL ));if (IS_ERR (handle)) goto out; inode->i_mtime = inode->i_ctime =CURRENT_TIME ;
fs/ext4/xattr.c +2 -1
@@ -1084,7 +1084,8 @@ ext4_xattr_set(struct inode *inode, int name_index, const char *name,int error, retries =0 ; retry: - handle =ext4_journal_start (inode,EXT4_DATA_TRANS_BLOCKS (inode->i_sb)); + handle =ext4_journal_start (inode,EXT4_DATA_TRANS_BLOCKS (inode->i_sb), + (JBD2_FAIL_OK |JBD2_TOPLEVEL ));if (IS_ERR (handle)) { error =PTR_ERR (handle); }else {
Signature · 1 line
1.7.4.1
Jan Kara
reviewerRe: [PATCH v2 2/3] jbd2: Add extra parameter in start_this_handle() to control allocation flags.
In reply to Manish KatiyarQuoted 5 lines · Manish Katiyar
changes from v1 -> v2 :
*) Updatestart_this_handleto take extra parameter to specify whether
to retry the allocation or not.
*) Added jbd allocation flags for callers to control the transaction allocation behavior. Callers can passJBD2_TOPLEVELif allocation needs to be done usingGFP_KERNEL.
The above changelog should be below where (*) is.
Also - this is mainly for Ted: I've looked at where we JBD2_TOPLEVEL could actually be enabled and the results are: Pretty much nowhere.
The problem is that with ext4, we need i_mutex in io completion path to end page writeback. So we cannot do GFP_KERNEL allocation whenever we hold i_mutex because mm might wait in direct reclaim for IO to complete and that cannot happen until we release i_mutex. And pretty much every write path in ext4 holds i_mutex.
So JBD2_TOPLEVEL looks like a useless excercise to me and I'd just don't do it.
Quoted 7 lines
Pass extra flags in journal routines to specify if its ok to
fail in the journal transaction allocation. PassingJBD2_FAIL_OKmeans caller is ok with journal start failures and can handle ENOMEM.Update ocfs2 and ext4 routines to pass
JBD2_NO_FAILfor the updated journal interface by default, to retain the existing behavior.
Quoted 8 lines
Signed-off-by Manish Katiyar <[email protected]>--- fs/ext4/ext4_jbd2.h | 2 +- fs/ext4/super.c | 2 +- fs/jbd2/transaction.c | 44 ++++++++++++++++---------------------------- fs/ocfs2/journal.c | 8 ++++---- include/linux/jbd2.h | 13 +++++++++---- 5 files changed, 31 insertions(+), 38 deletions(-)
(*) HERE
include/linux/jbd2.h static inline int jbd_space_needed(journal_t *journal) · line 1329
Quoted 5 lines
include/linux/jbd2.h +5
-0+/* JBD2 transaction allocation flags */ +#define JBD2_NO_FAIL 0x00000001 +#define JBD2_FAIL_OK 0x00000002 +#define JBD2_TOPLEVEL 0x00000004 +
I guess there's no need for JBD2_FAIL_OK - if NOFAIL is not set, we can
fail. Otherwise the patch looks OK.
Honza
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR
Jan Kara
reviewerRe: [PATCH v2 3/3] ext4: Fix ext4 to use pass jbd allocation flags if they can handle ENOMEM.
In reply to Manish KatiyarQuoted 4 lines · Manish Katiyar
This patch updates ext4 code to pass appropriate transaction allocation flags to callers who are safe to deal with ENOMEM. Pass
JBD2_TOPLEVELfrom the callers who are safe to do allocations withGFP_KERNELinstead ofGFP_NOFS.
I've indicated places where TOPLEVEL cannot be below. There are about 4
or 5 which are probably OK. Otherwise the patch is OK.
Quoted 21 lines
Signed-off-by Manish Katiyar <[email protected]>--- fs/ext4/acl.c | 6 ++++-- fs/ext4/ext4_jbd2.h | 8 +++++--- fs/ext4/extents.c | 11 ++++++----- fs/ext4/ialloc.c | 2 +- fs/ext4/inode.c | 40 ++++++++++++++++++++++++---------------- fs/ext4/ioctl.c | 6 ++++-- fs/ext4/migrate.c | 10 +++++----- fs/ext4/move_extent.c | 3 ++- fs/ext4/namei.c | 47 ++++++++++++++++++++++++++++++----------------- fs/ext4/resize.c | 8 ++++---- fs/ext4/super.c | 18 +++++++++++------- fs/ext4/xattr.c | 3 ++- 12 files changed, 98 insertions(+), 64 deletions(-)fs/ext4/acl.c +0
-0
fs/ext4/acl.c ext4_acl_chmod(struct inode *inode) · line 355
Quoted 6 lines
fs/ext4/acl.c +2
-1@@ -351,7 +351,8 @@ ext4_acl_chmod(struct inode *inode) retry: handle =ext4_journal_start (inode, -EXT4_DATA_TRANS_BLOCKS (inode->i_sb)); +EXT4_DATA_TRANS_BLOCKS (inode->i_sb), + (JBD2_FAIL_OK |JBD2_TOPLEVEL ));
As I wrote in my previous email, JBD2_TOPLEVEL is not OK here because we
hold i_mutex.
fs/ext4/acl.c ext4_xattr_set_acl(struct dentry *dentry, const char *name, const void *value, · line 455
Quoted 10 lines
fs/ext4/acl.c +2
-1if (IS_ERR (handle)) { error =PTR_ERR (handle);if (error != -ENOMEM )@@ -450,7 +451,8 @@ ext4_xattr_set_acl(struct dentry *dentry, const char *name, const void *value, acl =NULL ; retry: - handle =ext4_journal_start (inode,EXT4_DATA_TRANS_BLOCKS (inode->i_sb)); + handle =ext4_journal_start (inode,EXT4_DATA_TRANS_BLOCKS (inode->i_sb), + (JBD2_FAIL_OK |JBD2_TOPLEVEL ));
The same here.
Quoted 3 lines
fs/ext4/acl.c +0
-0if (IS_ERR (handle)) { error =PTR_ERR (handle); goto release_and_out;
...
fs/ext4/extents.c retry: · line 3815
Quoted 11 lines
fs/ext4/extents.c +2
-1@@ -3811,7 +3811,8 @@ retry:while (ret >=0 && ret < max_blocks) { map.m_lblk = map.m_lblk + ret; map.m_len = max_blocks = max_blocks - ret; - handle =ext4_journal_start (inode, credits); + handle =ext4_journal_start (inode, credits, + (JBD2_FAIL_OK |JBD2_TOPLEVEL ));
And here as well.
Quoted 3 lines
fs/ext4/extents.c +0
-0if (IS_ERR (handle)) { ret =PTR_ERR (handle);break ;
...
Quoted 7 lines
fs/ext4/inode.c +0
-0@@ -5329,8 +5332,10 @@ int ext4_setattr(struct dentry *dentry, struct iattr *attr)/* (user+group)*(old+new) structure, inode write (sb,
fs/ext4/inode.c int ext4_setattr(struct dentry *dentry, struct iattr *attr) · line 5341
Quoted 10 lines
fs/ext4/inode.c +4
-2* inode block, ? - but truncate inode update has it) */ - handle =ext4_journal_start (inode, (EXT4_MAXQUOTAS_INIT_BLOCKS (inode->i_sb)+ -EXT4_MAXQUOTAS_DEL_BLOCKS (inode->i_sb))+3 ); + handle =ext4_journal_start (inode, + (EXT4_MAXQUOTAS_INIT_BLOCKS (inode->i_sb)+ +EXT4_MAXQUOTAS_DEL_BLOCKS (inode->i_sb))+3 , + (JBD2_FAIL_OK |JBD2_TOPLEVEL ));if (IS_ERR (handle)) { error =PTR_ERR (handle); goto err_out;
Again, TOPLEVEL cannot be here.
fs/ext4/inode.c int ext4_setattr(struct dentry *dentry, struct iattr *attr) · line 5376
Quoted 10 lines
fs/ext4/inode.c +2
-1@@ -5364,7 +5369,8 @@ int ext4_setattr(struct dentry *dentry, struct iattr *attr) (attr->ia_size < inode->i_size)) {handle_t *handle; - handle =ext4_journal_start (inode,3 ); + handle =ext4_journal_start (inode,3 , + (JBD2_FAIL_OK |JBD2_TOPLEVEL ));if (IS_ERR (handle)) { error =PTR_ERR (handle); goto err_out;
And here as well.
fs/ext4/ioctl.c long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) · line 105
Quoted 11 lines
fs/ext4/ioctl.c +2
-1@@ -101,7 +101,8 @@ long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) }else if (oldflags &EXT4_EOFBLOCKS_FL )ext4_truncate (inode); - handle =ext4_journal_start (inode,1 ); + handle =ext4_journal_start (inode,1 , + (JBD2_FAIL_OK |JBD2_TOPLEVEL ));
And here as well.
fs/ext4/ioctl.c flags_out: · line 162
Quoted 10 lines
fs/ext4/ioctl.c +2
-1if (IS_ERR (handle)) { err =PTR_ERR (handle); goto flags_out;@@ -157,7 +158,8 @@ flags_out: goto setversion_out; } - handle =ext4_journal_start (inode,1 ); + handle =ext4_journal_start (inode,1 , + (JBD2_FAIL_OK |JBD2_TOPLEVEL ));
Here, actually TOPLEVEL is OK.
Quoted 9 lines
fs/ext4/ioctl.c +0
-0if (IS_ERR (handle)) { err =PTR_ERR (handle); goto setversion_out;fs/ext4/migrate.c +0
-0@@ -485,10 +485,10 @@ int ext4_ext_migrate(struct inode *inode)return retval;
fs/ext4/migrate.c int ext4_ext_migrate(struct inode *inode) · line 491
Quoted 10 lines
fs/ext4/migrate.c +4
-4handle =ext4_journal_start (inode, -EXT4_DATA_TRANS_BLOCKS (inode->i_sb) + -EXT4_INDEX_EXTRA_TRANS_BLOCKS +3 + -EXT4_MAXQUOTAS_INIT_BLOCKS (inode->i_sb) - +1 ); +EXT4_DATA_TRANS_BLOCKS (inode->i_sb) + +EXT4_INDEX_EXTRA_TRANS_BLOCKS +3 + +EXT4_MAXQUOTAS_INIT_BLOCKS (inode->i_sb) + +1 , (JBD2_FAIL_OK |JBD2_TOPLEVEL ));
TOPLEVEL cannot be here.
Quoted 3 lines
fs/ext4/migrate.c +0
-0if (IS_ERR (handle)) { retval =PTR_ERR (handle);return retval;
...
fs/ext4/move_extent.c move_extent_per_page(struct file *o_filp, struct inode *donor_inode, · line 817
Quoted 11 lines
fs/ext4/move_extent.c +2
-1@@ -813,7 +813,8 @@ move_extent_per_page(struct file *o_filp, struct inode *donor_inode,* inode and donor_inode may change each different metadata blocks. */ jblocks =ext4_writepage_trans_blocks (orig_inode) *2 ; - handle =ext4_journal_start (orig_inode, jblocks); + handle =ext4_journal_start (orig_inode, jblocks, + (JBD2_FAIL_OK |JBD2_TOPLEVEL ));
TOPLEVEL cannot be here.
Quoted 9 lines
fs/ext4/move_extent.c +0
-0if (IS_ERR (handle)) { *err =PTR_ERR (handle);return 0 ;fs/ext4/namei.c +0
-0@@ -1750,9 +1750,11 @@ static int ext4_create(struct inode *dir, struct dentry *dentry, int mode,dquot_initialize (dir);
fs/ext4/namei.c static int ext4_create(struct inode *dir, struct dentry *dentry, int mode, · line 1757
Quoted 10 lines
fs/ext4/namei.c +5
-3retry: - handle =ext4_journal_start (dir,EXT4_DATA_TRANS_BLOCKS (dir->i_sb) + -EXT4_INDEX_EXTRA_TRANS_BLOCKS +3 + -EXT4_MAXQUOTAS_INIT_BLOCKS (dir->i_sb)); + handle =ext4_journal_start (dir, +EXT4_DATA_TRANS_BLOCKS (dir->i_sb) + +EXT4_INDEX_EXTRA_TRANS_BLOCKS +3 + +EXT4_MAXQUOTAS_INIT_BLOCKS (dir->i_sb), + (JBD2_FAIL_OK |JBD2_TOPLEVEL ));
OK, TOPLEVEL possibly could be here because we hold only directory mutex
so writeback won't be stalled. But it's a bit subtle. The same holds for mknod, mkdir and rmdir below.
Quoted 44 lines
fs/ext4/namei.c +12
-7if (IS_ERR (handle))return PTR_ERR (handle);@@ -1786,9 +1788,11 @@ static int ext4_mknod(struct inode *dir, struct dentry *dentry,dquot_initialize (dir); retry: - handle =ext4_journal_start (dir,EXT4_DATA_TRANS_BLOCKS (dir->i_sb) + -EXT4_INDEX_EXTRA_TRANS_BLOCKS +3 + -EXT4_MAXQUOTAS_INIT_BLOCKS (dir->i_sb)); + handle =ext4_journal_start (dir, +EXT4_DATA_TRANS_BLOCKS (dir->i_sb) + +EXT4_INDEX_EXTRA_TRANS_BLOCKS +3 + +EXT4_MAXQUOTAS_INIT_BLOCKS (dir->i_sb), + (JBD2_FAIL_OK |JBD2_TOPLEVEL ));if (IS_ERR (handle))return PTR_ERR (handle);@@ -1825,9 +1829,11 @@ static int ext4_mkdir(struct inode *dir, struct dentry *dentry, int mode)dquot_initialize (dir); retry: - handle =ext4_journal_start (dir,EXT4_DATA_TRANS_BLOCKS (dir->i_sb) + -EXT4_INDEX_EXTRA_TRANS_BLOCKS +3 + -EXT4_MAXQUOTAS_INIT_BLOCKS (dir->i_sb)); + handle =ext4_journal_start (dir, +EXT4_DATA_TRANS_BLOCKS (dir->i_sb) + +EXT4_INDEX_EXTRA_TRANS_BLOCKS +3 + +EXT4_MAXQUOTAS_INIT_BLOCKS (dir->i_sb), + (JBD2_FAIL_OK |JBD2_TOPLEVEL ));if (IS_ERR (handle))return PTR_ERR (handle);@@ -2140,7 +2146,8 @@ static int ext4_rmdir(struct inode *dir, struct dentry *dentry)dquot_initialize (dir);dquot_initialize (dentry->d_inode); - handle =ext4_journal_start (dir,EXT4_DELETE_TRANS_BLOCKS (dir->i_sb)); + handle =ext4_journal_start (dir,EXT4_DELETE_TRANS_BLOCKS (dir->i_sb), + (JBD2_FAIL_OK |JBD2_TOPLEVEL ));if (IS_ERR (handle))return PTR_ERR (handle);
fs/ext4/namei.c static int ext4_unlink(struct inode *dir, struct dentry *dentry) · line 2213
Quoted 6 lines
fs/ext4/namei.c +2
-1@@ -2202,7 +2209,8 @@ static int ext4_unlink(struct inode *dir, struct dentry *dentry)dquot_initialize (dir);dquot_initialize (dentry->d_inode); - handle =ext4_journal_start (dir,EXT4_DELETE_TRANS_BLOCKS (dir->i_sb)); + handle =ext4_journal_start (dir,EXT4_DELETE_TRANS_BLOCKS (dir->i_sb), + (JBD2_FAIL_OK |JBD2_TOPLEVEL ));
TOPLEVEL cannot be here.
Quoted 14 lines
fs/ext4/namei.c +2
-1if (IS_ERR (handle))return PTR_ERR (handle);@@ -2279,7 +2287,8 @@ static int ext4_symlink(struct inode *dir,EXT4_MAXQUOTAS_INIT_BLOCKS (dir->i_sb); } retry: - handle =ext4_journal_start (dir, credits); + handle =ext4_journal_start (dir, + credits, (JBD2_FAIL_OK |JBD2_TOPLEVEL ));if (IS_ERR (handle))return PTR_ERR (handle);
fs/ext4/namei.c retry: · line 2332
Quoted 6 lines
fs/ext4/namei.c +2
-1@@ -2319,7 +2328,8 @@ retry:*/ handle =ext4_journal_start (dir,EXT4_DATA_TRANS_BLOCKS (dir->i_sb) + -EXT4_INDEX_EXTRA_TRANS_BLOCKS +1 ); +EXT4_INDEX_EXTRA_TRANS_BLOCKS +1 , + (JBD2_FAIL_OK |JBD2_TOPLEVEL ));
Above two cases should be OK.
fs/ext4/namei.c static int ext4_link(struct dentry *old_dentry, · line 2380
Quoted 13 lines
fs/ext4/namei.c +4
-2if (IS_ERR (handle)) { err =PTR_ERR (handle); goto err_drop_inode;@@ -2364,8 +2374,10 @@ static int ext4_link(struct dentry *old_dentry,dquot_initialize (dir); retry: - handle =ext4_journal_start (dir,EXT4_DATA_TRANS_BLOCKS (dir->i_sb) + -EXT4_INDEX_EXTRA_TRANS_BLOCKS ); + handle =ext4_journal_start (dir, +EXT4_DATA_TRANS_BLOCKS (dir->i_sb) + +EXT4_INDEX_EXTRA_TRANS_BLOCKS , + (JBD2_FAIL_OK |JBD2_TOPLEVEL ));
TOPLEVEL cannot be here.
fs/ext4/namei.c static int ext4_rename(struct inode *old_dir, struct dentry *old_dentry, · line 2433
Quoted 12 lines
fs/ext4/namei.c +3
-2if (IS_ERR (handle))return PTR_ERR (handle);@@ -2416,8 +2428,9 @@ static int ext4_rename(struct inode *old_dir, struct dentry *old_dentry,if (new_dentry->d_inode)dquot_initialize (new_dentry->d_inode); handle =ext4_journal_start (old_dir,2 * -EXT4_DATA_TRANS_BLOCKS (old_dir->i_sb) + -EXT4_INDEX_EXTRA_TRANS_BLOCKS +2 ); +EXT4_DATA_TRANS_BLOCKS (old_dir->i_sb) + +EXT4_INDEX_EXTRA_TRANS_BLOCKS +2 , + (JBD2_FAIL_OK |JBD2_TOPLEVEL ));
And it cannot be here either.
Quoted 3 lines
fs/ext4/namei.c +0
-0if (IS_ERR (handle))return PTR_ERR (handle);
...
Quoted 4 lines
fs/ext4/super.c +0
-0
...
fs/ext4/super.c static int ext4_quota_off(struct super_block *sb, int type) · line 4709
Quoted 6 lines
fs/ext4/super.c +1
-1@@ -4702,7 +4706,7 @@ static int ext4_quota_off(struct super_block *sb, int type)/* Update modification times of quota files when userspace can * start looking at them */ - handle =ext4_journal_start (inode,1 ); + handle =ext4_journal_start (inode,1 , (JBD2_FAIL_OK |JBD2_TOPLEVEL ));
TOPLEVEL cannot be here because we hold s_umount on superblock.
Quoted 8 lines
fs/ext4/super.c +0
-0if (IS_ERR (handle)) goto out; inode->i_mtime = inode->i_ctime =CURRENT_TIME ;fs/ext4/xattr.c +0
-0
fs/ext4/xattr.c ext4_xattr_set(struct inode *inode, int name_index, const char *name, · line 1088
Quoted 6 lines
fs/ext4/xattr.c +2
-1@@ -1084,7 +1084,8 @@ ext4_xattr_set(struct inode *inode, int name_index, const char *name,int error, retries =0 ; retry: - handle =ext4_journal_start (inode,EXT4_DATA_TRANS_BLOCKS (inode->i_sb)); + handle =ext4_journal_start (inode,EXT4_DATA_TRANS_BLOCKS (inode->i_sb), + (JBD2_FAIL_OK |JBD2_TOPLEVEL ));
TOPLEVEL cannot be here.
Quoted 3 lines
fs/ext4/xattr.c +0
-0if (IS_ERR (handle)) { error =PTR_ERR (handle); }else {
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR
Ted Ts'o
maintainerRe: [PATCH v2 2/3] jbd2: Add extra parameter in start_this_handle() to control allocation flags.
In reply to Jan KaraQuoted 5 lines · Jan Kara
The problem is that with ext4, we need
i_mutexin io completion path to end page writeback. So we cannot doGFP_KERNELallocation whenever we holdi_mutexbecause mm might wait in direct reclaim for IO to complete and that cannot happen until we releasei_mutex.
OK, maybe I'm being dense, but I'm not seeing it. I see where we need i_mutex on the ext4_da_writepages() codepath, but that's never used for direct reclaim. Direct reclaim only calls ext4_writepage(), and that doesn't seem to try to grab i_mutex as near as I can tell. Am I missing something?
- Ted
Jan Kara
reviewerRe: [PATCH v2 2/3] jbd2: Add extra parameter in start_this_handle() to control allocation flags.
Quoted 7 lines · Ted Tso
Quoted 5 lines · Jan Kara
The problem is that with ext4, we need
i_mutexin io completion path to end page writeback. So we cannot doGFP_KERNELallocation whenever we holdi_mutexbecause mm might wait in direct reclaim for IO to complete and that cannot happen until we releasei_mutex.
Quoted 5 lines
OK, maybe I'm being dense, but I'm not seeing it. I see where we need
i_mutexon theext4_da_writepages()codepath, but that's never used for direct reclaim. Direct reclaim only callsext4_writepage(), and that doesn't seem to try to grabi_mutexas near as I can tell. Am I missing something?
What happens is that direct reclaim sometimes doeswait_on_page_writeback() (e.g. shrink_page_list()) or it explicitely waits for NR_WRITEBACK statistics to go below some threshold (throttle_vm_writeout()). And that is deadlockable if we hold i_mutex while doing this because we may need i_mutex to actually move the page from PageWriteback state...
As I'm saying this, I've realized ext4 has this problem also with stable-pages patches because there we can wait for PageWriteback in grab_cache_page_write_begin() when we also hold i_mutex. So I think we'll have to come up with a way to convert unwritten extents without having to hold i_mutex. That's going to be interesting.
Honza
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR
Re: [PATCH v2 2/3] jbd2: Add extra parameter in start_this_handle() to control allocation flags.
Quoted 20 lines · Jan Kara
Quoted 7 lines · Ted Tso
Quoted 5 lines · Jan Kara
The problem is that with ext4, we need
i_mutexin io completion path to end page writeback. So we cannot doGFP_KERNELallocation whenever we holdi_mutexbecause mm might wait in direct reclaim for IO to complete and that cannot happen until we releasei_mutex.Quoted 5 lines
OK, maybe I'm being dense, but I'm not seeing it. I see where we need
i_mutexon theext4_da_writepages()codepath, but that's never used for direct reclaim. Direct reclaim only callsext4_writepage(), and that doesn't seem to try to grabi_mutexas near as I can tell. Am I missing something?What happens is that direct reclaim sometimes does
wait_on_page_writeback()(e.g.shrink_page_list()) or it explicitely waits forNR_WRITEBACKstatistics to go below some threshold (throttle_vm_writeout()). And that is deadlockable if we holdi_mutexwhile doing this because we may needi_mutexto actually move the page from PageWriteback state...
Quoted 5 lines
As I'm saying this, I've realized ext4 has this problem also with stable-pages patches because there we can wait for PageWriteback in
grab_cache_page_write_begin()when we also holdi_mutex. So I think we'll have to come up with a way to convert unwritten extents without having to holdi_mutex. That's going to be interesting.
Hi Jan/Ted,
Does that mean I should remove the whole JBD2_TOPLEVEL thing from my revised patch ? Or should I fix it as per your feedback in the other patch ?
Signature · 6 lines
Thanks - Manish -- To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Ted Ts'o
maintainerRe: [PATCH v2 2/3] jbd2: Add extra parameter in start_this_handle() to control allocation flags.
In reply to Jan KaraQuoted 6 lines · Jan Kara
What happens is that direct reclaim sometimes does
wait_on_page_writeback()(e.g.shrink_page_list()) or it explicitely waits forNR_WRITEBACKstatistics to go below some threshold (throttle_vm_writeout()). And that is deadlockable if we holdi_mutexwhile doing this because we may needi_mutexto actually move the page from PageWriteback state...
We don't actully call set_page_writeback() until right before we submit the page for writeback. And we convert the unwritten extents in a workqueue, which gets submitted after we call end_page_writeback(). So I'm still not seeing a problem; sorry if I'm being dense!
- Ted
Quoted 14 lines
As I'm saying this, I've realized ext4 has this problem also with stable-pages patches because there we can wait for PageWriteback in
grab_cache_page_write_begin()when we also holdi_mutex. So I think we'll have to come up with a way to convert unwritten extents without having to holdi_mutex. That's going to be interesting.Honza
Signature · 6 lines
Jan Kara <[email protected]> SUSE Labs, CR -- To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Ted Ts'o
maintainerRe: [PATCH v2 2/3] jbd2: Add extra parameter in start_this_handle() to control allocation flags.
Ping?
- Ted
Quoted 34 lines · Ted Ts'o
Quoted 6 lines · Jan Kara
What happens is that direct reclaim sometimes does
wait_on_page_writeback()(e.g.shrink_page_list()) or it explicitely waits forNR_WRITEBACKstatistics to go below some threshold (throttle_vm_writeout()). And that is deadlockable if we holdi_mutexwhile doing this because we may needi_mutexto actually move the page from PageWriteback state...We don't actully call
set_page_writeback()until right before we submit the page for writeback. And we convert the unwritten extents in a workqueue, which gets submitted after we callend_page_writeback(). So I'm still not seeing a problem; sorry if I'm being dense!- Ted
Quoted 6 lines
As I'm saying this, I've realized ext4 has this problem also with stable-pages patches because there we can wait for PageWriteback in
grab_cache_page_write_begin()when we also holdi_mutex. So I think we'll have to come up with a way to convert unwritten extents without having to holdi_mutex. That's going to be interesting.Quoted 8 lines
Honza
Signature · 6 lines
Jan Kara <[email protected]> SUSE Labs, CR -- To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2 2/3] jbd2: Add extra parameter in start_this_handle() to control allocation flags.
Quoted 1 line · Ted Ts'o
Ping?
Hi Jan,
Is there anything required from my side on this patch ? From your other post it seems that holding i_mutex isn't a problem. Please advise.
Signature · 2 lines
Thanks - Manish
Jan Kara
reviewerRe: [PATCH v2 2/3] jbd2: Add extra parameter in start_this_handle() to control allocation flags.
Hi,
Quoted 6 lines · Manish Katiyar
Quoted 1 line · Ted Ts'o
Ping?
Is there anything required from my side on this patch ? From your other post it seems that holding
i_mutexisn't a problem. Please advise.
OK, after my discussion with Ted today, i_mutex really shouldn't be an
issue so your patch should be fine. I just suggest you resend it to Ted to remind yourself :).
Honza
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR
Re: [PATCH v2 2/3] jbd2: Add extra parameter in start_this_handle() to control allocation flags.
Quoted 4 lines · Jan Kara
Hi,
Quoted 1 line · Manish Katiyar
On Wed, Jun 8, 2011 at 7:10 AM, Ted Ts'o <[email protected]> wrote:
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
Ping?
Is there anything required from my side on this patch ? From your other post it seems that holding
i_mutexisn't a problem. Please advise.OK, after my discussion with Ted today,
i_mutexreally shouldn't be an issue so your patch should be fine. I just suggest you resend it to Ted to remind yourself :).
Thanks a lot Jan, Will resend the series to Ted.
Signature · 6 lines
Thanks - Manish -- To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Ted Ts'o
maintainerRe: [PATCH v2 2/3] jbd2: Add extra parameter in start_this_handle() to control allocation flags.
Quoted 5 lines · Manish Katiyar
Quoted 3 lines
OK, after my discussion with Ted today,
i_mutexreally shouldn't be an issue so your patch should be fine. I just suggest you resend it to Ted to remind yourself :).Thanks a lot Jan, Will resend the series to Ted.
Thanks, but don't bother resending it unless you have any changes to update.
I do keep track of patches using patchwork[1], so I haven't forgotten. :-)
[1] http://patchwork.ozlabs.org/project/linux-ext4/list/
I'll be starting to go through patches for the next merge window this week.
- Ted
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2 2/3] jbd2: Add extra parameter in start_this_handle() to control allocation flags.
Quoted 9 lines · Ted Ts'o
Quoted 5 lines · Manish Katiyar
Quoted 3 lines
OK, after my discussion with Ted today,
i_mutexreally shouldn't be an issue so your patch should be fine. I just suggest you resend it to Ted to remind yourself :).Thanks a lot Jan, Will resend the series to Ted.
Thanks, but don't bother resending it unless you have any changes to update.
Thanks Ted, ... I don't have any other changes.
Signature · 6 lines
Thanks - Manish -- To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html