mirror of
https://github.com/torvalds/linux.git
synced 2026-04-18 06:44:00 -04:00
jbd2, ext4, ocfs2: introduce/use journal callbacks j_submit|finish_inode_data_buffers()
Introduce journal callbacks to allow different behaviors for an inode in journal_submit|finish_inode_data_buffers(). The existing users of the current behavior (ext4, ocfs2) are adapted to use the previously exported functions that implement the current behavior. Users are callers of jbd2_journal_inode_ranged_write|wait(), which adds the inode to the transaction's inode list with the JI_WRITE|WAIT_DATA flags. Only ext4 and ocfs2 in-tree. Both CONFIG_EXT4_FS and CONFIG_OCSFS2_FS select CONFIG_JBD2, which builds fs/jbd2/commit.c and journal.c that define and export the functions, so we can call directly in ext4/ocfs2. Signed-off-by: Mauricio Faria de Oliveira <mfo@canonical.com> Suggested-by: Jan Kara <jack@suse.cz> Reviewed-by: Jan Kara <jack@suse.cz> Reviewed-by: Andreas Dilger <adilger@dilger.ca> Link: https://lore.kernel.org/r/20201006004841.600488-3-mfo@canonical.com Signed-off-by: Theodore Ts'o <tytso@mit.edu>
This commit is contained in:
committed by
Theodore Ts'o
parent
aa3c0c61f6
commit
342af94ec6
@@ -197,6 +197,12 @@ int jbd2_journal_submit_inode_data_buffers(struct jbd2_inode *jinode)
|
||||
.range_end = jinode->i_dirty_end,
|
||||
};
|
||||
|
||||
/*
|
||||
* submit the inode data buffers. We use writepage
|
||||
* instead of writepages. Because writepages can do
|
||||
* block allocation with delalloc. We need to write
|
||||
* only allocated blocks here.
|
||||
*/
|
||||
return generic_writepages(mapping, &wbc);
|
||||
}
|
||||
|
||||
@@ -220,16 +226,13 @@ static int journal_submit_data_buffers(journal_t *journal,
|
||||
continue;
|
||||
jinode->i_flags |= JI_COMMIT_RUNNING;
|
||||
spin_unlock(&journal->j_list_lock);
|
||||
/*
|
||||
* submit the inode data buffers. We use writepage
|
||||
* instead of writepages. Because writepages can do
|
||||
* block allocation with delalloc. We need to write
|
||||
* only allocated blocks here.
|
||||
*/
|
||||
/* submit the inode data buffers. */
|
||||
trace_jbd2_submit_inode_data(jinode->i_vfs_inode);
|
||||
err = jbd2_journal_submit_inode_data_buffers(jinode);
|
||||
if (!ret)
|
||||
ret = err;
|
||||
if (journal->j_submit_inode_data_buffers) {
|
||||
err = journal->j_submit_inode_data_buffers(jinode);
|
||||
if (!ret)
|
||||
ret = err;
|
||||
}
|
||||
spin_lock(&journal->j_list_lock);
|
||||
J_ASSERT(jinode->i_transaction == commit_transaction);
|
||||
jinode->i_flags &= ~JI_COMMIT_RUNNING;
|
||||
@@ -267,9 +270,12 @@ static int journal_finish_inode_data_buffers(journal_t *journal,
|
||||
continue;
|
||||
jinode->i_flags |= JI_COMMIT_RUNNING;
|
||||
spin_unlock(&journal->j_list_lock);
|
||||
err = jbd2_journal_finish_inode_data_buffers(jinode);
|
||||
if (!ret)
|
||||
ret = err;
|
||||
/* wait for the inode data buffers writeout. */
|
||||
if (journal->j_finish_inode_data_buffers) {
|
||||
err = journal->j_finish_inode_data_buffers(jinode);
|
||||
if (!ret)
|
||||
ret = err;
|
||||
}
|
||||
spin_lock(&journal->j_list_lock);
|
||||
jinode->i_flags &= ~JI_COMMIT_RUNNING;
|
||||
smp_mb();
|
||||
|
||||
Reference in New Issue
Block a user