Commit 13d8498a authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] JBD: plan JBD locking schema

This is the start of the JBD locking rework.

The aims of all this are to remove all lock_kernel() calls from JBD, to
remove all lock_journal() calls (the context switch rate is astonishing when
the lock_kernel()s are removed) and to remove all sleep_on() instances.




The strategy which is taken is:

a) Define the lcoking schema (this patch)

b) Work through every JBD data structure and implement its locking fully,
   according to the above schema.  We work from "innermost" data structures
   and outwards.

It isn't guaranteed that the filesystem will work very well at all stages of
this patch series.



In this patch:


Add commentary and various locks to jbd.h describing the locking scheme which
is about to be implemented.

Initialise the new locks.

Coding-style goodness in jbd.h
parent 47bb09d8
...@@ -576,7 +576,6 @@ void __journal_drop_transaction(journal_t *journal, transaction_t *transaction) ...@@ -576,7 +576,6 @@ void __journal_drop_transaction(journal_t *journal, transaction_t *transaction)
journal->j_checkpoint_transactions = NULL; journal->j_checkpoint_transactions = NULL;
} }
J_ASSERT (transaction->t_ilist == NULL);
J_ASSERT (transaction->t_buffers == NULL); J_ASSERT (transaction->t_buffers == NULL);
J_ASSERT (transaction->t_sync_datalist == NULL); J_ASSERT (transaction->t_sync_datalist == NULL);
J_ASSERT (transaction->t_forget == NULL); J_ASSERT (transaction->t_forget == NULL);
......
...@@ -707,6 +707,9 @@ static journal_t * journal_init_common (void) ...@@ -707,6 +707,9 @@ static journal_t * journal_init_common (void)
init_MUTEX(&journal->j_barrier); init_MUTEX(&journal->j_barrier);
init_MUTEX(&journal->j_checkpoint_sem); init_MUTEX(&journal->j_checkpoint_sem);
init_MUTEX(&journal->j_sem); init_MUTEX(&journal->j_sem);
spin_lock_init(&journal->j_revoke_lock);
spin_lock_init(&journal->j_list_lock);
spin_lock_init(&journal->j_state_lock);
journal->j_commit_interval = (HZ * 5); journal->j_commit_interval = (HZ * 5);
......
...@@ -58,6 +58,8 @@ static transaction_t * get_transaction (journal_t * journal, int is_try) ...@@ -58,6 +58,8 @@ static transaction_t * get_transaction (journal_t * journal, int is_try)
transaction->t_tid = journal->j_transaction_sequence++; transaction->t_tid = journal->j_transaction_sequence++;
transaction->t_expires = jiffies + journal->j_commit_interval; transaction->t_expires = jiffies + journal->j_commit_interval;
INIT_LIST_HEAD(&transaction->t_jcb); INIT_LIST_HEAD(&transaction->t_jcb);
spin_lock_init(&transaction->t_handle_lock);
spin_lock_init(&transaction->t_jcb_lock);
/* Set up the commit timer for the new transaction. */ /* Set up the commit timer for the new transaction. */
J_ASSERT (!journal->j_commit_timer_active); J_ASSERT (!journal->j_commit_timer_active);
......
This diff is collapsed.
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* *
* buffer_head fields for JBD * buffer_head fields for JBD
* *
* 27 May 2001 ANdrew Morton <andrewm@uow.edu.au> * 27 May 2001 Andrew Morton <akpm@digeo.com>
* Created - pulled out of fs.h * Created - pulled out of fs.h
*/ */
...@@ -15,55 +15,70 @@ typedef struct transaction_s transaction_t; /* Compound transaction type */ ...@@ -15,55 +15,70 @@ typedef struct transaction_s transaction_t; /* Compound transaction type */
struct buffer_head; struct buffer_head;
struct journal_head { struct journal_head {
#ifndef CONFIG_JBD_UNIFIED_BUFFERS /*
/* Points back to our buffer_head. */ * Points back to our buffer_head. [jbd_lock_bh_journal_head()]
*/
struct buffer_head *b_bh; struct buffer_head *b_bh;
#endif
/* Reference count - see description in journal.c */ /*
* Reference count - see description in journal.c
* [jbd_lock_bh_journal_head()]
*/
int b_jcount; int b_jcount;
/* Journaling list for this buffer */ /*
* Journalling list for this buffer [jbd_lock_bh_state()]
*/
unsigned b_jlist; unsigned b_jlist;
/* Copy of the buffer data frozen for writing to the log. */ /*
char * b_frozen_data; * Copy of the buffer data frozen for writing to the log.
* [jbd_lock_bh_state()]
*/
char *b_frozen_data;
/* Pointer to a saved copy of the buffer containing no /*
uncommitted deallocation references, so that allocations can * Pointer to a saved copy of the buffer containing no uncommitted
avoid overwriting uncommitted deletes. */ * deallocation references, so that allocations can avoid overwriting
char * b_committed_data; * uncommitted deletes. [jbd_lock_bh_state()]
*/
char *b_committed_data;
/* Pointer to the compound transaction which owns this buffer's /*
metadata: either the running transaction or the committing * Pointer to the compound transaction which owns this buffer's
transaction (if there is one). Only applies to buffers on a * metadata: either the running transaction or the committing
transaction's data or metadata journaling list. */ * transaction (if there is one). Only applies to buffers on a
/* Protected by journal_datalist_lock */ * transaction's data or metadata journaling list.
transaction_t * b_transaction; * [j_list_lock] [jbd_lock_bh_state()]
*/
/* Pointer to the running compound transaction which is transaction_t *b_transaction;
currently modifying the buffer's metadata, if there was
already a transaction committing it when the new transaction /*
touched it. */ * Pointer to the running compound transaction which is currently
transaction_t * b_next_transaction; * modifying the buffer's metadata, if there was already a transaction
* committing it when the new transaction touched it.
/* Doubly-linked list of buffers on a transaction's data, * [t_list_lock] [jbd_lock_bh_state()]
metadata or forget queue. */ */
/* Protected by journal_datalist_lock */ transaction_t *b_next_transaction;
/*
* Doubly-linked list of buffers on a transaction's data, metadata or
* forget queue. [jbd_lock_bh_state()]
*/
struct journal_head *b_tnext, *b_tprev; struct journal_head *b_tnext, *b_tprev;
/* /*
* Pointer to the compound transaction against which this buffer * Pointer to the compound transaction against which this buffer
* is checkpointed. Only dirty buffers can be checkpointed. * is checkpointed. Only dirty buffers can be checkpointed.
* [j_list_lock]
*/ */
/* Protected by journal_datalist_lock */ transaction_t *b_cp_transaction;
transaction_t * b_cp_transaction;
/* /*
* Doubly-linked list of buffers still remaining to be flushed * Doubly-linked list of buffers still remaining to be flushed
* before an old transaction can be checkpointed. * before an old transaction can be checkpointed.
* [j_list_lock]
*/ */
/* Protected by journal_datalist_lock */
struct journal_head *b_cpnext, *b_cpprev; struct journal_head *b_cpnext, *b_cpprev;
}; };
......
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