From b9dd75fd7271a7d7290875b08d40837b281c6f94 Mon Sep 17 00:00:00 2001 From: Manish Katiyar Date: Sun, 24 Apr 2011 16:57:11 -0700 Subject: [PATCH 5/5] Update ext4 routines to call ext4_journal_start_tryhard() if the transaction allocation isn't supposed to fail. When ext4_journal_start_tryhard is called, allocation is done with GFP_NOFS flags instead of GFP_KERNEL. Signed-off-by: Manish Katiyar --- fs/ext4/extents.c | 6 +++--- fs/ext4/ialloc.c | 2 +- fs/ext4/inode.c | 27 ++++++++++++++++----------- fs/ext4/super.c | 8 ++++---- 4 files changed, 24 insertions(+), 19 deletions(-) diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c index 4890d6f..bf0bb9c 100644 --- a/fs/ext4/extents.c +++ b/fs/ext4/extents.c @@ -2337,7 +2337,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_tryhard(inode, depth + 1); if (IS_ERR(handle)) return PTR_ERR(handle); @@ -3550,7 +3550,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_tryhard(inode, err); if (IS_ERR(handle)) return; @@ -3762,7 +3762,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_tryhard(inode, credits); if (IS_ERR(handle)) { ret = PTR_ERR(handle); break; diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c index 21bb2f6..40902f3 100644 --- a/fs/ext4/ialloc.c +++ b/fs/ext4/ialloc.c @@ -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_tryhard(sb, 1); if (IS_ERR(handle)) { ret = PTR_ERR(handle); goto out; diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index f2fa5e8..0c2b693 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -129,7 +129,7 @@ static handle_t *start_transaction(struct inode *inode) { handle_t *result; - result = ext4_journal_start(inode, blocks_for_truncate(inode)); + result = ext4_journal_start_tryhard(inode, blocks_for_truncate(inode)); if (!IS_ERR(result)) return result; @@ -204,7 +204,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_tryhard(inode, + blocks_for_truncate(inode)+3); if (IS_ERR(handle)) { ext4_std_error(inode->i_sb, PTR_ERR(handle)); /* @@ -1401,7 +1402,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_tryhard(inode, dio_credits); if (IS_ERR(handle)) { ret = PTR_ERR(handle); return ret; @@ -2558,7 +2559,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_tryhard(inode, + ext4_writepage_trans_blocks(inode)); if (IS_ERR(handle)) { ret = PTR_ERR(handle); goto out; @@ -2990,7 +2992,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_tryhard(inode, needed_blocks); if (IS_ERR(handle)) { ret = PTR_ERR(handle); ext4_msg(inode->i_sb, KERN_CRIT, "%s: jbd2_start: " @@ -5279,8 +5281,9 @@ 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); if (IS_ERR(handle)) { error = PTR_ERR(handle); goto err_out; @@ -5335,7 +5338,7 @@ 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_tryhard(inode, 3); if (IS_ERR(handle)) { ext4_orphan_del(NULL, inode); goto err_out; @@ -5371,7 +5374,9 @@ 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; @@ -5687,7 +5692,7 @@ void ext4_dirty_inode(struct inode *inode) { handle_t *handle; - handle = ext4_journal_start(inode, 2); + handle = ext4_journal_start_tryhard(inode, 2); if (IS_ERR(handle)) goto out; @@ -5771,7 +5776,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_tryhard(inode, 1); if (IS_ERR(handle)) return PTR_ERR(handle); diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 03eac6a..b0fc83e 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -4526,7 +4526,7 @@ static int ext4_write_dquot(struct dquot *dquot) struct inode *inode; inode = dquot_to_inode(dquot); - handle = ext4_journal_start(inode, + handle = ext4_journal_start_tryhard(inode, EXT4_QUOTA_TRANS_BLOCKS(dquot->dq_sb)); if (IS_ERR(handle)) return PTR_ERR(handle); @@ -4542,7 +4542,7 @@ static int ext4_acquire_dquot(struct dquot *dquot) int ret, err; handle_t *handle; - handle = ext4_journal_start(dquot_to_inode(dquot), + handle = ext4_journal_start_tryhard(dquot_to_inode(dquot), EXT4_QUOTA_INIT_BLOCKS(dquot->dq_sb)); if (IS_ERR(handle)) return PTR_ERR(handle); @@ -4558,7 +4558,7 @@ static int ext4_release_dquot(struct dquot *dquot) int ret, err; handle_t *handle; - handle = ext4_journal_start(dquot_to_inode(dquot), + handle = ext4_journal_start_tryhard(dquot_to_inode(dquot), EXT4_QUOTA_DEL_BLOCKS(dquot->dq_sb)); if (IS_ERR(handle)) { /* Release dquot anyway to avoid endless cycle in dqput() */ @@ -4590,7 +4590,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_tryhard(sb->s_root->d_inode, 2); if (IS_ERR(handle)) return PTR_ERR(handle); ret = dquot_commit_info(sb, type); -- 1.7.1