fs/9p: call vmtruncate before setattr 9p opeation
authorAneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Mon, 28 Feb 2011 11:34:10 +0000 (17:04 +0530)
committerEric Van Hensbergen <ericvh@gmail.com>
Tue, 15 Mar 2011 14:57:42 +0000 (09:57 -0500)
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 <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>
fs/9p/vfs_inode.c
fs/9p/vfs_inode_dotl.c

index 524d255a574805ae00dda44a1e39b1a2700987f8..2555776920ad8647e78b47535b6ecd223360b41c 100644 (file)
@@ -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);
index 81bb4c2a0b82dd0f6b1335e9db463896109ad455..bcd0ee2e549a872ff76f9bbba30f834a20457db0 100644 (file)
@@ -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);