* 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/
*/
int sptlrpc_rule_set_expand(struct sptlrpc_rule_set *rset)
{
- struct sptlrpc_rule *rules;
- int nslot;
+ struct sptlrpc_rule *rules;
+ int nslot;
- cfs_might_sleep();
+ might_sleep();
- if (rset->srs_nrule < rset->srs_nslot)
- return 0;
+ if (rset->srs_nrule < rset->srs_nslot)
+ return 0;
- nslot = rset->srs_nslot + 8;
+ nslot = rset->srs_nslot + 8;
/* better use realloc() if available */
OBD_ALLOC(rules, nslot * sizeof(*rset->srs_rules));
int sptlrpc_rule_set_merge(struct sptlrpc_rule_set *rset,
struct sptlrpc_rule *rule)
{
- struct sptlrpc_rule *p = rset->srs_rules;
- int spec_dir, spec_net;
- int rc, n, match = 0;
+ struct sptlrpc_rule *p = rset->srs_rules;
+ int spec_dir, spec_net;
+ int rc, n, match = 0;
- cfs_might_sleep();
+ might_sleep();
- spec_net = rule_spec_net(rule);
- spec_dir = rule_spec_dir(rule);
+ spec_net = rule_spec_net(rule);
+ spec_dir = rule_spec_dir(rule);
for (n = 0; n < rset->srs_nrule; n++) {
p = &rset->srs_rules[n];
enum lustre_sec_part to,
struct sptlrpc_rule_set *rset)
{
- struct sptlrpc_rule_set *src[2] = { gen, tgt };
- struct sptlrpc_rule *rule;
- int i, n, rc;
+ struct sptlrpc_rule_set *src[2] = { gen, tgt };
+ struct sptlrpc_rule *rule;
+ int i, n, rc;
- cfs_might_sleep();
+ might_sleep();
- /* merge general rules firstly, then target-specific rules */
- for (i = 0; i < 2; i++) {
- if (src[i] == NULL)
- continue;
+ /* merge general rules firstly, then target-specific rules */
+ for (i = 0; i < 2; i++) {
+ if (src[i] == NULL)
+ continue;
for (n = 0; n < src[i]->srs_nrule; n++) {
rule = &src[i]->srs_rules[n];
OBD_ALLOC_PTR(conf_tgt);
if (conf_tgt) {
- strncpy(conf_tgt->sct_name, name, sizeof(conf_tgt->sct_name));
+ strlcpy(conf_tgt->sct_name, name, sizeof(conf_tgt->sct_name));
sptlrpc_rule_set_init(&conf_tgt->sct_rset);
cfs_list_add(&conf_tgt->sct_list, &conf->sc_tgts);
}
if (conf == NULL)
return NULL;
- strcpy(conf->sc_fsname, fsname);
+ if (strlcpy(conf->sc_fsname, fsname, sizeof(conf->sc_fsname)) >=
+ sizeof(conf->sc_fsname)) {
+ OBD_FREE_PTR(conf);
+ return NULL;
+ }
sptlrpc_rule_set_init(&conf->sc_rset);
CFS_INIT_LIST_HEAD(&conf->sc_tgts);
cfs_list_add(&conf->sc_list, &sptlrpc_confs);
mutex_lock(&sptlrpc_conf_lock);
conf = sptlrpc_conf_get(fsname, 0);
- if (conf && conf->sc_local) {
- LASSERT(conf->sc_updated == 0);
- sptlrpc_conf_free_rsets(conf);
- }
- conf->sc_modified = 0;
+ if (conf) {
+ if (conf->sc_local) {
+ LASSERT(conf->sc_updated == 0);
+ sptlrpc_conf_free_rsets(conf);
+ }
+ conf->sc_modified = 0;
+ }
mutex_unlock(&sptlrpc_conf_lock);
}
int rc;
ENTRY;
- ctxt = llog_get_context(obd, LLOG_CONFIG_ORIG_CTXT);
+ ctxt = llog_get_context(obd, LLOG_CONFIG_ORIG_CTXT);
if (ctxt == NULL)
- RETURN(-EINVAL);
+ RETURN(-EINVAL);
- push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
+ push_ctxt(&saved, &obd->obd_lvfs_ctxt);
- dentry = ll_lookup_one_len(MOUNT_CONFIGS_DIR, cfs_fs_pwd(current->fs),
+ dentry = ll_lookup_one_len(MOUNT_CONFIGS_DIR, current->fs->pwd.dentry,
strlen(MOUNT_CONFIGS_DIR));
if (IS_ERR(dentry)) {
rc = PTR_ERR(dentry);
rc = lustre_rename(dentry, obd->obd_lvfs_ctxt.pwdmnt,
LOG_SPTLRPC_TMP, LOG_SPTLRPC);
out_dput:
- l_dput(dentry);
+ dput(dentry);
out_ctx:
- pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
- llog_ctxt_put(ctxt);
- CDEBUG(D_SEC, "target %s: write local sptlrpc conf: rc = %d\n",
- obd->obd_name, rc);
- RETURN(rc);
+ pop_ctxt(&saved, &obd->obd_lvfs_ctxt);
+ llog_ctxt_put(ctxt);
+ CDEBUG(D_SEC, "target %s: write local sptlrpc conf: rc = %d\n",
+ obd->obd_name, rc);
+ RETURN(rc);
}
static int local_read_handler(const struct lu_env *env,
RETURN(-EINVAL);
}
- push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
+ push_ctxt(&saved, &obd->obd_lvfs_ctxt);
rc = llog_open(NULL, ctxt, &llh, NULL, LOG_SPTLRPC, LLOG_OPEN_EXISTS);
if (rc < 0) {
out_close:
llog_close(NULL, llh);
out_pop:
- pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
- llog_ctxt_put(ctxt);
- CDEBUG(D_SEC, "target %s: read local sptlrpc conf: rc = %d\n",
- obd->obd_name, rc);
- RETURN(rc);
+ pop_ctxt(&saved, &obd->obd_lvfs_ctxt);
+ llog_ctxt_put(ctxt);
+ CDEBUG(D_SEC, "target %s: read local sptlrpc conf: rc = %d\n",
+ obd->obd_name, rc);
+ RETURN(rc);
}
#endif /* __KRENEL__ */