ctxt = llog_get_context(mgs->mgs_obd, LLOG_CONFIG_ORIG_CTXT);
LASSERT(ctxt != NULL);
- name_create(&logname, fsdb->fsdb_name, "-client");
+ rc = name_create(&logname, fsdb->fsdb_name, "-client");
+ if (rc)
+ GOTO(out_put, rc);
cfs_mutex_lock(&fsdb->fsdb_mutex);
push_ctxt(&saved, &mgs->mgs_obd->obd_lvfs_ctxt, NULL);
rc = llog_open_create(NULL, ctxt, &loghandle, NULL, logname);
pop_ctxt(&saved, &mgs->mgs_obd->obd_lvfs_ctxt, NULL);
cfs_mutex_unlock(&fsdb->fsdb_mutex);
name_destroy(&logname);
+out_put:
llog_ctxt_put(ctxt);
RETURN(rc);
OBD_ALLOC(fsdb->fsdb_mdt_index_map, INDEX_MAP_SIZE);
if (!fsdb->fsdb_ost_index_map || !fsdb->fsdb_mdt_index_map) {
CERROR("No memory for index maps\n");
- GOTO(err, 0);
+ GOTO(err, rc = -ENOMEM);
}
rc = name_create(&fsdb->fsdb_mdtlov, fsname, "-mdtlov");
rc = llog_process_or_fork(env, loghandle, mgs_modify_handler,
(void *)mml, NULL, false);
if (!rc && !mml->mml_modified)
- rc = -ENODEV;
+ rc = 1;
OBD_FREE_PTR(mml);
out_close:
rc = rc2;
out_pop:
pop_ctxt(&saved, &mgs->mgs_obd->obd_lvfs_ctxt, NULL);
- if (rc && rc != -ENODEV)
+ if (rc < 0)
CERROR("modify %s/%s failed %d\n",
mti->mti_svname, comment, rc);
llog_ctxt_put(ctxt);
/* FIXME These should be a single journal transaction */
rc = record_marker(env, llh, fsdb, CM_START, devname, comment);
-
+ if (rc)
+ GOTO(out_end, rc);
rc = record_lcfg(env, llh, lcfg);
-
+ if (rc)
+ GOTO(out_end, rc);
rc = record_marker(env, llh, fsdb, CM_END, devname, comment);
- rc = record_end_log(env, &llh);
-
+ if (rc)
+ GOTO(out_end, rc);
+out_end:
+ record_end_log(env, &llh);
RETURN(rc);
}
as well. FIXME Append this file to every new log.
Actually, we should store as params (text), not llogs. Or
in a database. */
- name_create(&logname, fsname, "-params");
+ rc = name_create(&logname, fsname, "-params");
+ if (rc)
+ RETURN(rc);
if (mgs_log_is_empty(env, mgs, logname)) {
struct llog_handle *llh = NULL;
rc = record_start_log(env, mgs, &llh, logname);
struct mgs_target_info *mti,
char *logname, char *suffix, char *lovname,
enum lustre_sec_part sec_part, int flags);
-static void name_create_mdt_and_lov(char **logname, char **lovname,
- struct fs_db *fsdb, int i);
+static int name_create_mdt_and_lov(char **logname, char **lovname,
+ struct fs_db *fsdb, int i);
static int mgs_steal_llog_handler(const struct lu_env *env,
struct llog_handle *llh,
sizeof(tmti->mti_svname));
rc = record_start_log(env, mgs, &mdt_llh,
mti->mti_svname);
+ if (rc)
+ RETURN(rc);
rc = record_marker(env, mdt_llh, fsdb, CM_START,
mti->mti_svname,"add osc(copied)");
- rc = record_end_log(env, &mdt_llh);
+ record_end_log(env, &mdt_llh);
last_step = marker->cm_step;
RETURN(rc);
}
got_an_osc_or_mdc = 0;
rc = record_start_log(env, mgs, &mdt_llh,
mti->mti_svname);
+ if (rc)
+ RETURN(rc);
rc = record_marker(env, mdt_llh, fsdb, CM_END,
mti->mti_svname,"add osc(copied)");
- rc = record_end_log(env, &mdt_llh);
+ record_end_log(env, &mdt_llh);
RETURN(rc);
}
if (!strncmp(marker->cm_comment,"add mdc",7) &&
strlen(mti->mti_fsname));
tmti->mti_stripe_index = index;
- mgs_write_log_mdc_to_mdt(env, mgs, fsdb,
- tmti, mti->mti_svname);
+ rc = mgs_write_log_mdc_to_mdt(env, mgs, fsdb, tmti,
+ mti->mti_svname);
memset(tmti, 0, sizeof(*tmti));
RETURN(rc);
}
char mdt_index[9];
char *logname, *lovname;
- name_create_mdt_and_lov(&logname, &lovname, fsdb,
- mti->mti_stripe_index);
+ rc = name_create_mdt_and_lov(&logname, &lovname, fsdb,
+ mti->mti_stripe_index);
+ if (rc)
+ RETURN(rc);
sprintf(mdt_index, "-MDT%04x", mti->mti_stripe_index);
if (sscanf(lustre_cfg_buf(lcfg, 2), "%d", &index) != 1) {
}
tmti->mti_stripe_index = index;
- mgs_write_log_osc_to_lov(env, mgs, fsdb, tmti, logname,
+ rc = mgs_write_log_osc_to_lov(env, mgs, fsdb, tmti, logname,
mdt_index, lovname,
LUSTRE_SP_MDT, 0);
name_destroy(&logname);
uuid = (char *)lmvdesc->ld_uuid.uuid;
rc = record_start_log(env, mgs, &llh, logname);
+ if (rc)
+ GOTO(out_free, rc);
rc = record_marker(env, llh, fsdb, CM_START, lmvname, "lmv setup");
+ if (rc)
+ GOTO(out_end, rc);
rc = record_attach(env, llh, lmvname, "lmv", uuid);
+ if (rc)
+ GOTO(out_end, rc);
rc = record_lmv_setup(env, llh, lmvname, lmvdesc);
+ if (rc)
+ GOTO(out_end, rc);
rc = record_marker(env, llh, fsdb, CM_END, lmvname, "lmv setup");
- rc = record_end_log(env, &llh);
-
+ if (rc)
+ GOTO(out_end, rc);
+out_end:
+ record_end_log(env, &llh);
+out_free:
OBD_FREE_PTR(lmvdesc);
RETURN(rc);
}
rc = mgs_clear_log(obd, logname); */
rc = record_start_log(env, mgs, &llh, logname);
if (rc)
- GOTO(out, rc);
+ GOTO(out_free, rc);
/* FIXME these should be a single journal transaction */
rc = record_marker(env, llh, fsdb, CM_START, lovname, "lov setup");
+ if (rc)
+ GOTO(out_end, rc);
rc = record_attach(env, llh, lovname, "lov", uuid);
+ if (rc)
+ GOTO(out_end, rc);
rc = record_lov_setup(env, llh, lovname, lovdesc);
+ if (rc)
+ GOTO(out_end, rc);
rc = record_marker(env, llh, fsdb, CM_END, lovname, "lov setup");
- rc = record_end_log(env, &llh);
-
+ if (rc)
+ GOTO(out_end, rc);
EXIT;
-out:
+out_end:
+ record_end_log(env, &llh);
+out_free:
OBD_FREE_PTR(lovdesc);
return rc;
}
failnodeuuid, cliname);
rc = record_add_uuid(env, llh, nid, failnodeuuid);
}
- if (failnodeuuid) {
+ if (failnodeuuid)
rc = record_add_conn(env, llh, cliname, failnodeuuid);
- name_destroy(&failnodeuuid);
- failnodeuuid = NULL;
- }
}
+ name_destroy(&failnodeuuid);
return rc;
}
char *logname, char *lmvname)
{
struct llog_handle *llh = NULL;
- char *mdcname, *nodeuuid, *mdcuuid, *lmvuuid;
+ char *mdcname = NULL;
+ char *nodeuuid = NULL;
+ char *mdcuuid = NULL;
+ char *lmvuuid = NULL;
char index[6];
int i, rc;
ENTRY;
CDEBUG(D_MGS, "adding mdc for %s to log %s:lmv(%s)\n",
mti->mti_svname, logname, lmvname);
- name_create(&nodeuuid, libcfs_nid2str(mti->mti_nids[0]), "");
- name_create(&mdcname, mti->mti_svname, "-mdc");
- name_create(&mdcuuid, mdcname, "_UUID");
- name_create(&lmvuuid, lmvname, "_UUID");
+ rc = name_create(&nodeuuid, libcfs_nid2str(mti->mti_nids[0]), "");
+ if (rc)
+ RETURN(rc);
+ rc = name_create(&mdcname, mti->mti_svname, "-mdc");
+ if (rc)
+ GOTO(out_free, rc);
+ rc = name_create(&mdcuuid, mdcname, "_UUID");
+ if (rc)
+ GOTO(out_free, rc);
+ rc = name_create(&lmvuuid, lmvname, "_UUID");
+ if (rc)
+ GOTO(out_free, rc);
rc = record_start_log(env, mgs, &llh, logname);
+ if (rc)
+ GOTO(out_free, rc);
rc = record_marker(env, llh, fsdb, CM_START, mti->mti_svname,
"add mdc");
-
+ if (rc)
+ GOTO(out_end, rc);
for (i = 0; i < mti->mti_nid_count; i++) {
CDEBUG(D_MGS, "add nid %s for mdt\n",
libcfs_nid2str(mti->mti_nids[i]));
rc = record_add_uuid(env, llh, mti->mti_nids[i], nodeuuid);
+ if (rc)
+ GOTO(out_end, rc);
}
rc = record_attach(env, llh, mdcname, LUSTRE_MDC_NAME, lmvuuid);
+ if (rc)
+ GOTO(out_end, rc);
rc = record_setup(env, llh, mdcname, mti->mti_uuid, nodeuuid, 0, 0);
+ if (rc)
+ GOTO(out_end, rc);
rc = mgs_write_log_failnids(env, mti, llh, mdcname);
+ if (rc)
+ GOTO(out_end, rc);
snprintf(index, sizeof(index), "%d", mti->mti_stripe_index);
rc = record_mdc_add(env, llh, lmvname, mdcuuid, mti->mti_uuid,
index, "1");
+ if (rc)
+ GOTO(out_end, rc);
rc = record_marker(env, llh, fsdb, CM_END, mti->mti_svname,
"add mdc");
- rc = record_end_log(env, &llh);
-
+ if (rc)
+ GOTO(out_end, rc);
+out_end:
+ record_end_log(env, &llh);
+out_free:
name_destroy(&lmvuuid);
name_destroy(&mdcuuid);
name_destroy(&mdcname);
char *logname)
{
struct llog_handle *llh = NULL;
- char *nodeuuid, *mdcname, *mdcuuid, *mdtuuid;
+ char *nodeuuid = NULL;
+ char *mdcname = NULL;
+ char *mdcuuid = NULL;
+ char *mdtuuid = NULL;
int idx = mti->mti_stripe_index;
char index[9];
int i, rc;
CDEBUG(D_MGS, "adding mdc index %d to %s\n", idx, logname);
- name_create(&nodeuuid, libcfs_nid2str(mti->mti_nids[0]), "");
- snprintf(index, sizeof(index), "-mdc%04x", idx);
- name_create(&mdcname, logname, index);
- name_create(&mdcuuid, mdcname, "_UUID");
- name_create(&mdtuuid, logname, "_UUID");
+ rc = name_create(&nodeuuid, libcfs_nid2str(mti->mti_nids[0]), "");
+ if (rc)
+ RETURN(rc);
+ snprintf(index, sizeof(index), "-mdc%04x", idx);
+ rc = name_create(&mdcname, logname, index);
+ if (rc)
+ GOTO(out_free, rc);
+ rc = name_create(&mdcuuid, mdcname, "_UUID");
+ if (rc)
+ GOTO(out_free, rc);
+ rc = name_create(&mdtuuid, logname, "_UUID");
+ if (rc)
+ GOTO(out_free, rc);
rc = record_start_log(env, mgs, &llh, logname);
+ if (rc)
+ GOTO(out_free, rc);
rc = record_marker(env, llh, fsdb, CM_START, mti->mti_svname, "add mdc");
+ if (rc)
+ GOTO(out_end, rc);
for (i = 0; i < mti->mti_nid_count; i++) {
CDEBUG(D_MGS, "add nid %s for mdt\n",
libcfs_nid2str(mti->mti_nids[i]));
rc = record_add_uuid(env, llh, mti->mti_nids[i], nodeuuid);
+ if (rc)
+ GOTO(out_end, rc);
}
rc = record_attach(env, llh, mdcname, LUSTRE_MDC_NAME, mdcuuid);
+ if (rc)
+ GOTO(out_end, rc);
rc = record_setup(env, llh, mdcname, mti->mti_uuid, nodeuuid, 0, 0);
+ if (rc)
+ GOTO(out_end, rc);
rc = mgs_write_log_failnids(env, mti, llh, mdcname);
+ if (rc)
+ GOTO(out_end, rc);
snprintf(index, sizeof(index), "%d", idx);
rc = record_mdc_add(env, llh, logname, mdcuuid, mti->mti_uuid,
index, "1");
+ if (rc)
+ GOTO(out_end, rc);
rc = record_marker(env, llh, fsdb, CM_END, mti->mti_svname, "add mdc");
- rc = record_end_log(env, &llh);
-
+ if (rc)
+ GOTO(out_end, rc);
+out_end:
+ record_end_log(env, &llh);
+out_free:
+ name_destroy(&mdtuuid);
name_destroy(&mdcuuid);
name_destroy(&mdcname);
name_destroy(&nodeuuid);
- name_destroy(&mdtuuid);
RETURN(rc);
}
if (class_find_param(ptr, PARAM_FAILMODE, &ptr) == 0)
failout = (strncmp(ptr, "failout", 7) == 0);
- name_create(&lovname, log, "-mdtlov");
- if (mgs_log_is_empty(env, mgs, log))
+ rc = name_create(&lovname, log, "-mdtlov");
+ if (rc)
+ GOTO(out_free, rc);
+ if (mgs_log_is_empty(env, mgs, log)) {
rc = mgs_write_log_lov(env, mgs, fsdb, mti, log, lovname);
+ if (rc)
+ GOTO(out_lod, rc);
+ }
- sprintf(uuid, "%s_UUID", log);
sprintf(mdt_index, "%d", mti->mti_stripe_index);
- /* add MDT itself */
rc = record_start_log(env, mgs, &llh, log);
- if (rc)
- GOTO(out, rc);
+ if (rc)
+ GOTO(out_lod, rc);
+
+ /* add MDT itself */
/* FIXME this whole fn should be a single journal transaction */
+ sprintf(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);
+ 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,
failout ? "n" : "f");
+ if (rc)
+ GOTO(out_end, rc);
rc = record_marker(env, llh, fsdb, CM_END, log, "add mdt");
- rc = record_end_log(env, &llh);
-out:
- name_destroy(&lovname);
+ if (rc)
+ GOTO(out_end, rc);
+out_end:
+ record_end_log(env, &llh);
+out_lod:
+ name_destroy(&lovname);
+out_free:
OBD_FREE(uuid, sizeof(struct obd_uuid));
RETURN(rc);
}
-static inline void name_create_mdt(char **logname, char *fsname, int i)
+static inline int name_create_mdt(char **logname, char *fsname, int i)
{
char mdt_index[9];
sprintf(mdt_index, "-MDT%04x", i);
- name_create(logname, fsname, mdt_index);
+ return name_create(logname, fsname, mdt_index);
}
-static void name_create_mdt_and_lov(char **logname, char **lovname,
+static int name_create_mdt_and_lov(char **logname, char **lovname,
struct fs_db *fsdb, int i)
{
- name_create_mdt(logname, fsdb->fsdb_name, i);
+ int rc;
+
+ rc = name_create_mdt(logname, fsdb->fsdb_name, i);
+ if (rc)
+ return rc;
/* COMPAT_180 */
if (i == 0 && cfs_test_bit(FSDB_OSCNAME18, &fsdb->fsdb_flags))
- name_create(lovname, fsdb->fsdb_name, "-mdtlov");
+ rc = name_create(lovname, fsdb->fsdb_name, "-mdtlov");
else
- name_create(lovname, *logname, "-mdtlov");
+ rc = name_create(lovname, *logname, "-mdtlov");
+ if (rc) {
+ name_destroy(logname);
+ *logname = NULL;
+ }
+ return rc;
}
-static inline void name_create_mdt_osc(char **oscname, char *ostname,
+static inline int name_create_mdt_osc(char **oscname, char *ostname,
struct fs_db *fsdb, int i)
{
char suffix[16];
sprintf(suffix, "-osc");
else
sprintf(suffix, "-osc-MDT%04x", i);
- name_create(oscname, ostname, suffix);
+ return name_create(oscname, ostname, suffix);
}
/* envelope method for all layers log */
/* add mdt */
rc = mgs_write_log_mdt0(env, mgs, fsdb, mti);
-
+ if (rc)
+ RETURN(rc);
/* Append the mdt info to the client log */
- name_create(&cliname, mti->mti_fsname, "-client");
+ rc = name_create(&cliname, mti->mti_fsname, "-client");
+ if (rc)
+ RETURN(rc);
if (mgs_log_is_empty(env, mgs, cliname)) {
/* Start client log */
rc = mgs_write_log_lov(env, mgs, fsdb, mti, cliname,
fsdb->fsdb_clilov);
+ if (rc)
+ GOTO(out_free, rc);
rc = mgs_write_log_lmv(env, mgs, fsdb, mti, cliname,
fsdb->fsdb_clilmv);
+ if (rc)
+ GOTO(out_free, rc);
}
/*
rc = mgs_steal_llog_for_mdt_from_client(env, mgs, cliname,
&mgi->mgi_comp);
-
+ if (rc)
+ GOTO(out_free, rc);
rc = mgs_write_log_mdc_to_lmv(env, mgs, fsdb, mti, cliname,
fsdb->fsdb_clilmv);
+ if (rc)
+ GOTO(out_free, rc);
+
/* add mountopts */
rc = record_start_log(env, mgs, &llh, cliname);
- if (rc)
- GOTO(out, rc);
+ if (rc)
+ GOTO(out_free, rc);
rc = record_marker(env, llh, fsdb, CM_START, cliname,
"mount opts");
+ if (rc)
+ GOTO(out_end, rc);
rc = record_mount_opt(env, llh, cliname, fsdb->fsdb_clilov,
fsdb->fsdb_clilmv);
+ if (rc)
+ GOTO(out_end, rc);
rc = record_marker(env, llh, fsdb, CM_END, cliname,
"mount opts");
- }
-
- rc = record_end_log(env, &llh);
-out:
- name_destroy(&cliname);
+ }
- // for_all_existing_mdt except current one
+ if (rc)
+ GOTO(out_end, rc);
+ /* for_all_existing_mdt except current one */
for (i = 0; i < INDEX_MAP_SIZE * 8; i++){
char *mdtname;
if (i != mti->mti_stripe_index &&
cfs_test_bit(i, fsdb->fsdb_mdt_index_map)) {
- name_create_mdt(&mdtname, mti->mti_fsname, i);
- rc = mgs_write_log_mdc_to_mdt(env, mgs, fsdb,
- mti, mdtname);
+ rc = name_create_mdt(&mdtname, mti->mti_fsname, i);
+ if (rc)
+ GOTO(out_end, rc);
+ rc = mgs_write_log_mdc_to_mdt(env, mgs, fsdb, mti, mdtname);
name_destroy(&mdtname);
+ if (rc)
+ GOTO(out_end, rc);
}
}
-
+out_end:
+ record_end_log(env, &llh);
+out_free:
+ name_destroy(&cliname);
RETURN(rc);
}
enum lustre_sec_part sec_part, int flags)
{
struct llog_handle *llh = NULL;
- char *nodeuuid, *oscname, *oscuuid, *lovuuid, *svname;
+ char *nodeuuid = NULL;
+ char *oscname = NULL;
+ char *oscuuid = NULL;
+ char *lovuuid = NULL;
+ char *svname = NULL;
char index[6];
int i, rc;
RETURN (-EINVAL);
}
- name_create(&nodeuuid, libcfs_nid2str(mti->mti_nids[0]), "");
- name_create(&svname, mti->mti_svname, "-osc");
- name_create(&oscname, svname, suffix);
- name_create(&oscuuid, oscname, "_UUID");
- name_create(&lovuuid, lovname, "_UUID");
+ rc = name_create(&nodeuuid, libcfs_nid2str(mti->mti_nids[0]), "");
+ if (rc)
+ RETURN(rc);
+ rc = name_create(&svname, mti->mti_svname, "-osc");
+ if (rc)
+ GOTO(out_free, rc);
+ rc = name_create(&oscname, svname, suffix);
+ if (rc)
+ GOTO(out_free, rc);
+ rc = name_create(&oscuuid, oscname, "_UUID");
+ if (rc)
+ GOTO(out_free, rc);
+ rc = name_create(&lovuuid, lovname, "_UUID");
+ if (rc)
+ GOTO(out_free, rc);
/*
#03 L add_uuid nid=uml1@tcp(0x20000c0a80201) 0: 1:uml1_UUID
rc = record_start_log(env, mgs, &llh, logname);
if (rc)
- GOTO(out, rc);
+ GOTO(out_free, rc);
/* FIXME these should be a single journal transaction */
rc = record_marker(env, llh, fsdb, CM_START | flags, mti->mti_svname,
"add osc");
+ if (rc)
+ GOTO(out_end, rc);
for (i = 0; i < mti->mti_nid_count; i++) {
CDEBUG(D_MGS, "add nid %s\n", libcfs_nid2str(mti->mti_nids[i]));
rc = record_add_uuid(env, llh, mti->mti_nids[i], nodeuuid);
+ if (rc)
+ GOTO(out_end, rc);
}
rc = record_attach(env, llh, oscname, LUSTRE_OSC_NAME, lovuuid);
+ if (rc)
+ GOTO(out_end, rc);
rc = record_setup(env, llh, oscname, mti->mti_uuid, nodeuuid, 0, 0);
+ if (rc)
+ GOTO(out_end, rc);
rc = mgs_write_log_failnids(env, mti, llh, oscname);
+ if (rc)
+ GOTO(out_end, rc);
snprintf(index, sizeof(index), "%d", mti->mti_stripe_index);
rc = record_lov_add(env, llh, lovname, mti->mti_uuid, index, "1");
+ if (rc)
+ GOTO(out_end, rc);
rc = record_marker(env, llh, fsdb, CM_END | flags, mti->mti_svname,
"add osc");
- rc = record_end_log(env, &llh);
-out:
- name_destroy(&lovuuid);
- name_destroy(&oscuuid);
- name_destroy(&oscname);
- name_destroy(&svname);
- name_destroy(&nodeuuid);
+ if (rc)
+ GOTO(out_end, rc);
+out_end:
+ record_end_log(env, &llh);
+out_free:
+ name_destroy(&lovuuid);
+ name_destroy(&oscuuid);
+ name_destroy(&oscname);
+ name_destroy(&svname);
+ name_destroy(&nodeuuid);
RETURN(rc);
}
RETURN(rc);
/* FIXME these should be a single journal transaction */
rc = record_marker(env, llh, fsdb, CM_START, mti->mti_svname,"add ost");
+ if (rc)
+ GOTO(out_end, rc);
if (*mti->mti_uuid == '\0')
snprintf(mti->mti_uuid, sizeof(mti->mti_uuid),
"%s_UUID", mti->mti_svname);
rc = record_attach(env, llh, mti->mti_svname,
"obdfilter"/*LUSTRE_OST_NAME*/, mti->mti_uuid);
+ if (rc)
+ GOTO(out_end, rc);
rc = record_setup(env, llh, mti->mti_svname,
"dev"/*ignored*/, "type"/*ignored*/,
failout ? "n" : "f", 0/*options*/);
+ if (rc)
+ GOTO(out_end, rc);
rc = record_marker(env, llh, fsdb, CM_END, mti->mti_svname, "add ost");
- rc = record_end_log(env, &llh);
-
+ if (rc)
+ GOTO(out_end, rc);
+out_end:
+ record_end_log(env, &llh);
+ if (rc)
+ RETURN(rc);
/* We also have to update the other logs where this osc is part of
the lov */
if (cfs_test_bit(i, fsdb->fsdb_mdt_index_map)) {
char mdt_index[9];
- name_create_mdt_and_lov(&logname, &lovname, fsdb, i);
+ rc = name_create_mdt_and_lov(&logname, &lovname, fsdb,
+ i);
+ if (rc)
+ RETURN(rc);
sprintf(mdt_index, "-MDT%04x", i);
- mgs_write_log_osc_to_lov(env, mgs, fsdb, mti, logname,
- mdt_index, lovname,
- LUSTRE_SP_MDT, flags);
+ rc = mgs_write_log_osc_to_lov(env, mgs, fsdb, mti,
+ logname, mdt_index,
+ lovname, LUSTRE_SP_MDT,
+ flags);
name_destroy(&logname);
name_destroy(&lovname);
+ if (rc)
+ RETURN(rc);
}
}
/* Append ost info to the client log */
- name_create(&logname, mti->mti_fsname, "-client");
+ rc = name_create(&logname, mti->mti_fsname, "-client");
+ if (rc)
+ RETURN(rc);
if (mgs_log_is_empty(env, mgs, logname)) {
/* Start client log */
rc = mgs_write_log_lov(env, mgs, fsdb, mti, logname,
fsdb->fsdb_clilov);
+ if (rc)
+ GOTO(out_free, rc);
rc = mgs_write_log_lmv(env, mgs, fsdb, mti, logname,
fsdb->fsdb_clilmv);
+ if (rc)
+ GOTO(out_free, rc);
}
- mgs_write_log_osc_to_lov(env, mgs, fsdb, mti, logname, "",
- fsdb->fsdb_clilov, LUSTRE_SP_CLI, flags);
+ rc = mgs_write_log_osc_to_lov(env, mgs, fsdb, mti, logname, "",
+ fsdb->fsdb_clilov, LUSTRE_SP_CLI, 0);
+out_free:
name_destroy(&logname);
RETURN(rc);
}
/* Remove _all_ failnids */
rc = mgs_modify(env, mgs, fsdb, mti, logname,
mti->mti_svname, "add failnid", CM_SKIP);
- return rc;
+ return rc < 0 ? rc : 0;
}
/* Otherwise failover nids are additive */
rc = record_start_log(env, mgs, &llh, logname);
- if (!rc) {
+ if (rc)
+ return rc;
/* FIXME this should be a single journal transaction */
- rc = record_marker(env, llh, fsdb, CM_START,
- mti->mti_svname, "add failnid");
- rc = mgs_write_log_failnids(env, mti, llh, cliname);
- rc = record_marker(env, llh, fsdb, CM_END,
- mti->mti_svname, "add failnid");
- rc = record_end_log(env, &llh);
- }
-
+ rc = record_marker(env, llh, fsdb, CM_START, mti->mti_svname,
+ "add failnid");
+ if (rc)
+ goto out_end;
+ rc = mgs_write_log_failnids(env, mti, llh, cliname);
+ if (rc)
+ goto out_end;
+ rc = record_marker(env, llh, fsdb, CM_END,
+ mti->mti_svname, "add failnid");
+out_end:
+ record_end_log(env, &llh);
return rc;
}
/* Create mdc/osc client name (e.g. lustre-OST0001-osc) */
if (mti->mti_flags & LDD_F_SV_TYPE_MDT) {
- name_create(&cliname, mti->mti_svname, "-mdc");
+ rc = name_create(&cliname, mti->mti_svname, "-mdc");
} else if (mti->mti_flags & LDD_F_SV_TYPE_OST) {
- name_create(&cliname, mti->mti_svname, "-osc");
+ rc = name_create(&cliname, mti->mti_svname, "-osc");
} else {
RETURN(-EINVAL);
}
-
+ if (rc)
+ RETURN(rc);
/* Add failover nids to the client log */
- name_create(&logname, mti->mti_fsname, "-client");
+ rc = name_create(&logname, mti->mti_fsname, "-client");
+ if (rc) {
+ name_destroy(&cliname);
+ RETURN(rc);
+ }
rc = mgs_write_log_failnid_internal(env, mgs, fsdb,mti,logname,cliname);
name_destroy(&logname);
name_destroy(&cliname);
+ if (rc)
+ RETURN(rc);
if (mti->mti_flags & LDD_F_SV_TYPE_OST) {
/* Add OST failover nids to the MDT logs as well */
for (i = 0; i < INDEX_MAP_SIZE * 8; i++) {
if (!cfs_test_bit(i, fsdb->fsdb_mdt_index_map))
continue;
- name_create_mdt(&logname, mti->mti_fsname, i);
- name_create_mdt_osc(&cliname, mti->mti_svname, fsdb, i);
- rc = mgs_write_log_failnid_internal(env, mgs, fsdb, mti,
- logname, cliname);
+ rc = name_create_mdt(&logname, mti->mti_fsname, i);
+ if (rc)
+ RETURN(rc);
+ rc = name_create_mdt_osc(&cliname, mti->mti_svname,
+ fsdb, i);
+ if (rc) {
+ name_destroy(&logname);
+ RETURN(rc);
+ }
+ rc = mgs_write_log_failnid_internal(env, mgs, fsdb,
+ mti, logname,
+ cliname);
name_destroy(&cliname);
name_destroy(&logname);
+ if (rc)
+ RETURN(rc);
}
}
*tmp = 0;
/* FIXME we should skip settings that are the same as old values */
rc = mgs_modify(env, mgs, fsdb, mti, logname, tgtname, comment,CM_SKIP);
+ if (rc < 0)
+ return rc;
del = mgs_param_empty(ptr);
LCONSOLE_INFO("%sing parameter %s.%s in log %s\n", del ? "Disabl" : rc ?
if (mgs_log_is_empty(env, mgs, logname)) {
rc = record_start_log(env, mgs, &llh, logname);
- record_end_log(env, &llh);
if (rc)
GOTO(out, rc);
+ record_end_log(env, &llh);
}
/* obsolete old one */
- mgs_modify(env, mgs, fsdb, mti, logname, mti->mti_svname,
- comment, CM_SKIP);
-
+ rc = mgs_modify(env, mgs, fsdb, mti, logname, mti->mti_svname,
+ comment, CM_SKIP);
+ if (rc < 0)
+ GOTO(out, rc);
/* write the new one */
rc = mgs_write_log_direct(env, mgs, fsdb, logname, lcfg,
mti->mti_svname, comment);
- if (rc)
- CERROR("err %d writing log %s\n", rc, logname);
-
+ if (rc)
+ CERROR("err %d writing log %s\n", rc, logname);
out:
name_destroy(&logname);
out_lcfg:
LCONSOLE_WARN("Permanently %sactivating %s\n",
flag ? "de": "re", mti->mti_svname);
/* Modify clilov */
- name_create(&logname, mti->mti_fsname, "-client");
+ rc = name_create(&logname, mti->mti_fsname, "-client");
+ if (rc)
+ GOTO(end, rc);
rc = mgs_modify(env, mgs, fsdb, mti, logname,
mti->mti_svname, "add osc", flag);
name_destroy(&logname);
for (i = 0; i < INDEX_MAP_SIZE * 8; i++) {
if (!cfs_test_bit(i, fsdb->fsdb_mdt_index_map))
continue;
- name_create_mdt(&logname, mti->mti_fsname, i);
+ rc = name_create_mdt(&logname, mti->mti_fsname, i);
+ if (rc)
+ GOTO(end, rc);
rc = mgs_modify(env, mgs, fsdb, mti, logname,
- mti->mti_svname, "add osc", flag);
+ mti->mti_svname, "add osc", flag);
name_destroy(&logname);
if (rc)
goto active_err;
if (mgs_log_is_empty(env, mgs, mti->mti_svname))
GOTO(end, rc = -ENODEV);
- name_create_mdt_and_lov(&logname, &mdtlovname, fsdb,
- mti->mti_stripe_index);
+ rc = name_create_mdt_and_lov(&logname, &mdtlovname, fsdb,
+ mti->mti_stripe_index);
+ if (rc)
+ GOTO(end, rc);
rc = mgs_wlp_lcfg(env, mgs, fsdb, mti, mti->mti_svname,
&mgi->mgi_bufs, mdtlovname, ptr);
name_destroy(&logname);
GOTO(end, rc);
/* Modify clilov */
- name_create(&logname, mti->mti_fsname, "-client");
+ rc = name_create(&logname, mti->mti_fsname, "-client");
+ if (rc)
+ GOTO(end, rc);
rc = mgs_wlp_lcfg(env, mgs, fsdb, mti, logname, &mgi->mgi_bufs,
fsdb->fsdb_clilov, ptr);
name_destroy(&logname);
} else {
GOTO(end, rc = -EINVAL);
}
+ if (rc)
+ GOTO(end, rc);
CDEBUG(D_MGS, "%.3s param %s\n", ptr, ptr + 4);
/* Modify client */
- name_create(&logname, mti->mti_fsname, "-client");
+ rc = name_create(&logname, mti->mti_fsname, "-client");
+ if (rc) {
+ name_destroy(&cname);
+ GOTO(end, rc);
+ }
rc = mgs_wlp_lcfg(env, mgs, fsdb, mti, logname, &mgi->mgi_bufs,
cname, ptr);
if (!cfs_test_bit(i, fsdb->fsdb_mdt_index_map))
continue;
name_destroy(&cname);
- name_create_mdt_osc(&cname, mti->mti_svname,
- fsdb, i);
+ rc = name_create_mdt_osc(&cname, mti->mti_svname,
+ fsdb, i);
name_destroy(&logname);
- name_create_mdt(&logname, mti->mti_fsname, i);
- if (!mgs_log_is_empty(env, mgs, logname))
- rc = mgs_wlp_lcfg(env, mgs, fsdb, mti,
- logname, &mgi->mgi_bufs,
+ if (rc)
+ break;
+ rc = name_create_mdt(&logname,
+ mti->mti_fsname, i);
+ if (rc)
+ break;
+ if (!mgs_log_is_empty(env, mgs, logname)) {
+ rc = mgs_wlp_lcfg(env, mgs, fsdb,
+ mti, logname,
+ &mgi->mgi_bufs,
cname, ptr);
- if (rc)
- break;
- }
- }
+ if (rc)
+ break;
+ }
+ }
+ }
name_destroy(&logname);
name_destroy(&cname);
GOTO(end, rc);
if (!cfs_test_bit(i,
fsdb->fsdb_mdt_index_map))
continue;
- name_create_mdt(&logname, mti->mti_fsname, i);
+ rc = name_create_mdt(&logname,
+ mti->mti_fsname, i);
+ if (rc)
+ goto active_err;
rc = mgs_wlp_lcfg(env, mgs, fsdb, mti,
logname, &mgi->mgi_bufs,
logname, ptr);
int rc;
rc = record_start_log(env, mgs, &llh, logname);
- if (rc)
- return rc;
+ if (rc)
+ return rc;
rc = record_marker(env, llh, fsdb, CM_START, lovname, comment);
- record_base(env, llh, lovname, 0, cmd, poolname, fsname, ostname, 0);
+ if (rc)
+ goto out;
+ rc = record_base(env, llh, lovname, 0, cmd, poolname, fsname, ostname, 0);
+ if (rc)
+ goto out;
rc = record_marker(env, llh, fsdb, CM_END, lovname, comment);
- rc = record_end_log(env, &llh);
-
+out:
+ record_end_log(env, &llh);
return rc;
}
OBD_ALLOC(label, label_sz);
if (label == NULL)
- GOTO(out, rc = -ENOMEM);
+ RETURN(-ENOMEM);
switch(cmd) {
case LCFG_POOL_NEW:
case LCFG_POOL_REM:
OBD_ALLOC(canceled_label, label_sz);
if (canceled_label == NULL)
- GOTO(out, rc = -ENOMEM);
+ GOTO(out_label, rc = -ENOMEM);
sprintf(label,
"rem %s.%s.%s", fsname, poolname, ostname);
sprintf(canceled_label,
case LCFG_POOL_DEL:
OBD_ALLOC(canceled_label, label_sz);
if (canceled_label == NULL)
- GOTO(out, rc = -ENOMEM);
+ GOTO(out_label, rc = -ENOMEM);
sprintf(label,
"del %s.%s", fsname, poolname);
sprintf(canceled_label,
if (canceled_label != NULL) {
OBD_ALLOC_PTR(mti);
if (mti == NULL)
- GOTO(out, rc = -ENOMEM);
+ GOTO(out_cancel, rc = -ENOMEM);
}
/* write pool def to all MDT logs */
for (i = 0; i < INDEX_MAP_SIZE * 8; i++) {
if (cfs_test_bit(i, fsdb->fsdb_mdt_index_map)) {
- name_create_mdt_and_lov(&logname, &lovname, fsdb, i);
-
+ rc = name_create_mdt_and_lov(&logname, &lovname,
+ fsdb, i);
+ if (rc) {
+ cfs_mutex_unlock(&fsdb->fsdb_mutex);
+ GOTO(out_mti, rc);
+ }
if (canceled_label != NULL) {
strcpy(mti->mti_svname, "lov pool");
- mgs_modify(env, mgs, fsdb, mti, logname,
- lovname, canceled_label,
- CM_SKIP);
+ rc = mgs_modify(env, mgs, fsdb, mti, logname,
+ lovname, canceled_label,
+ CM_SKIP);
}
- mgs_write_log_pool(env, mgs, logname, fsdb, lovname,
- cmd, fsname, poolname, ostname,
- label);
+ if (rc >= 0)
+ rc = mgs_write_log_pool(env, mgs, logname,
+ fsdb, lovname, cmd,
+ fsname, poolname,
+ ostname, label);
name_destroy(&logname);
name_destroy(&lovname);
+ if (rc) {
+ cfs_mutex_unlock(&fsdb->fsdb_mutex);
+ GOTO(out_mti, rc);
+ }
}
}
- name_create(&logname, fsname, "-client");
- if (canceled_label != NULL)
- mgs_modify(env, mgs, fsdb, mti, logname, fsdb->fsdb_clilov,
- canceled_label, CM_SKIP);
-
- mgs_write_log_pool(env, mgs, logname, fsdb, fsdb->fsdb_clilov,
- cmd, fsname, poolname, ostname, label);
- name_destroy(&logname);
+ rc = name_create(&logname, fsname, "-client");
+ if (rc) {
+ cfs_mutex_unlock(&fsdb->fsdb_mutex);
+ GOTO(out_mti, rc);
+ }
+ if (canceled_label != NULL) {
+ rc = mgs_modify(env, mgs, fsdb, mti, logname,
+ fsdb->fsdb_clilov, canceled_label, CM_SKIP);
+ if (rc < 0) {
+ cfs_mutex_unlock(&fsdb->fsdb_mutex);
+ name_destroy(&logname);
+ GOTO(out_mti, rc);
+ }
+ }
+ rc = mgs_write_log_pool(env, mgs, logname, fsdb, fsdb->fsdb_clilov,
+ cmd, fsname, poolname, ostname, label);
cfs_mutex_unlock(&fsdb->fsdb_mutex);
+ name_destroy(&logname);
/* request for update */
mgs_revoke_lock(mgs, fsdb, CONFIG_T_CONFIG);
EXIT;
-out:
- if (label != NULL)
- OBD_FREE(label, label_sz);
-
- if (canceled_label != NULL)
- OBD_FREE(canceled_label, label_sz);
-
+out_mti:
if (mti != NULL)
OBD_FREE_PTR(mti);
-
+out_cancel:
+ if (canceled_label != NULL)
+ OBD_FREE(canceled_label, label_sz);
+out_label:
+ OBD_FREE(label, label_sz);
return rc;
}