aboutsummaryrefslogtreecommitdiffstats
path: root/fs/jbd2/journal.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/jbd2/journal.c')
-rw-r--r--fs/jbd2/journal.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
index 8b220f1ab54f..f6c5ba027f4f 100644
--- a/fs/jbd2/journal.c
+++ b/fs/jbd2/journal.c
@@ -708,6 +708,37 @@ int jbd2_log_wait_commit(journal_t *journal, tid_t tid)
708} 708}
709 709
710/* 710/*
711 * When this function returns the transaction corresponding to tid
712 * will be completed. If the transaction has currently running, start
713 * committing that transaction before waiting for it to complete. If
714 * the transaction id is stale, it is by definition already completed,
715 * so just return SUCCESS.
716 */
717int jbd2_complete_transaction(journal_t *journal, tid_t tid)
718{
719 int need_to_wait = 1;
720
721 read_lock(&journal->j_state_lock);
722 if (journal->j_running_transaction &&
723 journal->j_running_transaction->t_tid == tid) {
724 if (journal->j_commit_request != tid) {
725 /* transaction not yet started, so request it */
726 read_unlock(&journal->j_state_lock);
727 jbd2_log_start_commit(journal, tid);
728 goto wait_commit;
729 }
730 } else if (!(journal->j_committing_transaction &&
731 journal->j_committing_transaction->t_tid == tid))
732 need_to_wait = 0;
733 read_unlock(&journal->j_state_lock);
734 if (!need_to_wait)
735 return 0;
736wait_commit:
737 return jbd2_log_wait_commit(journal, tid);
738}
739EXPORT_SYMBOL(jbd2_complete_transaction);
740
741/*
711 * Log buffer allocation routines: 742 * Log buffer allocation routines:
712 */ 743 */
713 744