* GPL HEADER END
*/
/*
- * Copyright (c) 2012, 2015, Intel Corporation.
+ * Copyright (c) 2012, 2016, Intel Corporation.
*/
/*
* lustre/utils/lustre_lfsck.c
#include <time.h>
#include "obdctl.h"
+#include "lustreapi_internal.h"
#include <lustre/lustre_lfsck_user.h>
#include <lnet/lnetctl.h>
-#include <lustre_ioctl.h>
+#include <linux/lustre_ioctl.h>
/* Needs to be last to avoid clashes */
#include <libcfs/util/ioctl.h>
#include <libcfs/util/param.h>
{"create-ostobj", optional_argument, 0, 'c'},
{"create_mdtobj", optional_argument, 0, 'C'},
{"create-mdtobj", optional_argument, 0, 'C'},
+ {"delay_create_ostobj", optional_argument, 0, 'd'},
+ {"delay-create-ostobj", optional_argument, 0, 'd'},
{"error", required_argument, 0, 'e'},
{"help", no_argument, 0, 'h'},
{"dryrun", optional_argument, 0, 'n'},
};
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 }
-};
+ { .val = 'A', .name = "all", .has_arg = no_argument },
+ { .val = 'h', .name = "help", .has_arg = no_argument },
+ { .val = 'M', .name = "device", .has_arg = required_argument },
+ { .name = NULL } };
static struct option long_opt_query[] = {
- {"device", required_argument, 0, 'M'},
- {"type", required_argument, 0, 't'},
- {"help", no_argument, 0, 'h'},
- {"wait", no_argument, 0, 'w'},
- {0, 0, 0, 0 }
-};
+ { .val = 'h', .name = "help", .has_arg = no_argument },
+ { .val = 'M', .name = "device", .has_arg = required_argument },
+ { .val = 't', .name = "type", .has_arg = required_argument },
+ { .val = 'w', .name = "wait", .has_arg = no_argument },
+ { .name = NULL } };
struct lfsck_type_name {
char *ltn_name;
};
static struct lfsck_type_name lfsck_types_names[] = {
- { "scrub", LFSCK_TYPE_SCRUB },
- { "layout", LFSCK_TYPE_LAYOUT },
- { "namespace", LFSCK_TYPE_NAMESPACE },
- { "default", LFSCK_TYPES_DEF },
- { "all", LFSCK_TYPES_SUPPORTED },
- { NULL, 0 }
-};
+ { .ltn_name = "all", .ltn_type = LFSCK_TYPES_SUPPORTED },
+ { .ltn_name = "default", .ltn_type = LFSCK_TYPES_DEF },
+ { .ltn_name = "layout", .ltn_type = LFSCK_TYPE_LAYOUT },
+ { .ltn_name = "namespace", .ltn_type = LFSCK_TYPE_NAMESPACE },
+ { .ltn_name = "scrub", .ltn_type = LFSCK_TYPE_SCRUB },
+ { .ltn_name = NULL } };
static enum lfsck_type lfsck_name2type(const char *name)
{
"lfsck_start [-M | --device {MDT,OST}_device]\n"
" [-A | --all] [-c | --create_ostobj [on | off]]\n"
" [-C | --create_mdtobj [on | off]]\n"
+ " [-d | --delay_create_ostobj [on | off]]\n"
" [-e | --error {continue | abort}] [-h | --help]\n"
" [-n | --dryrun [on | off]] [-o | --orphan]\n"
" [-r | --reset] [-s | --speed ops_per_sec_limit]\n"
"(default 'off', or 'on')\n"
"-C: create the lost MDT-object for dangling name entry "
"(default 'off', or 'on')\n"
+ "-d: delay create the lost OST-object for dangling LOV EA "
+ "until orphan OST-objects handled (default 'off', or 'on')\n"
"-e: error handle mode (default 'continue', or 'abort')\n"
"-h: this help message\n"
"-n: check with no modification (default 'off', or 'on')\n"
}
ptr = strrchr(param.gl_pathv[0], '-');
- LASSERT(ptr != NULL);
+ if (ptr == NULL) {
+ rc = -EINVAL;
+ goto out;
+ }
for (i = 1; i < param.gl_pathc; i++) {
char *ptr2 = strrchr(param.gl_pathv[i], '-');
- LASSERT(ptr2 != NULL);
+ if (ptr2 == NULL) {
+ rc = -EINVAL;
+ goto out;
+ }
if ((ptr - param.gl_pathv[0]) != (ptr2 - param.gl_pathv[i]) ||
strncmp(param.gl_pathv[0], param.gl_pathv[i],
char rawbuf[MAX_IOC_BUFLEN], *buf = rawbuf;
char device[MAX_OBD_NAME];
struct lfsck_start start;
- char *optstring = "Ac::C::e:hM:n::ors:t:w:";
+ char *optstring = "Ac::C::d::e:hM:n::ors:t:w:";
int opt, index, rc, val, i;
memset(&data, 0, sizeof(data));
}
start.ls_valid |= LSV_CREATE_MDTOBJ;
break;
+ case 'd':
+ if (optarg == NULL || strcmp(optarg, "on") == 0) {
+ start.ls_flags |= LPF_DELAY_CREATE_OSTOBJ;
+ } else if (strcmp(optarg, "off") != 0) {
+ fprintf(stderr, "invalid switch: -c '%s'. "
+ "valid switches are:\n"
+ "empty ('on'), or 'off' without space. "
+ "For example:\n"
+ "'-c', '-con', '-coff'\n", optarg);
+ return -EINVAL;
+ }
+ start.ls_valid |= LSV_DELAY_CREATE_OSTOBJ;
+ break;
case 'e':
if (strcmp(optarg, "abort") == 0) {
start.ls_flags |= LPF_FAILOUT;