diff options
Diffstat (limited to 'drivers/staging/lustre/lustre/obdclass/obd_config.c')
-rw-r--r-- | drivers/staging/lustre/lustre/obdclass/obd_config.c | 144 |
1 files changed, 87 insertions, 57 deletions
diff --git a/drivers/staging/lustre/lustre/obdclass/obd_config.c b/drivers/staging/lustre/lustre/obdclass/obd_config.c index 0d81d3232f31..5e7b3d7cc984 100644 --- a/drivers/staging/lustre/lustre/obdclass/obd_config.c +++ b/drivers/staging/lustre/lustre/obdclass/obd_config.c @@ -365,7 +365,7 @@ int class_attach(struct lustre_cfg *lcfg) obd = NULL; CERROR("Cannot create device %s of type %s : %d\n", name, typename, rc); - GOTO(out, rc); + goto out; } LASSERTF(obd != NULL, "Cannot get obd device %s of type %s\n", name, typename); @@ -412,15 +412,18 @@ int class_attach(struct lustre_cfg *lcfg) if (len >= sizeof(obd->obd_uuid)) { CERROR("uuid must be < %d bytes long\n", (int)sizeof(obd->obd_uuid)); - GOTO(out, rc = -EINVAL); + rc = -EINVAL; + goto out; } memcpy(obd->obd_uuid.uuid, uuid, len); /* do the attach */ if (OBP(obd, attach)) { rc = OBP(obd, attach)(obd, sizeof(*lcfg), lcfg); - if (rc) - GOTO(out, rc = -EINVAL); + if (rc) { + rc = -EINVAL; + goto out; + } } /* Detach drops this */ @@ -494,8 +497,10 @@ int class_setup(struct obd_device *obd, struct lustre_cfg *lcfg) CFS_HASH_MIN_THETA, CFS_HASH_MAX_THETA, &uuid_hash_ops, CFS_HASH_DEFAULT); - if (!obd->obd_uuid_hash) - GOTO(err_hash, err = -ENOMEM); + if (!obd->obd_uuid_hash) { + err = -ENOMEM; + goto err_hash; + } /* create a nid-export lustre hash */ obd->obd_nid_hash = cfs_hash_create("NID_HASH", @@ -505,8 +510,10 @@ int class_setup(struct obd_device *obd, struct lustre_cfg *lcfg) CFS_HASH_MIN_THETA, CFS_HASH_MAX_THETA, &nid_hash_ops, CFS_HASH_DEFAULT); - if (!obd->obd_nid_hash) - GOTO(err_hash, err = -ENOMEM); + if (!obd->obd_nid_hash) { + err = -ENOMEM; + goto err_hash; + } /* create a nid-stats lustre hash */ obd->obd_nid_stats_hash = cfs_hash_create("NID_STATS", @@ -516,12 +523,16 @@ int class_setup(struct obd_device *obd, struct lustre_cfg *lcfg) CFS_HASH_MIN_THETA, CFS_HASH_MAX_THETA, &nid_stat_hash_ops, CFS_HASH_DEFAULT); - if (!obd->obd_nid_stats_hash) - GOTO(err_hash, err = -ENOMEM); + if (!obd->obd_nid_stats_hash) { + err = -ENOMEM; + goto err_hash; + } exp = class_new_export(obd, &obd->obd_uuid); - if (IS_ERR(exp)) - GOTO(err_hash, err = PTR_ERR(exp)); + if (IS_ERR(exp)) { + err = PTR_ERR(exp); + goto err_hash; + } obd->obd_self_export = exp; list_del_init(&exp->exp_obd_chain_timed); @@ -529,7 +540,7 @@ int class_setup(struct obd_device *obd, struct lustre_cfg *lcfg) err = obd_setup(obd, lcfg); if (err) - GOTO(err_exp, err); + goto err_exp; obd->obd_set_up = 1; @@ -856,21 +867,27 @@ int class_add_profile(int proflen, char *prof, int osclen, char *osc, LASSERT(proflen == (strlen(prof) + 1)); OBD_ALLOC(lprof->lp_profile, proflen); - if (lprof->lp_profile == NULL) - GOTO(out, err = -ENOMEM); + if (lprof->lp_profile == NULL) { + err = -ENOMEM; + goto out; + } memcpy(lprof->lp_profile, prof, proflen); LASSERT(osclen == (strlen(osc) + 1)); OBD_ALLOC(lprof->lp_dt, osclen); - if (lprof->lp_dt == NULL) - GOTO(out, err = -ENOMEM); + if (lprof->lp_dt == NULL) { + err = -ENOMEM; + goto out; + } memcpy(lprof->lp_dt, osc, osclen); if (mdclen > 0) { LASSERT(mdclen == (strlen(mdc) + 1)); OBD_ALLOC(lprof->lp_md, mdclen); - if (lprof->lp_md == NULL) - GOTO(out, err = -ENOMEM); + if (lprof->lp_md == NULL) { + err = -ENOMEM; + goto out; + } memcpy(lprof->lp_md, mdc, mdclen); } @@ -1050,7 +1067,7 @@ static int process_param2_config(struct lustre_cfg *lcfg) } do_gettimeofday(&start); - rc = USERMODEHELPER(argv[0], argv, NULL); + rc = call_usermodehelper(argv[0], argv, NULL, 1); do_gettimeofday(&end); if (rc < 0) { @@ -1087,10 +1104,10 @@ int class_process_config(struct lustre_cfg *lcfg) CDEBUG(D_IOCTL, "processing cmd: %x\n", lcfg->lcfg_command); /* Commands that don't need a device */ - switch(lcfg->lcfg_command) { + switch (lcfg->lcfg_command) { case LCFG_ATTACH: { err = class_attach(lcfg); - GOTO(out, err); + goto out; } case LCFG_ADD_UUID: { CDEBUG(D_IOCTL, "adding mapping from uuid %s to nid %#llx (%s)\n", @@ -1098,7 +1115,7 @@ int class_process_config(struct lustre_cfg *lcfg) libcfs_nid2str(lcfg->lcfg_nid)); err = class_add_uuid(lustre_cfg_string(lcfg, 1), lcfg->lcfg_nid); - GOTO(out, err); + goto out; } case LCFG_DEL_UUID: { CDEBUG(D_IOCTL, "removing mappings for uuid %s\n", @@ -1106,7 +1123,7 @@ int class_process_config(struct lustre_cfg *lcfg) ? "<all uuids>" : lustre_cfg_string(lcfg, 1)); err = class_del_uuid(lustre_cfg_string(lcfg, 1)); - GOTO(out, err); + goto out; } case LCFG_MOUNTOPT: { CDEBUG(D_IOCTL, "mountopt: profile %s osc %s mdc %s\n", @@ -1121,20 +1138,22 @@ int class_process_config(struct lustre_cfg *lcfg) lustre_cfg_string(lcfg, 2), LUSTRE_CFG_BUFLEN(lcfg, 3), lustre_cfg_string(lcfg, 3)); - GOTO(out, err); + goto out; } case LCFG_DEL_MOUNTOPT: { CDEBUG(D_IOCTL, "mountopt: profile %s\n", lustre_cfg_string(lcfg, 1)); class_del_profile(lustre_cfg_string(lcfg, 1)); - GOTO(out, err = 0); + err = 0; + goto out; } case LCFG_SET_TIMEOUT: { CDEBUG(D_IOCTL, "changing lustre timeout from %d to %d\n", obd_timeout, lcfg->lcfg_num); obd_timeout = max(lcfg->lcfg_num, 1U); obd_timeout_set = 1; - GOTO(out, err = 0); + err = 0; + goto out; } case LCFG_SET_LDLM_TIMEOUT: { CDEBUG(D_IOCTL, "changing lustre ldlm_timeout from %d to %d\n", @@ -1143,19 +1162,22 @@ int class_process_config(struct lustre_cfg *lcfg) if (ldlm_timeout >= obd_timeout) ldlm_timeout = max(obd_timeout / 3, 1U); ldlm_timeout_set = 1; - GOTO(out, err = 0); + err = 0; + goto out; } case LCFG_SET_UPCALL: { LCONSOLE_ERROR_MSG(0x15a, "recovery upcall is deprecated\n"); /* COMPAT_146 Don't fail on old configs */ - GOTO(out, err = 0); + err = 0; + goto out; } case LCFG_MARKER: { struct cfg_marker *marker; marker = lustre_cfg_buf(lcfg, 1); CDEBUG(D_IOCTL, "marker %d (%#x) %.16s %s\n", marker->cm_step, marker->cm_flags, marker->cm_tgtname, marker->cm_comment); - GOTO(out, err = 0); + err = 0; + goto out; } case LCFG_PARAM: { char *tmp; @@ -1164,7 +1186,7 @@ int class_process_config(struct lustre_cfg *lcfg) PARAM_LLITE, NULL) == 0) && client_process_config) { err = (*client_process_config)(lcfg); - GOTO(out, err); + goto out; } else if ((class_match_param(lustre_cfg_string(lcfg, 1), PARAM_SYS, &tmp) == 0)) { /* Global param settings */ @@ -1176,19 +1198,20 @@ int class_process_config(struct lustre_cfg *lcfg) if (err != 0) CWARN("Ignoring unknown param %s\n", tmp); - GOTO(out, err = 0); + err = 0; + goto out; } else if ((class_match_param(lustre_cfg_string(lcfg, 1), PARAM_QUOTA, &tmp) == 0) && quota_process_config) { err = (*quota_process_config)(lcfg); - GOTO(out, err); + goto out; } break; } case LCFG_SET_PARAM: { err = process_param2_config(lcfg); - GOTO(out, 0); + goto out; } } /* Commands that require a device */ @@ -1200,55 +1223,60 @@ int class_process_config(struct lustre_cfg *lcfg) CERROR("no device for: %s\n", lustre_cfg_string(lcfg, 0)); - GOTO(out, err = -EINVAL); + err = -EINVAL; + goto out; } - switch(lcfg->lcfg_command) { + switch (lcfg->lcfg_command) { case LCFG_SETUP: { err = class_setup(obd, lcfg); - GOTO(out, err); + goto out; } case LCFG_DETACH: { err = class_detach(obd, lcfg); - GOTO(out, err = 0); + err = 0; + goto out; } case LCFG_CLEANUP: { err = class_cleanup(obd, lcfg); - GOTO(out, err = 0); + err = 0; + goto out; } case LCFG_ADD_CONN: { err = class_add_conn(obd, lcfg); - GOTO(out, err = 0); + err = 0; + goto out; } case LCFG_DEL_CONN: { err = class_del_conn(obd, lcfg); - GOTO(out, err = 0); + err = 0; + goto out; } case LCFG_POOL_NEW: { err = obd_pool_new(obd, lustre_cfg_string(lcfg, 2)); - GOTO(out, err = 0); - break; + err = 0; + goto out; } case LCFG_POOL_ADD: { err = obd_pool_add(obd, lustre_cfg_string(lcfg, 2), lustre_cfg_string(lcfg, 3)); - GOTO(out, err = 0); - break; + err = 0; + goto out; } case LCFG_POOL_REM: { err = obd_pool_rem(obd, lustre_cfg_string(lcfg, 2), lustre_cfg_string(lcfg, 3)); - GOTO(out, err = 0); - break; + err = 0; + goto out; } case LCFG_POOL_DEL: { err = obd_pool_del(obd, lustre_cfg_string(lcfg, 2)); - GOTO(out, err = 0); - break; + err = 0; + goto out; } default: { err = obd_process_config(obd, sizeof(*lcfg), lcfg); - GOTO(out, err); + goto out; } } @@ -1361,7 +1389,7 @@ int class_config_llog_handler(const struct lu_env *env, { struct config_llog_instance *clli = data; int cfg_len = rec->lrh_len; - char *cfg_buf = (char*) (rec + 1); + char *cfg_buf = (char *) (rec + 1); int rc = 0; //class_config_dump_handler(handle, rec, data); @@ -1382,7 +1410,7 @@ int class_config_llog_handler(const struct lu_env *env, rc = lustre_cfg_sanity_check(cfg_buf, cfg_len); if (rc) - GOTO(out, rc); + goto out; /* Figure out config state info */ if (lcfg->lcfg_command == LCFG_MARKER) { @@ -1469,8 +1497,10 @@ int class_config_llog_handler(const struct lu_env *env, inst_len = LUSTRE_CFG_BUFLEN(lcfg, 0) + sizeof(clli->cfg_instance) * 2 + 4; OBD_ALLOC(inst_name, inst_len); - if (inst_name == NULL) - GOTO(out, rc = -ENOMEM); + if (inst_name == NULL) { + rc = -ENOMEM; + goto out; + } sprintf(inst_name, "%s-%p", lustre_cfg_string(lcfg, 0), clli->cfg_instance); @@ -1562,7 +1592,7 @@ int class_config_parse_llog(const struct lu_env *env, struct llog_ctxt *ctxt, rc = llog_init_handle(env, llh, LLOG_F_IS_PLAIN, NULL); if (rc) - GOTO(parse_out, rc); + goto parse_out; /* continue processing from where we last stopped to end-of-log */ if (cfg) { @@ -1674,7 +1704,7 @@ int class_config_dump_llog(const struct lu_env *env, struct llog_ctxt *ctxt, rc = llog_init_handle(env, llh, LLOG_F_IS_PLAIN, NULL); if (rc) - GOTO(parse_out, rc); + goto parse_out; rc = llog_process(env, llh, class_config_dump_handler, cfg, NULL); parse_out: @@ -1717,7 +1747,7 @@ int class_manual_cleanup(struct obd_device *obd) rc = class_process_config(lcfg); if (rc) { CERROR("cleanup failed %d: %s\n", rc, obd->obd_name); - GOTO(out, rc); + goto out; } /* the lcfg is almost the same for both ops */ |