diff options
| author | Jan Kara <jack@suse.cz> | 2008-05-13 19:11:51 -0400 |
|---|---|---|
| committer | Theodore Ts'o <tytso@mit.edu> | 2008-05-13 19:11:51 -0400 |
| commit | 0623543b3335c8e439cacf21af99bbf45da42c5a (patch) | |
| tree | 41f6df8f1c11594df2834e3f54a68d08df25ef63 | |
| parent | cd59e7b9781a35716b8a3e8c4aa2d48081d7daf7 (diff) | |
ext4: fix synchronization of quota files in journal=data mode
In journal=data mode, it is not enough to do write_inode_now as done in
vfs_quota_on() to write all data to their final location (which is
needed for quota_read to work correctly). Calling journal_flush() does
its job.
Cc: <linux-ext4@vger.kernel.org>
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Mingming Cao <cmm@us.ibm.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
| -rw-r--r-- | fs/ext4/super.c | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 94a527261cae..cddf7f0e0fda 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c | |||
| @@ -3170,23 +3170,42 @@ static int ext4_quota_on(struct super_block *sb, int type, int format_id, | |||
| 3170 | 3170 | ||
| 3171 | if (!test_opt(sb, QUOTA)) | 3171 | if (!test_opt(sb, QUOTA)) |
| 3172 | return -EINVAL; | 3172 | return -EINVAL; |
| 3173 | /* Not journalling quota? */ | 3173 | /* When remounting, no checks are needed and in fact, path is NULL */ |
| 3174 | if ((!EXT4_SB(sb)->s_qf_names[USRQUOTA] && | 3174 | if (remount) |
| 3175 | !EXT4_SB(sb)->s_qf_names[GRPQUOTA]) || remount) | ||
| 3176 | return vfs_quota_on(sb, type, format_id, path, remount); | 3175 | return vfs_quota_on(sb, type, format_id, path, remount); |
| 3176 | |||
| 3177 | err = path_lookup(path, LOOKUP_FOLLOW, &nd); | 3177 | err = path_lookup(path, LOOKUP_FOLLOW, &nd); |
| 3178 | if (err) | 3178 | if (err) |
| 3179 | return err; | 3179 | return err; |
| 3180 | |||
| 3180 | /* Quotafile not on the same filesystem? */ | 3181 | /* Quotafile not on the same filesystem? */ |
| 3181 | if (nd.path.mnt->mnt_sb != sb) { | 3182 | if (nd.path.mnt->mnt_sb != sb) { |
| 3182 | path_put(&nd.path); | 3183 | path_put(&nd.path); |
| 3183 | return -EXDEV; | 3184 | return -EXDEV; |
| 3184 | } | 3185 | } |
| 3185 | /* Quotafile not of fs root? */ | 3186 | /* Journaling quota? */ |
| 3186 | if (nd.path.dentry->d_parent->d_inode != sb->s_root->d_inode) | 3187 | if (EXT4_SB(sb)->s_qf_names[type]) { |
| 3187 | printk(KERN_WARNING | 3188 | /* Quotafile not of fs root? */ |
| 3188 | "EXT4-fs: Quota file not on filesystem root. " | 3189 | if (nd.path.dentry->d_parent->d_inode != sb->s_root->d_inode) |
| 3189 | "Journalled quota will not work.\n"); | 3190 | printk(KERN_WARNING |
| 3191 | "EXT4-fs: Quota file not on filesystem root. " | ||
| 3192 | "Journaled quota will not work.\n"); | ||
| 3193 | } | ||
| 3194 | |||
| 3195 | /* | ||
| 3196 | * When we journal data on quota file, we have to flush journal to see | ||
| 3197 | * all updates to the file when we bypass pagecache... | ||
| 3198 | */ | ||
| 3199 | if (ext4_should_journal_data(nd.path.dentry->d_inode)) { | ||
| 3200 | /* | ||
| 3201 | * We don't need to lock updates but journal_flush() could | ||
| 3202 | * otherwise be livelocked... | ||
| 3203 | */ | ||
| 3204 | jbd2_journal_lock_updates(EXT4_SB(sb)->s_journal); | ||
| 3205 | jbd2_journal_flush(EXT4_SB(sb)->s_journal); | ||
| 3206 | jbd2_journal_unlock_updates(EXT4_SB(sb)->s_journal); | ||
| 3207 | } | ||
| 3208 | |||
| 3190 | path_put(&nd.path); | 3209 | path_put(&nd.path); |
| 3191 | return vfs_quota_on(sb, type, format_id, path, remount); | 3210 | return vfs_quota_on(sb, type, format_id, path, remount); |
| 3192 | } | 3211 | } |
