linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] jbd2: Make jbd2_handle_buffer_credits() handle reserved handles
@ 2019-11-15 10:22 Jan Kara
  2019-11-15 14:23 ` Theodore Y. Ts'o
  2019-11-18  7:59 ` Ritesh Harjani
  0 siblings, 2 replies; 3+ messages in thread
From: Jan Kara @ 2019-11-15 10:22 UTC (permalink / raw)
  To: Ted Tso; +Cc: linux-ext4, Eric Biggers, 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")
Reported-by: Eric Biggers <ebiggers@kernel.org>
Signed-off-by: Jan Kara <jack@suse.cz>
---
 include/linux/jbd2.h | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/include/linux/jbd2.h b/include/linux/jbd2.h
index 3115eeb44039..a23a3528e07a 100644
--- a/include/linux/jbd2.h
+++ b/include/linux/jbd2.h
@@ -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,
-- 
2.16.4


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] jbd2: Make jbd2_handle_buffer_credits() handle reserved handles
  2019-11-15 10:22 [PATCH] jbd2: Make jbd2_handle_buffer_credits() handle reserved handles Jan Kara
@ 2019-11-15 14:23 ` Theodore Y. Ts'o
  2019-11-18  7:59 ` Ritesh Harjani
  1 sibling, 0 replies; 3+ messages in thread
From: Theodore Y. Ts'o @ 2019-11-15 14:23 UTC (permalink / raw)
  To: Jan Kara; +Cc: linux-ext4, Eric Biggers

On Fri, Nov 15, 2019 at 11:22:10AM +0100, Jan Kara wrote:
> 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>

Thanks, applied.

					- Ted

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] jbd2: Make jbd2_handle_buffer_credits() handle reserved handles
  2019-11-15 10:22 [PATCH] jbd2: Make jbd2_handle_buffer_credits() handle reserved handles Jan Kara
  2019-11-15 14:23 ` Theodore Y. Ts'o
@ 2019-11-18  7:59 ` Ritesh Harjani
  1 sibling, 0 replies; 3+ messages in thread
From: Ritesh Harjani @ 2019-11-18  7:59 UTC (permalink / raw)
  To: Jan Kara, Ted Tso; +Cc: linux-ext4, Eric Biggers



On 11/15/19 3:52 PM, Jan Kara wrote:
> 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>

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

You may add -

Tested-by: Ritesh Harjani <riteshh@linux.ibm.com>


> ---
>   include/linux/jbd2.h | 8 ++++++--
>   1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/include/linux/jbd2.h b/include/linux/jbd2.h
> index 3115eeb44039..a23a3528e07a 100644
> --- a/include/linux/jbd2.h
> +++ b/include/linux/jbd2.h
> @@ -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,
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-11-18  7:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-15 10:22 [PATCH] jbd2: Make jbd2_handle_buffer_credits() handle reserved handles Jan Kara
2019-11-15 14:23 ` Theodore Y. Ts'o
2019-11-18  7:59 ` Ritesh Harjani

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).