Skip to contentSkip to conversation

jbd2: Make jbd2_handle_buffer_credits() handle reserved handles

PATCH Applied Jan Kara 3 participants 3 messages Nov 15, 2019 – Nov 18, 2019 Journalling layer for block devices (JBD2)

lore
Share & tools
lore

Jan Kara

author
#0 lore raw

PATCH 1/1 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")
---
 include/linux/jbd2.h | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
include/linux/jbd2.h +6 -2
index 3115eeb44039..a23a3528e07a 100644
@@ -1648,10 +1648,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,
Signature · 1 line
2.16.4
maintainer Applied
#1 lore raw
Quoted 7 lines · Jan Kara

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")

Thanks, applied.

- Ted

Tested-by on v1 1/1
#2 lore raw
In reply to Jan Kara
Quoted 7 lines · Jan Kara

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")

Thanks Jan,
Yes, this also fixes the problem for me with dioread_nolock on ppc64 machine.

You may add -

Quoted 26 lines
---
  include/linux/jbd2.h | 8 ++++++--
  1 file changed, 6 insertions(+), 2 deletions(-)
include/linux/jbd2.h +6 -2
index 3115eeb44039..a23a3528e07a 100644
@@ -1648,10 +1648,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,