aboutsummaryrefslogtreecommitdiffstats
path: root/fs/jbd/commit.c
diff options
context:
space:
mode:
authorFelix Blyakher <felixb@sgi.com>2009-06-10 18:07:47 -0400
committerFelix Blyakher <felixb@sgi.com>2009-06-10 18:07:47 -0400
commit4e73e0eb633f8a1b5cbf20e7f42c6dbfec1d1ca7 (patch)
tree0cea46e43f0625244c3d06a71d6559e5ec5419ca /fs/jbd/commit.c
parent4156e735d3abde8e9243b5d22f7999dd3fffab2e (diff)
parent07a2039b8eb0af4ff464efd3dfd95de5c02648c6 (diff)
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
Diffstat (limited to 'fs/jbd/commit.c')
-rw-r--r--fs/jbd/commit.c36
1 files changed, 25 insertions, 11 deletions
diff --git a/fs/jbd/commit.c b/fs/jbd/commit.c
index 3fbffb1ea714..618e21c0b7a3 100644
--- a/fs/jbd/commit.c
+++ b/fs/jbd/commit.c
@@ -20,6 +20,7 @@
20#include <linux/slab.h> 20#include <linux/slab.h>
21#include <linux/mm.h> 21#include <linux/mm.h>
22#include <linux/pagemap.h> 22#include <linux/pagemap.h>
23#include <linux/bio.h>
23 24
24/* 25/*
25 * Default IO end handler for temporary BJ_IO buffer_heads. 26 * Default IO end handler for temporary BJ_IO buffer_heads.
@@ -171,14 +172,15 @@ static int journal_write_commit_record(journal_t *journal,
171 return (ret == -EIO); 172 return (ret == -EIO);
172} 173}
173 174
174static void journal_do_submit_data(struct buffer_head **wbuf, int bufs) 175static void journal_do_submit_data(struct buffer_head **wbuf, int bufs,
176 int write_op)
175{ 177{
176 int i; 178 int i;
177 179
178 for (i = 0; i < bufs; i++) { 180 for (i = 0; i < bufs; i++) {
179 wbuf[i]->b_end_io = end_buffer_write_sync; 181 wbuf[i]->b_end_io = end_buffer_write_sync;
180 /* We use-up our safety reference in submit_bh() */ 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
@@ -186,7 +188,8 @@ static void journal_do_submit_data(struct buffer_head **wbuf, int bufs)
186 * Submit all the data buffers to disk 188 * Submit all the data buffers to disk
187 */ 189 */
188static int journal_submit_data_buffers(journal_t *journal, 190static 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 struct journal_head *jh; 194 struct journal_head *jh;
192 struct buffer_head *bh; 195 struct buffer_head *bh;
@@ -225,7 +228,7 @@ write_out_data:
225 BUFFER_TRACE(bh, "needs blocking lock"); 228 BUFFER_TRACE(bh, "needs blocking lock");
226 spin_unlock(&journal->j_list_lock); 229 spin_unlock(&journal->j_list_lock);
227 /* Write out all data to prevent deadlocks */ 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 bufs = 0; 232 bufs = 0;
230 lock_buffer(bh); 233 lock_buffer(bh);
231 spin_lock(&journal->j_list_lock); 234 spin_lock(&journal->j_list_lock);
@@ -238,7 +241,7 @@ write_out_data:
238 spin_lock(&journal->j_list_lock); 241 spin_lock(&journal->j_list_lock);
239 } 242 }
240 /* Someone already cleaned up the buffer? */ 243 /* Someone already cleaned up the buffer? */
241 if (!buffer_jbd(bh) 244 if (!buffer_jbd(bh) || bh2jh(bh) != jh
242 || jh->b_transaction != commit_transaction 245 || jh->b_transaction != commit_transaction
243 || jh->b_jlist != BJ_SyncData) { 246 || jh->b_jlist != BJ_SyncData) {
244 jbd_unlock_bh_state(bh); 247 jbd_unlock_bh_state(bh);
@@ -256,7 +259,7 @@ write_out_data:
256 jbd_unlock_bh_state(bh); 259 jbd_unlock_bh_state(bh);
257 if (bufs == journal->j_wbufsize) { 260 if (bufs == journal->j_wbufsize) {
258 spin_unlock(&journal->j_list_lock); 261 spin_unlock(&journal->j_list_lock);
259 journal_do_submit_data(wbuf, bufs); 262 journal_do_submit_data(wbuf, bufs, write_op);
260 bufs = 0; 263 bufs = 0;
261 goto write_out_data; 264 goto write_out_data;
262 } 265 }
@@ -286,7 +289,7 @@ write_out_data:
286 } 289 }
287 } 290 }
288 spin_unlock(&journal->j_list_lock); 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 return err; 294 return err;
292} 295}
@@ -315,6 +318,7 @@ void journal_commit_transaction(journal_t *journal)
315 int first_tag = 0; 318 int first_tag = 0;
316 int tag_flag; 319 int tag_flag;
317 int i; 320 int i;
321 int write_op = WRITE;
318 322
319 /* 323 /*
320 * First job: lock down the current transaction and wait for 324 * First job: lock down the current transaction and wait for
@@ -347,6 +351,13 @@ void journal_commit_transaction(journal_t *journal)
347 spin_lock(&journal->j_state_lock); 351 spin_lock(&journal->j_state_lock);
348 commit_transaction->t_state = T_LOCKED; 352 commit_transaction->t_state = T_LOCKED;
349 353
354 /*
355 * Use plugged writes here, since we want to submit several before
356 * we unplug the device. We don't do explicit unplugging in here,
357 * instead we rely on sync_buffer() doing the unplug for us.
358 */
359 if (commit_transaction->t_synchronous_commit)
360 write_op = WRITE_SYNC_PLUG;
350 spin_lock(&commit_transaction->t_handle_lock); 361 spin_lock(&commit_transaction->t_handle_lock);
351 while (commit_transaction->t_updates) { 362 while (commit_transaction->t_updates) {
352 DEFINE_WAIT(wait); 363 DEFINE_WAIT(wait);
@@ -431,7 +442,8 @@ void journal_commit_transaction(journal_t *journal)
431 * Now start flushing things to disk, in the order they appear 442 * Now start flushing things to disk, in the order they appear
432 * on the transaction lists. Data blocks go first. 443 * on the transaction lists. Data blocks go first.
433 */ 444 */
434 err = journal_submit_data_buffers(journal, commit_transaction); 445 err = journal_submit_data_buffers(journal, commit_transaction,
446 write_op);
435 447
436 /* 448 /*
437 * Wait for all previously submitted IO to complete. 449 * Wait for all previously submitted IO to complete.
@@ -466,7 +478,9 @@ void journal_commit_transaction(journal_t *journal)
466 spin_lock(&journal->j_list_lock); 478 spin_lock(&journal->j_list_lock);
467 continue; 479 continue;
468 } 480 }
469 if (buffer_jbd(bh) && jh->b_jlist == BJ_Locked) { 481 if (buffer_jbd(bh) && bh2jh(bh) == jh &&
482 jh->b_transaction == commit_transaction &&
483 jh->b_jlist == BJ_Locked) {
470 __journal_unfile_buffer(jh); 484 __journal_unfile_buffer(jh);
471 jbd_unlock_bh_state(bh); 485 jbd_unlock_bh_state(bh);
472 journal_remove_journal_head(bh); 486 journal_remove_journal_head(bh);
@@ -490,7 +504,7 @@ void journal_commit_transaction(journal_t *journal)
490 err = 0; 504 err = 0;
491 } 505 }
492 506
493 journal_write_revoke_records(journal, commit_transaction); 507 journal_write_revoke_records(journal, commit_transaction, write_op);
494 508
495 /* 509 /*
496 * If we found any dirty or locked buffers, then we should have 510 * If we found any dirty or locked buffers, then we should have
@@ -660,7 +674,7 @@ start_journal_io:
660 clear_buffer_dirty(bh); 674 clear_buffer_dirty(bh);
661 set_buffer_uptodate(bh); 675 set_buffer_uptodate(bh);
662 bh->b_end_io = journal_end_buffer_io_sync; 676 bh->b_end_io = journal_end_buffer_io_sync;
663 submit_bh(WRITE, bh); 677 submit_bh(write_op, bh);
664 } 678 }
665 cond_resched(); 679 cond_resched();
666 680