@@ -2518,64 +2518,76 @@ static int f2fs_enable_quotas(struct super_block *sb)
2518
2518
return 0 ;
2519
2519
}
2520
2520
2521
+ static int f2fs_quota_sync_file (struct f2fs_sb_info * sbi , int type )
2522
+ {
2523
+ struct quota_info * dqopt = sb_dqopt (sbi -> sb );
2524
+ struct address_space * mapping = dqopt -> files [type ]-> i_mapping ;
2525
+ int ret = 0 ;
2526
+
2527
+ ret = dquot_writeback_dquots (sbi -> sb , type );
2528
+ if (ret )
2529
+ goto out ;
2530
+
2531
+ ret = filemap_fdatawrite (mapping );
2532
+ if (ret )
2533
+ goto out ;
2534
+
2535
+ /* if we are using journalled quota */
2536
+ if (is_journalled_quota (sbi ))
2537
+ goto out ;
2538
+
2539
+ ret = filemap_fdatawait (mapping );
2540
+
2541
+ truncate_inode_pages (& dqopt -> files [type ]-> i_data , 0 );
2542
+ out :
2543
+ if (ret )
2544
+ set_sbi_flag (sbi , SBI_QUOTA_NEED_REPAIR );
2545
+ return ret ;
2546
+ }
2547
+
2521
2548
int f2fs_quota_sync (struct super_block * sb , int type )
2522
2549
{
2523
2550
struct f2fs_sb_info * sbi = F2FS_SB (sb );
2524
2551
struct quota_info * dqopt = sb_dqopt (sb );
2525
2552
int cnt ;
2526
2553
int ret ;
2527
2554
2528
- /*
2529
- * do_quotactl
2530
- * f2fs_quota_sync
2531
- * down_read(quota_sem)
2532
- * dquot_writeback_dquots()
2533
- * f2fs_dquot_commit
2534
- * block_operation
2535
- * down_read(quota_sem)
2536
- */
2537
- f2fs_lock_op (sbi );
2538
-
2539
- down_read (& sbi -> quota_sem );
2540
- ret = dquot_writeback_dquots (sb , type );
2541
- if (ret )
2542
- goto out ;
2543
-
2544
2555
/*
2545
2556
* Now when everything is written we can discard the pagecache so
2546
2557
* that userspace sees the changes.
2547
2558
*/
2548
2559
for (cnt = 0 ; cnt < MAXQUOTAS ; cnt ++ ) {
2549
- struct address_space * mapping ;
2550
2560
2551
2561
if (type != -1 && cnt != type )
2552
2562
continue ;
2553
- if (!sb_has_quota_active (sb , cnt ))
2554
- continue ;
2555
2563
2556
- mapping = dqopt -> files [cnt ]-> i_mapping ;
2564
+ if (!sb_has_quota_active (sb , type ))
2565
+ return 0 ;
2557
2566
2558
- ret = filemap_fdatawrite (mapping );
2559
- if (ret )
2560
- goto out ;
2567
+ inode_lock (dqopt -> files [cnt ]);
2561
2568
2562
- /* if we are using journalled quota */
2563
- if (is_journalled_quota (sbi ))
2564
- continue ;
2569
+ /*
2570
+ * do_quotactl
2571
+ * f2fs_quota_sync
2572
+ * down_read(quota_sem)
2573
+ * dquot_writeback_dquots()
2574
+ * f2fs_dquot_commit
2575
+ * block_operation
2576
+ * down_read(quota_sem)
2577
+ */
2578
+ f2fs_lock_op (sbi );
2579
+ down_read (& sbi -> quota_sem );
2565
2580
2566
- ret = filemap_fdatawait (mapping );
2567
- if (ret )
2568
- set_sbi_flag (F2FS_SB (sb ), SBI_QUOTA_NEED_REPAIR );
2581
+ ret = f2fs_quota_sync_file (sbi , cnt );
2582
+
2583
+ up_read (& sbi -> quota_sem );
2584
+ f2fs_unlock_op (sbi );
2569
2585
2570
- inode_lock (dqopt -> files [cnt ]);
2571
- truncate_inode_pages (& dqopt -> files [cnt ]-> i_data , 0 );
2572
2586
inode_unlock (dqopt -> files [cnt ]);
2587
+
2588
+ if (ret )
2589
+ break ;
2573
2590
}
2574
- out :
2575
- if (ret )
2576
- set_sbi_flag (F2FS_SB (sb ), SBI_QUOTA_NEED_REPAIR );
2577
- up_read (& sbi -> quota_sem );
2578
- f2fs_unlock_op (sbi );
2579
2591
return ret ;
2580
2592
}
2581
2593
0 commit comments