public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <djwong@kernel.org>
To: Andrey Albershteyn <aalbersh@redhat.com>
Cc: cem@kernel.org, linux-xfs@vger.kernel.org
Subject: Re: [PATCH v2 2/4] xfs_repair: make duration take time_t
Date: Tue, 16 Apr 2024 14:00:37 -0700	[thread overview]
Message-ID: <20240416210037.GG11948@frogsfrogsfrogs> (raw)
In-Reply-To: <20240416202402.724492-3-aalbersh@redhat.com>

On Tue, Apr 16, 2024 at 10:24:00PM +0200, Andrey Albershteyn wrote:
> In most of the uses of duration() takes time_t instead of int.
> Convert the rest to use time_t and make duration() take time_t to
> not truncate it to int.
> 
> While at it remove unnecessary parentheses around 'elapsed'.
> 
> Signed-off-by: Andrey Albershteyn <aalbersh@redhat.com>
> ---
>  repair/globals.c    | 2 +-
>  repair/globals.h    | 2 +-
>  repair/progress.c   | 7 ++++---
>  repair/progress.h   | 2 +-
>  repair/xfs_repair.c | 2 +-
>  5 files changed, 8 insertions(+), 7 deletions(-)
> 
> diff --git a/repair/globals.c b/repair/globals.c
> index c40849853b8f..7c819d70a0ab 100644
> --- a/repair/globals.c
> +++ b/repair/globals.c
> @@ -116,7 +116,7 @@ uint32_t	sb_width;
>  struct aglock	*ag_locks;
>  struct aglock	rt_lock;
>  
> -int		report_interval;
> +time_t		report_interval;
>  uint64_t	*prog_rpt_done;
>  
>  int		ag_stride;
> diff --git a/repair/globals.h b/repair/globals.h
> index 89f1b0e078f3..2d05c8b2c00f 100644
> --- a/repair/globals.h
> +++ b/repair/globals.h
> @@ -160,7 +160,7 @@ struct aglock {
>  extern struct aglock	*ag_locks;
>  extern struct aglock	rt_lock;
>  
> -extern int		report_interval;
> +extern time_t		report_interval;
>  extern uint64_t		*prog_rpt_done;
>  
>  extern int		ag_stride;
> diff --git a/repair/progress.c b/repair/progress.c
> index f6c4d988444e..5f80fb68ddfd 100644
> --- a/repair/progress.c
> +++ b/repair/progress.c
> @@ -268,12 +268,13 @@ progress_rpt_thread (void *p)
>  				_("\t- %02d:%02d:%02d: Phase %d: elapsed time %s - processed %d %s per minute\n"),
>  				tmp->tm_hour, tmp->tm_min, tmp->tm_sec,
>  				current_phase, duration(elapsed, msgbuf),
> -				(int) (60*sum/(elapsed)), *msgp->format->type);
> +				(int) (60*sum/elapsed), *msgp->format->type);
>  			do_log(
>  	_("\t- %02d:%02d:%02d: Phase %d: %" PRIu64 "%% done - estimated remaining time %s\n"),
>  				tmp->tm_hour, tmp->tm_min, tmp->tm_sec,
>  				current_phase, percent,
> -				duration((int) ((*msgp->total - sum) * (elapsed)/sum), msgbuf));
> +				duration((*msgp->total - sum) * elapsed/sum,
> +					msgbuf));
>  		}
>  
>  		if (pthread_mutex_unlock(&msgp->mutex) != 0) {
> @@ -420,7 +421,7 @@ timestamp(int end, int phase, char *buf)
>  }
>  
>  char *
> -duration(int length, char *buf)
> +duration(time_t length, char *buf)
>  {
>  	int sum;
>  	int weeks;
> diff --git a/repair/progress.h b/repair/progress.h
> index 2c1690db1b17..9575df164aa0 100644
> --- a/repair/progress.h
> +++ b/repair/progress.h
> @@ -38,7 +38,7 @@ extern void summary_report(void);
>  extern int  set_progress_msg(int report, uint64_t total);
>  extern uint64_t print_final_rpt(void);
>  extern char *timestamp(int end, int phase, char *buf);
> -extern char *duration(int val, char *buf);
> +extern char *duration(time_t val, char *buf);
>  extern int do_parallel;
>  
>  #define	PROG_RPT_INC(a,b) if (ag_stride && prog_rpt_done) (a) += (b)
> diff --git a/repair/xfs_repair.c b/repair/xfs_repair.c
> index ba9d28330d82..2ceea87dc57d 100644
> --- a/repair/xfs_repair.c
> +++ b/repair/xfs_repair.c
> @@ -377,7 +377,7 @@ process_args(int argc, char **argv)
>  			do_prefetch = 0;
>  			break;
>  		case 't':
> -			report_interval = (int)strtol(optarg, NULL, 0);
> +			report_interval = strtol(optarg, NULL, 0);

This also needs to clear and check errno to report errors.  However,
that should be a separate patch.

Reviewed-by: Darrick J. Wong <djwong@kernel.org>

--D

>  			break;
>  		case 'e':
>  			report_corrected = true;
> -- 
> 2.42.0
> 
> 

  reply	other threads:[~2024-04-16 21:00 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-16 20:23 [PATCH v2 0/4] xfsprogs random fixes found by Coverity scan Andrey Albershteyn
2024-04-16 20:23 ` [PATCH v2 1/4] xfs_db: fix leak in flist_find_ftyp() Andrey Albershteyn
2024-04-16 20:24 ` [PATCH v2 2/4] xfs_repair: make duration take time_t Andrey Albershteyn
2024-04-16 21:00   ` Darrick J. Wong [this message]
2024-04-16 20:24 ` [PATCH v2 3/4] xfs_scrub: don't call phase_end if phase_rusage was not initialized Andrey Albershteyn
2024-04-16 20:24 ` [PATCH v2 4/4] xfs_fsr: convert fsrallfs to use time_t instead of int Andrey Albershteyn
2024-04-16 20:59   ` Darrick J. Wong
2024-04-16 20:51 ` [PATCH v2 0/4] xfsprogs random fixes found by Coverity scan Bill O'Donnell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240416210037.GG11948@frogsfrogsfrogs \
    --to=djwong@kernel.org \
    --cc=aalbersh@redhat.com \
    --cc=cem@kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox