@@ -2399,64 +2399,76 @@ static int f2fs_enable_quotas(struct super_block *sb)
2399
2399
return 0 ;
2400
2400
}
2401
2401
2402
+ static int f2fs_quota_sync_file (struct f2fs_sb_info * sbi , int type )
2403
+ {
2404
+ struct quota_info * dqopt = sb_dqopt (sbi -> sb );
2405
+ struct address_space * mapping = dqopt -> files [type ]-> i_mapping ;
2406
+ int ret = 0 ;
2407
+
2408
+ ret = dquot_writeback_dquots (sbi -> sb , type );
2409
+ if (ret )
2410
+ goto out ;
2411
+
2412
+ ret = filemap_fdatawrite (mapping );
2413
+ if (ret )
2414
+ goto out ;
2415
+
2416
+ /* if we are using journalled quota */
2417
+ if (is_journalled_quota (sbi ))
2418
+ goto out ;
2419
+
2420
+ ret = filemap_fdatawait (mapping );
2421
+
2422
+ truncate_inode_pages (& dqopt -> files [type ]-> i_data , 0 );
2423
+ out :
2424
+ if (ret )
2425
+ set_sbi_flag (sbi , SBI_QUOTA_NEED_REPAIR );
2426
+ return ret ;
2427
+ }
2428
+
2402
2429
int f2fs_quota_sync (struct super_block * sb , int type )
2403
2430
{
2404
2431
struct f2fs_sb_info * sbi = F2FS_SB (sb );
2405
2432
struct quota_info * dqopt = sb_dqopt (sb );
2406
2433
int cnt ;
2407
2434
int ret ;
2408
2435
2409
- /*
2410
- * do_quotactl
2411
- * f2fs_quota_sync
2412
- * down_read(quota_sem)
2413
- * dquot_writeback_dquots()
2414
- * f2fs_dquot_commit
2415
- * block_operation
2416
- * down_read(quota_sem)
2417
- */
2418
- f2fs_lock_op (sbi );
2419
-
2420
- down_read (& sbi -> quota_sem );
2421
- ret = dquot_writeback_dquots (sb , type );
2422
- if (ret )
2423
- goto out ;
2424
-
2425
2436
/*
2426
2437
* Now when everything is written we can discard the pagecache so
2427
2438
* that userspace sees the changes.
2428
2439
*/
2429
2440
for (cnt = 0 ; cnt < MAXQUOTAS ; cnt ++ ) {
2430
- struct address_space * mapping ;
2431
2441
2432
2442
if (type != -1 && cnt != type )
2433
2443
continue ;
2434
- if (!sb_has_quota_active (sb , cnt ))
2435
- continue ;
2436
2444
2437
- mapping = dqopt -> files [cnt ]-> i_mapping ;
2445
+ if (!sb_has_quota_active (sb , type ))
2446
+ return 0 ;
2438
2447
2439
- ret = filemap_fdatawrite (mapping );
2440
- if (ret )
2441
- goto out ;
2448
+ inode_lock (dqopt -> files [cnt ]);
2442
2449
2443
- /* if we are using journalled quota */
2444
- if (is_journalled_quota (sbi ))
2445
- continue ;
2450
+ /*
2451
+ * do_quotactl
2452
+ * f2fs_quota_sync
2453
+ * down_read(quota_sem)
2454
+ * dquot_writeback_dquots()
2455
+ * f2fs_dquot_commit
2456
+ * block_operation
2457
+ * down_read(quota_sem)
2458
+ */
2459
+ f2fs_lock_op (sbi );
2460
+ down_read (& sbi -> quota_sem );
2446
2461
2447
- ret = filemap_fdatawait (mapping );
2448
- if (ret )
2449
- set_sbi_flag (F2FS_SB (sb ), SBI_QUOTA_NEED_REPAIR );
2462
+ ret = f2fs_quota_sync_file (sbi , cnt );
2463
+
2464
+ up_read (& sbi -> quota_sem );
2465
+ f2fs_unlock_op (sbi );
2450
2466
2451
- inode_lock (dqopt -> files [cnt ]);
2452
- truncate_inode_pages (& dqopt -> files [cnt ]-> i_data , 0 );
2453
2467
inode_unlock (dqopt -> files [cnt ]);
2468
+
2469
+ if (ret )
2470
+ break ;
2454
2471
}
2455
- out :
2456
- if (ret )
2457
- set_sbi_flag (F2FS_SB (sb ), SBI_QUOTA_NEED_REPAIR );
2458
- up_read (& sbi -> quota_sem );
2459
- f2fs_unlock_op (sbi );
2460
2472
return ret ;
2461
2473
}
2462
2474
0 commit comments