|
20 | 20 | #include <linux/slab.h> |
21 | 21 | #include <linux/mm.h> |
22 | 22 | #include <linux/pagemap.h> |
| 23 | +#include <linux/bio.h> |
23 | 24 |
|
24 | 25 | /* |
25 | 26 | * Default IO end handler for temporary BJ_IO buffer_heads. |
@@ -171,22 +172,24 @@ static int journal_write_commit_record(journal_t *journal, |
171 | 172 | return (ret == -EIO); |
172 | 173 | } |
173 | 174 |
|
174 | | -static void journal_do_submit_data(struct buffer_head **wbuf, int bufs) |
| 175 | +static void journal_do_submit_data(struct buffer_head **wbuf, int bufs, |
| 176 | + int write_op) |
175 | 177 | { |
176 | 178 | int i; |
177 | 179 |
|
178 | 180 | for (i = 0; i < bufs; i++) { |
179 | 181 | wbuf[i]->b_end_io = end_buffer_write_sync; |
180 | 182 | /* We use-up our safety reference in submit_bh() */ |
181 | | - submit_bh(WRITE, wbuf[i]); |
| 183 | + submit_bh(write_op, wbuf[i]); |
182 | 184 | } |
183 | 185 | } |
184 | 186 |
|
185 | 187 | /* |
186 | 188 | * Submit all the data buffers to disk |
187 | 189 | */ |
188 | 190 | static int journal_submit_data_buffers(journal_t *journal, |
189 | | - transaction_t *commit_transaction) |
| 191 | + transaction_t *commit_transaction, |
| 192 | + int write_op) |
190 | 193 | { |
191 | 194 | struct journal_head *jh; |
192 | 195 | struct buffer_head *bh; |
@@ -225,7 +228,7 @@ static int journal_submit_data_buffers(journal_t *journal, |
225 | 228 | BUFFER_TRACE(bh, "needs blocking lock"); |
226 | 229 | spin_unlock(&journal->j_list_lock); |
227 | 230 | /* Write out all data to prevent deadlocks */ |
228 | | - journal_do_submit_data(wbuf, bufs); |
| 231 | + journal_do_submit_data(wbuf, bufs, write_op); |
229 | 232 | bufs = 0; |
230 | 233 | lock_buffer(bh); |
231 | 234 | spin_lock(&journal->j_list_lock); |
@@ -256,7 +259,7 @@ static int journal_submit_data_buffers(journal_t *journal, |
256 | 259 | jbd_unlock_bh_state(bh); |
257 | 260 | if (bufs == journal->j_wbufsize) { |
258 | 261 | spin_unlock(&journal->j_list_lock); |
259 | | - journal_do_submit_data(wbuf, bufs); |
| 262 | + journal_do_submit_data(wbuf, bufs, write_op); |
260 | 263 | bufs = 0; |
261 | 264 | goto write_out_data; |
262 | 265 | } |
@@ -286,7 +289,7 @@ static int journal_submit_data_buffers(journal_t *journal, |
286 | 289 | } |
287 | 290 | } |
288 | 291 | spin_unlock(&journal->j_list_lock); |
289 | | - journal_do_submit_data(wbuf, bufs); |
| 292 | + journal_do_submit_data(wbuf, bufs, write_op); |
290 | 293 |
|
291 | 294 | return err; |
292 | 295 | } |
@@ -315,6 +318,7 @@ void journal_commit_transaction(journal_t *journal) |
315 | 318 | int first_tag = 0; |
316 | 319 | int tag_flag; |
317 | 320 | int i; |
| 321 | + int write_op = WRITE; |
318 | 322 |
|
319 | 323 | /* |
320 | 324 | * First job: lock down the current transaction and wait for |
@@ -347,6 +351,8 @@ void journal_commit_transaction(journal_t *journal) |
347 | 351 | spin_lock(&journal->j_state_lock); |
348 | 352 | commit_transaction->t_state = T_LOCKED; |
349 | 353 |
|
| 354 | + if (commit_transaction->t_synchronous_commit) |
| 355 | + write_op = WRITE_SYNC; |
350 | 356 | spin_lock(&commit_transaction->t_handle_lock); |
351 | 357 | while (commit_transaction->t_updates) { |
352 | 358 | DEFINE_WAIT(wait); |
@@ -431,7 +437,8 @@ void journal_commit_transaction(journal_t *journal) |
431 | 437 | * Now start flushing things to disk, in the order they appear |
432 | 438 | * on the transaction lists. Data blocks go first. |
433 | 439 | */ |
434 | | - err = journal_submit_data_buffers(journal, commit_transaction); |
| 440 | + err = journal_submit_data_buffers(journal, commit_transaction, |
| 441 | + write_op); |
435 | 442 |
|
436 | 443 | /* |
437 | 444 | * Wait for all previously submitted IO to complete. |
@@ -660,7 +667,7 @@ void journal_commit_transaction(journal_t *journal) |
660 | 667 | clear_buffer_dirty(bh); |
661 | 668 | set_buffer_uptodate(bh); |
662 | 669 | bh->b_end_io = journal_end_buffer_io_sync; |
663 | | - submit_bh(WRITE, bh); |
| 670 | + submit_bh(write_op, bh); |
664 | 671 | } |
665 | 672 | cond_resched(); |
666 | 673 |
|
|
0 commit comments