From: Wendy Cheng <wcheng@redhat.com> Subject: [RHEL5.1 PATCH] 4/4 BZ 243136 GFS2 inode size Date: Thu, 28 Jun 2007 01:30:34 -0400 Bugzilla: 243136 Message-Id: <4683477A.4040208@redhat.com> Changelog: [gfs2] inode size inconsistency BZ 243136 [patch 4/4] GFS2 inode size inconsistency GFS2 truncate code is chopped into two parts, one for vfs inode changes (in vmtruncate()) and one of gfs inode (in gfs2_truncatei()). These two operations are not atomic. It could happens that vmtruncate() succeeds (inode->i_size is changed) but gfs2_truncatei fails (say temporarily out of memory). This leaves gfs inode i_di.di_size out of sync with vfs inode i_size. It will later confuse gfs2_commit_write() if a write is issued that results with file corruption. -- Wendy --- gfs2-nfs2/fs/gfs2/ops_inode.c 2007-06-23 01:24:22.000000000 -0400 +++ gfs2-nfs/fs/gfs2/ops_inode.c 2007-06-27 10:45:57.000000000 -0400 @@ -903,8 +903,8 @@ static int setattr_size(struct inode *in } error = gfs2_truncatei(ip, attr->ia_size); - if (error) - return error; + if (error && (inode->i_size != ip->i_di.di_size)) + i_size_write(inode, ip->i_di.di_size); return error; }