提交 81be12c8 编写于 作者: J Jan Kara 提交者: Theodore Ts'o

jbd2: fix sending of data flush on journal commit


In data=ordered mode, it's theoretically possible (however rare) that
an inode is filed to transaction's t_inode_list and a flusher thread
writes all the data and inode is reclaimed before the transaction
starts to commit.  In such a case, we could erroneously omit sending a
flush to file system device when it is different from the journal
device (because data can still be in disk cache only).

Fix the problem by setting a flag in a transaction when some inode is added
to it and then send disk flush in the commit code when the flag is set.
Signed-off-by: NJan Kara <jack@suse.cz>
Signed-off-by: N"Theodore Ts'o" <tytso@mit.edu>
上级 b221349f
...@@ -219,7 +219,6 @@ static int journal_submit_data_buffers(journal_t *journal, ...@@ -219,7 +219,6 @@ static int journal_submit_data_buffers(journal_t *journal,
ret = err; ret = err;
spin_lock(&journal->j_list_lock); spin_lock(&journal->j_list_lock);
J_ASSERT(jinode->i_transaction == commit_transaction); J_ASSERT(jinode->i_transaction == commit_transaction);
commit_transaction->t_flushed_data_blocks = 1;
clear_bit(__JI_COMMIT_RUNNING, &jinode->i_flags); clear_bit(__JI_COMMIT_RUNNING, &jinode->i_flags);
smp_mb__after_clear_bit(); smp_mb__after_clear_bit();
wake_up_bit(&jinode->i_flags, __JI_COMMIT_RUNNING); wake_up_bit(&jinode->i_flags, __JI_COMMIT_RUNNING);
...@@ -683,7 +682,7 @@ void jbd2_journal_commit_transaction(journal_t *journal) ...@@ -683,7 +682,7 @@ void jbd2_journal_commit_transaction(journal_t *journal)
* then we must flush the file system device before we issue * then we must flush the file system device before we issue
* the commit record * the commit record
*/ */
if (commit_transaction->t_flushed_data_blocks && if (commit_transaction->t_need_data_flush &&
(journal->j_fs_dev != journal->j_dev) && (journal->j_fs_dev != journal->j_dev) &&
(journal->j_flags & JBD2_BARRIER)) (journal->j_flags & JBD2_BARRIER))
blkdev_issue_flush(journal->j_fs_dev, GFP_KERNEL, NULL); blkdev_issue_flush(journal->j_fs_dev, GFP_KERNEL, NULL);
......
...@@ -2147,6 +2147,13 @@ int jbd2_journal_file_inode(handle_t *handle, struct jbd2_inode *jinode) ...@@ -2147,6 +2147,13 @@ int jbd2_journal_file_inode(handle_t *handle, struct jbd2_inode *jinode)
jinode->i_next_transaction == transaction) jinode->i_next_transaction == transaction)
goto done; goto done;
/*
* We only ever set this variable to 1 so the test is safe. Since
* t_need_data_flush is likely to be set, we do the test to save some
* cacheline bouncing
*/
if (!transaction->t_need_data_flush)
transaction->t_need_data_flush = 1;
/* On some different transaction's list - should be /* On some different transaction's list - should be
* the committing one */ * the committing one */
if (jinode->i_transaction) { if (jinode->i_transaction) {
......
...@@ -658,7 +658,9 @@ struct transaction_s ...@@ -658,7 +658,9 @@ struct transaction_s
* waiting for it to finish. * waiting for it to finish.
*/ */
unsigned int t_synchronous_commit:1; unsigned int t_synchronous_commit:1;
unsigned int t_flushed_data_blocks:1;
/* Disk flush needs to be sent to fs partition [no locking] */
int t_need_data_flush;
/* /*
* For use by the filesystem to store fs-specific data * For use by the filesystem to store fs-specific data
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册