int cfg_len = rec->lrh_len;
char *cfg_buf = (char*) (rec + 1);
struct lustre_cfg *lcfg;
- __u32 index;
+ u32 index;
int rc = 0;
ENTRY;
CDEBUG(D_INFO, "cmd %x %s %s\n", lcfg->lcfg_command,
lustre_cfg_string(lcfg, 0), lustre_cfg_string(lcfg, 1));
- /* Figure out ost indicies */
- /* lov_modify_tgts add 0:lov1 1:ost1_UUID 2(index):0 3(gen):1 */
- if (lcfg->lcfg_command == LCFG_LOV_ADD_OBD ||
- lcfg->lcfg_command == LCFG_LOV_DEL_OBD) {
- index = simple_strtoul(lustre_cfg_string(lcfg, 2),
- NULL, 10);
+ /* Figure out ost indicies */
+ /* lov_modify_tgts add 0:lov1 1:ost1_UUID 2(index):0 3(gen):1 */
+ if (lcfg->lcfg_command == LCFG_LOV_ADD_OBD ||
+ lcfg->lcfg_command == LCFG_LOV_DEL_OBD) {
+ rc = kstrtouint(lustre_cfg_string(lcfg, 2), 10, &index);
+ if (rc)
+ RETURN(rc);
+
CDEBUG(D_MGS, "OST index for %s is %u (%s)\n",
lustre_cfg_string(lcfg, 1), index,
lustre_cfg_string(lcfg, 2));
return (num_devices <= 3) && (num_exports == 0);
}
-static int name_create_mdt(char **logname, char *fsname, int i)
+static int name_create_mdt(char **logname, char *fsname, int mdt_idx)
{
- char mdt_index[9];
+ char postfix[9];
+
+ if (mdt_idx > INDEX_MAP_MAX_VALUE)
+ return -E2BIG;
- sprintf(mdt_index, "-MDT%04x", i);
- return name_create(logname, fsname, mdt_index);
+ snprintf(postfix, sizeof(postfix), "-MDT%04x", mdt_idx);
+ return name_create(logname, fsname, postfix);
}
/**
}
/* Process client llogs */
- name_create(&logname, fsname, "-client");
+ rc = name_create(&logname, fsname, "-client");
+ if (rc)
+ GOTO(out, rc);
rc = mgs_replace_nids_log(env, mgs_obd, logname, devname, nids);
name_destroy(&logname);
if (rc) {
for (i = 0; i < INDEX_MAP_SIZE * 8; i++) {
if (!test_bit(i, fsdb->fsdb_mdt_index_map))
continue;
- name_create_mdt(&logname, fsname, i);
+ rc = name_create_mdt(&logname, fsname, i);
+ if (rc)
+ GOTO(out, rc);
rc = mgs_replace_nids_log(env, mgs_obd, logname, devname, nids);
name_destroy(&logname);
if (rc)
{
char *log = mti->mti_svname;
struct llog_handle *llh = NULL;
- char *uuid, *lovname;
+ struct obd_uuid *uuid;
+ char *lovname;
char mdt_index[6];
char *ptr = mti->mti_params;
int rc = 0, failout = 0;
ENTRY;
- OBD_ALLOC(uuid, sizeof(struct obd_uuid));
+ OBD_ALLOC_PTR(uuid);
if (uuid == NULL)
RETURN(-ENOMEM);
/* add MDT itself */
/* FIXME this whole fn should be a single journal transaction */
- sprintf(uuid, "%s_UUID", log);
+ sprintf(uuid->uuid, "%s_UUID", log);
rc = record_marker(env, llh, fsdb, CM_START, log, "add mdt");
if (rc)
GOTO(out_lod, rc);
- rc = record_attach(env, llh, log, LUSTRE_MDT_NAME, uuid);
+ rc = record_attach(env, llh, log, LUSTRE_MDT_NAME, uuid->uuid);
if (rc)
GOTO(out_end, rc);
rc = record_mount_opt(env, llh, log, lovname, NULL);
if (rc)
GOTO(out_end, rc);
- rc = record_setup(env, llh, log, uuid, mdt_index, lovname,
+ rc = record_setup(env, llh, log, uuid->uuid, mdt_index, lovname,
failout ? "n" : "f");
if (rc)
GOTO(out_end, rc);
out_lod:
name_destroy(&lovname);
out_free:
- OBD_FREE(uuid, sizeof(struct obd_uuid));
+ OBD_FREE_PTR(uuid);
RETURN(rc);
}
int rc, del;
/* Erase any old settings of this same parameter */
- memcpy(comment, ptr, MTI_NAME_MAXLEN);
- comment[MTI_NAME_MAXLEN - 1] = 0;
+ strlcpy(comment, ptr, sizeof(comment));
/* But don't try to match the value. */
tmp = strchr(comment, '=');
if (tmp != NULL)
return -ENOMEM;
lcfg = &lcr->lcr_cfg;
- lcfg->lcfg_num = convert ? simple_strtoul(tmp, NULL, 0) : 0;
+ if (convert) {
+ rc = kstrtouint(tmp, 0, &lcfg->lcfg_num);
+ if (rc)
+ GOTO(out_rec_free, rc);
+ } else {
+ lcfg->lcfg_num = 0;
+ }
+
/* truncate the comment to the parameter name */
ptr = tmp - 1;
sep = *ptr;
}
}
*ptr = sep;
+out_rec_free:
lustre_cfg_rec_free(lcr);
return rc;
}
if (class_match_param(ptr, PARAM_NETWORK, NULL) == 0)
GOTO(end, rc);
- /* Processed in mgs_write_log_ost */
- if (class_match_param(ptr, PARAM_FAILMODE, NULL) == 0) {
- if (mti->mti_flags & LDD_F_PARAM) {
- LCONSOLE_ERROR_MSG(0x169, "%s can only be "
- "changed with tunefs.lustre"
- "and --writeconf\n", ptr);
- rc = -EPERM;
- }
- GOTO(end, rc);
- }
+ /* Processed in mgs_write_log_ost */
+ if (class_match_param(ptr, PARAM_FAILMODE, NULL) == 0) {
+ if (mti->mti_flags & LDD_F_PARAM) {
+ LCONSOLE_ERROR_MSG(0x169,
+ "%s can only be changed with tunefs.lustre and --writeconf\n",
+ ptr);
+ rc = -EPERM;
+ }
+ GOTO(end, rc);
+ }
if (class_match_param(ptr, PARAM_SRPC, NULL) == 0) {
rc = mgs_srpc_set_param(env, mgs, fsdb, mti, ptr);
}
active_err:
if (rc < 0) {
- LCONSOLE_ERROR_MSG(0x145, "Couldn't find %s in"
- "log (%d). No permanent "
- "changes were made to the "
- "config log.\n",
+ LCONSOLE_ERROR_MSG(0x145,
+ "Couldn't find %s in log (%d). No permanent changes were made to the config log.\n",
mti->mti_svname, rc);
if (test_bit(FSDB_OLDLOG14, &fsdb->fsdb_flags))
- LCONSOLE_ERROR_MSG(0x146, "This may be"
- " because the log"
- "is in the old 1.4"
- "style. Consider "
- " --writeconf to "
- "update the logs.\n");
+ LCONSOLE_ERROR_MSG(0x146,
+ "This may be because the log is in the old 1.4 style. Consider --writeconf to update the logs.\n");
GOTO(end, rc);
}
/* Fall through to osc/mdc proc for deactivating live
list_del_init(&dirent->mde_list);
suffix = strrchr(dirent->mde_name, '-');
if (suffix != NULL) {
- l = snprintf(out, remains, "config_log: %s\n",
- dirent->mde_name);
+ l = scnprintf(out, remains, "config_log: %s\n",
+ dirent->mde_name);
out += l;
remains -= l;
}
} /* else case fall through */
} /* else case fall through */
}
+ /* fallthrough */
default: {
for (i = 1; i < cnt; i++) {
o_buflen = o_lcfg->lcfg_buflens[i];
enum lcfg_command_type cmd, const char *nodemap_name,
char *param)
{
- lnet_nid_t nid[2];
- __u32 idmap[2];
- bool bool_switch;
- __u32 int_id;
- int rc = 0;
- ENTRY;
+ lnet_nid_t nid[2];
+ u32 idmap[2];
+ bool bool_switch;
+ u32 int_id;
+ int rc = 0;
+ ENTRY;
switch (cmd) {
case LCFG_NODEMAP_ADD:
rc = nodemap_add(nodemap_name);
rc = nodemap_del_range(nodemap_name, nid);
break;
case LCFG_NODEMAP_ADMIN:
- bool_switch = simple_strtoul(param, NULL, 10);
+ rc = kstrtobool(param, &bool_switch);
+ if (rc)
+ break;
rc = nodemap_set_allow_root(nodemap_name, bool_switch);
break;
case LCFG_NODEMAP_DENY_UNKNOWN:
- bool_switch = simple_strtoul(param, NULL, 10);
+ rc = kstrtobool(param, &bool_switch);
+ if (rc)
+ break;
rc = nodemap_set_deny_unknown(nodemap_name, bool_switch);
break;
case LCFG_NODEMAP_AUDIT_MODE:
rc = -EINVAL;
break;
case LCFG_NODEMAP_TRUSTED:
- bool_switch = simple_strtoul(param, NULL, 10);
+ rc = kstrtobool(param, &bool_switch);
+ if (rc)
+ break;
rc = nodemap_set_trust_client_ids(nodemap_name, bool_switch);
break;
case LCFG_NODEMAP_SQUASH_UID:
- int_id = simple_strtoul(param, NULL, 10);
+ rc = kstrtouint(param, 10, &int_id);
+ if (rc)
+ break;
rc = nodemap_set_squash_uid(nodemap_name, int_id);
break;
case LCFG_NODEMAP_SQUASH_GID:
- int_id = simple_strtoul(param, NULL, 10);
+ rc = kstrtouint(param, 10, &int_id);
+ if (rc)
+ break;
rc = nodemap_set_squash_gid(nodemap_name, int_id);
break;
case LCFG_NODEMAP_ADD_UIDMAP:
case LCFG_NODEMAP_SET_FILESET:
rc = nodemap_set_fileset(nodemap_name, param);
break;
+ case LCFG_NODEMAP_SET_SEPOL:
+ rc = nodemap_set_sepol(nodemap_name, param);
+ break;
default:
rc = -EINVAL;
}