Skip to content

Commit

Permalink
[GFS2] inode size inconsistency
Browse files Browse the repository at this point in the history
This should have been part of the NFS patch #1 but somehow I missed it
when packaging the patches. It is not a critical issue as the others (I
hope). RHEL 5.1 31.el5 kernel runs fine without this change.

Our truncate code is chopped into two parts, one for vfs inode changes
(in vmtruncate()) and one of gfs inode (in gfs2_truncatei()). These two
operatons are, unfortunately, not atomic. So it could happens that
vmtruncate() succeeds (inode->i_size is changed) but gfs2_truncatei
fails (say kernel temporarily out of memory). This would leave 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. Last time I checked, it will
cause file corruption.

Signed-off-by: S. Wendy Cheng <wcheng@redhat.com>
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
  • Loading branch information
Wendy Cheng authored and Steven Whitehouse committed Jul 9, 2007
1 parent 97d8483 commit 090ffaa
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions fs/gfs2/ops_inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -903,8 +903,8 @@ static int setattr_size(struct inode *inode, struct iattr *attr)
}

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;
}
Expand Down

0 comments on commit 090ffaa

Please sign in to comment.