]> git.baikalelectronics.ru Git - kernel.git/commit
jbd2: avoid long hold times of j_state_lock while committing a transaction
authorJan Kara <jack@suse.cz>
Tue, 4 Dec 2018 04:16:07 +0000 (23:16 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Tue, 4 Dec 2018 04:16:07 +0000 (23:16 -0500)
commitc144b689b6850a6af4510edf1233a1cc560228ba
tree60a2865f4e0f909fdea3b069ba80534148200ab0
parent83f5fdef1e0da8935460339a9272cb614f1929d4
jbd2: avoid long hold times of j_state_lock while committing a transaction

We can hold j_state_lock for writing at the beginning of
jbd2_journal_commit_transaction() for a rather long time (reportedly for
30 ms) due cleaning revoke bits of all revoked buffers under it. The
handling of revoke tables as well as cleaning of t_reserved_list, and
checkpoint lists does not need j_state_lock for anything. It is only
needed to prevent new handles from joining the transaction. Generally
T_LOCKED transaction state prevents new handles from joining the
transaction - except for reserved handles which have to allowed to join
while we wait for other handles to complete.

To prevent reserved handles from joining the transaction while cleaning
up lists, add new transaction state T_SWITCH and watch for it when
starting reserved handles. With this we can just drop the lock for
operations that don't need it.

Reported-and-tested-by: Adrian Hunter <adrian.hunter@intel.com>
Suggested-by: "Theodore Y. Ts'o" <tytso@mit.edu>
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
fs/jbd2/commit.c
fs/jbd2/transaction.c
include/linux/jbd2.h