Commit 516e0cf7 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] JBD: implement t_jcb locking

Provide the designed locking around the transaction's t_jcb callback list.

It turns out that this is wholly redundant at present.
parent 8c379633
...@@ -607,10 +607,14 @@ void journal_commit_transaction(journal_t *journal) ...@@ -607,10 +607,14 @@ void journal_commit_transaction(journal_t *journal)
unlock_journal(journal); unlock_journal(journal);
} }
/* Call any callbacks that had been registered for handles in this /*
* Call any callbacks that had been registered for handles in this
* transaction. It is up to the callback to free any allocated * transaction. It is up to the callback to free any allocated
* memory. * memory.
*
* The spinlocking (t_jcb_lock) here is surely unnecessary...
*/ */
spin_lock(&commit_transaction->t_jcb_lock);
if (!list_empty(&commit_transaction->t_jcb)) { if (!list_empty(&commit_transaction->t_jcb)) {
struct list_head *p, *n; struct list_head *p, *n;
int error = is_journal_aborted(journal); int error = is_journal_aborted(journal);
...@@ -620,9 +624,12 @@ void journal_commit_transaction(journal_t *journal) ...@@ -620,9 +624,12 @@ void journal_commit_transaction(journal_t *journal)
jcb = list_entry(p, struct journal_callback, jcb_list); jcb = list_entry(p, struct journal_callback, jcb_list);
list_del(p); list_del(p);
spin_unlock(&commit_transaction->t_jcb_lock);
jcb->jcb_func(jcb, error); jcb->jcb_func(jcb, error);
spin_lock(&commit_transaction->t_jcb_lock);
} }
} }
spin_unlock(&commit_transaction->t_jcb_lock);
lock_journal(journal); lock_journal(journal);
......
...@@ -41,15 +41,15 @@ ...@@ -41,15 +41,15 @@
* processes trying to touch the journal while it is in transition. * processes trying to touch the journal while it is in transition.
*/ */
static transaction_t * get_transaction (journal_t * journal, int is_try) static transaction_t *get_transaction(journal_t *journal)
{ {
transaction_t * transaction; transaction_t * transaction;
transaction = jbd_kmalloc (sizeof (transaction_t), GFP_NOFS); transaction = jbd_kmalloc(sizeof(*transaction), GFP_NOFS);
if (!transaction) if (!transaction)
return NULL; return NULL;
memset (transaction, 0, sizeof (transaction_t)); memset(transaction, 0, sizeof(*transaction));
transaction->t_journal = journal; transaction->t_journal = journal;
transaction->t_state = T_RUNNING; transaction->t_state = T_RUNNING;
...@@ -120,7 +120,7 @@ static int start_this_handle(journal_t *journal, handle_t *handle) ...@@ -120,7 +120,7 @@ static int start_this_handle(journal_t *journal, handle_t *handle)
repeat_locked: repeat_locked:
if (!journal->j_running_transaction) if (!journal->j_running_transaction)
get_transaction(journal, 0); get_transaction(journal);
/* @@@ Error? */ /* @@@ Error? */
J_ASSERT(journal->j_running_transaction); J_ASSERT(journal->j_running_transaction);
...@@ -1280,13 +1280,12 @@ void journal_callback_set(handle_t *handle, ...@@ -1280,13 +1280,12 @@ void journal_callback_set(handle_t *handle,
void (*func)(struct journal_callback *jcb, int error), void (*func)(struct journal_callback *jcb, int error),
struct journal_callback *jcb) struct journal_callback *jcb)
{ {
lock_kernel(); spin_lock(&handle->h_transaction->t_jcb_lock);
list_add_tail(&jcb->jcb_list, &handle->h_jcb); list_add_tail(&jcb->jcb_list, &handle->h_jcb);
spin_unlock(&handle->h_transaction->t_jcb_lock);
jcb->jcb_func = func; jcb->jcb_func = func;
unlock_kernel();
} }
/** /**
* int journal_stop() - complete a transaction * int journal_stop() - complete a transaction
* @handle: tranaction to complete. * @handle: tranaction to complete.
...@@ -1357,7 +1356,9 @@ int journal_stop(handle_t *handle) ...@@ -1357,7 +1356,9 @@ int journal_stop(handle_t *handle)
} }
/* Move callbacks from the handle to the transaction. */ /* Move callbacks from the handle to the transaction. */
spin_lock(&transaction->t_jcb_lock);
list_splice(&handle->h_jcb, &transaction->t_jcb); list_splice(&handle->h_jcb, &transaction->t_jcb);
spin_unlock(&transaction->t_jcb_lock);
/* /*
* If the handle is marked SYNC, we need to set another commit * If the handle is marked SYNC, we need to set another commit
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment