rc = llog_setup(obd, olg, LLOG_SIZE_REPL_CTXT, tgt, 0, NULL,
&lov_size_repl_logops);
if (rc)
- RETURN(rc);
+ GOTO(err_cleanup, rc);
lov_getref(obd);
/* count may not match lov->desc.ld_tgt_count during dynamic ost add */
break;
}
lov_putref(obd);
- RETURN(rc);
+ GOTO(err_cleanup, rc);
+err_cleanup:
+ if (rc) {
+ struct llog_ctxt *ctxt =
+ llog_get_context(obd, LLOG_SIZE_REPL_CTXT);
+ if (ctxt)
+ llog_cleanup(ctxt);
+ ctxt = llog_get_context(obd, LLOG_MDS_OST_ORIG_CTXT);
+ if (ctxt)
+ llog_cleanup(ctxt);
+ }
+ return rc;
}
int lov_llog_finish(struct obd_device *obd, int count)
static int mds_postsetup(struct obd_device *obd)
{
struct mds_obd *mds = &obd->u.mds;
+ struct llog_ctxt *ctxt;
int rc = 0;
ENTRY;
rc = llog_setup(obd, &obd->obd_olg, LLOG_LOVEA_ORIG_CTXT, obd, 0, NULL,
&llog_lvfs_ops);
if (rc)
- RETURN(rc);
+ GOTO(err_llog, rc);
if (mds->mds_profile) {
struct lustre_profile *lprof;
err_cleanup:
mds_lov_clean(obd);
- llog_cleanup(llog_get_context(obd, LLOG_CONFIG_ORIG_CTXT));
- llog_cleanup(llog_get_context(obd, LLOG_LOVEA_ORIG_CTXT));
- RETURN(rc);
+ ctxt = llog_get_context(obd, LLOG_LOVEA_ORIG_CTXT);
+ if (ctxt)
+ llog_cleanup(ctxt);
+err_llog:
+ ctxt = llog_get_context(obd, LLOG_CONFIG_ORIG_CTXT);
+ if (ctxt)
+ llog_cleanup(ctxt);
+ return rc;
}
int mds_postrecov(struct obd_device *obd)
struct obd_uuid *uuid)
{
struct obd_device *lov_obd = obd->u.mds.mds_osc_obd;
+ struct llog_ctxt *ctxt;
int rc;
ENTRY;
rc = llog_setup(obd, &obd->obd_olg, LLOG_SIZE_REPL_CTXT, tgt, 0, NULL,
&mds_size_repl_logops);
if (rc)
- RETURN(rc);
+ GOTO(err_llog, rc);
rc = obd_llog_init(lov_obd, &lov_obd->obd_olg, tgt, count, logid, uuid);
- if (rc)
+ if (rc) {
CERROR("lov_llog_init err %d\n", rc);
+ GOTO(err_cleanup, rc);
+ }
RETURN(rc);
+err_cleanup:
+ ctxt = llog_get_context(obd, LLOG_SIZE_REPL_CTXT);
+ if (ctxt)
+ llog_cleanup(ctxt);
+err_llog:
+ ctxt = llog_get_context(obd, LLOG_MDS_OST_ORIG_CTXT);
+ if (ctxt)
+ llog_cleanup(ctxt);
+ return rc;
}
int mds_llog_finish(struct obd_device *obd, int count)
ctxt = llog_get_context(obd, LLOG_CONFIG_REPL_CTXT);
llog_initiator_connect(ctxt);
llog_ctxt_put(ctxt);
+ } else {
+ ctxt = llog_get_context(obd, LLOG_CONFIG_ORIG_CTXT);
+ if (ctxt)
+ llog_cleanup(ctxt);
}
RETURN(rc);
int i;
ENTRY;
- if (!lh)
- return;
+ LASSERT(lh != NULL);
write_lock(&lh->lh_rwlock);
obd = ctxt->loc_obd;
spin_lock(&obd->obd_dev_lock);
spin_unlock(&obd->obd_dev_lock); /* sync with llog ctxt user thread */
- LASSERT(obd->obd_stopping == 1 || obd->obd_set_up == 0);
+
+ /* obd->obd_starting is needed for the case of cleanup
+ * in error case while obd is starting up. */
+ LASSERTF(obd->obd_starting == 1 ||
+ obd->obd_stopping == 1 || obd->obd_set_up == 0,
+ "wrong obd state: %d/%d/%d\n", !!obd->obd_starting,
+ !!obd->obd_stopping, !!obd->obd_set_up);
+
/* cleanup the llog ctxt here */
if (CTXTP(ctxt, cleanup))
rc = CTXTP(ctxt, cleanup)(ctxt);
obd->obd_uuid_hash = lustre_hash_init("UUID_HASH", 128, 128,
&uuid_hash_ops, 0);
if (!obd->obd_uuid_hash)
- GOTO(err_hash, -ENOMEM);
+ GOTO(err_hash, err = -ENOMEM);
/* create a nid-export lustre hash */
obd->obd_nid_hash = lustre_hash_init("NID_HASH", 128, 128,
&nid_hash_ops, 0);
if (!obd->obd_nid_hash)
- GOTO(err_hash, -ENOMEM);
+ GOTO(err_hash, err = -ENOMEM);
/* create a nid-stats lustre hash */
obd->obd_nid_stats_hash = lustre_hash_init("NID_STATS", 128, 128,
&nid_stat_hash_ops, 0);
if (!obd->obd_nid_stats_hash)
- GOTO(err_hash, -ENOMEM);
+ GOTO(err_hash, err = -ENOMEM);
exp = class_new_export(obd, &obd->obd_uuid);
if (IS_ERR(exp))
- RETURN(PTR_ERR(exp));
+ GOTO(err_hash, err = PTR_ERR(exp));
obd->obd_self_export = exp;
list_del_init(&exp->exp_obd_chain_timed);
obd->obd_name, obd->obd_uuid.uuid);
RETURN(0);
-
err_exp:
class_unlink_export(obd->obd_self_export);
obd->obd_self_export = NULL;
err_hash:
- lustre_hash_exit(obd->obd_uuid_hash);
- lustre_hash_exit(obd->obd_nid_hash);
- lustre_hash_exit(obd->obd_nid_stats_hash);
+ if (obd->obd_uuid_hash) {
+ lustre_hash_exit(obd->obd_uuid_hash);
+ obd->obd_uuid_hash = NULL;
+ }
+ if (obd->obd_nid_hash) {
+ lustre_hash_exit(obd->obd_nid_hash);
+ obd->obd_nid_hash = NULL;
+ }
+ if (obd->obd_nid_stats_hash) {
+ lustre_hash_exit(obd->obd_nid_stats_hash);
+ obd->obd_nid_stats_hash = NULL;
+ }
obd->obd_starting = 0;
CERROR("setup %s failed (%d)\n", obd->obd_name, err);
- RETURN(err);
+ return err;
}
int class_detach(struct obd_device *obd, struct lustre_cfg *lcfg)
lsi = s2lsi(lmi->lmi_sb);
mntget(lmi->lmi_mnt);
atomic_inc(&lsi->lsi_mounts);
-
+
CDEBUG(D_MOUNT, "get_mnt %p from %s, refs=%d, vfscount=%d\n",
lmi->lmi_mnt, name, atomic_read(&lsi->lsi_mounts),
atomic_read(&lmi->lmi_mnt->mnt_count));
if (rc) {
CERROR("failed to start server %s: %d\n",
lsi->lsi_ldd->ldd_svname, rc);
- server_deregister_mount(lsi->lsi_ldd->ldd_svname);
GOTO(out_mgc, rc);
}
struct lustre_sb_info *lsi = s2lsi(sb);
ENTRY;
- if (!lsi)
- RETURN(0);
-
- CDEBUG(D_MOUNT, "Freeing lsi\n");
+ LASSERT(lsi != NULL);
+ CDEBUG(D_MOUNT, "Freeing lsi %p\n", lsi);
/* someone didn't call server_put_mount. */
LASSERT(atomic_read(&lsi->lsi_mounts) == 0);
struct lustre_sb_info *lsi = s2lsi(sb);
ENTRY;
- LASSERT(lsi);
+ LASSERT(lsi != NULL);
CDEBUG(D_MOUNT, "put %p %d\n", sb, atomic_read(&lsi->lsi_mounts));
-
if (atomic_dec_and_test(&lsi->lsi_mounts)) {
lustre_free_lsi(sb);
RETURN(1);
if (IS_ERR(mnt)) {
rc = PTR_ERR(mnt);
CERROR("Unable to mount device %s: %d\n",
- lsi->lsi_lmd->lmd_dev, rc);
+ lsi->lsi_lmd->lmd_dev, rc);
lustre_put_lsi(sb);
- GOTO(out, rc);
+ RETURN(rc);
}
lsi->lsi_srv_mnt = mnt;
"running. Double-mount may have compromised"
" the disk journal.\n",
lsi->lsi_ldd->ldd_svname);
- unlock_mntput(mnt);
lustre_put_lsi(sb);
- GOTO(out, rc = -EALREADY);
+ unlock_mntput(mnt);
+ RETURN(-EALREADY);
}
- /* start MGS before MGC */
+ /* Start MGS before MGC */
if (IS_MGS(lsi->lsi_ldd) && !(lsi->lsi_lmd->lmd_flags & LMD_FLG_NOMGS)) {
rc = server_start_mgs(sb);
if (rc)
lsi->lsi_ldd->ldd_svname, lsi->lsi_lmd->lmd_dev);
RETURN(0);
-
out_mnt:
+ /* We jump here in case of failure while starting targets or MGS.
+ * In this case we can't just put @mnt and have to do real cleanup
+ * with stoping targets, etc. */
server_put_super(sb);
-out:
- RETURN(rc);
+ return rc;
}
/* Get the index from the obd name.
/* Figure out the lmd from the mount options */
if (lmd_parse((char *)data, lmd)) {
lustre_put_lsi(sb);
- RETURN(-EINVAL);
+ GOTO(out, rc = -EINVAL);
}
if (lmd_is_client(lmd)) {
LCONSOLE_ERROR_MSG(0x165, "Nothing registered for "
"client mount! Is the 'lustre' "
"module loaded?\n");
+ lustre_put_lsi(sb);
rc = -ENODEV;
} else {
rc = lustre_start_mgc(sb);
if (rc) {
- lustre_stop_mgc(sb);
- goto out;
+ lustre_put_lsi(sb);
+ GOTO(out, rc);
}
/* Connect and start */
/* (should always be ll_fill_super) */
/* s_f_s will call server_put_super on failure */
}
+ /* If error happens in fill_super() call, @lsi will be killed there.
+ * This is why we do not put it here. */
+ GOTO(out, rc);
out:
- if (rc){
+ if (rc) {
CERROR("Unable to mount %s (%d)\n",
s2lsi(sb) ? lmd->lmd_dev : "", rc);
} else {
- CDEBUG(D_SUPER, "mount %s complete\n", lmd->lmd_dev);
+ CDEBUG(D_SUPER, "Mount %s complete\n",
+ lmd->lmd_dev);
}
- RETURN(rc);
+ return rc;
}
rc = llog_setup(obd, &obd->obd_olg, LLOG_SIZE_REPL_CTXT, tgt, count,
NULL, &osc_size_repl_logops);
- if (rc)
+ if (rc) {
+ struct llog_ctxt *ctxt =
+ llog_get_context(obd, LLOG_MDS_OST_ORIG_CTXT);
+ if (ctxt)
+ llog_cleanup(ctxt);
CERROR("failed LLOG_SIZE_REPL_CTXT\n");
+ }
+ GOTO(out, rc);
out:
if (rc) {
CERROR("osc '%s' tgt '%s' cnt %d catid %p rc=%d\n",
CERROR("logid "LPX64":0x%x\n",
catid->lci_logid.lgl_oid, catid->lci_logid.lgl_ogen);
}
- RETURN(rc);
+ return rc;
}
static int osc_llog_finish(struct obd_device *obd, int count)