Skip to content

Commit a117782

Browse files
jankaraAl Viro
authored andcommitted
quota: Move quota syncing to ->sync_fs method
Since the moment writes to quota files are using block device page cache and space for quota structures is reserved at the moment they are first accessed we have no reason to sync quota before inode writeback. In fact this order is now only harmful since quota information can easily change during inode writeback (either because conversion of delayed-allocated extents or simply because of allocation of new blocks for simple filesystems not using page_mkwrite). So move syncing of quota information after writeback of inodes into ->sync_fs method. This way we do not have to use ->quota_sync callback which is primarily intended for use by quotactl syscall anyway and we get rid of calling ->sync_fs() twice unnecessarily. We skip quota syncing for OCFS2 since it does proper quota journalling in all cases (unlike ext3, ext4, and reiserfs which also support legacy non-journalled quotas) and thus there are no dirty quota structures. CC: "Theodore Ts'o" <tytso@mit.edu> CC: Joel Becker <jlbec@evilplan.org> CC: reiserfs-devel@vger.kernel.org Acked-by: Steven Whitehouse <swhiteho@redhat.com> Acked-by: Dave Kleikamp <shaggy@kernel.org> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Jan Kara <jack@suse.cz> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent ceed172 commit a117782

7 files changed

Lines changed: 28 additions & 3 deletions

File tree

‎fs/ext2/super.c‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1184,6 +1184,12 @@ static int ext2_sync_fs(struct super_block *sb, int wait)
11841184
struct ext2_sb_info *sbi = EXT2_SB(sb);
11851185
struct ext2_super_block *es = EXT2_SB(sb)->s_es;
11861186

1187+
/*
1188+
* Write quota structures to quota file, sync_blockdev() will write
1189+
* them to disk later
1190+
*/
1191+
dquot_writeback_dquots(sb, -1);
1192+
11871193
spin_lock(&sbi->s_lock);
11881194
if (es->s_state & cpu_to_le16(EXT2_VALID_FS)) {
11891195
ext2_debug("setting valid to 0\n");

‎fs/ext3/super.c‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2526,6 +2526,11 @@ static int ext3_sync_fs(struct super_block *sb, int wait)
25262526
tid_t target;
25272527

25282528
trace_ext3_sync_fs(sb, wait);
2529+
/*
2530+
* Writeback quota in non-journalled quota case - journalled quota has
2531+
* no dirty dquots
2532+
*/
2533+
dquot_writeback_dquots(sb, -1);
25292534
if (journal_start_commit(EXT3_SB(sb)->s_journal, &target)) {
25302535
if (wait)
25312536
log_wait_commit(EXT3_SB(sb)->s_journal, target);

‎fs/ext4/super.c‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4325,6 +4325,11 @@ static int ext4_sync_fs(struct super_block *sb, int wait)
43254325

43264326
trace_ext4_sync_fs(sb, wait);
43274327
flush_workqueue(sbi->dio_unwritten_wq);
4328+
/*
4329+
* Writeback quota in non-journalled quota case - journalled quota has
4330+
* no dirty dquots
4331+
*/
4332+
dquot_writeback_dquots(sb, -1);
43284333
if (jbd2_journal_start_commit(sbi->s_journal, &target)) {
43294334
if (wait)
43304335
jbd2_log_wait_commit(sbi->s_journal, target);

‎fs/gfs2/super.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -952,6 +952,8 @@ static void gfs2_put_super(struct super_block *sb)
952952
static int gfs2_sync_fs(struct super_block *sb, int wait)
953953
{
954954
struct gfs2_sbd *sdp = sb->s_fs_info;
955+
956+
gfs2_quota_sync(sb, -1);
955957
if (wait && sdp)
956958
gfs2_log_flush(sdp, NULL);
957959
return 0;

‎fs/jfs/super.c‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -601,6 +601,11 @@ static int jfs_sync_fs(struct super_block *sb, int wait)
601601

602602
/* log == NULL indicates read-only mount */
603603
if (log) {
604+
/*
605+
* Write quota structures to quota file, sync_blockdev() will
606+
* write them to disk later
607+
*/
608+
dquot_writeback_dquots(sb, -1);
604609
jfs_flush_journal(log, wait);
605610
jfs_syncpt(log, 0);
606611
}

‎fs/reiserfs/super.c‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@ static int reiserfs_sync_fs(struct super_block *s, int wait)
6868
{
6969
struct reiserfs_transaction_handle th;
7070

71+
/*
72+
* Writeback quota in non-journalled quota case - journalled quota has
73+
* no dirty dquots
74+
*/
75+
dquot_writeback_dquots(s, -1);
7176
reiserfs_write_lock(s);
7277
if (!journal_begin(&th, s, 1))
7378
if (!journal_end_sync(&th, s, 1))

‎fs/sync.c‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@
2929
*/
3030
static int __sync_filesystem(struct super_block *sb, int wait)
3131
{
32-
if (sb->s_qcop && sb->s_qcop->quota_sync)
33-
sb->s_qcop->quota_sync(sb, -1);
34-
3532
if (wait)
3633
sync_inodes_sb(sb);
3734
else

0 commit comments

Comments
 (0)