[PATCH 01/14] fs/9p: Fix inode i_size update in file_write

From: Aneesh Kumar K.V
Date: Thu Feb 17 2011 - 13:05:44 EST


Only update inode i_size when we write towards end of file.

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@xxxxxxxxxxxxxxxxxx>
---
fs/9p/vfs_file.c | 9 ++++++---
1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/fs/9p/vfs_file.c b/fs/9p/vfs_file.c
index e9cd277..a56a33b 100644
--- a/fs/9p/vfs_file.c
+++ b/fs/9p/vfs_file.c
@@ -451,6 +451,7 @@ v9fs_file_write_internal(struct inode *inode, struct p9_fid *fid, char *data,
size_t count, loff_t *offset)
{
int n;
+ loff_t i_size;
size_t total = 0;
struct p9_client *clnt;
loff_t origin = *offset;
@@ -475,10 +476,12 @@ v9fs_file_write_internal(struct inode *inode, struct p9_fid *fid, char *data,
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;

--
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/