-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
+/*
* GPL HEADER START
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
/*
* Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
* Use is subject to license terms.
+ *
+ * Copyright (c) 2011, 2012, Whamcloud, Inc.
*/
/*
* This file is part of Lustre, http://www.lustre.org/
* Author: Eric Mei <ericm@clusterfs.com>
*/
-#ifndef EXPORT_SYMTAB
-#define EXPORT_SYMTAB
-#endif
#define DEBUG_SUBSYSTEM S_SEC
#include <libcfs/libcfs.h>
static
struct ptlrpc_sec_policy * sptlrpc_wireflavor2policy(__u32 flavor)
{
- static CFS_DECLARE_MUTEX(load_mutex);
+ static CFS_DEFINE_MUTEX(load_mutex);
static cfs_atomic_t loaded = CFS_ATOMIC_INIT(0);
struct ptlrpc_sec_policy *policy;
__u16 number = SPTLRPC_FLVR_POLICY(flavor);
break;
/* try to load gss module, once */
- cfs_mutex_down(&load_mutex);
+ cfs_mutex_lock(&load_mutex);
if (cfs_atomic_read(&loaded) == 0) {
if (cfs_request_module("ptlrpc_gss") == 0)
- CWARN("module ptlrpc_gss loaded on demand\n");
+ CDEBUG(D_SEC,
+ "module ptlrpc_gss loaded on demand\n");
else
CERROR("Unable to load module ptlrpc_gss\n");
cfs_atomic_set(&loaded, 1);
}
- cfs_mutex_up(&load_mutex);
+ cfs_mutex_unlock(&load_mutex);
}
return policy;
char *sptlrpc_secflags2str(__u32 flags, char *buf, int bufsize)
{
- buf[0] = '\0';
+ buf[0] = '\0';
- if (flags & PTLRPC_SEC_FL_REVERSE)
- strncat(buf, "reverse,", bufsize);
- if (flags & PTLRPC_SEC_FL_ROOTONLY)
- strncat(buf, "rootonly,", bufsize);
- if (flags & PTLRPC_SEC_FL_UDESC)
- strncat(buf, "udesc,", bufsize);
- if (flags & PTLRPC_SEC_FL_BULK)
- strncat(buf, "bulk,", bufsize);
- if (buf[0] == '\0')
- strncat(buf, "-,", bufsize);
+ if (flags & PTLRPC_SEC_FL_REVERSE)
+ strlcat(buf, "reverse,", bufsize);
+ if (flags & PTLRPC_SEC_FL_ROOTONLY)
+ strlcat(buf, "rootonly,", bufsize);
+ if (flags & PTLRPC_SEC_FL_UDESC)
+ strlcat(buf, "udesc,", bufsize);
+ if (flags & PTLRPC_SEC_FL_BULK)
+ strlcat(buf, "bulk,", bufsize);
+ if (buf[0] == '\0')
+ strlcat(buf, "-,", bufsize);
- buf[bufsize - 1] = '\0';
- return buf;
+ return buf;
}
EXPORT_SYMBOL(sptlrpc_secflags2str);
LASSERT(req->rq_reqlen);
LASSERT(req->rq_replen);
- CWARN("req %p: switch ctx %p(%u->%s) -> %p(%u->%s), "
- "switch sec %p(%s) -> %p(%s)\n", req,
- oldctx, oldctx->cc_vcred.vc_uid, sec2target_str(oldctx->cc_sec),
- newctx, newctx->cc_vcred.vc_uid, sec2target_str(newctx->cc_sec),
- oldctx->cc_sec, oldctx->cc_sec->ps_policy->sp_name,
- newctx->cc_sec, newctx->cc_sec->ps_policy->sp_name);
+ CDEBUG(D_SEC, "req %p: switch ctx %p(%u->%s) -> %p(%u->%s), "
+ "switch sec %p(%s) -> %p(%s)\n", req,
+ oldctx, oldctx->cc_vcred.vc_uid, sec2target_str(oldctx->cc_sec),
+ newctx, newctx->cc_vcred.vc_uid, sec2target_str(newctx->cc_sec),
+ oldctx->cc_sec, oldctx->cc_sec->ps_policy->sp_name,
+ newctx->cc_sec, newctx->cc_sec->ps_policy->sp_name);
/* save flavor */
old_flvr = req->rq_flvr;
/*
* still get the old dead ctx, usually means system too busy
*/
- CWARN("ctx (%p, fl %lx) doesn't switch, relax a little bit\n",
- newctx, newctx->cc_flags);
+ CDEBUG(D_SEC,
+ "ctx (%p, fl %lx) doesn't switch, relax a little bit\n",
+ newctx, newctx->cc_flags);
cfs_schedule_timeout_and_set_state(CFS_TASK_INTERRUPTIBLE,
CFS_HZ);
switch (opcode) {
case OST_READ:
case MDS_READPAGE:
+ case MGS_CONFIG_READ:
+ case OBD_IDX_READ:
req->rq_bulk_read = 1;
break;
case OST_WRITE:
char str1[32], str2[32];
if (sec->ps_flvr.sf_flags != sf->sf_flags)
- CWARN("changing sec flags: %s -> %s\n",
- sptlrpc_secflags2str(sec->ps_flvr.sf_flags,
- str1, sizeof(str1)),
- sptlrpc_secflags2str(sf->sf_flags,
- str2, sizeof(str2)));
+ CDEBUG(D_SEC, "changing sec flags: %s -> %s\n",
+ sptlrpc_secflags2str(sec->ps_flvr.sf_flags,
+ str1, sizeof(str1)),
+ sptlrpc_secflags2str(sf->sf_flags,
+ str2, sizeof(str2)));
cfs_spin_lock(&sec->ps_lock);
flavor_copy(&sec->ps_flvr, sf);
if (flavor_equal(&sf, &sec->ps_flvr))
GOTO(out, rc);
- CWARN("import %s->%s: changing flavor %s -> %s\n",
- imp->imp_obd->obd_name,
- obd_uuid2str(&conn->c_remote_uuid),
- sptlrpc_flavor2name(&sec->ps_flvr, str, sizeof(str)),
- sptlrpc_flavor2name(&sf, str2, sizeof(str2)));
+ CDEBUG(D_SEC, "import %s->%s: changing flavor %s -> %s\n",
+ imp->imp_obd->obd_name,
+ obd_uuid2str(&conn->c_remote_uuid),
+ sptlrpc_flavor2name(&sec->ps_flvr, str, sizeof(str)),
+ sptlrpc_flavor2name(&sf, str2, sizeof(str2)));
if (SPTLRPC_FLVR_POLICY(sf.sf_rpc) ==
SPTLRPC_FLVR_POLICY(sec->ps_flvr.sf_rpc) &&
sptlrpc_import_sec_adapt_inplace(imp, sec, &sf);
GOTO(out, rc);
}
- } else if (sptlrpc_flavor2name_base(sf.sf_rpc) != SPTLRPC_FLVR_NULL) {
- LCONSOLE_INFO("import %s->%s netid %x: select flavor %s\n",
- imp->imp_obd->obd_name,
- obd_uuid2str(&conn->c_remote_uuid),
- LNET_NIDNET(conn->c_self),
- sptlrpc_flavor2name(&sf, str, sizeof(str)));
+ } else if (SPTLRPC_FLVR_BASE(sf.sf_rpc) !=
+ SPTLRPC_FLVR_BASE(SPTLRPC_FLVR_NULL)) {
+ CDEBUG(D_SEC, "import %s->%s netid %x: select flavor %s\n",
+ imp->imp_obd->obd_name,
+ obd_uuid2str(&conn->c_remote_uuid),
+ LNET_NIDNET(conn->c_self),
+ sptlrpc_flavor2name(&sf, str, sizeof(str)));
}
- cfs_mutex_down(&imp->imp_sec_mutex);
+ cfs_mutex_lock(&imp->imp_sec_mutex);
newsec = sptlrpc_sec_create(imp, svc_ctx, &sf, sp);
if (newsec) {
rc = -EPERM;
}
- cfs_mutex_up(&imp->imp_sec_mutex);
+ cfs_mutex_unlock(&imp->imp_sec_mutex);
out:
sptlrpc_sec_put(sec);
RETURN(rc);
rc = policy->sp_sops->alloc_rs(req, msglen);
if (unlikely(rc == -ENOMEM)) {
/* failed alloc, try emergency pool */
- rs = lustre_get_emerg_rs(req->rq_rqbd->rqbd_service);
+ rs = lustre_get_emerg_rs(req->rq_rqbd->rqbd_svcpt);
if (rs == NULL)
RETURN(-ENOMEM);
}
EXPORT_SYMBOL(sptlrpc_cli_unwrap_bulk_write);
+#ifdef HAVE_SERVER_SUPPORT
/**
* Performe transformation upon outgoing bulk read.
*/
}
EXPORT_SYMBOL(sptlrpc_svc_prep_bulk);
+#endif /* HAVE_SERVER_SUPPORT */
+
/****************************************
* user descriptor helpers *
****************************************/
* initialize/finalize *
****************************************/
-int __init sptlrpc_init(void)
+int sptlrpc_init(void)
{
int rc;
return rc;
}
-void __exit sptlrpc_fini(void)
+void sptlrpc_fini(void)
{
sptlrpc_lproc_fini();
sptlrpc_plain_fini();