diff options
author | 2019-11-15 11:22:10 +0100 | |
---|---|---|
committer | 2019-11-15 09:23:03 -0500 | |
commit | 3c845acd0237caef617f330a0e3b37ad8ae9fea5 (patch) | |
tree | 463edd05db61fcd4305bb928bfb90086bd9c31be /include/linux/jbd2.h | |
parent | ext4: fix a bug in ext4_wait_for_tail_page_commit (diff) | |
download | linux-3c845acd0237caef617f330a0e3b37ad8ae9fea5.tar.gz linux-3c845acd0237caef617f330a0e3b37ad8ae9fea5.tar.bz2 linux-3c845acd0237caef617f330a0e3b37ad8ae9fea5.zip |
jbd2: make jbd2_handle_buffer_credits() handle reserved handles
The helper jbd2_handle_buffer_credits() doesn't correctly handle reserved
handles which can lead to crashes. Fix it getting of journal pointer to
work for reserved handles as well.
Fixes: a9a8344ee171 ("ext4, jbd2: Provide accessor function for handle credits")
Reported-by: Eric Biggers <ebiggers@kernel.org>
Signed-off-by: Jan Kara <jack@suse.cz>
Link: https://lore.kernel.org/r/20191115102210.29445-1-jack@suse.cz
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Diffstat (limited to 'include/linux/jbd2.h')
-rw-r--r-- | include/linux/jbd2.h | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/include/linux/jbd2.h b/include/linux/jbd2.h index 587c146d3987..842b62606025 100644 --- a/include/linux/jbd2.h +++ b/include/linux/jbd2.h @@ -1627,10 +1627,14 @@ static inline tid_t jbd2_get_latest_transaction(journal_t *journal) return tid; } - static inline int jbd2_handle_buffer_credits(handle_t *handle) { - journal_t *journal = handle->h_transaction->t_journal; + journal_t *journal; + + if (!handle->h_reserved) + journal = handle->h_transaction->t_journal; + else + journal = handle->h_journal; return handle->h_total_credits - DIV_ROUND_UP(handle->h_revoke_credits_requested, |