linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] jbd2: Fix the wrong calculation of t_max_wait in update_t_max_wait.
@ 2011-05-10 10:48 Tao Ma
  2011-05-10 21:52 ` Eric Sandeen
  2011-05-23  1:47 ` Ted Ts'o
  0 siblings, 2 replies; 3+ messages in thread
From: Tao Ma @ 2011-05-10 10:48 UTC (permalink / raw)
  To: linux-ext4; +Cc: Jan Kara, Theodore Ts'o

From: Tao Ma <boyu.mt@taobao.com>

t_max_wait is added in commit 8e85fb3f to indicate how long we
were waiting for new transaction to start. In commit 6d0bf005,
it is moved to another function named update_t_max_wait to
avoid a build warning. But the wrong thing is that the original
'ts' is initialized in the start of function start_this_handle
and we can calculate t_max_wait in the right way. while with
this change, ts is initialized within the function and t_max_wait
can never be calculated right.

This patch moves the initialization of ts to the original beginning
of start_this_handle and pass it to function update_t_max_wait so
that it can be calculated right and the build warning is avoided also.

Cc: Jan Kara <jack@suse.cz>
Cc: "Theodore Ts'o" <tytso@mit.edu>
Signed-off-by: Tao Ma <boyu.mt@taobao.com>
---
 fs/jbd2/transaction.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/fs/jbd2/transaction.c b/fs/jbd2/transaction.c
index 05fa77a..85a055e 100644
--- a/fs/jbd2/transaction.c
+++ b/fs/jbd2/transaction.c
@@ -82,7 +82,7 @@ jbd2_get_transaction(journal_t *journal, transaction_t *transaction)
  */
 
 /*
- * Update transiaction's maximum wait time, if debugging is enabled.
+ * Update transaction's maximum wait time, if debugging is enabled.
  *
  * In order for t_max_wait to be reliable, it must be protected by a
  * lock.  But doing so will mean that start_this_handle() can not be
@@ -91,11 +91,10 @@ jbd2_get_transaction(journal_t *journal, transaction_t *transaction)
  * means that maximum wait time reported by the jbd2_run_stats
  * tracepoint will always be zero.
  */
