1 From stable-bounces@linux.kernel.org Tue Jun 9 02:28:16 2009
2 From: Jan Kara <jack@suse.cz>
3 Date: Tue, 2 Jun 2009 08:07:52 -0400
4 Subject: jbd2: Update locking coments
6 Cc: "Theodore Ts'o" <tytso@mit.edu>, linux-ext4@vger.kernel.org, Jan Kara <jack@suse.cz>
7 Message-ID: <1243944479-20574-11-git-send-email-tytso@mit.edu>
10 From: Jan Kara <jack@suse.cz>
12 (cherry picked from commit 86db97c87f744364d5889ca8a4134ca2048b8f83)
14 Update information about locking in JBD2 revoke code. Inconsistency in
15 comments found by Lin Tan <tammy000@gmail.com>
17 CC: Lin Tan <tammy000@gmail.com>
18 Signed-off-by: Jan Kara <jack@suse.cz>
19 Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
20 Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
22 fs/jbd2/revoke.c | 24 +++++++++++++++++++-----
23 1 file changed, 19 insertions(+), 5 deletions(-)
25 --- a/fs/jbd2/revoke.c
26 +++ b/fs/jbd2/revoke.c
29 * RevokeValid set, Revoked set:
30 * buffer has been revoked.
33 + * We keep two hash tables of revoke records. One hashtable belongs to the
34 + * running transaction (is pointed to by journal->j_revoke), the other one
35 + * belongs to the committing transaction. Accesses to the second hash table
36 + * happen only from the kjournald and no other thread touches this table. Also
37 + * journal_switch_revoke_table() which switches which hashtable belongs to the
38 + * running and which to the committing transaction is called only from
39 + * kjournald. Therefore we need no locks when accessing the hashtable belonging
40 + * to the committing transaction.
42 + * All users operating on the hash table belonging to the running transaction
43 + * have a handle to the transaction. Therefore they are safe from kjournald
44 + * switching hash tables under them. For operations on the lists of entries in
45 + * the hash table j_revoke_lock is used.
47 + * Finally, also replay code uses the hash tables but at this moment noone else
48 + * can touch them (filesystem isn't mounted yet) and hence no locking is
53 @@ -401,8 +420,6 @@ int jbd2_journal_revoke(handle_t *handle
54 * the second time we would still have a pending revoke to cancel. So,
55 * do not trust the Revoked bit on buffers unless RevokeValid is also
58 - * The caller must have the journal locked.
60 int jbd2_journal_cancel_revoke(handle_t *handle, struct journal_head *jh)
62 @@ -480,10 +497,7 @@ void jbd2_journal_switch_revoke_table(jo
64 * Write revoke records to the journal for all entries in the current
65 * revoke hash, deleting the entries as we go.
67 - * Called with the journal lock held.
70 void jbd2_journal_write_revoke_records(journal_t *journal,
71 transaction_t *transaction)