X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Fptlrpc%2Fsec_config.c;h=74f1b657d76ef7f67d54e7f05a354b0e94e37aca;hb=f4547f0569774eb794fb143362e201f658415f4c;hp=e0b8ebb082838db08ab41ac1a597f5b40026f45e;hpb=2d617260aaa5f778ab8dcb006e2a827f4b8f8567;p=fs%2Flustre-release.git diff --git a/lustre/ptlrpc/sec_config.c b/lustre/ptlrpc/sec_config.c index e0b8ebb..74f1b65 100644 --- a/lustre/ptlrpc/sec_config.c +++ b/lustre/ptlrpc/sec_config.c @@ -27,7 +27,7 @@ * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. * Use is subject to license terms. * - * Copyright (c) 2011, Whamcloud, Inc. + * Copyright (c) 2011, 2012, Intel Corporation. */ /* * This file is part of Lustre, http://www.lustre.org/ @@ -515,7 +515,7 @@ struct sptlrpc_conf { cfs_list_t sc_tgts; /* target-specific rules */ }; -static cfs_mutex_t sptlrpc_conf_lock; +static struct mutex sptlrpc_conf_lock; static CFS_LIST_HEAD(sptlrpc_confs); static inline int is_hex(char c) @@ -696,7 +696,7 @@ static int __sptlrpc_process_config(struct lustre_cfg *lcfg, if (conf == NULL) { target2fsname(target, fsname, sizeof(fsname)); - cfs_mutex_lock(&sptlrpc_conf_lock); + mutex_lock(&sptlrpc_conf_lock); conf = sptlrpc_conf_get(fsname, 0); if (conf == NULL) { CERROR("can't find conf\n"); @@ -704,9 +704,9 @@ static int __sptlrpc_process_config(struct lustre_cfg *lcfg, } else { rc = sptlrpc_conf_merge_rule(conf, target, &rule); } - cfs_mutex_unlock(&sptlrpc_conf_lock); + mutex_unlock(&sptlrpc_conf_lock); } else { - LASSERT(cfs_mutex_is_locked(&sptlrpc_conf_lock)); + LASSERT(mutex_is_locked(&sptlrpc_conf_lock)); rc = sptlrpc_conf_merge_rule(conf, target, &rule); } @@ -748,7 +748,7 @@ void sptlrpc_conf_log_update_begin(const char *logname) if (logname2fsname(logname, fsname, sizeof(fsname))) return; - cfs_mutex_lock(&sptlrpc_conf_lock); + mutex_lock(&sptlrpc_conf_lock); conf = sptlrpc_conf_get(fsname, 0); if (conf && conf->sc_local) { @@ -757,7 +757,7 @@ void sptlrpc_conf_log_update_begin(const char *logname) } conf->sc_modified = 0; - cfs_mutex_unlock(&sptlrpc_conf_lock); + mutex_unlock(&sptlrpc_conf_lock); } EXPORT_SYMBOL(sptlrpc_conf_log_update_begin); @@ -772,7 +772,7 @@ void sptlrpc_conf_log_update_end(const char *logname) if (logname2fsname(logname, fsname, sizeof(fsname))) return; - cfs_mutex_lock(&sptlrpc_conf_lock); + mutex_lock(&sptlrpc_conf_lock); conf = sptlrpc_conf_get(fsname, 0); if (conf) { @@ -786,7 +786,7 @@ void sptlrpc_conf_log_update_end(const char *logname) conf->sc_updated = 1; } - cfs_mutex_unlock(&sptlrpc_conf_lock); + mutex_unlock(&sptlrpc_conf_lock); } EXPORT_SYMBOL(sptlrpc_conf_log_update_end); @@ -797,9 +797,9 @@ void sptlrpc_conf_log_start(const char *logname) if (logname2fsname(logname, fsname, sizeof(fsname))) return; - cfs_mutex_lock(&sptlrpc_conf_lock); + mutex_lock(&sptlrpc_conf_lock); sptlrpc_conf_get(fsname, 1); - cfs_mutex_unlock(&sptlrpc_conf_lock); + mutex_unlock(&sptlrpc_conf_lock); } EXPORT_SYMBOL(sptlrpc_conf_log_start); @@ -811,11 +811,11 @@ void sptlrpc_conf_log_stop(const char *logname) if (logname2fsname(logname, fsname, sizeof(fsname))) return; - cfs_mutex_lock(&sptlrpc_conf_lock); + mutex_lock(&sptlrpc_conf_lock); conf = sptlrpc_conf_get(fsname, 0); if (conf) sptlrpc_conf_free(conf); - cfs_mutex_unlock(&sptlrpc_conf_lock); + mutex_unlock(&sptlrpc_conf_lock); } EXPORT_SYMBOL(sptlrpc_conf_log_stop); @@ -857,7 +857,7 @@ void sptlrpc_conf_choose_flavor(enum lustre_sec_part from, target2fsname(target->uuid, name, sizeof(name)); - cfs_mutex_lock(&sptlrpc_conf_lock); + mutex_lock(&sptlrpc_conf_lock); conf = sptlrpc_conf_get(name, 0); if (conf == NULL) @@ -879,7 +879,7 @@ void sptlrpc_conf_choose_flavor(enum lustre_sec_part from, rc = sptlrpc_rule_set_choose(&conf->sc_rset, from, to, nid, sf); out: - cfs_mutex_unlock(&sptlrpc_conf_lock); + mutex_unlock(&sptlrpc_conf_lock); if (rc == 0) get_default_flavor(sf); @@ -917,19 +917,19 @@ void sptlrpc_conf_client_adapt(struct obd_device *obd) CDEBUG(D_SEC, "obd %s\n", obd->u.cli.cl_target_uuid.uuid); /* serialize with connect/disconnect import */ - cfs_down_read(&obd->u.cli.cl_sem); - - imp = obd->u.cli.cl_import; - if (imp) { - cfs_spin_lock(&imp->imp_lock); - if (imp->imp_sec) - imp->imp_sec_expire = cfs_time_current_sec() + - SEC_ADAPT_DELAY; - cfs_spin_unlock(&imp->imp_lock); - } - - cfs_up_read(&obd->u.cli.cl_sem); - EXIT; + down_read(&obd->u.cli.cl_sem); + + imp = obd->u.cli.cl_import; + if (imp) { + spin_lock(&imp->imp_lock); + if (imp->imp_sec) + imp->imp_sec_expire = cfs_time_current_sec() + + SEC_ADAPT_DELAY; + spin_unlock(&imp->imp_lock); + } + + up_read(&obd->u.cli.cl_sem); + EXIT; } EXPORT_SYMBOL(sptlrpc_conf_client_adapt); @@ -983,7 +983,7 @@ static int sptlrpc_record_rule_set(struct llog_handle *llh, lcfg->lcfg_buflens); rec.lrh_len = llog_data_len(buflen); rec.lrh_type = OBD_CFG_REC; - rc = llog_write_rec(NULL, llh, &rec, NULL, 0, (void *)lcfg, -1); + rc = llog_write(NULL, llh, &rec, NULL, 0, (void *)lcfg, -1); if (rc) CERROR("failed to write a rec: rc = %d\n", rc); lustre_cfg_free(lcfg); @@ -1020,10 +1020,8 @@ int sptlrpc_target_local_copy_conf(struct obd_device *obd, ENTRY; ctxt = llog_get_context(obd, LLOG_CONFIG_ORIG_CTXT); - if (ctxt == NULL) { - CERROR("missing llog context\n"); + if (ctxt == NULL) RETURN(-EINVAL); - } push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL); @@ -1037,25 +1035,15 @@ int sptlrpc_target_local_copy_conf(struct obd_device *obd, } /* erase the old tmp log */ - rc = llog_create(NULL, ctxt, &llh, NULL, LOG_SPTLRPC_TMP); - if (rc == 0) { - rc = llog_init_handle(NULL, llh, LLOG_F_IS_PLAIN, NULL); - if (rc == 0) { - rc = llog_destroy(NULL, llh); - llog_free_handle(llh); - } else { - llog_close(NULL, llh); - } - } - - if (rc) { - CERROR("target %s: cannot erase temporary sptlrpc log: " - "rc = %d\n", obd->obd_name, rc); - GOTO(out_dput, rc); - } + rc = llog_erase(NULL, ctxt, NULL, LOG_SPTLRPC_TMP); + if (rc < 0 && rc != -ENOENT) { + CERROR("%s: cannot erase temporary sptlrpc log: rc = %d\n", + obd->obd_name, rc); + GOTO(out_dput, rc); + } - /* write temporary log */ - rc = llog_create(NULL, ctxt, &llh, NULL, LOG_SPTLRPC_TMP); + /* write temporary log */ + rc = llog_open_create(NULL, ctxt, &llh, NULL, LOG_SPTLRPC_TMP); if (rc) GOTO(out_dput, rc); rc = llog_init_handle(NULL, llh, LLOG_F_IS_PLAIN, NULL); @@ -1066,12 +1054,9 @@ int sptlrpc_target_local_copy_conf(struct obd_device *obd, out_close: llog_close(NULL, llh); - - if (rc == 0) { - rc = lustre_rename(dentry, obd->obd_lvfs_ctxt.pwdmnt, - LOG_SPTLRPC_TMP, LOG_SPTLRPC); - } - + if (rc == 0) + rc = lustre_rename(dentry, obd->obd_lvfs_ctxt.pwdmnt, + LOG_SPTLRPC_TMP, LOG_SPTLRPC); out_dput: l_dput(dentry); out_ctx: @@ -1133,9 +1118,12 @@ int sptlrpc_target_local_read_conf(struct obd_device *obd, push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL); - rc = llog_create(NULL, ctxt, &llh, NULL, LOG_SPTLRPC); - if (rc) + rc = llog_open(NULL, ctxt, &llh, NULL, LOG_SPTLRPC, LLOG_OPEN_EXISTS); + if (rc < 0) { + if (rc == -ENOENT) + rc = 0; GOTO(out_pop, rc); + } rc = llog_init_handle(NULL, llh, LLOG_F_IS_PLAIN, NULL); if (rc) @@ -1193,7 +1181,7 @@ int sptlrpc_conf_target_get_rules(struct obd_device *obd, target2fsname(obd->obd_uuid.uuid, fsname, sizeof(fsname)); - cfs_mutex_lock(&sptlrpc_conf_lock); + mutex_lock(&sptlrpc_conf_lock); conf = sptlrpc_conf_get(fsname, 0); if (conf == NULL) { @@ -1230,14 +1218,14 @@ int sptlrpc_conf_target_get_rules(struct obd_device *obd, conf_tgt ? &conf_tgt->sct_rset: NULL, LUSTRE_SP_ANY, sp_dst, rset); out: - cfs_mutex_unlock(&sptlrpc_conf_lock); + mutex_unlock(&sptlrpc_conf_lock); RETURN(rc); } EXPORT_SYMBOL(sptlrpc_conf_target_get_rules); int sptlrpc_conf_init(void) { - cfs_mutex_init(&sptlrpc_conf_lock); + mutex_init(&sptlrpc_conf_lock); return 0; } @@ -1245,10 +1233,10 @@ void sptlrpc_conf_fini(void) { struct sptlrpc_conf *conf, *conf_next; - cfs_mutex_lock(&sptlrpc_conf_lock); + mutex_lock(&sptlrpc_conf_lock); cfs_list_for_each_entry_safe(conf, conf_next, &sptlrpc_confs, sc_list) { sptlrpc_conf_free(conf); } LASSERT(cfs_list_empty(&sptlrpc_confs)); - cfs_mutex_unlock(&sptlrpc_conf_lock); + mutex_unlock(&sptlrpc_conf_lock); }