Commit 86db97c87f744364d5889ca8a4134ca2048b8f83

Authored by Jan Kara
Committed by Theodore Ts'o
1 parent cc0fb9ad7d

jbd2: Update locking coments

Update information about locking in JBD2 revoke code. Inconsistency in
comments found by Lin Tan <tammy000@gmail.com>.

CC: Lin Tan <tammy000@gmail.com>.
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>

Showing 1 changed file with 19 additions and 5 deletions Side-by-side Diff

... ... @@ -55,6 +55,25 @@
55 55 * need do nothing.
56 56 * RevokeValid set, Revoked set:
57 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 79 #ifndef __KERNEL__
... ... @@ -401,8 +420,6 @@
401 420 * the second time we would still have a pending revoke to cancel. So,
402 421 * do not trust the Revoked bit on buffers unless RevokeValid is also
403 422 * set.
404   - *
405   - * The caller must have the journal locked.
406 423 */
407 424 int jbd2_journal_cancel_revoke(handle_t *handle, struct journal_head *jh)
408 425 {
409 426  
... ... @@ -480,10 +497,7 @@
480 497 /*
481 498 * Write revoke records to the journal for all entries in the current
482 499 * revoke hash, deleting the entries as we go.
483   - *
484   - * Called with the journal lock held.
485 500 */
486   -
487 501 void jbd2_journal_write_revoke_records(journal_t *journal,
488 502 transaction_t *transaction)
489 503 {