mirror of
https://gitee.com/bianbu-linux/linux-6.6-fh
synced 2025-04-25 16:37:07 -04:00
jbd2: add fast commit machinery
This functions adds necessary APIs needed in JBD2 layer for fast commits. Signed-off-by: Harshad Shirwadkar <harshadshirwadkar@gmail.com> Link: https://lore.kernel.org/r/20201015203802.3597742-5-harshadshirwadkar@gmail.com Signed-off-by: Theodore Ts'o <tytso@mit.edu>
This commit is contained in:
parent
6866d7b3f2
commit
ff780b91ef
4 changed files with 268 additions and 1 deletions
|
@ -206,6 +206,30 @@ int jbd2_journal_submit_inode_data_buffers(struct jbd2_inode *jinode)
|
|||
return generic_writepages(mapping, &wbc);
|
||||
}
|
||||
|
||||
/* Send all the data buffers related to an inode */
|
||||
int jbd2_submit_inode_data(struct jbd2_inode *jinode)
|
||||
{
|
||||
|
||||
if (!jinode || !(jinode->i_flags & JI_WRITE_DATA))
|
||||
return 0;
|
||||
|
||||
trace_jbd2_submit_inode_data(jinode->i_vfs_inode);
|
||||
return jbd2_journal_submit_inode_data_buffers(jinode);
|
||||
|
||||
}
|
||||
EXPORT_SYMBOL(jbd2_submit_inode_data);
|
||||
|
||||
int jbd2_wait_inode_data(journal_t *journal, struct jbd2_inode *jinode)
|
||||
{
|
||||
if (!jinode || !(jinode->i_flags & JI_WAIT_DATA) ||
|
||||
!jinode->i_vfs_inode || !jinode->i_vfs_inode->i_mapping)
|
||||
return 0;
|
||||
return filemap_fdatawait_range_keep_errors(
|
||||
jinode->i_vfs_inode->i_mapping, jinode->i_dirty_start,
|
||||
jinode->i_dirty_end);
|
||||
}
|
||||
EXPORT_SYMBOL(jbd2_wait_inode_data);
|
||||
|
||||
/*
|
||||
* Submit all the data buffers of inode associated with the transaction to
|
||||
* disk.
|
||||
|
@ -415,6 +439,20 @@ void jbd2_journal_commit_transaction(journal_t *journal)
|
|||
J_ASSERT(journal->j_running_transaction != NULL);
|
||||
J_ASSERT(journal->j_committing_transaction == NULL);
|
||||
|
||||
write_lock(&journal->j_state_lock);
|
||||
journal->j_flags |= JBD2_FULL_COMMIT_ONGOING;
|
||||
while (journal->j_flags & JBD2_FAST_COMMIT_ONGOING) {
|
||||
DEFINE_WAIT(wait);
|
||||
|
||||
prepare_to_wait(&journal->j_fc_wait, &wait,
|
||||
TASK_UNINTERRUPTIBLE);
|
||||
write_unlock(&journal->j_state_lock);
|
||||
schedule();
|
||||
write_lock(&journal->j_state_lock);
|
||||
finish_wait(&journal->j_fc_wait, &wait);
|
||||
}
|
||||
write_unlock(&journal->j_state_lock);
|
||||
|
||||
commit_transaction = journal->j_running_transaction;
|
||||
|
||||
trace_jbd2_start_commit(journal, commit_transaction);
|
||||
|
@ -422,6 +460,7 @@ void jbd2_journal_commit_transaction(journal_t *journal)
|
|||
commit_transaction->t_tid);
|
||||
|
||||
write_lock(&journal->j_state_lock);
|
||||
journal->j_fc_off = 0;
|
||||
J_ASSERT(commit_transaction->t_state == T_RUNNING);
|
||||
commit_transaction->t_state = T_LOCKED;
|
||||
|
||||
|
@ -1121,12 +1160,16 @@ restart_loop:
|
|||
|
||||
if (journal->j_commit_callback)
|
||||
journal->j_commit_callback(journal, commit_transaction);
|
||||
if (journal->j_fc_cleanup_callback)
|
||||
journal->j_fc_cleanup_callback(journal, 1);
|
||||
|
||||
trace_jbd2_end_commit(journal, commit_transaction);
|
||||
jbd_debug(1, "JBD2: commit %d complete, head %d\n",
|
||||
journal->j_commit_sequence, journal->j_tail_sequence);
|
||||
|
||||
write_lock(&journal->j_state_lock);
|
||||
journal->j_flags &= ~JBD2_FULL_COMMIT_ONGOING;
|
||||
journal->j_flags &= ~JBD2_FAST_COMMIT_ONGOING;
|
||||
spin_lock(&journal->j_list_lock);
|
||||
commit_transaction->t_state = T_FINISHED;
|
||||
/* Check if the transaction can be dropped now that we are finished */
|
||||
|
@ -1138,6 +1181,7 @@ restart_loop:
|
|||
spin_unlock(&journal->j_list_lock);
|
||||
write_unlock(&journal->j_state_lock);
|
||||
wake_up(&journal->j_wait_done_commit);
|
||||
wake_up(&journal->j_fc_wait);
|
||||
|
||||
/*
|
||||
* Calculate overall stats
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue