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 <aneesh.kumar@linux.vnet.ibm.com> Signed-off-by: Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com> Signed-off-by: Eric Van Hensbergen <ericvh@gmail.com>
This commit is contained in:
parent
6b365604ca
commit
fa6ea16160
|
@ -440,6 +440,7 @@ v9fs_file_write_internal(struct inode *inode, struct p9_fid *fid,
|
||||||
loff_t *offset, int invalidate)
|
loff_t *offset, int invalidate)
|
||||||
{
|
{
|
||||||
int n;
|
int n;
|
||||||
|
loff_t i_size;
|
||||||
size_t total = 0;
|
size_t total = 0;
|
||||||
struct p9_client *clnt;
|
struct p9_client *clnt;
|
||||||
loff_t origin = *offset;
|
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,
|
invalidate_inode_pages2_range(inode->i_mapping,
|
||||||
pg_start, pg_end);
|
pg_start, pg_end);
|
||||||
*offset += total;
|
*offset += total;
|
||||||
i_size_write(inode, i_size_read(inode) + total);
|
i_size = i_size_read(inode);
|
||||||
inode->i_blocks = (i_size_read(inode) + 512 - 1) >> 9;
|
if (*offset > i_size) {
|
||||||
|
inode_add_bytes(inode, *offset - i_size);
|
||||||
|
i_size_write(inode, *offset);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (n < 0)
|
if (n < 0)
|
||||||
return n;
|
return n;
|
||||||
|
|
Loading…
Reference in a new issue