6565 *
6666 * Fast Commit Ineligibility
6767 * -------------------------
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.
7468 *
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.
8373 *
8474 * Atomicity of commits
8575 * --------------------
@@ -328,44 +318,6 @@ void ext4_fc_mark_ineligible(struct super_block *sb, int reason)
328318 sbi -> s_fc_stats .fc_ineligible_reason_count [reason ]++ ;
329319}
330320
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-
369321/*
370322 * Generic fast commit tracking function. If this is the first time this we are
371323 * called after a full commit, we initialize fast commit fields and then call
@@ -391,7 +343,7 @@ static int ext4_fc_track_template(
391343 (sbi -> s_mount_state & EXT4_FC_REPLAY ))
392344 return - EOPNOTSUPP ;
393345
394- if (ext4_fc_is_ineligible (inode -> i_sb ))
346+ if (ext4_test_mount_flag (inode -> i_sb , EXT4_MF_FC_INELIGIBLE ))
395347 return - EINVAL ;
396348
397349 tid = handle -> h_transaction -> t_tid ;
@@ -1142,11 +1094,8 @@ int ext4_fc_commit(journal_t *journal, tid_t commit_tid)
11421094
11431095 start_time = ktime_get ();
11441096
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 );
11501099
11511100restart_fc :
11521101 ret = jbd2_fc_begin_commit (journal , commit_tid );
@@ -1162,6 +1111,14 @@ int ext4_fc_commit(journal_t *journal, tid_t commit_tid)
11621111 reason = EXT4_FC_REASON_FC_START_FAILED ;
11631112 goto out ;
11641113 }
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+ }
11651122
11661123 fc_bufs_before = (sbi -> s_fc_bytes + bsize - 1 ) / bsize ;
11671124 ret = ext4_fc_perform_commit (journal );
@@ -1180,12 +1137,6 @@ int ext4_fc_commit(journal_t *journal, tid_t commit_tid)
11801137 atomic_inc (& sbi -> s_fc_subtid );
11811138 jbd2_fc_end_commit (journal );
11821139out :
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-
11891140 spin_lock (& sbi -> s_fc_lock );
11901141 if (reason != EXT4_FC_REASON_OK &&
11911142 reason != EXT4_FC_REASON_ALREADY_COMMITTED ) {
0 commit comments