Skip to contentSkip to conversation

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

PATCH In review Jan Kara 2 participants 2 messages Mar 2, 2010

Subsystems (2)
lore
Share & tools
lore

Jan Kara

author reviewer
#0 lore raw

PATCH 1/1 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.

---
 fs/quota/dquot.c |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)

I'm sending this patch for review. I plan to merge this fix via my tree.

Honza

fs/quota/dquot.c +7 -5
index 4d2041f..10d021d 100644
@@ -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)) {
-		/* As we bypass the pagecache we must now flush the inode so
-		 * that we see all the changes from userspace... */
-		write_inode_now(inode, 1);
-		/* And now flush the block cache so that kernel sees the
-		 * changes */
+		/* As we bypass the pagecache we must now flush all the
+		 * dirty data and invalidate caches so that kernel sees
+		 * changes from userspace. It is not enough to just flush
+		 * the quota file since if blocksize < pagesize, invalidation
+		 * of the cache could fail because of other unrelated dirty
+		 * data */
+		sync_filesystem(sb);
 		invalidate_bdev(sb->s_bdev);
 	}
 	mutex_lock(&dqopt->dqonoff_mutex);
Signature · 1 line
1.6.4.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Jan Kara

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.

Looks good to me,