All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] xfs_repair: don't use do_warn for normal log message
@ 2017-09-13 11:30 Masatake YAMATO
  2017-09-13 13:57 ` Eric Sandeen
  0 siblings, 1 reply; 2+ messages in thread
From: Masatake YAMATO @ 2017-09-13 11:30 UTC (permalink / raw)
  To: linux-xfs; +Cc: yamato

In some case, exit statuses of xfs_repair -n are different even for the
same file system when -v is specified or not. This patch fixes this
behavior.

If -v is specified, do_warn() is used in zero_log() for printing
a normal message. That makes the exit status to 1 though there
is no dirtiness in the file system.

The original zero_log():

	error = xlog_find_tail(log, &head_blk, &tail_blk);
	if (error) {...
	} else {
		if (verbose) {
			do_warn(
	_("zero_log: head block %" PRId64 " tail block %" PRId64 "\n"),
				head_blk, tail_blkn);
		}

do_warn() is used for the message, "zero_log:...".  do_log
should be used instead because this log message is for just reporting the
values of head_blk, and tail_blk. do_log is for "just reporting".

Using do_warn unintentionally has an impact.
It causes the exit status of the command.
do_warn sets fs_is_dirty global variable.
That refers in main function to decide the exit status.

    void
    do_warn(char const *msg, ...)
    {
	    va_list args;

	    fs_is_dirty = 1;

    int
    main(int argc, char **argv)
    {
    ...

		    if (fs_is_dirty)
			    return(1);

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
---
 Please, ignore the original patch I submitted a few minutes ago.
 The change is applied to wrong if/else block in the original patch.
 
 repair/phase2.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/repair/phase2.c b/repair/phase2.c
index c21778b8..850cd99e 100644
--- a/repair/phase2.c
+++ b/repair/phase2.c
@@ -86,7 +86,7 @@ zero_log(
 			exit(2);
 	} else {
 		if (verbose) {
-			do_warn(
+			do_log(
 	_("zero_log: head block %" PRId64 " tail block %" PRId64 "\n"),
 				head_blk, tail_blk);
 		}
-- 
2.13.5


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

* Re: [PATCH v2] xfs_repair: don't use do_warn for normal log message
  2017-09-13 11:30 [PATCH v2] xfs_repair: don't use do_warn for normal log message Masatake YAMATO
@ 2017-09-13 13:57 ` Eric Sandeen
  0 siblings, 0 replies; 2+ messages in thread
From: Eric Sandeen @ 2017-09-13 13:57 UTC (permalink / raw)
  To: Masatake YAMATO, linux-xfs

On 9/13/17 6:30 AM, Masatake YAMATO wrote:
> In some case, exit statuses of xfs_repair -n are different even for the
> same file system when -v is specified or not. This patch fixes this
> behavior.

Ah yes, we've fixed some of these before I think, though I can't find
them now... there's at least one more in main(), 

               if (fstat(fd, &statbuf) < 0)
                       do_warn(_("%s: couldn't stat \"%s\"\n"),
                               progname, fs_name);

This patch looks fine, though, thanks:

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

> If -v is specified, do_warn() is used in zero_log() for printing
> a normal message. That makes the exit status to 1 though there
> is no dirtiness in the file system.
> 
> The original zero_log():
> 
> 	error = xlog_find_tail(log, &head_blk, &tail_blk);
> 	if (error) {...
> 	} else {
> 		if (verbose) {
> 			do_warn(
> 	_("zero_log: head block %" PRId64 " tail block %" PRId64 "\n"),
> 				head_blk, tail_blkn);
> 		}
> 
> do_warn() is used for the message, "zero_log:...".  do_log
> should be used instead because this log message is for just reporting the
> values of head_blk, and tail_blk. do_log is for "just reporting".
> 
> Using do_warn unintentionally has an impact.
> It causes the exit status of the command.
> do_warn sets fs_is_dirty global variable.
> That refers in main function to decide the exit status.
> 
>     void
>     do_warn(char const *msg, ...)
>     {
> 	    va_list args;
> 
> 	    fs_is_dirty = 1;
> 
>     int
>     main(int argc, char **argv)
>     {
>     ...
> 
> 		    if (fs_is_dirty)
> 			    return(1);
> 
> Signed-off-by: Masatake YAMATO <yamato@redhat.com>
> ---
>  Please, ignore the original patch I submitted a few minutes ago.
>  The change is applied to wrong if/else block in the original patch.
>  
>  repair/phase2.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/repair/phase2.c b/repair/phase2.c
> index c21778b8..850cd99e 100644
> --- a/repair/phase2.c
> +++ b/repair/phase2.c
> @@ -86,7 +86,7 @@ zero_log(
>  			exit(2);
>  	} else {
>  		if (verbose) {
> -			do_warn(
> +			do_log(
>  	_("zero_log: head block %" PRId64 " tail block %" PRId64 "\n"),
>  				head_blk, tail_blk);
>  		}
> 

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

end of thread, other threads:[~2017-09-13 13:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-13 11:30 [PATCH v2] xfs_repair: don't use do_warn for normal log message Masatake YAMATO
2017-09-13 13:57 ` Eric Sandeen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.