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];
- sprintf(mdt_index, "-MDT%04x", i);
- return name_create(logname, fsname, mdt_index);
+ if (mdt_idx > INDEX_MAP_MAX_VALUE)
+ return -E2BIG;
+
+ 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)
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;
}