| @@ -65,21 +65,11 @@ · 64 unmodified lines |
| 65 | 65 | * |
| 66 | 66 | * Fast Commit Ineligibility |
| 67 | 67 | * ------------------------- |
| 68 | | − * Not all operations are supported by fast commits today (e.g extended |
| 69 | | − * attributes). Fast commit ineligibility is marked by calling one of the |
| 70 | | − * two following functions: |
| 71 | | − * |
| 72 | | − * - ext4_fc_mark_ineligible(): This makes next fast commit operation to fall |
| 73 | | − * back to full commit. This is useful in case of transient errors. |
| 74 | 68 | * |
| 75 | | − * - ext4_fc_start_ineligible() and ext4_fc_stop_ineligible() - This makes all |
| 76 | | − * the fast commits happening between ext4_fc_start_ineligible() and |
| 77 | | − * ext4_fc_stop_ineligible() and one fast commit after the call to |
| 78 | | − * ext4_fc_stop_ineligible() to fall back to full commits. It is important to |
| 79 | | − * make one more fast commit to fall back to full commit after stop call so |
| 80 | | − * that it guaranteed that the fast commit ineligible operation contained |
| 81 | | − * within ext4_fc_start_ineligible() and ext4_fc_stop_ineligible() is |
| 82 | | − * followed by at least 1 full commit. |
| 69 | + * Not all operations are supported by fast commits today (e.g extended |
| 70 | + * attributes). Fast commit ineligibility is marked by calling |
| 71 | + * ext4_fc_mark_ineligible(): This makes next fast commit operation to fall back |
| 72 | + * to full commit. |
| 83 | 73 | * |
| 84 | 74 | * Atomicity of commits |
| 85 | 75 | * -------------------- |
| @@ -328,44 +318,6 @@ void ext4_fc_mark_ineligible(struct super_block *sb, int reason) · 242 unmodified lines |
| 328 | 318 | sbi->s_fc_stats.fc_ineligible_reason_count[reason]++; |
| 329 | 319 | } |
| 330 | 320 | |
| 331 | | −/* |
| 332 | | − * Start a fast commit ineligible update. Any commits that happen while |
| 333 | | − * such an operation is in progress fall back to full commits. |
| 334 | | − */ |
| 335 | | −void ext4_fc_start_ineligible(struct super_block *sb, int reason) |
| 336 | | −{ |
| 337 | | − struct ext4_sb_info *sbi = EXT4_SB(sb); |
| 338 | | − |
| 339 | | − if (!test_opt2(sb, JOURNAL_FAST_COMMIT) || |
| 340 | | − (EXT4_SB(sb)->s_mount_state & EXT4_FC_REPLAY)) |
| 341 | | − return; |
| 342 | | − |
| 343 | | − WARN_ON(reason >= EXT4_FC_REASON_MAX); |
| 344 | | − sbi->s_fc_stats.fc_ineligible_reason_count[reason]++; |
| 345 | | − atomic_inc(&sbi->s_fc_ineligible_updates); |
| 346 | | −} |
| 347 | | − |
| 348 | | −/* |
| 349 | | − * Stop a fast commit ineligible update. We set EXT4_MF_FC_INELIGIBLE flag here |
| 350 | | − * to ensure that after stopping the ineligible update, at least one full |
| 351 | | − * commit takes place. |
| 352 | | − */ |
| 353 | | −void ext4_fc_stop_ineligible(struct super_block *sb) |
| 354 | | −{ |
| 355 | | − if (!test_opt2(sb, JOURNAL_FAST_COMMIT) || |
| 356 | | − (EXT4_SB(sb)->s_mount_state & EXT4_FC_REPLAY)) |
| 357 | | − return; |
| 358 | | − |
| 359 | | − ext4_set_mount_flag(sb, EXT4_MF_FC_INELIGIBLE); |
| 360 | | − atomic_dec(&EXT4_SB(sb)->s_fc_ineligible_updates); |
| 361 | | −} |
| 362 | | − |
| 363 | | −static inline int ext4_fc_is_ineligible(struct super_block *sb) |
| 364 | | −{ |
| 365 | | − return (ext4_test_mount_flag(sb, EXT4_MF_FC_INELIGIBLE) || |
| 366 | | − atomic_read(&EXT4_SB(sb)->s_fc_ineligible_updates)); |
| 367 | | −} |
| 368 | | − |
| 369 | 321 | /* |
| 370 | 322 | * Generic fast commit tracking function. If this is the first time this we are |
| 371 | 323 | * called after a full commit, we initialize fast commit fields and then call |
| @@ -391,7 +343,7 @@ static int ext4_fc_track_template( · 19 unmodified lines |
| 391 | 343 | (sbi->s_mount_state & EXT4_FC_REPLAY)) |
| 392 | 344 | return -EOPNOTSUPP; |
| 393 | 345 | |
| 394 | | − if (ext4_fc_is_ineligible(inode->i_sb)) |
| 346 | + if (ext4_test_mount_flag(inode->i_sb, EXT4_MF_FC_INELIGIBLE)) |
| 395 | 347 | return -EINVAL; |
| 396 | 348 | |
| 397 | 349 | tid = handle->h_transaction->t_tid; |
| @@ -1142,11 +1094,8 @@ int ext4_fc_commit(journal_t *journal, tid_t commit_tid) · 744 unmodified lines |
| 1142 | 1094 | |
| 1143 | 1095 | start_time = ktime_get(); |
| 1144 | 1096 | |
| 1145 | | − if (!test_opt2(sb, JOURNAL_FAST_COMMIT) || |
| 1146 | | − (ext4_fc_is_ineligible(sb))) { |
| 1147 | | − reason = EXT4_FC_REASON_INELIGIBLE; |
| 1148 | | − goto out; |
| 1149 | | − } |
| 1097 | + if (!test_opt2(sb, JOURNAL_FAST_COMMIT)) |
| 1098 | + return jbd2_complete_transaction(journal, commit_tid); |
| 1150 | 1099 | |
| 1151 | 1100 | restart_fc: |
| 1152 | 1101 | ret = jbd2_fc_begin_commit(journal, commit_tid); |
| @@ -1162,6 +1111,14 @@ restart_fc: · 9 unmodified lines |
| 1162 | 1111 | reason = EXT4_FC_REASON_FC_START_FAILED; |
| 1163 | 1112 | goto out; |
| 1164 | 1113 | } |
| 1114 | + /* |
| 1115 | + * After establishing journal barrier via jbd2_fc_begin_commit(), check |
| 1116 | + * if we are fast commit ineligible. |
| 1117 | + */ |
| 1118 | + if (ext4_test_mount_flag(sb, EXT4_MF_FC_INELIGIBLE)) { |
| 1119 | + reason = EXT4_FC_REASON_INELIGIBLE; |
| 1120 | + goto out; |
| 1121 | + } |
| 1165 | 1122 | |
| 1166 | 1123 | fc_bufs_before = (sbi->s_fc_bytes + bsize - 1) / bsize; |
| 1167 | 1124 | ret = ext4_fc_perform_commit(journal); |
| @@ -1180,12 +1137,6 @@ restart_fc: · 12 unmodified lines |
| 1180 | 1137 | atomic_inc(&sbi->s_fc_subtid); |
| 1181 | 1138 | jbd2_fc_end_commit(journal); |
| 1182 | 1139 | out: |
| 1183 | | − /* Has any ineligible update happened since we started? */ |
| 1184 | | − if (reason == EXT4_FC_REASON_OK && ext4_fc_is_ineligible(sb)) { |
| 1185 | | − sbi->s_fc_stats.fc_ineligible_reason_count[EXT4_FC_COMMIT_FAILED]++; |
| 1186 | | − reason = EXT4_FC_REASON_INELIGIBLE; |
| 1187 | | − } |
| 1188 | | − |
| 1189 | 1140 | spin_lock(&sbi->s_fc_lock); |
| 1190 | 1141 | if (reason != EXT4_FC_REASON_OK && |
| 1191 | 1142 | reason != EXT4_FC_REASON_ALREADY_COMMITTED) { |