aboutsummaryrefslogtreecommitdiffstats
path: root/fs/f2fs/checkpoint.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/f2fs/checkpoint.c')
-rw-r--r--fs/f2fs/checkpoint.c41
1 files changed, 19 insertions, 22 deletions
diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c
index 2d23671d2034..a0eef95b9e0e 100644
--- a/fs/f2fs/checkpoint.c
+++ b/fs/f2fs/checkpoint.c
@@ -1133,17 +1133,24 @@ static void __prepare_cp_block(struct f2fs_sb_info *sbi)
1133 1133
1134static bool __need_flush_quota(struct f2fs_sb_info *sbi) 1134static bool __need_flush_quota(struct f2fs_sb_info *sbi)
1135{ 1135{
1136 bool ret = false;
1137
1136 if (!is_journalled_quota(sbi)) 1138 if (!is_journalled_quota(sbi))
1137 return false; 1139 return false;
1138 if (is_sbi_flag_set(sbi, SBI_QUOTA_SKIP_FLUSH)) 1140
1139 return false; 1141 down_write(&sbi->quota_sem);
1140 if (is_sbi_flag_set(sbi, SBI_QUOTA_NEED_REPAIR)) 1142 if (is_sbi_flag_set(sbi, SBI_QUOTA_SKIP_FLUSH)) {
1141 return false; 1143 ret = false;
1142 if (is_sbi_flag_set(sbi, SBI_QUOTA_NEED_FLUSH)) 1144 } else if (is_sbi_flag_set(sbi, SBI_QUOTA_NEED_REPAIR)) {
1143 return true; 1145 ret = false;
1144 if (get_pages(sbi, F2FS_DIRTY_QDATA)) 1146 } else if (is_sbi_flag_set(sbi, SBI_QUOTA_NEED_FLUSH)) {
1145 return true; 1147 clear_sbi_flag(sbi, SBI_QUOTA_NEED_FLUSH);
1146 return false; 1148 ret = true;
1149 } else if (get_pages(sbi, F2FS_DIRTY_QDATA)) {
1150 ret = true;
1151 }
1152 up_write(&sbi->quota_sem);
1153 return ret;
1147} 1154}
1148 1155
1149/* 1156/*
@@ -1162,26 +1169,22 @@ static int block_operations(struct f2fs_sb_info *sbi)
1162 blk_start_plug(&plug); 1169 blk_start_plug(&plug);
1163 1170
1164retry_flush_quotas: 1171retry_flush_quotas:
1172 f2fs_lock_all(sbi);
1165 if (__need_flush_quota(sbi)) { 1173 if (__need_flush_quota(sbi)) {
1166 int locked; 1174 int locked;
1167 1175
1168 if (++cnt > DEFAULT_RETRY_QUOTA_FLUSH_COUNT) { 1176 if (++cnt > DEFAULT_RETRY_QUOTA_FLUSH_COUNT) {
1169 set_sbi_flag(sbi, SBI_QUOTA_SKIP_FLUSH); 1177 set_sbi_flag(sbi, SBI_QUOTA_SKIP_FLUSH);
1170 f2fs_lock_all(sbi); 1178 set_sbi_flag(sbi, SBI_QUOTA_NEED_FLUSH);
1171 goto retry_flush_dents; 1179 goto retry_flush_dents;
1172 } 1180 }
1173 clear_sbi_flag(sbi, SBI_QUOTA_NEED_FLUSH); 1181 f2fs_unlock_all(sbi);
1174 1182
1175 /* only failed during mount/umount/freeze/quotactl */ 1183 /* only failed during mount/umount/freeze/quotactl */
1176 locked = down_read_trylock(&sbi->sb->s_umount); 1184 locked = down_read_trylock(&sbi->sb->s_umount);
1177 f2fs_quota_sync(sbi->sb, -1); 1185 f2fs_quota_sync(sbi->sb, -1);
1178 if (locked) 1186 if (locked)
1179 up_read(&sbi->sb->s_umount); 1187 up_read(&sbi->sb->s_umount);
1180 }
1181
1182 f2fs_lock_all(sbi);
1183 if (__need_flush_quota(sbi)) {
1184 f2fs_unlock_all(sbi);
1185 cond_resched(); 1188 cond_resched();
1186 goto retry_flush_quotas; 1189 goto retry_flush_quotas;
1187 } 1190 }
@@ -1203,12 +1206,6 @@ retry_flush_dents:
1203 */ 1206 */
1204 down_write(&sbi->node_change); 1207 down_write(&sbi->node_change);
1205 1208
1206 if (__need_flush_quota(sbi)) {
1207 up_write(&sbi->node_change);
1208 f2fs_unlock_all(sbi);
1209 goto retry_flush_quotas;
1210 }
1211
1212 if (get_pages(sbi, F2FS_DIRTY_IMETA)) { 1209 if (get_pages(sbi, F2FS_DIRTY_IMETA)) {
1213 up_write(&sbi->node_change); 1210 up_write(&sbi->node_change);
1214 f2fs_unlock_all(sbi); 1211 f2fs_unlock_all(sbi);