diff options
author | Theodore Ts'o <tytso@mit.edu> | 2013-07-01 08:12:40 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-07-21 21:21:22 -0400 |
commit | 15f26a4c4820d1fb5f1ba979b4fe4d00a2d38b7d (patch) | |
tree | 64b275628cb168feb2e2e1a457658827a5b7e0b7 /fs | |
parent | 5f81e313889bcaf53faec9c05a4c92e0b43823f4 (diff) |
jbd2: fix theoretical race in jbd2__journal_restart
commit 39c04153fda8c32e85b51c96eb5511a326ad7609 upstream.
Once we decrement transaction->t_updates, if this is the last handle
holding the transaction from closing, and once we release the
t_handle_lock spinlock, it's possible for the transaction to commit
and be released. In practice with normal kernels, this probably won't
happen, since the commit happens in a separate kernel thread and it's
unlikely this could all happen within the space of a few CPU cycles.
On the other hand, with a real-time kernel, this could potentially
happen, so save the tid found in transaction->t_tid before we release
t_handle_lock. It would require an insane configuration, such as one
where the jbd2 thread was set to a very high real-time priority,
perhaps because a high priority real-time thread is trying to read or
write to a file system. But some people who use real-time kernels
have been known to do insane things, including controlling
laser-wielding industrial robots. :-)
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/jbd2/transaction.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/fs/jbd2/transaction.c b/fs/jbd2/transaction.c index 10f524c59ea8..e0c0bc275924 100644 --- a/fs/jbd2/transaction.c +++ b/fs/jbd2/transaction.c | |||
@@ -517,10 +517,10 @@ int jbd2__journal_restart(handle_t *handle, int nblocks, gfp_t gfp_mask) | |||
517 | &transaction->t_outstanding_credits); | 517 | &transaction->t_outstanding_credits); |
518 | if (atomic_dec_and_test(&transaction->t_updates)) | 518 | if (atomic_dec_and_test(&transaction->t_updates)) |
519 | wake_up(&journal->j_wait_updates); | 519 | wake_up(&journal->j_wait_updates); |
520 | tid = transaction->t_tid; | ||
520 | spin_unlock(&transaction->t_handle_lock); | 521 | spin_unlock(&transaction->t_handle_lock); |
521 | 522 | ||
522 | jbd_debug(2, "restarting handle %p\n", handle); | 523 | jbd_debug(2, "restarting handle %p\n", handle); |
523 | tid = transaction->t_tid; | ||
524 | need_to_start = !tid_geq(journal->j_commit_request, tid); | 524 | need_to_start = !tid_geq(journal->j_commit_request, tid); |
525 | read_unlock(&journal->j_state_lock); | 525 | read_unlock(&journal->j_state_lock); |
526 | if (need_to_start) | 526 | if (need_to_start) |