From: Aneesh Kumar K.V Date: Mon, 28 Feb 2011 11:34:04 +0000 (+0530) Subject: fs/9p: Fix inode i_size update in file_write X-Git-Tag: v2.6.39-rc1~489^2~14 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fa6ea16160c72c448e2728dab4b6b0a133fdfc98;p=platform%2Fkernel%2Flinux-3.10.git fs/9p: Fix inode i_size update in file_write Only update inode i_size when we write towards end of file. Signed-off-by: Aneesh Kumar K.V Signed-off-by: Venkateswararao Jujjuri Signed-off-by: Eric Van Hensbergen --- diff --git a/fs/9p/vfs_file.c b/fs/9p/vfs_file.c index 98c4307a..3cff25e 100644 --- a/fs/9p/vfs_file.c +++ b/fs/9p/vfs_file.c @@ -440,6 +440,7 @@ v9fs_file_write_internal(struct inode *inode, struct p9_fid *fid, loff_t *offset, int invalidate) { int n; + loff_t i_size; size_t total = 0; struct p9_client *clnt; loff_t origin = *offset; @@ -464,8 +465,11 @@ v9fs_file_write_internal(struct inode *inode, struct p9_fid *fid, invalidate_inode_pages2_range(inode->i_mapping, pg_start, pg_end); *offset += total; - i_size_write(inode, i_size_read(inode) + total); - inode->i_blocks = (i_size_read(inode) + 512 - 1) >> 9; + i_size = i_size_read(inode); + if (*offset > i_size) { + inode_add_bytes(inode, *offset - i_size); + i_size_write(inode, *offset); + } } if (n < 0) return n;