Skip to content

Commit

Permalink
fs/9p: call vmtruncate before setattr 9p opeation
Browse files Browse the repository at this point in the history
We need to call vmtruncate before 9p setattr operation, otherwise we
could write back some dirty pages between setattr with ATTR_SIZE and vmtruncate
causing some truncated pages to be written back to server

Signed-off-by: Aneesh Kumar K.V <[email protected]>
Signed-off-by: Venkateswararao Jujjuri <[email protected]>
Signed-off-by: Eric Van Hensbergen <[email protected]>
  • Loading branch information
kvaneesh authored and ericvh committed Mar 15, 2011
1 parent c06c066 commit f10fc50
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
10 changes: 4 additions & 6 deletions fs/9p/vfs_inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -993,18 +993,16 @@ static int v9fs_vfs_setattr(struct dentry *dentry, struct iattr *iattr)
if (iattr->ia_valid & ATTR_GID)
wstat.n_gid = iattr->ia_gid;
}

retval = p9_client_wstat(fid, &wstat);
if (retval < 0)
return retval;

v9fs_invalidate_inode_attr(dentry->d_inode);
if ((iattr->ia_valid & ATTR_SIZE) &&
iattr->ia_size != i_size_read(dentry->d_inode)) {
retval = vmtruncate(dentry->d_inode, iattr->ia_size);
if (retval)
return retval;
}
retval = p9_client_wstat(fid, &wstat);
if (retval < 0)
return retval;
v9fs_invalidate_inode_attr(dentry->d_inode);

setattr_copy(dentry->d_inode, iattr);
mark_inode_dirty(dentry->d_inode);
Expand Down
9 changes: 4 additions & 5 deletions fs/9p/vfs_inode_dotl.c
Original file line number Diff line number Diff line change
Expand Up @@ -453,17 +453,16 @@ int v9fs_vfs_setattr_dotl(struct dentry *dentry, struct iattr *iattr)
if (IS_ERR(fid))
return PTR_ERR(fid);

retval = p9_client_setattr(fid, &p9attr);
if (retval < 0)
return retval;

v9fs_invalidate_inode_attr(dentry->d_inode);
if ((iattr->ia_valid & ATTR_SIZE) &&
iattr->ia_size != i_size_read(dentry->d_inode)) {
retval = vmtruncate(dentry->d_inode, iattr->ia_size);
if (retval)
return retval;
}
retval = p9_client_setattr(fid, &p9attr);
if (retval < 0)
return retval;
v9fs_invalidate_inode_attr(dentry->d_inode);

setattr_copy(dentry->d_inode, iattr);
mark_inode_dirty(dentry->d_inode);
Expand Down

0 comments on commit f10fc50

Please sign in to comment.