提交 7058548c 编写于 作者: T Theodore Ts'o

ext4: Use WRITE_SYNC for commits which are caused by fsync()

If a commit is triggered by fsync(), set a flag indicating the journal
blocks associated with the transaction should be flushed out using
WRITE_SYNC.
Signed-off-by: N"Theodore Ts'o" <tytso@mit.edu>
上级 afd4672d
...@@ -367,6 +367,7 @@ void jbd2_journal_commit_transaction(journal_t *journal) ...@@ -367,6 +367,7 @@ void jbd2_journal_commit_transaction(journal_t *journal)
int tag_bytes = journal_tag_bytes(journal); int tag_bytes = journal_tag_bytes(journal);
struct buffer_head *cbh = NULL; /* For transactional checksums */ struct buffer_head *cbh = NULL; /* For transactional checksums */
__u32 crc32_sum = ~0; __u32 crc32_sum = ~0;
int write_op = WRITE;
/* /*
* First job: lock down the current transaction and wait for * First job: lock down the current transaction and wait for
...@@ -401,6 +402,8 @@ void jbd2_journal_commit_transaction(journal_t *journal) ...@@ -401,6 +402,8 @@ void jbd2_journal_commit_transaction(journal_t *journal)
spin_lock(&journal->j_state_lock); spin_lock(&journal->j_state_lock);
commit_transaction->t_state = T_LOCKED; commit_transaction->t_state = T_LOCKED;
if (commit_transaction->t_synchronous_commit)
write_op = WRITE_SYNC;
stats.u.run.rs_wait = commit_transaction->t_max_wait; stats.u.run.rs_wait = commit_transaction->t_max_wait;
stats.u.run.rs_locked = jiffies; stats.u.run.rs_locked = jiffies;
stats.u.run.rs_running = jbd2_time_diff(commit_transaction->t_start, stats.u.run.rs_running = jbd2_time_diff(commit_transaction->t_start,
...@@ -680,7 +683,7 @@ void jbd2_journal_commit_transaction(journal_t *journal) ...@@ -680,7 +683,7 @@ void jbd2_journal_commit_transaction(journal_t *journal)
clear_buffer_dirty(bh); clear_buffer_dirty(bh);
set_buffer_uptodate(bh); set_buffer_uptodate(bh);
bh->b_end_io = journal_end_buffer_io_sync; bh->b_end_io = journal_end_buffer_io_sync;
submit_bh(WRITE, bh); submit_bh(write_op, bh);
} }
cond_resched(); cond_resched();
stats.u.run.rs_blocks_logged += bufs; stats.u.run.rs_blocks_logged += bufs;
......
...@@ -1315,6 +1315,8 @@ int jbd2_journal_stop(handle_t *handle) ...@@ -1315,6 +1315,8 @@ int jbd2_journal_stop(handle_t *handle)
} }
} }
if (handle->h_sync)
transaction->t_synchronous_commit = 1;
current->journal_info = NULL; current->journal_info = NULL;
spin_lock(&journal->j_state_lock); spin_lock(&journal->j_state_lock);
spin_lock(&transaction->t_handle_lock); spin_lock(&transaction->t_handle_lock);
......
...@@ -648,6 +648,12 @@ struct transaction_s ...@@ -648,6 +648,12 @@ struct transaction_s
*/ */
int t_handle_count; int t_handle_count;
/*
* This transaction is being forced and some process is
* waiting for it to finish.
*/
int t_synchronous_commit:1;
/* /*
* For use by the filesystem to store fs-specific data * For use by the filesystem to store fs-specific data
* structures associated with the transaction * structures associated with the transaction
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册