Commit aa3c0c61 authored by Mauricio Faria de Oliveira's avatar Mauricio Faria de Oliveira Committed by Theodore Ts'o

jbd2: introduce/export functions jbd2_journal_submit|finish_inode_data_buffers()

Export functions that implement the current behavior done
for an inode in journal_submit|finish_inode_data_buffers().

No functional change.
Signed-off-by: default avatarMauricio Faria de Oliveira <mfo@canonical.com>
Suggested-by: default avatarJan Kara <jack@suse.cz>
Reviewed-by: default avatarJan Kara <jack@suse.cz>
Reviewed-by: default avatarAndreas Dilger <adilger@dilger.ca>
Link: https://lore.kernel.org/r/20201006004841.600488-2-mfo@canonical.comSigned-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
parent 8394a6ab
...@@ -187,19 +187,17 @@ static int journal_wait_on_commit_record(journal_t *journal, ...@@ -187,19 +187,17 @@ static int journal_wait_on_commit_record(journal_t *journal,
* use writepages() because with delayed allocation we may be doing * use writepages() because with delayed allocation we may be doing
* block allocation in writepages(). * block allocation in writepages().
*/ */
static int journal_submit_inode_data_buffers(struct address_space *mapping, int jbd2_journal_submit_inode_data_buffers(struct jbd2_inode *jinode)
loff_t dirty_start, loff_t dirty_end)
{ {
int ret; struct address_space *mapping = jinode->i_vfs_inode->i_mapping;
struct writeback_control wbc = { struct writeback_control wbc = {
.sync_mode = WB_SYNC_ALL, .sync_mode = WB_SYNC_ALL,
.nr_to_write = mapping->nrpages * 2, .nr_to_write = mapping->nrpages * 2,
.range_start = dirty_start, .range_start = jinode->i_dirty_start,
.range_end = dirty_end, .range_end = jinode->i_dirty_end,
}; };
ret = generic_writepages(mapping, &wbc); return generic_writepages(mapping, &wbc);
return ret;
} }
/* /*
...@@ -215,16 +213,11 @@ static int journal_submit_data_buffers(journal_t *journal, ...@@ -215,16 +213,11 @@ static int journal_submit_data_buffers(journal_t *journal,
{ {
struct jbd2_inode *jinode; struct jbd2_inode *jinode;
int err, ret = 0; int err, ret = 0;
struct address_space *mapping;
spin_lock(&journal->j_list_lock); spin_lock(&journal->j_list_lock);
list_for_each_entry(jinode, &commit_transaction->t_inode_list, i_list) { list_for_each_entry(jinode, &commit_transaction->t_inode_list, i_list) {
loff_t dirty_start = jinode->i_dirty_start;
loff_t dirty_end = jinode->i_dirty_end;
if (!(jinode->i_flags & JI_WRITE_DATA)) if (!(jinode->i_flags & JI_WRITE_DATA))
continue; continue;
mapping = jinode->i_vfs_inode->i_mapping;
jinode->i_flags |= JI_COMMIT_RUNNING; jinode->i_flags |= JI_COMMIT_RUNNING;
spin_unlock(&journal->j_list_lock); spin_unlock(&journal->j_list_lock);
/* /*
...@@ -234,8 +227,7 @@ static int journal_submit_data_buffers(journal_t *journal, ...@@ -234,8 +227,7 @@ static int journal_submit_data_buffers(journal_t *journal,
* only allocated blocks here. * only allocated blocks here.
*/ */
trace_jbd2_submit_inode_data(jinode->i_vfs_inode); trace_jbd2_submit_inode_data(jinode->i_vfs_inode);
err = journal_submit_inode_data_buffers(mapping, dirty_start, err = jbd2_journal_submit_inode_data_buffers(jinode);
dirty_end);
if (!ret) if (!ret)
ret = err; ret = err;
spin_lock(&journal->j_list_lock); spin_lock(&journal->j_list_lock);
...@@ -248,6 +240,15 @@ static int journal_submit_data_buffers(journal_t *journal, ...@@ -248,6 +240,15 @@ static int journal_submit_data_buffers(journal_t *journal,
return ret; return ret;
} }
int jbd2_journal_finish_inode_data_buffers(struct jbd2_inode *jinode)
{
struct address_space *mapping = jinode->i_vfs_inode->i_mapping;
return filemap_fdatawait_range_keep_errors(mapping,
jinode->i_dirty_start,
jinode->i_dirty_end);
}
/* /*
* Wait for data submitted for writeout, refile inodes to proper * Wait for data submitted for writeout, refile inodes to proper
* transaction if needed. * transaction if needed.
...@@ -262,16 +263,11 @@ static int journal_finish_inode_data_buffers(journal_t *journal, ...@@ -262,16 +263,11 @@ static int journal_finish_inode_data_buffers(journal_t *journal,
/* For locking, see the comment in journal_submit_data_buffers() */ /* For locking, see the comment in journal_submit_data_buffers() */
spin_lock(&journal->j_list_lock); spin_lock(&journal->j_list_lock);
list_for_each_entry(jinode, &commit_transaction->t_inode_list, i_list) { list_for_each_entry(jinode, &commit_transaction->t_inode_list, i_list) {
loff_t dirty_start = jinode->i_dirty_start;
loff_t dirty_end = jinode->i_dirty_end;
if (!(jinode->i_flags & JI_WAIT_DATA)) if (!(jinode->i_flags & JI_WAIT_DATA))
continue; continue;
jinode->i_flags |= JI_COMMIT_RUNNING; jinode->i_flags |= JI_COMMIT_RUNNING;
spin_unlock(&journal->j_list_lock); spin_unlock(&journal->j_list_lock);
err = filemap_fdatawait_range_keep_errors( err = jbd2_journal_finish_inode_data_buffers(jinode);
jinode->i_vfs_inode->i_mapping, dirty_start,
dirty_end);
if (!ret) if (!ret)
ret = err; ret = err;
spin_lock(&journal->j_list_lock); spin_lock(&journal->j_list_lock);
......
...@@ -91,6 +91,8 @@ EXPORT_SYMBOL(jbd2_journal_try_to_free_buffers); ...@@ -91,6 +91,8 @@ EXPORT_SYMBOL(jbd2_journal_try_to_free_buffers);
EXPORT_SYMBOL(jbd2_journal_force_commit); EXPORT_SYMBOL(jbd2_journal_force_commit);
EXPORT_SYMBOL(jbd2_journal_inode_ranged_write); EXPORT_SYMBOL(jbd2_journal_inode_ranged_write);
EXPORT_SYMBOL(jbd2_journal_inode_ranged_wait); EXPORT_SYMBOL(jbd2_journal_inode_ranged_wait);
EXPORT_SYMBOL(jbd2_journal_submit_inode_data_buffers);
EXPORT_SYMBOL(jbd2_journal_finish_inode_data_buffers);
EXPORT_SYMBOL(jbd2_journal_init_jbd_inode); EXPORT_SYMBOL(jbd2_journal_init_jbd_inode);
EXPORT_SYMBOL(jbd2_journal_release_jbd_inode); EXPORT_SYMBOL(jbd2_journal_release_jbd_inode);
EXPORT_SYMBOL(jbd2_journal_begin_ordered_truncate); EXPORT_SYMBOL(jbd2_journal_begin_ordered_truncate);
......
...@@ -1421,6 +1421,10 @@ extern int jbd2_journal_inode_ranged_write(handle_t *handle, ...@@ -1421,6 +1421,10 @@ extern int jbd2_journal_inode_ranged_write(handle_t *handle,
extern int jbd2_journal_inode_ranged_wait(handle_t *handle, extern int jbd2_journal_inode_ranged_wait(handle_t *handle,
struct jbd2_inode *inode, loff_t start_byte, struct jbd2_inode *inode, loff_t start_byte,
loff_t length); loff_t length);
extern int jbd2_journal_submit_inode_data_buffers(
struct jbd2_inode *jinode);
extern int jbd2_journal_finish_inode_data_buffers(
struct jbd2_inode *jinode);
extern int jbd2_journal_begin_ordered_truncate(journal_t *journal, extern int jbd2_journal_begin_ordered_truncate(journal_t *journal,
struct jbd2_inode *inode, loff_t new_size); struct jbd2_inode *inode, loff_t new_size);
extern void jbd2_journal_init_jbd_inode(struct jbd2_inode *jinode, struct inode *inode); extern void jbd2_journal_init_jbd_inode(struct jbd2_inode *jinode, struct inode *inode);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment