aboutsummaryrefslogtreecommitdiffstats
path: root/fs/jbd2/commit.c
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2014-03-08 22:34:10 -0500
committerTheodore Ts'o <tytso@mit.edu>2014-03-08 22:34:10 -0500
commitd4e839d4a9dc31d0c229e616146b01e1ace56604 (patch)
tree1a04beaeb6a438212db18548f5e0ff37b048f973 /fs/jbd2/commit.c
parent42cf3452d5f5b0817d27c93e4e7d7eab6e89077d (diff)
jbd2: add transaction to checkpoint list earlier
We don't otherwise need j_list_lock during the rest of commit phase #7, so add the transaction to the checkpoint list at the very end of commit phase #6. This allows us to drop j_list_lock earlier, which is a good thing since it is a super hot lock. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'fs/jbd2/commit.c')
-rw-r--r--fs/jbd2/commit.c39
1 files changed, 20 insertions, 19 deletions
diff --git a/fs/jbd2/commit.c b/fs/jbd2/commit.c
index af36252b5b2d..5f26139a165a 100644
--- a/fs/jbd2/commit.c
+++ b/fs/jbd2/commit.c
@@ -1065,6 +1065,25 @@ restart_loop:
1065 goto restart_loop; 1065 goto restart_loop;
1066 } 1066 }
1067 1067
1068 /* Add the transaction to the checkpoint list
1069 * __journal_remove_checkpoint() can not destroy transaction
1070 * under us because it is not marked as T_FINISHED yet */
1071 if (journal->j_checkpoint_transactions == NULL) {
1072 journal->j_checkpoint_transactions = commit_transaction;
1073 commit_transaction->t_cpnext = commit_transaction;
1074 commit_transaction->t_cpprev = commit_transaction;
1075 } else {
1076 commit_transaction->t_cpnext =
1077 journal->j_checkpoint_transactions;
1078 commit_transaction->t_cpprev =
1079 commit_transaction->t_cpnext->t_cpprev;
1080 commit_transaction->t_cpnext->t_cpprev =
1081 commit_transaction;
1082 commit_transaction->t_cpprev->t_cpnext =
1083 commit_transaction;
1084 }
1085 spin_unlock(&journal->j_list_lock);
1086
1068 /* Done with this transaction! */ 1087 /* Done with this transaction! */
1069 1088
1070 jbd_debug(3, "JBD2: commit phase 7\n"); 1089 jbd_debug(3, "JBD2: commit phase 7\n");
@@ -1103,24 +1122,6 @@ restart_loop:
1103 1122
1104 write_unlock(&journal->j_state_lock); 1123 write_unlock(&journal->j_state_lock);
1105 1124
1106 if (journal->j_checkpoint_transactions == NULL) {
1107 journal->j_checkpoint_transactions = commit_transaction;
1108 commit_transaction->t_cpnext = commit_transaction;
1109 commit_transaction->t_cpprev = commit_transaction;
1110 } else {
1111 commit_transaction->t_cpnext =
1112 journal->j_checkpoint_transactions;
1113 commit_transaction->t_cpprev =
1114 commit_transaction->t_cpnext->t_cpprev;
1115 commit_transaction->t_cpnext->t_cpprev =
1116 commit_transaction;
1117 commit_transaction->t_cpprev->t_cpnext =
1118 commit_transaction;
1119 }
1120 spin_unlock(&journal->j_list_lock);
1121 /* Drop all spin_locks because commit_callback may be block.
1122 * __journal_remove_checkpoint() can not destroy transaction
1123 * under us because it is not marked as T_FINISHED yet */
1124 if (journal->j_commit_callback) 1125 if (journal->j_commit_callback)
1125 journal->j_commit_callback(journal, commit_transaction); 1126 journal->j_commit_callback(journal, commit_transaction);
1126 1127
@@ -1131,7 +1132,7 @@ restart_loop:
1131 write_lock(&journal->j_state_lock); 1132 write_lock(&journal->j_state_lock);
1132 spin_lock(&journal->j_list_lock); 1133 spin_lock(&journal->j_list_lock);
1133 commit_transaction->t_state = T_FINISHED; 1134 commit_transaction->t_state = T_FINISHED;
1134 /* Recheck checkpoint lists after j_list_lock was dropped */ 1135 /* Check if the transaction can be dropped now that we are finished */
1135 if (commit_transaction->t_checkpoint_list == NULL && 1136 if (commit_transaction->t_checkpoint_list == NULL &&
1136 commit_transaction->t_checkpoint_io_list == NULL) { 1137 commit_transaction->t_checkpoint_io_list == NULL) {
1137 __jbd2_journal_drop_transaction(journal, commit_transaction); 1138 __jbd2_journal_drop_transaction(journal, commit_transaction);