/*
* Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
* Use is subject to license terms.
+ *
+ * Copyright (c) 2011 Whamcloud, Inc.
+ *
*/
/*
* This file is part of Lustre, http://www.lustre.org/
class_export_put(cld->cld_mgcexp);
OBD_FREE(cld->cld_logname, strlen(cld->cld_logname) + 1);
- if (cld->cld_cfg.cfg_instance != NULL)
- OBD_FREE(cld->cld_cfg.cfg_instance,
- strlen(cld->cld_cfg.cfg_instance) + 1);
OBD_FREE(cld, sizeof(*cld));
} else {
cfs_spin_unlock(&config_list_lock);
struct config_llog_instance *cfg)
{
struct config_llog_data *cld;
- char *logid = logname;
- int match_instance = 0;
+ struct config_llog_data *found = NULL;
+ void * instance;
ENTRY;
- if (cfg && cfg->cfg_instance) {
- match_instance++;
- logid = cfg->cfg_instance;
- }
- if (!logid) {
- CERROR("No log specified\n");
- RETURN(ERR_PTR(-EINVAL));
- }
+ LASSERT(logname != NULL);
+ instance = cfg ? cfg->cfg_instance : NULL;
cfs_spin_lock(&config_list_lock);
cfs_list_for_each_entry(cld, &config_llog_list, cld_list_chain) {
- if (match_instance && cld->cld_cfg.cfg_instance &&
- strcmp(logid, cld->cld_cfg.cfg_instance) == 0)
- goto out_found;
- if (!match_instance &&
- strcmp(logid, cld->cld_logname) == 0)
- goto out_found;
- }
- cfs_spin_unlock(&config_list_lock);
+ /* check if instance equals */
+ if (instance != cld->cld_cfg.cfg_instance)
+ continue;
- CDEBUG(D_CONFIG, "can't get log %s\n", logid);
- RETURN(ERR_PTR(-ENOENT));
-out_found:
- cfs_atomic_inc(&cld->cld_refcount);
+ /* instance may be NULL, should check name */
+ if (strcmp(logname, cld->cld_logname) == 0) {
+ found = cld;
+ break;
+ }
+ }
+ if (found) {
+ cfs_atomic_inc(&found->cld_refcount);
+ LASSERT(found->cld_stopping == 0 || found->cld_is_sptlrpc == 0);
+ }
cfs_spin_unlock(&config_list_lock);
- LASSERT(cld->cld_stopping == 0 || cld->cld_is_sptlrpc == 0);
- RETURN(cld);
+ RETURN(found);
}
static
int rc;
ENTRY;
- CDEBUG(D_MGC, "do adding config log %s:%s\n", logname,
- cfg ? cfg->cfg_instance : "NULL");
+ CDEBUG(D_MGC, "do adding config log %s:%p\n", logname,
+ cfg ? cfg->cfg_instance : 0);
OBD_ALLOC(cld, sizeof(*cld));
if (!cld)
/* Keep the mgc around until we are done */
cld->cld_mgcexp = class_export_get(obd->obd_self_export);
- if (cfg && cfg->cfg_instance != NULL) {
- OBD_ALLOC(cld->cld_cfg.cfg_instance,
- strlen(cfg->cfg_instance) + 1);
- strcpy(cld->cld_cfg.cfg_instance, cfg->cfg_instance);
- }
-
if (is_sptlrpc) {
sptlrpc_conf_log_start(logname);
cld->cld_cfg.cfg_obdname = obd->obd_name;
char *ptr;
ENTRY;
- CDEBUG(D_MGC, "adding config log %s:%s\n", logname, cfg->cfg_instance);
+ CDEBUG(D_MGC, "adding config log %s:%p\n", logname, cfg->cfg_instance);
/*
* for each regular log, the depended sptlrpc log name is
strcpy(seclogname + (ptr - logname), "-sptlrpc");
sptlrpc_cld = config_log_find(seclogname, NULL);
- if (IS_ERR(sptlrpc_cld)) {
+ if (sptlrpc_cld == NULL) {
sptlrpc_cld = do_config_log_add(obd, seclogname, 1, NULL, NULL);
if (IS_ERR(sptlrpc_cld)) {
CERROR("can't create sptlrpc log: %s\n", seclogname);
ENTRY;
cld = config_log_find(logname, cfg);
- if (IS_ERR(cld))
- RETURN(PTR_ERR(cld));
+ if (cld == NULL)
+ RETURN(-ENOENT);
cfs_mutex_lock(&cld->cld_lock);
/*
cfs_spin_unlock(&config_list_lock);
cfs_waitq_signal(&rq_waitq);
}
+ obd_cleanup_client_import(obd);
rc = obd_llog_finish(obd, 0);
if (rc != 0)
CERROR("failed to cleanup llogging subsystems\n");
struct llog_ctxt *ctxt, *lctxt;
struct lustre_handle lockh;
struct client_obd *cli = &mgc->u.cli;
- struct lvfs_run_ctxt saved;
+ struct lvfs_run_ctxt *saved_ctxt;
struct lustre_sb_info *lsi = NULL;
int rc = 0, rcl, flags = 0, must_pop = 0;
ENTRY;
if (cld->cld_cfg.cfg_sb)
lsi = s2lsi(cld->cld_cfg.cfg_sb);
- CDEBUG(D_MGC, "Process log %s:%s from %d\n", cld->cld_logname,
+ CDEBUG(D_MGC, "Process log %s:%p from %d\n", cld->cld_logname,
cld->cld_cfg.cfg_instance, cld->cld_cfg.cfg_last_idx + 1);
ctxt = llog_get_context(mgc, LLOG_CONFIG_REPL_CTXT);
RETURN(-EINVAL);
}
+ OBD_ALLOC_PTR(saved_ctxt);
+ if (saved_ctxt == NULL) {
+ cfs_mutex_unlock(&cld->cld_lock);
+ RETURN(-ENOMEM);
+ }
+
/* Get the cfg lock on the llog */
rcl = mgc_enqueue(mgc->u.cli.cl_mgc_mgsexp, NULL, LDLM_PLAIN, NULL,
LCK_CR, &flags, NULL, NULL, NULL,
if (lctxt && lsi && (lsi->lsi_flags & LSI_SERVER) &&
(lsi->lsi_srv_mnt == cli->cl_mgc_vfsmnt) &&
!IS_MGS(lsi->lsi_ldd)) {
- push_ctxt(&saved, &mgc->obd_lvfs_ctxt, NULL);
+ push_ctxt(saved_ctxt, &mgc->obd_lvfs_ctxt, NULL);
must_pop++;
if (rcl == 0)
/* Only try to copy log if we have the lock. */
if (ctxt != lctxt)
llog_ctxt_put(lctxt);
if (must_pop)
- pop_ctxt(&saved, &mgc->obd_lvfs_ctxt, NULL);
+ pop_ctxt(saved_ctxt, &mgc->obd_lvfs_ctxt, NULL);
+ OBD_FREE_PTR(saved_ctxt);
/*
* update settings on existing OBDs. doing it inside
* of llog_process_lock so no device is attaching/detaching
static int mgc_process_config(struct obd_device *obd, obd_count len, void *buf)
{
struct lustre_cfg *lcfg = buf;
- int cmd;
+ struct config_llog_instance *cfg = NULL;
+ char *logname;
int rc = 0;
ENTRY;
- switch(cmd = lcfg->lcfg_command) {
+ switch(lcfg->lcfg_command) {
case LCFG_LOV_ADD_OBD: {
/* Overloading this cfg command: register a new target */
struct mgs_target_info *mti;
}
case LCFG_LOG_START: {
struct config_llog_data *cld;
- struct config_llog_instance *cfg;
struct super_block *sb;
- char *logname = lustre_cfg_string(lcfg, 1);
+
+ logname = lustre_cfg_string(lcfg, 1);
cfg = (struct config_llog_instance *)lustre_cfg_buf(lcfg, 2);
sb = *(struct super_block **)lustre_cfg_buf(lcfg, 3);
if (rc)
break;
cld = config_log_find(logname, cfg);
- if (IS_ERR(cld)) {
- rc = PTR_ERR(cld);
+ if (cld == NULL) {
+ rc = -ENOENT;
break;
}
break;
}
case LCFG_LOG_END: {
- struct config_llog_instance *cfg = NULL;
- char *logname = lustre_cfg_string(lcfg, 1);
+ logname = lustre_cfg_string(lcfg, 1);
+
if (lcfg->lcfg_bufcount >= 2)
cfg = (struct config_llog_instance *)lustre_cfg_buf(
lcfg, 2);