fs/9p: Writeback dirty data before setattr
Aneesh Kumar K.V [Mon, 28 Feb 2011 11:34:11 +0000 (16:34 +0530)]
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 2555776..8a2c232 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 bcd0ee2..67c138e 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;