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
1725 */1725 */
1726 struct work_struct s_error_work;1726 struct work_struct s_error_work;
1727 1727
1728 /* Ext4 fast commit stuff */1728 /* Ext4 fast commit sub transaction ID */
1729 atomic_t s_fc_subtid;1729 atomic_t s_fc_subtid;
1730 atomic_t s_fc_ineligible_updates;1730
1731 /*1731 /*
1732 * After commit starts, the main queue gets locked, and the further1732 * After commit starts, the main queue gets locked, and the further
1733 * updates get added in the staging queue.1733 * 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
2926void ext4_fc_track_create(handle_t *handle, struct dentry *dentry);2926void ext4_fc_track_create(handle_t *handle, struct dentry *dentry);
2927void ext4_fc_track_inode(handle_t *handle, struct inode *inode);2927void ext4_fc_track_inode(handle_t *handle, struct inode *inode);
2928void ext4_fc_mark_ineligible(struct super_block *sb, int reason);2928void ext4_fc_mark_ineligible(struct super_block *sb, int reason);
2929void ext4_fc_start_ineligible(struct super_block *sb, int reason);
2930void ext4_fc_stop_ineligible(struct super_block *sb);
2931void ext4_fc_start_update(struct inode *inode);2929void ext4_fc_start_update(struct inode *inode);
2932void ext4_fc_stop_update(struct inode *inode);2930void ext4_fc_stop_update(struct inode *inode);
2933void ext4_fc_del(struct inode *inode);2931void 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
5341 ret = PTR_ERR(handle);5341 ret = PTR_ERR(handle);
5342 goto out_mmap;5342 goto out_mmap;
5343 }5343 }
5344 ext4_fc_start_ineligible(sb, EXT4_FC_REASON_FALLOC_RANGE);5344 ext4_fc_mark_ineligible(sb, EXT4_FC_REASON_FALLOC_RANGE);
5345 5345
5346 down_write(&EXT4_I(inode)->i_data_sem);5346 down_write(&EXT4_I(inode)->i_data_sem);
5347 ext4_discard_preallocations(inode, 0);5347 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
5380 5380
5381out_stop:5381out_stop:
5382 ext4_journal_stop(handle);5382 ext4_journal_stop(handle);
5383 ext4_fc_stop_ineligible(sb);
5384out_mmap:5383out_mmap:
5385 filemap_invalidate_unlock(mapping);5384 filemap_invalidate_unlock(mapping);
5386out_mutex:5385out_mutex:
@@ -5482,7 +5481,7 @@ static int ext4_insert_range(struct inode *inode, loff_t offset, loff_t len) · 95 unmodified lines
5482 ret = PTR_ERR(handle);5481 ret = PTR_ERR(handle);
5483 goto out_mmap;5482 goto out_mmap;
5484 }5483 }
5485 ext4_fc_start_ineligible(sb, EXT4_FC_REASON_FALLOC_RANGE);5484 ext4_fc_mark_ineligible(sb, EXT4_FC_REASON_FALLOC_RANGE);
5486 5485
5487 /* Expand file to avoid data loss if there is error while shifting */5486 /* Expand file to avoid data loss if there is error while shifting */
5488 inode->i_size += len;5487 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
5557 5556
5558out_stop:5557out_stop:
5559 ext4_journal_stop(handle);5558 ext4_journal_stop(handle);
5560 ext4_fc_stop_ineligible(sb);
5561out_mmap:5559out_mmap:
5562 filemap_invalidate_unlock(mapping);5560 filemap_invalidate_unlock(mapping);
5563out_mutex:5561out_mutex:
fs/ext4/fast_commit.c+15−64
@@ -65,21 +65,11 @@ · 64 unmodified lines
65 *65 *
66 * Fast Commit Ineligibility66 * 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 all69 * Not all operations are supported by fast commits today (e.g extended
76 * the fast commits happening between ext4_fc_start_ineligible() and70 * attributes). Fast commit ineligibility is marked by calling
77 * ext4_fc_stop_ineligible() and one fast commit after the call to71 * ext4_fc_mark_ineligible(): This makes next fast commit operation to fall back
78 * ext4_fc_stop_ineligible() to fall back to full commits. It is important to72 * to full commit.
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.
83 *73 *
84 * Atomicity of commits74 * Atomicity of commits
85 * --------------------75 * --------------------
@@ -328,44 +318,6 @@ void ext4_fc_mark_ineligible(struct super_block *sb, int reason) · 242 unmodified lines
328 sbi->s_fc_stats.fc_ineligible_reason_count[reason]++;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 */
335void 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 */
353void 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
363static 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 * Generic fast commit tracking function. If this is the first time this we are322 * Generic fast commit tracking function. If this is the first time this we are
371 * called after a full commit, we initialize fast commit fields and then call323 * 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 (sbi->s_mount_state & EXT4_FC_REPLAY))343 (sbi->s_mount_state & EXT4_FC_REPLAY))
392 return -EOPNOTSUPP;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 return -EINVAL;347 return -EINVAL;
396 348
397 tid = handle->h_transaction->t_tid;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 start_time = ktime_get();1095 start_time = ktime_get();
1144 1096
1145 if (!test_opt2(sb, JOURNAL_FAST_COMMIT) ||1097 if (!test_opt2(sb, JOURNAL_FAST_COMMIT))
1146 (ext4_fc_is_ineligible(sb))) {1098 return jbd2_complete_transaction(journal, commit_tid);
1147 reason = EXT4_FC_REASON_INELIGIBLE;
1148 goto out;
1149 }
1150 1099
1151restart_fc:1100restart_fc:
1152 ret = jbd2_fc_begin_commit(journal, commit_tid);1101 ret = jbd2_fc_begin_commit(journal, commit_tid);
@@ -1162,6 +1111,14 @@ restart_fc: · 9 unmodified lines
1162 reason = EXT4_FC_REASON_FC_START_FAILED;1111 reason = EXT4_FC_REASON_FC_START_FAILED;
1163 goto out;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 fc_bufs_before = (sbi->s_fc_bytes + bsize - 1) / bsize;1123 fc_bufs_before = (sbi->s_fc_bytes + bsize - 1) / bsize;
1167 ret = ext4_fc_perform_commit(journal);1124 ret = ext4_fc_perform_commit(journal);
@@ -1180,12 +1137,6 @@ restart_fc: · 12 unmodified lines
1180 atomic_inc(&sbi->s_fc_subtid);1137 atomic_inc(&sbi->s_fc_subtid);
1181 jbd2_fc_end_commit(journal);1138 jbd2_fc_end_commit(journal);
1182out:1139out:
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 spin_lock(&sbi->s_fc_lock);1140 spin_lock(&sbi->s_fc_lock);
1190 if (reason != EXT4_FC_REASON_OK &&1141 if (reason != EXT4_FC_REASON_OK &&
1191 reason != EXT4_FC_REASON_ALREADY_COMMITTED) {1142 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
169 err = -EINVAL;169 err = -EINVAL;
170 goto err_out;170 goto err_out;
171 }171 }
172 ext4_fc_start_ineligible(sb, EXT4_FC_REASON_SWAP_BOOT);172 ext4_fc_mark_ineligible(sb, EXT4_FC_REASON_SWAP_BOOT);
173 173
174 /* Protect extent tree against block allocations via delalloc */174 /* Protect extent tree against block allocations via delalloc */
175 ext4_double_down_write_data_sem(inode, inode_bl);175 ext4_double_down_write_data_sem(inode, inode_bl);
@@ -252,7 +252,6 @@ revert: · 76 unmodified lines
252 252
253err_out1:253err_out1:
254 ext4_journal_stop(handle);254 ext4_journal_stop(handle);
255 ext4_fc_stop_ineligible(sb);
256 ext4_double_up_write_data_sem(inode, inode_bl);255 ext4_double_up_write_data_sem(inode, inode_bl);
257 256
258err_out:257err_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
5074 5074
5075 /* Initialize fast commit stuff */5075 /* Initialize fast commit stuff */
5076 atomic_set(&sbi->s_fc_subtid, 0);5076 atomic_set(&sbi->s_fc_subtid, 0);
5077 atomic_set(&sbi->s_fc_ineligible_updates, 0);
5078 INIT_LIST_HEAD(&sbi->s_fc_q[FC_Q_MAIN]);5077 INIT_LIST_HEAD(&sbi->s_fc_q[FC_Q_MAIN]);
5079 INIT_LIST_HEAD(&sbi->s_fc_q[FC_Q_STAGING]);5078 INIT_LIST_HEAD(&sbi->s_fc_q[FC_Q_STAGING]);
5080 INIT_LIST_HEAD(&sbi->s_fc_dentry_q[FC_Q_MAIN]);5079 INIT_LIST_HEAD(&sbi->s_fc_dentry_q[FC_Q_MAIN]);