#include "obdctl.h"
-#include <obd.h>
#include <lustre/lustre_lfsck_user.h>
#include <libcfs/libcfsutil.h>
#include <lnet/lnetctl.h>
+#include <lustre_ioctl.h>
static struct option long_opt_start[] = {
- {"device", required_argument, 0, 'M'},
- {"error", required_argument, 0, 'e'},
- {"help", no_argument, 0, 'h'},
- {"dryrun", required_argument, 0, 'n'},
- {"reset", no_argument, 0, 'r'},
- {"speed", required_argument, 0, 's'},
- {"type", required_argument, 0, 't'},
- {0, 0, 0, 0}
+ {"device", required_argument, 0, 'M'},
+ {"all", no_argument, 0, 'A'},
+ {"create_ostobj", optional_argument, 0, 'c'},
+ {"error", required_argument, 0, 'e'},
+ {"help", no_argument, 0, 'h'},
+ {"dryrun", optional_argument, 0, 'n'},
+ {"orphan", no_argument, 0, 'o'},
+ {"reset", no_argument, 0, 'r'},
+ {"speed", required_argument, 0, 's'},
+ {"type", required_argument, 0, 't'},
+ {"windows", required_argument, 0, 'w'},
+ {0, 0, 0, 0 }
};
static struct option long_opt_stop[] = {
{"device", required_argument, 0, 'M'},
+ {"all", no_argument, 0, 'A'},
{"help", no_argument, 0, 'h'},
{0, 0, 0, 0}
};
fprintf(stderr, "Start LFSCK.\n"
"SYNOPSIS:\n"
"lfsck_start <-M | --device [MDT,OST]_device>\n"
+ " [-A | --all] [-c | --create_ostobj [swtich]]\n"
" [-e | --error error_handle] [-h | --help]\n"
- " [-n | --dryrun switch] [-r | --reset]\n"
- " [-s | --speed speed_limit]\n"
+ " [-n | --dryrun [switch]] [-o | --orphan]\n"
+ " [-r | --reset] [-s | --speed speed_limit]\n"
" [-t | --type lfsck_type[,lfsck_type...]]\n"
+ " [-w | --windows win_size]\n"
"OPTIONS:\n"
"-M: The device to start LFSCK/scrub on.\n"
+ "-A: Start LFSCK on all MDT devices.\n"
+ "-c: create the lost OST-object for dangling LOV EA. "
+ "'off'(default) or 'on'.\n"
"-e: Error handle, 'continue'(default) or 'abort'.\n"
"-h: Help information.\n"
"-n: Check without modification. 'off'(default) or 'on'.\n"
+ "-o: handle orphan objects.\n"
"-r: Reset scanning start position to the device beginning.\n"
"-s: How many items can be scanned at most per second. "
"'%d' means no limit (default).\n"
- "-t: The LFSCK type(s) to be started.\n",
+ "-t: The LFSCK type(s) to be started.\n"
+ "-w: The windows size for async requests pipeline.\n",
LFSCK_SPEED_NO_LIMIT);
}
{
fprintf(stderr, "Stop LFSCK.\n"
"SYNOPSIS:\n"
- "lfsck_stop <-M | --device [MDT,OST]_device> [-h | --help]\n"
+ "lfsck_stop <-M | --device [MDT,OST]_device>\n"
+ "[-A | --all] [-h | --help]\n"
"OPTIONS:\n"
"-M: The device to stop LFSCK/scrub on.\n"
+ "-A: Stop LFSCK on all MDT devices.\n"
"-h: Help information.\n");
}
char rawbuf[MAX_IOC_BUFLEN], *buf = rawbuf;
char device[MAX_OBD_NAME];
struct lfsck_start start;
- char *optstring = "M:e:hn:rs:t:";
+ char *optstring = "M:Ac::e:hn::ors:t:w:";
int opt, index, rc, val, i, type;
memset(&data, 0, sizeof(data));
if (rc != 0)
return rc;
break;
+ case 'A':
+ start.ls_flags |= LPF_ALL_TGT | LPF_BROADCAST;
+ break;
+ case 'c':
+ if (optarg == NULL || strcmp(optarg, "on") == 0) {
+ start.ls_flags |= LPF_CREATE_OSTOBJ;
+ } else if (strcmp(optarg, "off") != 0) {
+ fprintf(stderr, "Invalid switch: %s. "
+ "The valid switch should be: 'on' "
+ "or 'off' (default) without blank, "
+ "or empty. For example: '-non' or "
+ "'-noff' or '-n'.\n", optarg);
+ return -EINVAL;
+ }
+ start.ls_valid |= LSV_CREATE_OSTOBJ;
+ break;
case 'e':
if (strcmp(optarg, "abort") == 0) {
start.ls_flags |= LPF_FAILOUT;
usage_start();
return 0;
case 'n':
- if (strcmp(optarg, "on") == 0) {
+ if (optarg == NULL || strcmp(optarg, "on") == 0) {
start.ls_flags |= LPF_DRYRUN;
} else if (strcmp(optarg, "off") != 0) {
- fprintf(stderr, "Invalid dryrun switch: %s. "
- "The valid value shou be: 'off'"
- "(default) or 'on'\n", optarg);
+ fprintf(stderr, "Invalid switch: %s. "
+ "The valid switch should be: 'on' "
+ "or 'off' (default) without blank, "
+ "or empty. For example: '-non' or "
+ "'-noff' or '-n'.\n", optarg);
return -EINVAL;
}
start.ls_valid |= LSV_DRYRUN;
break;
+ case 'o':
+ start.ls_flags |= LPF_ALL_TGT | LPF_BROADCAST |
+ LPF_ORPHAN;
+ break;
case 'r':
start.ls_flags |= LPF_RESET;
break;
}
break;
}
+ case 'w':
+ val = atoi(optarg);
+ if (val < 0 || val > LFSCK_ASYNC_WIN_MAX) {
+ fprintf(stderr,
+ "Too large async windows size, "
+ "which may cause memory issues. "
+ "The valid range is [0 - %u]. "
+ "If you do not want to restrict "
+ "the windows size for async reqeusts "
+ "pipeline, just set it as 0.\n",
+ LFSCK_ASYNC_WIN_MAX);
+ return -EINVAL;
+ }
+
+ start.ls_async_windows = val;
+ start.ls_valid |= LSV_ASYNC_WINDOWS;
+ break;
default:
fprintf(stderr, "Invalid option, '-h' for help.\n");
return -EINVAL;
struct obd_ioctl_data data;
char rawbuf[MAX_IOC_BUFLEN], *buf = rawbuf;
char device[MAX_OBD_NAME];
- char *optstring = "M:h";
+ struct lfsck_stop stop;
+ char *optstring = "M:Ah";
int opt, index, rc;
memset(&data, 0, sizeof(data));
+ memset(&stop, 0, sizeof(stop));
memset(device, 0, MAX_OBD_NAME);
/* Reset the 'optind' for the case of getopt_long() called multiple
if (rc != 0)
return rc;
break;
+ case 'A':
+ stop.ls_flags |= LPF_ALL_TGT | LPF_BROADCAST;
+ break;
case 'h':
usage_stop();
return 0;
}
}
+ data.ioc_inlbuf1 = (char *)&stop;
+ data.ioc_inllen1 = sizeof(stop);
memset(buf, 0, sizeof(rawbuf));
rc = obd_ioctl_pack(&data, &buf, sizeof(rawbuf));
if (rc) {