Skip to content

Commit 3c845ac

Browse files
jankaratytso
authored andcommitted
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: a9a8344 ("ext4, jbd2: Provide accessor function for handle credits") Reported-by: Eric Biggers <[email protected]> Signed-off-by: Jan Kara <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Theodore Ts'o <[email protected]>
1 parent 565333a commit 3c845ac

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

include/linux/jbd2.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1627,10 +1627,14 @@ static inline tid_t jbd2_get_latest_transaction(journal_t *journal)
16271627
return tid;
16281628
}
16291629

1630-
16311630
static inline int jbd2_handle_buffer_credits(handle_t *handle)
16321631
{
1633-
journal_t *journal = handle->h_transaction->t_journal;
1632+
journal_t *journal;
1633+
1634+
if (!handle->h_reserved)
1635+
journal = handle->h_transaction->t_journal;
1636+
else
1637+
journal = handle->h_journal;
16341638

16351639
return handle->h_total_credits -
16361640
DIV_ROUND_UP(handle->h_revoke_credits_requested,

0 commit comments

Comments
 (0)