* [PATCH] xfs_repair: Ensure just xfs_repair without -n can return a status code of 2
@ 2018-02-27 5:50 Xiao Yang
2018-02-27 14:21 ` Eric Sandeen
0 siblings, 1 reply; 5+ messages in thread
From: Xiao Yang @ 2018-02-27 5:50 UTC (permalink / raw)
To: sandeen; +Cc: darrick.wong, linux-xfs, Xiao Yang
Since commit b04647edea32, xfs_repair -L could't succeed to clear a dirty log
and returned a status of 2. Besides, xfs_repair -n returned a status of 2
instead of 1 if a dirty log was detected. I think just xfs_repair without -n
should return a status code of 2 when getting a dirty log, so fix it. We can
expose this issue by xfstests case xfs/098.
Fixes:'commit b04647edea32 ("xfs_repair: exit with status 2 if log dirtiness is unknown")'
Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
---
repair/phase2.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/repair/phase2.c b/repair/phase2.c
index 992e997..c124882 100644
--- a/repair/phase2.c
+++ b/repair/phase2.c
@@ -78,12 +78,13 @@ zero_log(
do_warn(
_("zero_log: cannot find log head/tail (xlog_find_tail=%d)\n"),
error);
- if (!no_modify && !zap_log)
+ if (!no_modify && !zap_log) {
do_warn(_(
"ERROR: The log head and/or tail cannot be discovered. Attempt to mount the\n"
"filesystem to replay the log or use the -L option to destroy the log and\n"
"attempt a repair.\n"));
exit(2);
+ }
} else {
if (verbose) {
do_log(
--
1.8.3.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] xfs_repair: Ensure just xfs_repair without -n can return a status code of 2
2018-02-27 5:50 [PATCH] xfs_repair: Ensure just xfs_repair without -n can return a status code of 2 Xiao Yang
@ 2018-02-27 14:21 ` Eric Sandeen
2018-02-28 1:32 ` Xiao Yang
2018-02-28 3:41 ` [PATCH v2] xfs_repair: Add missing braces Xiao Yang
0 siblings, 2 replies; 5+ messages in thread
From: Eric Sandeen @ 2018-02-27 14:21 UTC (permalink / raw)
To: Xiao Yang; +Cc: darrick.wong, linux-xfs
On 2/26/18 11:50 PM, Xiao Yang wrote:
> Since commit b04647edea32, xfs_repair -L could't succeed to clear a dirty log
> and returned a status of 2. Besides, xfs_repair -n returned a status of 2
> instead of 1 if a dirty log was detected. I think just xfs_repair without -n
> should return a status code of 2 when getting a dirty log, so fix it. We can
> expose this issue by xfstests case xfs/098.
>
> Fixes:'commit b04647edea32 ("xfs_repair: exit with status 2 if log dirtiness is unknown")'
>
> Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
Whoops, yes this was a silly mistake, my fault, and definitely a bug -
and your fix is obviously correct.
However, your description isn't accurate; the bug exists only when
xlog_find_tail() fails to find the head or the tail, which
is why this went undiscovered for so long. xfs_repair -L certainly
can clear a dirty log today, it only fails if xlog_find_tail fails.
The core bug here is missing braces; the result is that an unparseable
log always exits with exit(2), even if we've asked for -n or -L which
should proceed.
Can you resend this patch with a proper summary and a description
which more closely matches the actual bug?
Thanks,
-Eric
> ---
> repair/phase2.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/repair/phase2.c b/repair/phase2.c
> index 992e997..c124882 100644
> --- a/repair/phase2.c
> +++ b/repair/phase2.c
> @@ -78,12 +78,13 @@ zero_log(
> do_warn(
> _("zero_log: cannot find log head/tail (xlog_find_tail=%d)\n"),
> error);
> - if (!no_modify && !zap_log)
> + if (!no_modify && !zap_log) {
> do_warn(_(
> "ERROR: The log head and/or tail cannot be discovered. Attempt to mount the\n"
> "filesystem to replay the log or use the -L option to destroy the log and\n"
> "attempt a repair.\n"));
> exit(2);
> + }
> } else {
> if (verbose) {
> do_log(
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] xfs_repair: Ensure just xfs_repair without -n can return a status code of 2
2018-02-27 14:21 ` Eric Sandeen
@ 2018-02-28 1:32 ` Xiao Yang
2018-02-28 3:41 ` [PATCH v2] xfs_repair: Add missing braces Xiao Yang
1 sibling, 0 replies; 5+ messages in thread
From: Xiao Yang @ 2018-02-28 1:32 UTC (permalink / raw)
To: Eric Sandeen; +Cc: darrick.wong, linux-xfs
On 2018/02/27 22:21, Eric Sandeen wrote:
> On 2/26/18 11:50 PM, Xiao Yang wrote:
>> Since commit b04647edea32, xfs_repair -L could't succeed to clear a dirty log
>> and returned a status of 2. Besides, xfs_repair -n returned a status of 2
>> instead of 1 if a dirty log was detected. I think just xfs_repair without -n
>> should return a status code of 2 when getting a dirty log, so fix it. We can
>> expose this issue by xfstests case xfs/098.
>>
>> Fixes:'commit b04647edea32 ("xfs_repair: exit with status 2 if log dirtiness is unknown")'
>>
>> Signed-off-by: Xiao Yang<yangx.jy@cn.fujitsu.com>
> Whoops, yes this was a silly mistake, my fault, and definitely a bug -
> and your fix is obviously correct.
>
> However, your description isn't accurate; the bug exists only when
> xlog_find_tail() fails to find the head or the tail, which
> is why this went undiscovered for so long. xfs_repair -L certainly
> can clear a dirty log today, it only fails if xlog_find_tail fails.
>
> The core bug here is missing braces; the result is that an unparseable
> log always exits with exit(2), even if we've asked for -n or -L which
> should proceed.
>
> Can you resend this patch with a proper summary and a description
> which more closely matches the actual bug?
Hi Eric,
Thanks for your comment.
I will resend this patch as you suggested.
Thanks,
Xiao Yang
> Thanks,
> -Eric
>
>> ---
>> repair/phase2.c | 3 ++-
>> 1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/repair/phase2.c b/repair/phase2.c
>> index 992e997..c124882 100644
>> --- a/repair/phase2.c
>> +++ b/repair/phase2.c
>> @@ -78,12 +78,13 @@ zero_log(
>> do_warn(
>> _("zero_log: cannot find log head/tail (xlog_find_tail=%d)\n"),
>> error);
>> - if (!no_modify&& !zap_log)
>> + if (!no_modify&& !zap_log) {
>> do_warn(_(
>> "ERROR: The log head and/or tail cannot be discovered. Attempt to mount the\n"
>> "filesystem to replay the log or use the -L option to destroy the log and\n"
>> "attempt a repair.\n"));
>> exit(2);
>> + }
>> } else {
>> if (verbose) {
>> do_log(
>>
>
> .
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2] xfs_repair: Add missing braces
2018-02-27 14:21 ` Eric Sandeen
2018-02-28 1:32 ` Xiao Yang
@ 2018-02-28 3:41 ` Xiao Yang
2018-02-28 3:57 ` Eric Sandeen
1 sibling, 1 reply; 5+ messages in thread
From: Xiao Yang @ 2018-02-28 3:41 UTC (permalink / raw)
To: sandeen; +Cc: darrick.wong, linux-xfs, Xiao Yang
When xlog_find_tail() fails to find the head or the tail, the missing
braces leads that an unparseable log always exits with status 2, even
if we've asked for -n or -L which should proceed. We can expose this
issue by xfstests case xfs/098.
Fixes:'commit b04647edea32 ("xfs_repair: exit with status 2 if log dirtiness is unknown")'
Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
---
repair/phase2.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/repair/phase2.c b/repair/phase2.c
index 992e997..c124882 100644
--- a/repair/phase2.c
+++ b/repair/phase2.c
@@ -78,12 +78,13 @@ zero_log(
do_warn(
_("zero_log: cannot find log head/tail (xlog_find_tail=%d)\n"),
error);
- if (!no_modify && !zap_log)
+ if (!no_modify && !zap_log) {
do_warn(_(
"ERROR: The log head and/or tail cannot be discovered. Attempt to mount the\n"
"filesystem to replay the log or use the -L option to destroy the log and\n"
"attempt a repair.\n"));
exit(2);
+ }
} else {
if (verbose) {
do_log(
--
1.8.3.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2] xfs_repair: Add missing braces
2018-02-28 3:41 ` [PATCH v2] xfs_repair: Add missing braces Xiao Yang
@ 2018-02-28 3:57 ` Eric Sandeen
0 siblings, 0 replies; 5+ messages in thread
From: Eric Sandeen @ 2018-02-28 3:57 UTC (permalink / raw)
To: Xiao Yang; +Cc: darrick.wong, linux-xfs
On 2/27/18 9:41 PM, Xiao Yang wrote:
> When xlog_find_tail() fails to find the head or the tail, the missing
> braces leads that an unparseable log always exits with status 2, even
> if we've asked for -n or -L which should proceed. We can expose this
> issue by xfstests case xfs/098.
>
> Fixes:'commit b04647edea32 ("xfs_repair: exit with status 2 if log dirtiness is unknown")'
>
> Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
Thanks. I may make the subject more descriptive of the resulting
bug, but this is much better.
And thanks again for spotting it!
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
> ---
> repair/phase2.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/repair/phase2.c b/repair/phase2.c
> index 992e997..c124882 100644
> --- a/repair/phase2.c
> +++ b/repair/phase2.c
> @@ -78,12 +78,13 @@ zero_log(
> do_warn(
> _("zero_log: cannot find log head/tail (xlog_find_tail=%d)\n"),
> error);
> - if (!no_modify && !zap_log)
> + if (!no_modify && !zap_log) {
> do_warn(_(
> "ERROR: The log head and/or tail cannot be discovered. Attempt to mount the\n"
> "filesystem to replay the log or use the -L option to destroy the log and\n"
> "attempt a repair.\n"));
> exit(2);
> + }
> } else {
> if (verbose) {
> do_log(
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2018-02-28 3:57 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-02-27 5:50 [PATCH] xfs_repair: Ensure just xfs_repair without -n can return a status code of 2 Xiao Yang
2018-02-27 14:21 ` Eric Sandeen
2018-02-28 1:32 ` Xiao Yang
2018-02-28 3:41 ` [PATCH v2] xfs_repair: Add missing braces Xiao Yang
2018-02-28 3:57 ` Eric Sandeen
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).