History

ext4: drop ineligible txn start stop APIs

This patch drops ext4_fc_start_ineligible() and ext4_fc_stop_ineligible() APIs. Fast commit ineligible transactions should simply call ext4_fc_mark_ineligible() after starting the trasaction.

Harshad Shirwadkar committed 4 years ago

Commit 7bbbe241 parent 2729cfd5 files · +20 −75Browse files

Unified · Split

5 files
  1. fs/ext4/ext4.h +2 −4
  2. fs/ext4/extents.c +2 −4
  3. fs/ext4/fast_commit.c +15 −64
  4. fs/ext4/ioctl.c +1 −2
  5. fs/ext4/super.c +0 −1
fs/ext4/ext4.h+2−4
@@ -1725,9 +1725,9 @@ struct ext4_sb_info { · 1724 unmodified lines
17251725 */
17261726 struct work_struct s_error_work;
17271727
1728− /* Ext4 fast commit stuff */
1728+ /* Ext4 fast commit sub transaction ID */
17291729 atomic_t s_fc_subtid;
1730− atomic_t s_fc_ineligible_updates;
1730+
17311731 /*
17321732 * After commit starts, the main queue gets locked, and the further
17331733 * updates get added in the staging queue.
@@ -2926,8 +2926,6 @@ void __ext4_fc_track_create(handle_t *handle, struct inode *inode, · 1192 unmodified lines
29262926 void ext4_fc_track_create(handle_t *handle, struct dentry *dentry);
29272927 void ext4_fc_track_inode(handle_t *handle, struct inode *inode);
29282928 void ext4_fc_mark_ineligible(struct super_block *sb, int reason);
2929−void ext4_fc_start_ineligible(struct super_block *sb, int reason);
2930−void ext4_fc_stop_ineligible(struct super_block *sb);
29312929 void ext4_fc_start_update(struct inode *inode);
29322930 void ext4_fc_stop_update(struct inode *inode);
29332931 void ext4_fc_del(struct inode *inode);
fs/ext4/extents.c+2−4
@@ -5341,7 +5341,7 @@ static int ext4_collapse_range(struct inode *inode, loff_t offset, loff_t len) · 5340 unmodified lines
53415341 ret = PTR_ERR(handle);
53425342 goto out_mmap;
53435343 }
5344− ext4_fc_start_ineligible(sb, EXT4_FC_REASON_FALLOC_RANGE);
5344+ ext4_fc_mark_ineligible(sb, EXT4_FC_REASON_FALLOC_RANGE);
53455345
53465346 down_write(&EXT4_I(inode)->i_data_sem);
53475347 ext4_discard_preallocations(inode, 0);
@@ -5380,7 +5380,6 @@ static int ext4_collapse_range(struct inode *inode, loff_t offset, loff_t len) · 32 unmodified lines
53805380
53815381 out_stop:
53825382 ext4_journal_stop(handle);
5383− ext4_fc_stop_ineligible(sb);
53845383 out_mmap:
53855384 filemap_invalidate_unlock(mapping);
53865385 out_mutex:
@@ -5482,7 +5481,7 @@ static int ext4_insert_range(struct inode *inode, loff_t offset, loff_t len) · 95 unmodified lines
54825481 ret = PTR_ERR(handle);
54835482 goto out_mmap;
54845483 }
5485− ext4_fc_start_ineligible(sb, EXT4_FC_REASON_FALLOC_RANGE);
5484+ ext4_fc_mark_ineligible(sb, EXT4_FC_REASON_FALLOC_RANGE);
54865485
54875486 /* Expand file to avoid data loss if there is error while shifting */
54885487 inode->i_size += len;
@@ -5557,7 +5556,6 @@ static int ext4_insert_range(struct inode *inode, loff_t offset, loff_t len) · 68 unmodified lines
55575556
55585557 out_stop:
55595558 ext4_journal_stop(handle);
5560− ext4_fc_stop_ineligible(sb);
55615559 out_mmap:
55625560 filemap_invalidate_unlock(mapping);
55635561 out_mutex:
fs/ext4/fast_commit.c+15−64
@@ -65,21 +65,11 @@ · 64 unmodified lines
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) · 242 unmodified lines
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( · 19 unmodified lines
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) · 744 unmodified lines
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
11511100 restart_fc:
11521101 ret = jbd2_fc_begin_commit(journal, commit_tid);
@@ -1162,6 +1111,14 @@ restart_fc: · 9 unmodified lines
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 @@ restart_fc: · 12 unmodified lines
11801137 atomic_inc(&sbi->s_fc_subtid);
11811138 jbd2_fc_end_commit(journal);
11821139 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−
11891140 spin_lock(&sbi->s_fc_lock);
11901141 if (reason != EXT4_FC_REASON_OK &&
11911142 reason != EXT4_FC_REASON_ALREADY_COMMITTED) {
fs/ext4/ioctl.c+1−2
@@ -169,7 +169,7 @@ static long swap_inode_boot_loader(struct super_block *sb, · 168 unmodified lines
169169 err = -EINVAL;
170170 goto err_out;
171171 }
172− ext4_fc_start_ineligible(sb, EXT4_FC_REASON_SWAP_BOOT);
172+ ext4_fc_mark_ineligible(sb, EXT4_FC_REASON_SWAP_BOOT);
173173
174174 /* Protect extent tree against block allocations via delalloc */
175175 ext4_double_down_write_data_sem(inode, inode_bl);
@@ -252,7 +252,6 @@ revert: · 76 unmodified lines
252252
253253 err_out1:
254254 ext4_journal_stop(handle);
255− ext4_fc_stop_ineligible(sb);
256255 ext4_double_up_write_data_sem(inode, inode_bl);
257256
258257 err_out:
fs/ext4/super.c+0−1
@@ -5074,7 +5074,6 @@ static int __ext4_fill_super(struct fs_context *fc, struct super_block *sb) · 5073 unmodified lines
50745074
50755075 /* Initialize fast commit stuff */
50765076 atomic_set(&sbi->s_fc_subtid, 0);
5077− atomic_set(&sbi->s_fc_ineligible_updates, 0);
50785077 INIT_LIST_HEAD(&sbi->s_fc_q[FC_Q_MAIN]);
50795078 INIT_LIST_HEAD(&sbi->s_fc_q[FC_Q_STAGING]);
50805079 INIT_LIST_HEAD(&sbi->s_fc_dentry_q[FC_Q_MAIN]);