mirror of
https://github.com/kdave/btrfs-progs
synced 2025-02-27 15:30:44 +00:00
Btrfs-progs: add option to skip whether a scrub has started/resumed in userspace
I hit a problem that i can not start scrub when i am trying to track superblock generation mismatch problems. The fact is that we are trying to check whether we have started a scrub operation in userspace, this will make us can't start scrub if that record file is damaged itself. By adding a option to skip that check, everything will be fine. Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <clm@fb.com>
This commit is contained in:
parent
b94a3003ae
commit
f8675eb30f
12
cmds-scrub.c
12
cmds-scrub.c
@ -1096,9 +1096,10 @@ static int scrub_start(int argc, char **argv, int resume)
|
|||||||
void *terr;
|
void *terr;
|
||||||
u64 devid;
|
u64 devid;
|
||||||
DIR *dirstream = NULL;
|
DIR *dirstream = NULL;
|
||||||
|
int force = 0;
|
||||||
|
|
||||||
optind = 1;
|
optind = 1;
|
||||||
while ((c = getopt(argc, argv, "BdqrRc:n:")) != -1) {
|
while ((c = getopt(argc, argv, "BdqrRc:n:f")) != -1) {
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'B':
|
case 'B':
|
||||||
do_background = 0;
|
do_background = 0;
|
||||||
@ -1123,6 +1124,9 @@ static int scrub_start(int argc, char **argv, int resume)
|
|||||||
case 'n':
|
case 'n':
|
||||||
ioprio_classdata = (int)strtol(optarg, NULL, 10);
|
ioprio_classdata = (int)strtol(optarg, NULL, 10);
|
||||||
break;
|
break;
|
||||||
|
case 'f':
|
||||||
|
force = 1;
|
||||||
|
break;
|
||||||
case '?':
|
case '?':
|
||||||
default:
|
default:
|
||||||
usage(resume ? cmd_scrub_resume_usage :
|
usage(resume ? cmd_scrub_resume_usage :
|
||||||
@ -1195,7 +1199,7 @@ static int scrub_start(int argc, char **argv, int resume)
|
|||||||
* is a normal mode of operation to start scrub on multiple
|
* is a normal mode of operation to start scrub on multiple
|
||||||
* single devices, there is no reason to prevent this.
|
* single devices, there is no reason to prevent this.
|
||||||
*/
|
*/
|
||||||
if (is_scrub_running_on_fs(&fi_args, di_args, past_scrubs)) {
|
if (!force && is_scrub_running_on_fs(&fi_args, di_args, past_scrubs)) {
|
||||||
ERR(!do_quiet,
|
ERR(!do_quiet,
|
||||||
"ERROR: scrub is already running.\n"
|
"ERROR: scrub is already running.\n"
|
||||||
"To cancel use 'btrfs scrub cancel %s'.\n"
|
"To cancel use 'btrfs scrub cancel %s'.\n"
|
||||||
@ -1507,7 +1511,7 @@ out:
|
|||||||
}
|
}
|
||||||
|
|
||||||
static const char * const cmd_scrub_start_usage[] = {
|
static const char * const cmd_scrub_start_usage[] = {
|
||||||
"btrfs scrub start [-BdqrR] [-c ioprio_class -n ioprio_classdata] <path>|<device>",
|
"btrfs scrub start [-BdqrRf] [-c ioprio_class -n ioprio_classdata] <path>|<device>",
|
||||||
"Start a new scrub",
|
"Start a new scrub",
|
||||||
"",
|
"",
|
||||||
"-B do not background",
|
"-B do not background",
|
||||||
@ -1517,6 +1521,8 @@ static const char * const cmd_scrub_start_usage[] = {
|
|||||||
"-R raw print mode, print full data instead of summary"
|
"-R raw print mode, print full data instead of summary"
|
||||||
"-c set ioprio class (see ionice(1) manpage)",
|
"-c set ioprio class (see ionice(1) manpage)",
|
||||||
"-n set ioprio classdata (see ionice(1) manpage)",
|
"-n set ioprio classdata (see ionice(1) manpage)",
|
||||||
|
"-f force to skip checking whether scrub has started/resumed in userspace ",
|
||||||
|
" this is useful when scrub stats record file is damaged",
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ btrfs \- control a btrfs filesystem
|
|||||||
\fBbtrfs\fP \fBdevice stats\fP [-z] {\fI<path>\fP|\fI<device>\fP}
|
\fBbtrfs\fP \fBdevice stats\fP [-z] {\fI<path>\fP|\fI<device>\fP}
|
||||||
.PP
|
.PP
|
||||||
.PP
|
.PP
|
||||||
\fBbtrfs\fP \fBscrub start\fP [-BdqrR] [-c \fIioprio_class\fP -n \fIioprio_classdata\fP] {\fI<path>\fP|\fI<device>\fP}
|
\fBbtrfs\fP \fBscrub start\fP [-BdqrRf] [-c \fIioprio_class\fP -n \fIioprio_classdata\fP] {\fI<path>\fP|\fI<device>\fP}
|
||||||
.PP
|
.PP
|
||||||
\fBbtrfs\fP \fBscrub cancel\fP {\fI<path>\fP|\fI<device>\fP}
|
\fBbtrfs\fP \fBscrub cancel\fP {\fI<path>\fP|\fI<device>\fP}
|
||||||
.PP
|
.PP
|
||||||
@ -461,6 +461,9 @@ manpage).
|
|||||||
Set IO priority classdata (see
|
Set IO priority classdata (see
|
||||||
.BR ionice (1)
|
.BR ionice (1)
|
||||||
manpage).
|
manpage).
|
||||||
|
.IP "\fB-f\fP" 5
|
||||||
|
force to check whether scrub has started or resumed in userspace.
|
||||||
|
this is useful when scrub stat record file is damaged.
|
||||||
.RE
|
.RE
|
||||||
.TP
|
.TP
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user