aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorJan Kara <jack@suse.cz>2009-04-13 17:40:06 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2009-04-13 18:04:32 -0400
commit32433879480d13bc019d5a067ce884064a93dd63 (patch)
tree652230bb84c0d93d06b8ed17049e9a8229283907 /fs
parent9de100d001564f58c3fb2ec1bd03e540ac0aa357 (diff)
jbd: update locking coments
Update information about locking in JBD revoke code. Reported-by: Lin Tan <tammy000@gmail.com>. Signed-off-by: Jan Kara <jack@suse.cz> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/jbd/revoke.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/fs/jbd/revoke.c b/fs/jbd/revoke.c
index c7bd649bbbdc..3e9afc2a91d2 100644
--- a/fs/jbd/revoke.c
+++ b/fs/jbd/revoke.c
@@ -55,6 +55,25 @@
55 * need do nothing. 55 * need do nothing.
56 * RevokeValid set, Revoked set: 56 * RevokeValid set, Revoked set:
57 * buffer has been revoked. 57 * buffer has been revoked.
58 *
59 * Locking rules:
60 * We keep two hash tables of revoke records. One hashtable belongs to the
61 * running transaction (is pointed to by journal->j_revoke), the other one
62 * belongs to the committing transaction. Accesses to the second hash table
63 * happen only from the kjournald and no other thread touches this table. Also
64 * journal_switch_revoke_table() which switches which hashtable belongs to the
65 * running and which to the committing transaction is called only from
66 * kjournald. Therefore we need no locks when accessing the hashtable belonging
67 * to the committing transaction.
68 *
69 * All users operating on the hash table belonging to the running transaction
70 * have a handle to the transaction. Therefore they are safe from kjournald
71 * switching hash tables under them. For operations on the lists of entries in
72 * the hash table j_revoke_lock is used.
73 *
74 * Finally, also replay code uses the hash tables but at this moment noone else
75 * can touch them (filesystem isn't mounted yet) and hence no locking is
76 * needed.
58 */ 77 */
59 78
60#ifndef __KERNEL__ 79#ifndef __KERNEL__
@@ -402,8 +421,6 @@ int journal_revoke(handle_t *handle, unsigned long blocknr,
402 * the second time we would still have a pending revoke to cancel. So, 421 * the second time we would still have a pending revoke to cancel. So,
403 * do not trust the Revoked bit on buffers unless RevokeValid is also 422 * do not trust the Revoked bit on buffers unless RevokeValid is also
404 * set. 423 * set.
405 *
406 * The caller must have the journal locked.
407 */ 424 */
408int journal_cancel_revoke(handle_t *handle, struct journal_head *jh) 425int journal_cancel_revoke(handle_t *handle, struct journal_head *jh)
409{ 426{
@@ -481,10 +498,7 @@ void journal_switch_revoke_table(journal_t *journal)
481/* 498/*
482 * Write revoke records to the journal for all entries in the current 499 * Write revoke records to the journal for all entries in the current
483 * revoke hash, deleting the entries as we go. 500 * revoke hash, deleting the entries as we go.
484 *
485 * Called with the journal lock held.
486 */ 501 */
487
488void journal_write_revoke_records(journal_t *journal, 502void journal_write_revoke_records(journal_t *journal,
489 transaction_t *transaction) 503 transaction_t *transaction)
490{ 504{