quota: Properly invalidate caches even for filesystems with blocksize < pagesize

Sometimes invalidate_bdev() can fail to invalidate a part of block
device cache because of dirty data. If the filesystem has blocksize
smaller than page size, this can happen even for pages containing
quota files and thus kernel would operate on stale data. Fix the
issue by syncing the filesystem before invalidating the cache.

Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jan Kara <jack@suse.cz>
This commit is contained in:
Jan Kara
2010-02-22 21:07:17 +01:00
parent 8ddd69d6df
commit ab94c39b6f

View File

@@ -2033,11 +2033,13 @@ static int vfs_load_quota_inode(struct inode *inode, int type, int format_id,
} }
if (!(dqopt->flags & DQUOT_QUOTA_SYS_FILE)) { if (!(dqopt->flags & DQUOT_QUOTA_SYS_FILE)) {
/* As we bypass the pagecache we must now flush the inode so /* As we bypass the pagecache we must now flush all the
* that we see all the changes from userspace... */ * dirty data and invalidate caches so that kernel sees
write_inode_now(inode, 1); * changes from userspace. It is not enough to just flush
/* And now flush the block cache so that kernel sees the * the quota file since if blocksize < pagesize, invalidation
* changes */ * of the cache could fail because of other unrelated dirty
* data */
sync_filesystem(sb);
invalidate_bdev(sb->s_bdev); invalidate_bdev(sb->s_bdev);
} }
mutex_lock(&dqopt->dqonoff_mutex); mutex_lock(&dqopt->dqonoff_mutex);