Skip to content

Commit

Permalink
jbd2: make jbd2_handle_buffer_credits() handle reserved handles
Browse files Browse the repository at this point in the history
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: a9a8344 ("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>
  • Loading branch information
Jan Kara authored and Theodore Ts'o committed Nov 15, 2019
1 parent 565333a commit 3c845ac
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions include/linux/jbd2.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 3c845ac

Please sign in to comment.