Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 140271
b: refs/heads/master
c: 512a004
h: refs/heads/master
i:
  140269: 25eee3a
  140267: 8699b5c
  140263: 3ef7376
  140255: 2f53ad9
v: v3
  • Loading branch information
Theodore Ts'o committed Mar 28, 2009
1 parent d185374 commit a426269
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 9 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: a64c8610bd3b753c6aff58f51c04cdf0ae478c18
refs/heads/master: 512a004382f2c60d5c4f855476ba965adc00250c
23 changes: 15 additions & 8 deletions trunk/fs/jbd/commit.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <linux/slab.h>
#include <linux/mm.h>
#include <linux/pagemap.h>
#include <linux/bio.h>

/*
* Default IO end handler for temporary BJ_IO buffer_heads.
Expand Down Expand Up @@ -171,22 +172,24 @@ static int journal_write_commit_record(journal_t *journal,
return (ret == -EIO);
}

static void journal_do_submit_data(struct buffer_head **wbuf, int bufs)
static void journal_do_submit_data(struct buffer_head **wbuf, int bufs,
int write_op)
{
int i;

for (i = 0; i < bufs; i++) {
wbuf[i]->b_end_io = end_buffer_write_sync;
/* We use-up our safety reference in submit_bh() */
submit_bh(WRITE, wbuf[i]);
submit_bh(write_op, wbuf[i]);
}
}

/*
* Submit all the data buffers to disk
*/
static int journal_submit_data_buffers(journal_t *journal,
transaction_t *commit_transaction)
transaction_t *commit_transaction,
int write_op)
{
struct journal_head *jh;
struct buffer_head *bh;
Expand Down Expand Up @@ -225,7 +228,7 @@ static int journal_submit_data_buffers(journal_t *journal,
BUFFER_TRACE(bh, "needs blocking lock");
spin_unlock(&journal->j_list_lock);
/* Write out all data to prevent deadlocks */
journal_do_submit_data(wbuf, bufs);
journal_do_submit_data(wbuf, bufs, write_op);
bufs = 0;
lock_buffer(bh);
spin_lock(&journal->j_list_lock);
Expand Down Expand Up @@ -256,7 +259,7 @@ static int journal_submit_data_buffers(journal_t *journal,
jbd_unlock_bh_state(bh);
if (bufs == journal->j_wbufsize) {
spin_unlock(&journal->j_list_lock);
journal_do_submit_data(wbuf, bufs);
journal_do_submit_data(wbuf, bufs, write_op);
bufs = 0;
goto write_out_data;
}
Expand Down Expand Up @@ -286,7 +289,7 @@ static int journal_submit_data_buffers(journal_t *journal,
}
}
spin_unlock(&journal->j_list_lock);
journal_do_submit_data(wbuf, bufs);
journal_do_submit_data(wbuf, bufs, write_op);

return err;
}
Expand Down Expand Up @@ -315,6 +318,7 @@ void journal_commit_transaction(journal_t *journal)
int first_tag = 0;
int tag_flag;
int i;
int write_op = WRITE;

/*
* First job: lock down the current transaction and wait for
Expand Down Expand Up @@ -347,6 +351,8 @@ void journal_commit_transaction(journal_t *journal)
spin_lock(&journal->j_state_lock);
commit_transaction->t_state = T_LOCKED;

if (commit_transaction->t_synchronous_commit)
write_op = WRITE_SYNC;
spin_lock(&commit_transaction->t_handle_lock);
while (commit_transaction->t_updates) {
DEFINE_WAIT(wait);
Expand Down Expand Up @@ -431,7 +437,8 @@ void journal_commit_transaction(journal_t *journal)
* Now start flushing things to disk, in the order they appear
* on the transaction lists. Data blocks go first.
*/
err = journal_submit_data_buffers(journal, commit_transaction);
err = journal_submit_data_buffers(journal, commit_transaction,
write_op);

/*
* Wait for all previously submitted IO to complete.
Expand Down Expand Up @@ -660,7 +667,7 @@ void journal_commit_transaction(journal_t *journal)
clear_buffer_dirty(bh);
set_buffer_uptodate(bh);
bh->b_end_io = journal_end_buffer_io_sync;
submit_bh(WRITE, bh);
submit_bh(write_op, bh);
}
cond_resched();

Expand Down
2 changes: 2 additions & 0 deletions trunk/fs/jbd/transaction.c
Original file line number Diff line number Diff line change
Expand Up @@ -1440,6 +1440,8 @@ int journal_stop(handle_t *handle)
}
}

if (handle->h_sync)
transaction->t_synchronous_commit = 1;
current->journal_info = NULL;
spin_lock(&journal->j_state_lock);
spin_lock(&transaction->t_handle_lock);
Expand Down
5 changes: 5 additions & 0 deletions trunk/include/linux/jbd.h
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,11 @@ struct transaction_s
*/
int t_handle_count;

/*
* This transaction is being forced and some process is
* waiting for it to finish.
*/
int t_synchronous_commit:1;
};

/**
Expand Down

0 comments on commit a426269

Please sign in to comment.