fs/9p: Writeback dirty data before setattr
authorAneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Mon, 28 Feb 2011 11:34:11 +0000 (17:04 +0530)
committerEric Van Hensbergen <ericvh@gmail.com>
Tue, 15 Mar 2011 14:57:42 +0000 (09:57 -0500)
change file attribute can result in making the file readonly.
So flush the dirty pages before that.

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 2555776920ad8647e78b47535b6ecd223360b41c..8a2c232f708a022d44d72522544697d84233aa08 100644 (file)
@@ -999,6 +999,10 @@ static int v9fs_vfs_setattr(struct dentry *dentry, struct iattr *iattr)
                if (retval)
                        return retval;
        }
+       /* Write all dirty data */
+       if (S_ISREG(dentry->d_inode->i_mode))
+               filemap_write_and_wait(dentry->d_inode->i_mapping);
+
        retval = p9_client_wstat(fid, &wstat);
        if (retval < 0)
                return retval;
index bcd0ee2e549a872ff76f9bbba30f834a20457db0..67c138e94feb6f8d64ea78cba9d32c9aa0afd7fa 100644 (file)
@@ -459,6 +459,10 @@ int v9fs_vfs_setattr_dotl(struct dentry *dentry, struct iattr *iattr)
                if (retval)
                        return retval;
        }
+       /* Write all dirty data */
+       if (S_ISREG(dentry->d_inode->i_mode))
+               filemap_write_and_wait(dentry->d_inode->i_mapping);
+
        retval = p9_client_setattr(fid, &p9attr);
        if (retval < 0)
                return retval;