-static inline void update_t_max_wait(transaction_t *transaction)
+static inline void update_t_max_wait(transaction_t *transaction,
+				     unsigned long ts)
 {
 #ifdef CONFIG_JBD2_DEBUG
-	unsigned long ts = jiffies;

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

* Re: [PATCH] jbd2: Fix the wrong calculation of t_max_wait in update_t_max_wait.
  2011-05-10 10:48 [PATCH] jbd2: Fix the wrong calculation of t_max_wait in update_t_max_wait Tao Ma
@ 2011-05-10 21:52 ` Eric Sandeen
  2011-05-23  1:47 ` Ted Ts'o
  1 sibling, 0 replies; 3+ messages in thread
From: Eric Sandeen @ 2011-05-10 21:52 UTC (permalink / raw)
  To: Tao Ma; +Cc: linux-ext4, Jan Kara, Theodore Ts'o

On 5/10/11 5:48 AM, Tao Ma wrote:
> From: Tao Ma <boyu.mt@taobao.com>
> 
> t_max_wait is added in commit 8e85fb3f to indicate how long we
> were waiting for new transaction to start. In commit 6d0bf005,
> it is moved to another function named update_t_max_wait to
> avoid a build warning. But the wrong thing is that the original
> 'ts' is initialized in the start of function start_this_handle
> and we can calculate t_max_wait in the right way. while with
> this change, ts is initialized within the function and t_max_wait
> can never be calculated right.
> 
> This patch moves the initialization of ts to the original beginning
> of start_this_handle and pass it to function update_t_max_wait so
> that it can be calculated right and the build warning is avoided also.
> 
> Cc: Jan Kara <jack@suse.cz>
> Cc: "Theodore Ts'o" <tytso@mit.edu>
> Signed-off-by: Tao Ma <boyu.mt@taobao.com>

Makes sense.

Reviewed-by: Eric Sandeen <sandeen@redhat.com>

> ---
>  fs/jbd2/transaction.c |   10 +++++-----
>  1 files changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/fs/jbd2/transaction.c b/fs/jbd2/transaction.c
> index 05fa77a..85a055e 100644
> --- a/fs/jbd2/transaction.c
> +++ b/fs/jbd2/transaction.c
> @@ -82,7 +82,7 @@ jbd2_get_transaction(journal_t *journal, transaction_t *transaction)
>   */
>  
>  /*
> - * Update transiaction's maximum wait time, if debugging is enabled.
> + * Update transaction's maximum wait time, if debugging is enabled.
>   *
>   * In order for t_max_wait to be reliable, it must be protected by a
>   * lock.  But doing so will mean that start_this_handle() can not be
> @@ -91,11 +91,10 @@ jbd2_get_transaction(journal_t *journal, transaction_t *transaction)
>   * means that maximum wait time reported by the jbd2_run_stats
>   * tracepoint will always be zero.
>   */
> -static inline void update_t_max_wait(transaction_t *transaction)
> +static inline void update_t_max_wait(transaction_t *transaction,
> +				     unsigned long ts)
>  {
>  #ifdef CONFIG_JBD2_DEBUG
> -	unsigned long ts = jiffies;
> -
>  	if (jbd2_journal_enable_debug &&
>  	    time_after(transaction->t_start, ts)) {
>  		ts = jbd2_time_diff(ts, transaction->t_start);
> @@ -121,6 +120,7 @@ static int start_this_handle(journal_t *journal, handle_t *handle,
>  	tid_t		tid;
>  	int		needed, need_to_start;
>  	int		nblocks = handle->h_buffer_credits;
> +	unsigned long ts = jiffies;
>  
>  	if (nblocks > journal->j_max_transaction_buffers) {
>  		printk(KERN_ERR "JBD: %s wants too many credits (%d > %d)\n",
> @@ -271,7 +271,7 @@ repeat:
>  	/* OK, account for the buffers that this operation expects to
>  	 * use and add the handle to the running transaction. 
>  	 */
> -	update_t_max_wait(transaction);
> +	update_t_max_wait(transaction, ts);
>  	handle->h_transaction = transaction;
>  	atomic_inc(&transaction->t_updates);
>  	atomic_inc(&transaction->t_handle_count);


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

* Re: [PATCH] jbd2: Fix the wrong calculation of t_max_wait in update_t_max_wait.
  2011-05-10 10:48 [PATCH] jbd2: Fix the wrong calculation of t_max_wait in update_t_max_wait Tao Ma
  2011-05-10 21:52 ` Eric Sandeen
@ 2011-05-23  1:47 ` Ted Ts'o
  1 sibling, 0 replies; 3+ messages in thread
From: Ted Ts'o @ 2011-05-23  1:47 UTC (permalink / raw)
  To: Tao Ma; +Cc: linux-ext4, Jan Kara

On Tue, May 10, 2011 at 06:48:19PM +0800, Tao Ma wrote:
> From: Tao Ma <boyu.mt@taobao.com>
> 
> t_max_wait is added in commit 8e85fb3f to indicate how long we
> were waiting for new transaction to start. In commit 6d0bf005,
> it is moved to another function named update_t_max_wait to
> avoid a build warning. But the wrong thing is that the original
> 'ts' is initialized in the start of function start_this_handle
> and we can calculate t_max_wait in the right way. while with
> this change, ts is initialized within the function and t_max_wait
> can never be calculated right.
> 
> This patch moves the initialization of ts to the original beginning
> of start_this_handle and pass it to function update_t_max_wait so
> that it can be calculated right and the build warning is avoided also.
> 
> Cc: Jan Kara <jack@suse.cz>
> Cc: "Theodore Ts'o" <tytso@mit.edu>
> Signed-off-by: Tao Ma <boyu.mt@taobao.com>

Thanks, added to the ext4 tree.

						- Ted

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

end of thread, other threads:[~2011-05-23  1:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-10 10:48 [PATCH] jbd2: Fix the wrong calculation of t_max_wait in update_t_max_wait Tao Ma
2011-05-10 21:52 ` Eric Sandeen
2011-05-23  1:47 ` Ted Ts'o

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