From: Wendy Cheng <[email protected]> Current GFS2 setattr call unconditionally invokes do_shrink even the requested size and actual file size are equal. This has generated large amount of extra IOs found during NFS benchmark runs. This patch moves the relevant logic out of shrink code path. Since setattr is a system call, the time stamps update is still required. Signed-off-by: S. Wendy Cheng <[email protected]> Signed-off-by: Steven Whitehouse <[email protected]> diff --git a/fs/gfs2/bmap.c b/fs/gfs2/bmap.c index cd805a6..9b89904 100644 --- a/fs/gfs2/bmap.c +++ b/fs/gfs2/bmap.c @@ -1085,6 +1085,33 @@ static int do_shrink(struct gfs2_inode *ip, u64 size) return error; } +static int do_touch(struct gfs2_inode *ip, u64 size) +{ + struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); + struct buffer_head *dibh; + int error; + + error = gfs2_trans_begin(sdp, RES_DINODE, 0); + if (error) + return error; + + down_write(&ip->i_rw_mutex); + + error = gfs2_meta_inode_buffer(ip, &dibh); + if (error) + goto do_touch_out; + + ip->i_inode.i_mtime = ip->i_inode.i_ctime = CURRENT_TIME; + gfs2_trans_add_bh(ip->i_gl, dibh, 1); + gfs2_dinode_out(ip, dibh->b_data); + brelse(dibh); + +do_touch_out: + up_write(&ip->i_rw_mutex); + gfs2_trans_end(sdp); + return error; +} + /** * gfs2_truncatei - make a file a given size * @ip: the inode @@ -1105,8 +1132,11 @@ int gfs2_truncatei(struct gfs2_inode *ip, u64 size) if (size > ip->i_di.di_size) error = do_grow(ip, size); - else + else if (size < ip->i_di.di_size) error = do_shrink(ip, size); + else + /* update time stamps */ + error = do_touch(ip, size); return error; } -- 1.5.1.2 - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
- Follow-Ups:
- References:
- [GFS2/DLM] Pre-pull patch posting
- From: [email protected]
- [PATCH 01/51] [GFS2] Fix two races relating to glock callbacks
- From: [email protected]
- [PATCH 02/51] [GFS2] Fix calculation of demote state
- From: [email protected]
- [PATCH 03/51] [GFS2] Clean up duplicate includes in fs/gfs2/
- From: [email protected]
- [PATCH 04/51] [GFS2] GFS2 not checking pointer on create when running under nfsd
- From: [email protected]
- [PATCH 05/51] [GFS2] Fix an oops in glock dumping
- From: [email protected]
- [PATCH 06/51] [GFS2] Move some code inside the log lock
- From: [email protected]
- [PATCH 07/51] [GFS2] Revert part of earlier log.c changes
- From: [email protected]
- [PATCH 08/51] [GFS2] Prevent infinite loop in try_rgrp_unlink()
- From: [email protected]
- [PATCH 09/51] [GFS2] use an temp variable to reduce a spin_unlock
- From: [email protected]
- [PATCH 10/51] [GFS2] Detach buf data during in-place writeback
- From: [email protected]
- [PATCH 11/51] [GFS2] mark struct *_operations const
- From: [email protected]
- [PATCH 12/51] [GFS2] use the declaration of gfs2_dops in the header file instead
- From: [email protected]
- [PATCH 13/51] [GFS2] Reduce number of gfs2_scand processes to one
- From: [email protected]
- [PATCH 14/51] [GFS2] invalid metadata block - REVISED
- From: [email protected]
- [PATCH 15/51] [GFS2] Ensure journal file cache is flushed after recovery
- From: [email protected]
- [PATCH 16/51] [GFS2] use list_for_each_entry instead
- From: [email protected]
- [PATCH 17/51] [GFS2] unneeded typecast
- From: [email protected]
- [PATCH 18/51] [GFS2] better code for translating characters
- From: [email protected]
- [PATCH 19/51] [GFS2] Force unstuff of hidden quota inode
- From: [email protected]
- [PATCH 20/51] [GFS2] fixed a NULL pointer assignment BUG
- From: [email protected]
- [PATCH 21/51] [GFS2] Fix quota do_list operation hang
- From: [email protected]
- [PATCH 22/51] [GFS2] Clean up invalidatepage/releasepage
- From: [email protected]
- [PATCH 23/51] [GFS2] Add a missing gfs2_trans_add_bh()
- From: [email protected]
- [PATCH 24/51] [GFS2] Add NULL entry to token table
- From: [email protected]
- [GFS2/DLM] Pre-pull patch posting
- Prev by Date: [PATCH 24/51] [GFS2] Add NULL entry to token table
- Next by Date: [PATCH 26/51] [DLM] Fix lowcomms socket closing
- Previous by thread: [PATCH 24/51] [GFS2] Add NULL entry to token table
- Next by thread: [PATCH 26/51] [DLM] Fix lowcomms socket closing
- Index(es):