linux-xfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: Eric Sandeen <sandeen@sandeen.net>
Cc: sandeen@redhat.com, linux-xfs@vger.kernel.org
Subject: Re: [PATCH 7/7] xfs_scrub: refactor outcome display into a separate helper
Date: Mon, 12 Feb 2018 16:00:18 -0800	[thread overview]
Message-ID: <20180213000018.GD5217@magnolia> (raw)
In-Reply-To: <5279e63a-6ea9-517b-f73f-2b52d0a2f7ea@sandeen.net>

On Mon, Feb 12, 2018 at 03:06:58PM -0600, Eric Sandeen wrote:
> On 2/5/18 5:23 PM, Darrick J. Wong wrote:
> > From: Darrick J. Wong <darrick.wong@oracle.com>
> > 
> > Move all the printing of the scrub outcome into a separate helper to
> > declutter the main function.
> > 
> > Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> 
> 
> This might get a bit long, no?
> 
> "/path/to/filesystem: errors found 16384; warnings found 16.  Unmount and run xfs_repair."
> 
> Can we put the "Unmount and run xfs_repair" on its own line?
> That'd make it stand out more, as well.  </nitpick>

Sure, works for me.  Should I send a separate patch or will you just fix
it up on the way in?

--D

> 
> > ---
> >  scrub/xfs_scrub.c |   48 ++++++++++++++++++++++++++++++------------------
> >  1 file changed, 30 insertions(+), 18 deletions(-)
> > 
> > 
> > diff --git a/scrub/xfs_scrub.c b/scrub/xfs_scrub.c
> > index 89b7fa0..fdd35df 100644
> > --- a/scrub/xfs_scrub.c
> > +++ b/scrub/xfs_scrub.c
> > @@ -493,6 +493,34 @@ _("Scrub aborted after phase %d."),
> >  	return moveon;
> >  }
> >  
> > +static void
> > +report_outcome(
> > +	struct scrub_ctx	*ctx)
> > +{
> > +	unsigned long long	total_errors;
> > +
> > +	total_errors = ctx->errors_found + ctx->runtime_errors;
> > +
> > +	if (total_errors == 0 && ctx->warnings_found == 0)
> > +		return;
> > +
> > +	if (total_errors == 0)
> > +		fprintf(stderr, _("%s: warnings found: %llu."), ctx->mntpoint,
> > +				ctx->warnings_found);
> > +	else if (ctx->warnings_found == 0)
> > +		fprintf(stderr, _("%s: errors found: %llu."), ctx->mntpoint,
> > +				total_errors);
> > +	else
> > +		fprintf(stderr, _("%s: errors found: %llu; warnings found: %llu."),
> > +				ctx->mntpoint, total_errors,
> > +				ctx->warnings_found);
> > +
> > +	if (ctx->need_repair)
> > +		fprintf(stderr, "  %s\n", _("Unmount and run xfs_repair."));
> > +	else
> > +		fprintf(stderr, "\n");
> > +}
> > +
> >  int
> >  main(
> >  	int			argc,
> > @@ -501,9 +529,7 @@ main(
> >  	struct scrub_ctx	ctx = {0};
> >  	struct phase_rusage	all_pi;
> >  	char			*mtab = NULL;
> > -	char			*repairstr = "";
> >  	FILE			*progress_fp = NULL;
> > -	unsigned long long	total_errors;
> >  	bool			moveon = true;
> >  	bool			ismnt;
> >  	int			c;
> > @@ -692,22 +718,8 @@ _("%s: Not a XFS mount point or block device.\n"),
> >  		ctx.runtime_errors++;
> >  
> >  out:
> > -	total_errors = ctx.errors_found + ctx.runtime_errors;
> > -	if (ctx.need_repair)
> > -		repairstr = _("  Unmount and run xfs_repair.");
> > -	if (total_errors && ctx.warnings_found)
> > -		fprintf(stderr,
> > -_("%s: %llu errors and %llu warnings found.%s\n"),
> > -			ctx.mntpoint, total_errors, ctx.warnings_found,
> > -			repairstr);
> > -	else if (total_errors && ctx.warnings_found == 0)
> > -		fprintf(stderr,
> > -_("%s: %llu errors found.%s\n"),
> > -			ctx.mntpoint, total_errors, repairstr);
> > -	else if (total_errors == 0 && ctx.warnings_found)
> > -		fprintf(stderr,
> > -_("%s: %llu warnings found.\n"),
> > -			ctx.mntpoint, ctx.warnings_found);
> > +	report_outcome(&ctx);
> > +
> >  	if (ctx.errors_found) {
> >  		if (ctx.error_action == ERRORS_SHUTDOWN)
> >  			xfs_shutdown_fs(&ctx);
> > 
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
> > 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2018-02-13  0:00 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-05 23:22 [PATCH 0/7] xfsprogs: 4.15 rollup pt. 5 Darrick J. Wong
2018-02-05 23:22 ` [PATCH 1/7] xfs_scrub: log operational messages when interactive Darrick J. Wong
2018-02-12 20:47   ` Eric Sandeen
2018-02-14  0:39     ` Darrick J. Wong
2018-02-14  7:48       ` Jan Tulak
2018-02-14 16:51         ` Darrick J. Wong
2018-03-08 18:07     ` Darrick J. Wong
2018-03-08 18:27       ` Eric Sandeen
2018-02-14  7:50   ` Jan Tulak
2018-02-05 23:22 ` [PATCH 2/7] xfs_scrub: remove preen mode Darrick J. Wong
2018-02-12 20:49   ` Eric Sandeen
2018-02-12 23:57     ` Darrick J. Wong
2018-02-14  7:53     ` Jan Tulak
2018-02-05 23:22 ` [PATCH 3/7] xfs_scrub: classify lack of ioctl support as a runtime error Darrick J. Wong
2018-02-12 20:50   ` Eric Sandeen
2018-02-14  7:54   ` Jan Tulak
2018-02-05 23:22 ` [PATCH 4/7] xfs_scrub: reclassify runtime errors Darrick J. Wong
2018-02-12 20:52   ` Eric Sandeen
2018-02-14  7:56     ` Jan Tulak
2018-02-05 23:22 ` [PATCH 5/7] xfs_scrub: reclassify some of the warning messages Darrick J. Wong
2018-02-12 20:53   ` Eric Sandeen
2018-02-14  7:56     ` Jan Tulak
2018-02-05 23:23 ` [PATCH 6/7] xfs_scrub: always init phase information Darrick J. Wong
2018-02-12 20:53   ` Eric Sandeen
2018-02-14  7:57     ` Jan Tulak
2018-02-05 23:23 ` [PATCH 7/7] xfs_scrub: refactor outcome display into a separate helper Darrick J. Wong
2018-02-12 21:06   ` Eric Sandeen
2018-02-13  0:00     ` Darrick J. Wong [this message]
2018-02-14  7:59     ` Jan Tulak

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=20180213000018.GD5217@magnolia \
    --to=darrick.wong@oracle.com \
    --cc=linux-xfs@vger.kernel.org \
    --cc=sandeen@redhat.com \
    --cc=sandeen@sandeen.net \
    /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;
as well as URLs for NNTP newsgroup(s).