@@ -2206,64 +2206,76 @@ static int f2fs_enable_quotas(struct super_block *sb)
2206
2206
return 0 ;
2207
2207
}
2208
2208
2209
+ static int f2fs_quota_sync_file (struct f2fs_sb_info * sbi , int type )
2210
+ {
2211
+ struct quota_info * dqopt = sb_dqopt (sbi -> sb );
2212
+ struct address_space * mapping = dqopt -> files [type ]-> i_mapping ;
2213
+ int ret = 0 ;
2214
+
2215
+ ret = dquot_writeback_dquots (sbi -> sb , type );
2216
+ if (ret )
2217
+ goto out ;
2218
+
2219
+ ret = filemap_fdatawrite (mapping );
2220
+ if (ret )
2221
+ goto out ;
2222
+
2223
+ /* if we are using journalled quota */
2224
+ if (is_journalled_quota (sbi ))
2225
+ goto out ;
2226
+
2227
+ ret = filemap_fdatawait (mapping );
2228
+
2229
+ truncate_inode_pages (& dqopt -> files [type ]-> i_data , 0 );
2230
+ out :
2231
+ if (ret )
2232
+ set_sbi_flag (sbi , SBI_QUOTA_NEED_REPAIR );
2233
+ return ret ;
2234
+ }
2235
+
2209
2236
int f2fs_quota_sync (struct super_block * sb , int type )
2210
2237
{
2211
2238
struct f2fs_sb_info * sbi = F2FS_SB (sb );
2212
2239
struct quota_info * dqopt = sb_dqopt (sb );
2213
2240
int cnt ;
2214
2241
int ret ;
2215
2242
2216
- /*
2217
- * do_quotactl
2218
- * f2fs_quota_sync
2219
- * down_read(quota_sem)
2220
- * dquot_writeback_dquots()
2221
- * f2fs_dquot_commit
2222
- * block_operation
2223
- * down_read(quota_sem)
2224
- */
2225
- f2fs_lock_op (sbi );
2226
-
2227
- down_read (& sbi -> quota_sem );
2228
- ret = dquot_writeback_dquots (sb , type );
2229
- if (ret )
2230
- goto out ;
2231
-
2232
2243
/*
2233
2244
* Now when everything is written we can discard the pagecache so
2234
2245
* that userspace sees the changes.
2235
2246
*/
2236
2247
for (cnt = 0 ; cnt < MAXQUOTAS ; cnt ++ ) {
2237
- struct address_space * mapping ;
2238
2248
2239
2249
if (type != -1 && cnt != type )
2240
2250
continue ;
2241
- if (!sb_has_quota_active (sb , cnt ))
2242
- continue ;
2243
2251
2244
- mapping = dqopt -> files [cnt ]-> i_mapping ;
2252
+ if (!sb_has_quota_active (sb , type ))
2253
+ return 0 ;
2245
2254
2246
- ret = filemap_fdatawrite (mapping );
2247
- if (ret )
2248
- goto out ;
2255
+ inode_lock (dqopt -> files [cnt ]);
2249
2256
2250
- /* if we are using journalled quota */
2251
- if (is_journalled_quota (sbi ))
2252
- continue ;
2257
+ /*
2258
+ * do_quotactl
2259
+ * f2fs_quota_sync
2260
+ * down_read(quota_sem)
2261
+ * dquot_writeback_dquots()
2262
+ * f2fs_dquot_commit
2263
+ * block_operation
2264
+ * down_read(quota_sem)
2265
+ */
2266
+ f2fs_lock_op (sbi );
2267
+ down_read (& sbi -> quota_sem );
2253
2268
2254
- ret = filemap_fdatawait (mapping );
2255
- if (ret )
2256
- set_sbi_flag (F2FS_SB (sb ), SBI_QUOTA_NEED_REPAIR );
2269
+ ret = f2fs_quota_sync_file (sbi , cnt );
2270
+
2271
+ up_read (& sbi -> quota_sem );
2272
+ f2fs_unlock_op (sbi );
2257
2273
2258
- inode_lock (dqopt -> files [cnt ]);
2259
- truncate_inode_pages (& dqopt -> files [cnt ]-> i_data , 0 );
2260
2274
inode_unlock (dqopt -> files [cnt ]);
2275
+
2276
+ if (ret )
2277
+ break ;
2261
2278
}
2262
- out :
2263
- if (ret )
2264
- set_sbi_flag (F2FS_SB (sb ), SBI_QUOTA_NEED_REPAIR );
2265
- up_read (& sbi -> quota_sem );
2266
- f2fs_unlock_op (sbi );
2267
2279
return ret ;
2268
2280
}
2269
2281
0 commit comments