From: Nikolay Borisov <nborisov@suse.com>
To: Anand Jain <anand.jain@oracle.com>,
David Sterba <dsterba@suse.com>,
Johannes Thumshirn <jthumshirn@suse.de>
Cc: rbrown@suse.de, Linux BTRFS Mailinglist <linux-btrfs@vger.kernel.org>
Subject: Re: [PATCH] btrfs-progs: warn users about the possible dangers of check --repair
Date: Thu, 17 Oct 2019 09:40:34 +0300 [thread overview]
Message-ID: <a727c9e1-1db7-de0f-15a4-83578e5cbf93@suse.com> (raw)
In-Reply-To: <77db6cb7-b1e9-7834-a454-b01b4d4a1f59@oracle.com>
On 17.10.19 г. 4:25 ч., Anand Jain wrote:
> On 10/16/19 10:31 PM, Nikolay Borisov wrote:
>>
>>
>> On 16.10.19 г. 17:05 ч., Johannes Thumshirn wrote:
>>> The manual page of btrfsck clearly states 'btrfs check --repair' is a
>>> dangerous operation.
>>>
>>> Although this warning is in place users do not read the manual page
>>> and/or
>>> are used to the behaviour of fsck utilities which repair the filesystem,
>>> and thus potentially cause harm.
>>>
>>> Similar to 'btrfs balance' without any filters, add a warning and a
>>> countdown, so users can bail out before eventual corrupting the
>>> filesystem
>>> more than it already is.
>>>
>>> Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
>>> ---
>>> check/main.c | 17 +++++++++++++++++
>>> 1 file changed, 17 insertions(+)
>>>
>>> diff --git a/check/main.c b/check/main.c
>>> index fd05430c1f51..acded927281a 100644
>>> --- a/check/main.c
>>> +++ b/check/main.c
>>> @@ -9970,6 +9970,23 @@ static int cmd_check(const struct cmd_struct
>>> *cmd, int argc, char **argv)
>>> exit(1);
>>> }
>>> + if (repair) {
>>> + int delay = 10;
>>> + printf("WARNING:\n\n");
>>> + printf("\tDo not use --repair unless you are advised to do
>>> so by a developer\n");
>>> + printf("\tor an experienced user, and then only after having
>>> accepted that no\n");
>>> + printf("\tfsck successfully repair all types of filesystem
>>> corruption. Eg.\n");
>>> + printf("\tsome other software or hardware bugs can fatally
>>> damage a volume.\n");
>>
>> nit: The word 'other' here is redundant, no ?
>>
>>> + printf("\tThe operation will start in %d seconds.\n", delay);
>>> + printf("\tUse Ctrl-C to stop it.\n");
>>> + while (delay) {
>>> + printf("%2d", delay--);
>>> + fflush(stdout);
>>> + sleep(1);
>>> + }
>>
>> That's a long winded way to have a simple for loop that prints 10 dots,
>> 1 second apart.
>
>
>> IMO a better use experience would be to ask the user to
>> confirm and if the '-f' options i passed don't bother printing the
>> warning at all.
>
> Agreed. -f will suffice (at least make it non-default) is a good fix.
> But again as Qu pointed out our test cases will fail or old test case
> with new progs will fail.
They could be adjusted accordingly to always append the -f flag when
running --repair. After all when running tests we do expect to be able
to fix everything, no ?
>
> Thanks, Anand
>
>>> + printf("\nStarting repair.\n");
>>> + }
>>> +
>>> /*
>>> * experimental and dangerous
>>> */
>>>
>
>
next prev parent reply other threads:[~2019-10-17 6:40 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-16 14:05 [PATCH] btrfs-progs: warn users about the possible dangers of check --repair Johannes Thumshirn
2019-10-16 14:18 ` Qu Wenruo
2019-10-16 14:31 ` Nikolay Borisov
2019-10-17 1:25 ` Anand Jain
2019-10-17 6:40 ` Nikolay Borisov [this message]
2019-10-17 7:10 ` Johannes Thumshirn
2019-10-17 7:13 ` Johannes Thumshirn
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=a727c9e1-1db7-de0f-15a4-83578e5cbf93@suse.com \
--to=nborisov@suse.com \
--cc=anand.jain@oracle.com \
--cc=dsterba@suse.com \
--cc=jthumshirn@suse.de \
--cc=linux-btrfs@vger.kernel.org \
--cc=rbrown@suse.de \
/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