if (argc < 2 || argc > 4)
return CMD_HELP;
+ errno = 0;
id = strtoull(argv[1], &end, 0);
if (*end || id == 0 || errno != 0) {
fprintf(stderr, "error: %s: invalid objid '%s'\n",
* are skipped and recorded with new nids and uuid.
*
* \see mgs_replace_nids
- * \see mgs_replace_nids_log
- * \see mgs_replace_handler
+ * \see mgs_replace_log
+ * \see mgs_replace_nids_handler
*/
int jt_replace_nids(int argc, char **argv)
{
return rc;
}
+/**
+ * Clear config logs for given device or filesystem.
+ * lctl clear_conf <devicename|fsname>
+ * Command has to be run on MGS node having MGS device mounted with -o
+ * nosvc.
+ *
+ * Configuration logs for filesystem or one particular log is
+ * processed. New log is created, original log is read, its records
+ * marked SKIP do not get copied to new log. Others are copied as-is.
+ * Original file is renamed to log.${time}.bak.
+ *
+ * \see mgs_clear_configs
+ * \see mgs_replace_log
+ * \see mgs_clear_config_handler
+ **/
+int jt_lcfg_clear(int argc, char **argv)
+{
+ int rc;
+ char rawbuf[MAX_IOC_BUFLEN], *buf = rawbuf;
+ struct obd_ioctl_data data;
+
+ memset(&data, 0, sizeof(data));
+ data.ioc_dev = get_mgs_device();
+ if (argc != 2)
+ return CMD_HELP;
+
+ data.ioc_inllen1 = strlen(argv[1]) + 1;
+ data.ioc_inlbuf1 = argv[1];
+
+ memset(buf, 0, sizeof(rawbuf));
+ rc = llapi_ioctl_pack(&data, &buf, sizeof(rawbuf));
+ if (rc) {
+ fprintf(stderr, "error: %s: invalid ioctl\n",
+ jt_cmdname(argv[0]));
+ return rc;
+ }
+
+ rc = l2_ioctl(OBD_DEV_ID, OBD_IOC_CLEAR_CONFIGS, buf);
+ if (rc < 0) {
+ fprintf(stderr, "error: %s: %s\n", jt_cmdname(argv[0]),
+ strerror(rc = errno));
+ }
+
+ return rc;
+}
+
int jt_obd_deactivate(int argc, char **argv)
{
return do_activate(argc, argv, 0);
memset(&data, 0, sizeof(data));
data.ioc_dev = cur_device;
- data.ioc_inllen1 = sizeof(rawbuf) - cfs_size_round(sizeof(data));
+ data.ioc_inllen1 = sizeof(rawbuf) - __ALIGN_KERNEL(sizeof(data), 8);
memset(buf, 0, sizeof(rawbuf));
rc = llapi_ioctl_pack(&data, &buf, sizeof(rawbuf));
if (rc) {
data.ioc_dev = cur_device;
data.ioc_inllen1 = strlen(argv[1]) + 1;
data.ioc_inlbuf1 = argv[1];
- data.ioc_inllen2 = sizeof(rawbuf) - cfs_size_round(sizeof(data)) -
- cfs_size_round(data.ioc_inllen1);
+ data.ioc_inllen2 = sizeof(rawbuf) - __ALIGN_KERNEL(sizeof(data), 8) -
+ __ALIGN_KERNEL(data.ioc_inllen1, 8);
memset(buf, 0, sizeof(rawbuf));
rc = llapi_ioctl_pack(&data, &buf, sizeof(rawbuf));
if (rc) {
data.ioc_inllen3 = strlen(to) + 1;
data.ioc_inlbuf3 = to;
}
- data.ioc_inllen4 = sizeof(rawbuf) - cfs_size_round(sizeof(data)) -
- cfs_size_round(data.ioc_inllen1) -
- cfs_size_round(data.ioc_inllen2) -
- cfs_size_round(data.ioc_inllen3);
+ data.ioc_inllen4 = sizeof(rawbuf) - __ALIGN_KERNEL(sizeof(data), 8) -
+ __ALIGN_KERNEL(data.ioc_inllen1, 8) -
+ __ALIGN_KERNEL(data.ioc_inllen2, 8) -
+ __ALIGN_KERNEL(data.ioc_inllen3, 8);
memset(buf, 0, sizeof(rawbuf));
rc = llapi_ioctl_pack(&data, &buf, sizeof(rawbuf));
if (rc) {
data.ioc_inllen3 = strlen(to) + 1;
data.ioc_inlbuf3 = to;
}
- data.ioc_inllen4 = sizeof(rawbuf) - cfs_size_round(sizeof(data)) -
- cfs_size_round(data.ioc_inllen1) -
- cfs_size_round(data.ioc_inllen2) -
- cfs_size_round(data.ioc_inllen3);
+ data.ioc_inllen4 = sizeof(rawbuf) - __ALIGN_KERNEL(sizeof(data), 8) -
+ __ALIGN_KERNEL(data.ioc_inllen1, 8) -
+ __ALIGN_KERNEL(data.ioc_inllen2, 8) -
+ __ALIGN_KERNEL(data.ioc_inllen3, 8);
memset(buf, 0, sizeof(rawbuf));
rc = llapi_ioctl_pack(&data, &buf, sizeof(rawbuf));
if (rc) {
return -1;
}
- if (!cfs_nidrange_is_contiguous(&nidlist)) {
- fprintf(stderr, "error: %s: nodemap ranges must be "
- "contiguous\n", jt_cmdname(argv[0]));
- return -1;
+ rc = cfs_nidrange_find_min_max(&nidlist, &min_nid[0], &max_nid[0],
+ LNET_NIDSTR_SIZE);
+ if (rc < 0) {
+ errno = -rc;
+ if (rc == -EINVAL)
+ fprintf(stderr, "error: %s: nid range uses "
+ "currently unsupported features\n",
+ jt_cmdname(argv[0]));
+ else if (rc == -ERANGE)
+ fprintf(stderr, "error: %s: nodemap ranges must be "
+ "contiguous\n", jt_cmdname(argv[0]));
+
+ return rc;
}
- cfs_nidrange_find_min_max(&nidlist, &min_nid[0], &max_nid[0],
- LNET_NIDSTR_SIZE);
snprintf(nid_range, sizeof(nid_range), "%s:%s", min_nid, max_nid);
rc = nodemap_cmd(LCFG_NODEMAP_ADD_RANGE, NULL, 0, argv[0],
return -1;
}
- if (!cfs_nidrange_is_contiguous(&nidlist)) {
- fprintf(stderr, "error: %s: nodemap ranges must be "
- "contiguous\n", jt_cmdname(argv[0]));
- return -1;
+ rc = cfs_nidrange_find_min_max(&nidlist, &min_nid[0], &max_nid[0],
+ LNET_NIDSTR_SIZE);
+ if (rc < 0) {
+ errno = -rc;
+ if (rc == -EINVAL)
+ fprintf(stderr, "error: %s: nid range uses "
+ "currently unsupported features\n",
+ jt_cmdname(argv[0]));
+ else if (rc == -ERANGE)
+ fprintf(stderr, "error: %s: nodemap ranges must be "
+ "contiguous\n", jt_cmdname(argv[0]));
+
+ return rc;
}
- cfs_nidrange_find_min_max(&nidlist, &min_nid[0], &max_nid[0],
- LNET_NIDSTR_SIZE);
snprintf(nid_range, sizeof(nid_range), "%s:%s", min_nid, max_nid);
rc = nodemap_cmd(LCFG_NODEMAP_DEL_RANGE, NULL, 0, argv[0],
char *ptr;
int rc;
- strlcpy(fsname, arg, PATH_MAX + 1);
+ snprintf(fsname, PATH_MAX + 1, "%s", arg);
ptr = strchr(fsname, '.');
if (ptr == NULL) {
fprintf(stderr, ". is missing in %s\n", fsname);
strncpy(poolname, ptr, LOV_MAXPOOLNAME);
poolname[LOV_MAXPOOLNAME] = '\0';
+
+ if (strncmp(poolname, "none", LOV_MAXPOOLNAME) == 0) {
+ fprintf(stderr, "poolname cannot be 'none'\n");
+ return -EINVAL;
+ }
return 0;
err: