diff mbox

[V9fs-developer,01/14] fs/9p: Fix inode i_size update in file_write

Message ID 1297965725-25603-2-git-send-email-aneesh.kumar@linux.vnet.ibm.com (mailing list archive)
State Accepted, archived
Delegated to: Eric Van Hensbergen
Headers show

Commit Message

Aneesh Kumar K.V Feb. 17, 2011, 6:01 p.m. UTC
None
diff mbox

Patch

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;