-/* -*- 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) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* Use is subject to license terms.
+ *
+ * Copyright (c) 2012, Intel Corporation.
*/
/*
* This file is part of Lustre, http://www.lustre.org/
* Author: Lai Siyao<lsy@clusterfs.com>
*/
-#ifndef EXPORT_SYMTAB
-# define EXPORT_SYMTAB
-#endif
-
#define DEBUG_SUBSYSTEM S_SEC
#ifdef __KERNEL__
#ifdef __KERNEL__
/* lock for capa hash/capa_list/fo_capa_keys */
-cfs_spinlock_t capa_lock = CFS_SPIN_LOCK_UNLOCKED;
+DEFINE_SPINLOCK(capa_lock);
cfs_list_t capa_list[CAPA_SITE_MAX];
CFS_INIT_HLIST_HEAD(hash + i);
return hash;
}
+EXPORT_SYMBOL(init_capa_hash);
#ifdef __KERNEL__
static inline int capa_on_server(struct obd_capa *ocapa)
void cleanup_capa_hash(cfs_hlist_head_t *hash)
{
- int i;
- cfs_hlist_node_t *pos, *next;
- struct obd_capa *oc;
-
- cfs_spin_lock(&capa_lock);
- for (i = 0; i < NR_CAPAHASH; i++) {
- cfs_hlist_for_each_entry_safe(oc, pos, next, hash + i,
- u.tgt.c_hash)
- capa_delete(oc);
- }
- cfs_spin_unlock(&capa_lock);
-
- OBD_FREE(hash, CFS_PAGE_SIZE);
+ int i;
+ cfs_hlist_node_t *pos, *next;
+ struct obd_capa *oc;
+
+ spin_lock(&capa_lock);
+ for (i = 0; i < NR_CAPAHASH; i++) {
+ cfs_hlist_for_each_entry_safe(oc, pos, next, hash + i,
+ u.tgt.c_hash)
+ capa_delete(oc);
+ }
+ spin_unlock(&capa_lock);
+
+ OBD_FREE(hash, CFS_PAGE_SIZE);
}
+EXPORT_SYMBOL(cleanup_capa_hash);
static inline int capa_hashfn(struct lu_fid *fid)
{
if (IS_ERR(ocapa))
return NULL;
- cfs_spin_lock(&capa_lock);
+ spin_lock(&capa_lock);
old = find_capa(capa, head, 0);
if (!old) {
ocapa->c_capa = *capa;
capa_count[CAPA_SITE_SERVER]++;
if (capa_count[CAPA_SITE_SERVER] > CAPA_HASH_SIZE)
capa_delete_lru(list);
- cfs_spin_unlock(&capa_lock);
- return ocapa;
- } else {
- capa_get(old);
- cfs_spin_unlock(&capa_lock);
- capa_put(ocapa);
- return old;
- }
+ spin_unlock(&capa_lock);
+ return ocapa;
+ } else {
+ capa_get(old);
+ spin_unlock(&capa_lock);
+ capa_put(ocapa);
+ return old;
+ }
}
+EXPORT_SYMBOL(capa_add);
struct obd_capa *capa_lookup(cfs_hlist_head_t *hash, struct lustre_capa *capa,
- int alive)
+ int alive)
{
- struct obd_capa *ocapa;
-
- cfs_spin_lock(&capa_lock);
- ocapa = find_capa(capa, hash + capa_hashfn(&capa->lc_fid), alive);
- if (ocapa) {
- cfs_list_move_tail(&ocapa->c_list,
- &capa_list[CAPA_SITE_SERVER]);
- capa_get(ocapa);
- }
- cfs_spin_unlock(&capa_lock);
-
- return ocapa;
+ struct obd_capa *ocapa;
+
+ spin_lock(&capa_lock);
+ ocapa = find_capa(capa, hash + capa_hashfn(&capa->lc_fid), alive);
+ if (ocapa) {
+ cfs_list_move_tail(&ocapa->c_list,
+ &capa_list[CAPA_SITE_SERVER]);
+ capa_get(ocapa);
+ }
+ spin_unlock(&capa_lock);
+
+ return ocapa;
}
+EXPORT_SYMBOL(capa_lookup);
int capa_hmac(__u8 *hmac, struct lustre_capa *capa, __u8 *key)
{
return 0;
}
+EXPORT_SYMBOL(capa_hmac);
int capa_encrypt_id(__u32 *d, __u32 *s, __u8 *key, int keylen)
{
char alg[CRYPTO_MAX_ALG_NAME+1] = "aes";
ENTRY;
- /* passing "aes" in a variable instead of a constant string keeps gcc
- * 4.3.2 happy */
- tfm = ll_crypto_alloc_blkcipher(alg, 0, 0 );
- if (tfm == NULL) {
- CERROR("failed to load transform for aes\n");
- RETURN(-EFAULT);
- }
+ /* passing "aes" in a variable instead of a constant string keeps gcc
+ * 4.3.2 happy */
+ tfm = ll_crypto_alloc_blkcipher(alg, 0, 0 );
+ if (IS_ERR(tfm)) {
+ CERROR("failed to load transform for aes\n");
+ RETURN(PTR_ERR(tfm));
+ }
min = ll_crypto_tfm_alg_min_keysize(tfm);
if (keylen < min) {
ll_crypto_free_blkcipher(tfm);
return rc;
}
+EXPORT_SYMBOL(capa_encrypt_id);
int capa_decrypt_id(__u32 *d, __u32 *s, __u8 *key, int keylen)
{
char alg[CRYPTO_MAX_ALG_NAME+1] = "aes";
ENTRY;
- /* passing "aes" in a variable instead of a constant string keeps gcc
- * 4.3.2 happy */
- tfm = ll_crypto_alloc_blkcipher(alg, 0, 0 );
- if (tfm == NULL) {
- CERROR("failed to load transform for aes\n");
- RETURN(-EFAULT);
- }
+ /* passing "aes" in a variable instead of a constant string keeps gcc
+ * 4.3.2 happy */
+ tfm = ll_crypto_alloc_blkcipher(alg, 0, 0 );
+ if (IS_ERR(tfm)) {
+ CERROR("failed to load transform for aes\n");
+ RETURN(PTR_ERR(tfm));
+ }
min = ll_crypto_tfm_alg_min_keysize(tfm);
if (keylen < min) {
ll_crypto_free_blkcipher(tfm);
return rc;
}
+EXPORT_SYMBOL(capa_decrypt_id);
#endif
void capa_cpy(void *capa, struct obd_capa *ocapa)
{
- cfs_spin_lock(&ocapa->c_lock);
- *(struct lustre_capa *)capa = ocapa->c_capa;
- cfs_spin_unlock(&ocapa->c_lock);
+ spin_lock(&ocapa->c_lock);
+ *(struct lustre_capa *)capa = ocapa->c_capa;
+ spin_unlock(&ocapa->c_lock);
}
+EXPORT_SYMBOL(capa_cpy);
void _debug_capa(struct lustre_capa *c,
struct libcfs_debug_msg_data *msgdata,
va_end(args);
}
EXPORT_SYMBOL(_debug_capa);
-
-EXPORT_SYMBOL(init_capa_hash);
-EXPORT_SYMBOL(cleanup_capa_hash);
-EXPORT_SYMBOL(capa_add);
-EXPORT_SYMBOL(capa_lookup);
-EXPORT_SYMBOL(capa_hmac);
-EXPORT_SYMBOL(capa_encrypt_id);
-EXPORT_SYMBOL(capa_decrypt_id);
-EXPORT_SYMBOL(capa_cpy);