#define DEBUG_SUBSYSTEM S_SEC
-#ifdef __KERNEL__
#include <linux/version.h>
#include <linux/fs.h>
#include <asm/unistd.h>
#include <obd_class.h>
#include <lustre_debug.h>
#include <lustre/lustre_idl.h>
-#else
-#include <liblustre.h>
-#endif
#include <libcfs/list.h>
#include <lustre_capa.h>
struct kmem_cache *capa_cachep;
-#ifdef __KERNEL__
/* lock for capa hash/capa_list/fo_capa_keys */
DEFINE_SPINLOCK(capa_lock);
-cfs_list_t capa_list[CAPA_SITE_MAX];
+struct list_head capa_list[CAPA_SITE_MAX];
static struct capa_hmac_alg capa_hmac_algs[] = {
DEF_CAPA_HMAC_ALG("sha1", SHA1, 20, 20),
};
-#endif
/* capa count */
int capa_count[CAPA_SITE_MAX] = { 0, };
EXPORT_SYMBOL(capa_lock);
EXPORT_SYMBOL(capa_count);
-cfs_hlist_head_t *init_capa_hash(void)
+struct hlist_head *init_capa_hash(void)
{
- cfs_hlist_head_t *hash;
+ struct hlist_head *hash;
int nr_hash, i;
OBD_ALLOC(hash, PAGE_CACHE_SIZE);
if (!hash)
return NULL;
- nr_hash = PAGE_CACHE_SIZE / sizeof(cfs_hlist_head_t);
+ nr_hash = PAGE_CACHE_SIZE / sizeof(struct hlist_head);
LASSERT(nr_hash > NR_CAPAHASH);
for (i = 0; i < NR_CAPAHASH; i++)
- CFS_INIT_HLIST_HEAD(hash + i);
+ INIT_HLIST_HEAD(hash + i);
return hash;
}
EXPORT_SYMBOL(init_capa_hash);
-#ifdef __KERNEL__
static inline int capa_on_server(struct obd_capa *ocapa)
{
return ocapa->c_site == CAPA_SITE_SERVER;
static inline void capa_delete(struct obd_capa *ocapa)
{
- LASSERT(capa_on_server(ocapa));
- cfs_hlist_del_init(&ocapa->u.tgt.c_hash);
- cfs_list_del_init(&ocapa->c_list);
- capa_count[ocapa->c_site]--;
- /* release the ref when alloc */
- capa_put(ocapa);
+ LASSERT(capa_on_server(ocapa));
+ hlist_del_init(&ocapa->u.tgt.c_hash);
+ list_del_init(&ocapa->c_list);
+ capa_count[ocapa->c_site]--;
+ /* release the ref when alloc */
+ capa_put(ocapa);
}
-void cleanup_capa_hash(cfs_hlist_head_t *hash)
+void cleanup_capa_hash(struct hlist_head *hash)
{
- int i;
- cfs_hlist_node_t *pos, *next;
+ struct hlist_node __maybe_unused *pos;
+ struct hlist_node *next;
struct obd_capa *oc;
+ int i;
spin_lock(&capa_lock);
for (i = 0; i < NR_CAPAHASH; i++) {
}
static struct obd_capa *find_capa(struct lustre_capa *capa,
- cfs_hlist_head_t *head, int alive)
+ struct hlist_head *head, int alive)
{
- cfs_hlist_node_t *pos;
- struct obd_capa *ocapa;
- int len = alive ? offsetof(struct lustre_capa, lc_keyid):sizeof(*capa);
+ struct hlist_node __maybe_unused *pos;
+ struct obd_capa *ocapa;
+ int len = alive ? offsetof(struct lustre_capa, lc_keyid):sizeof(*capa);
- cfs_hlist_for_each_entry(ocapa, pos, head, u.tgt.c_hash) {
- if (memcmp(&ocapa->c_capa, capa, len))
- continue;
- /* don't return one that will expire soon in this case */
- if (alive && capa_is_to_expire(ocapa))
- continue;
+ cfs_hlist_for_each_entry(ocapa, pos, head, u.tgt.c_hash) {
+ if (memcmp(&ocapa->c_capa, capa, len))
+ continue;
+ /* don't return one that will expire soon in this case */
+ if (alive && capa_is_to_expire(ocapa))
+ continue;
LASSERT(capa_on_server(ocapa));
}
#define LRU_CAPA_DELETE_COUNT 12
-static inline void capa_delete_lru(cfs_list_t *head)
+static inline void capa_delete_lru(struct list_head *head)
{
- struct obd_capa *ocapa;
- cfs_list_t *node = head->next;
- int count = 0;
-
- /* free LRU_CAPA_DELETE_COUNT unused capa from head */
- while (count++ < LRU_CAPA_DELETE_COUNT) {
- ocapa = cfs_list_entry(node, struct obd_capa, c_list);
- node = node->next;
+ struct obd_capa *ocapa;
+ struct list_head *node = head->next;
+ int count = 0;
+
+ /* free LRU_CAPA_DELETE_COUNT unused capa from head */
+ while (count++ < LRU_CAPA_DELETE_COUNT) {
+ ocapa = list_entry(node, struct obd_capa, c_list);
+ node = node->next;
if (atomic_read(&ocapa->c_refc))
- continue;
+ continue;
- DEBUG_CAPA(D_SEC, &ocapa->c_capa, "free lru");
- capa_delete(ocapa);
- }
+ DEBUG_CAPA(D_SEC, &ocapa->c_capa, "free lru");
+ capa_delete(ocapa);
+ }
}
/* add or update */
-struct obd_capa *capa_add(cfs_hlist_head_t *hash, struct lustre_capa *capa)
+struct obd_capa *capa_add(struct hlist_head *hash, struct lustre_capa *capa)
{
- cfs_hlist_head_t *head = hash + capa_hashfn(&capa->lc_fid);
+ struct hlist_head *head = hash + capa_hashfn(&capa->lc_fid);
struct obd_capa *ocapa, *old = NULL;
- cfs_list_t *list = &capa_list[CAPA_SITE_SERVER];
+ struct list_head *list = &capa_list[CAPA_SITE_SERVER];
ocapa = alloc_capa(CAPA_SITE_SERVER);
if (IS_ERR(ocapa))
if (!old) {
ocapa->c_capa = *capa;
set_capa_expiry(ocapa);
- cfs_hlist_add_head(&ocapa->u.tgt.c_hash, head);
- cfs_list_add_tail(&ocapa->c_list, list);
+ hlist_add_head(&ocapa->u.tgt.c_hash, head);
+ list_add_tail(&ocapa->c_list, list);
capa_get(ocapa);
capa_count[CAPA_SITE_SERVER]++;
if (capa_count[CAPA_SITE_SERVER] > CAPA_HASH_SIZE)
}
EXPORT_SYMBOL(capa_add);
-struct obd_capa *capa_lookup(cfs_hlist_head_t *hash, struct lustre_capa *capa,
+struct obd_capa *capa_lookup(struct hlist_head *hash, struct lustre_capa *capa,
int alive)
{
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]);
+ list_move_tail(&ocapa->c_list, &capa_list[CAPA_SITE_SERVER]);
capa_get(ocapa);
}
spin_unlock(&capa_lock);
alg = &capa_hmac_algs[capa_alg(capa)];
tfm = crypto_alloc_hash(alg->ha_name, 0, 0);
- if (!tfm) {
+ if (IS_ERR(tfm)) {
CERROR("crypto_alloc_tfm failed, check whether your kernel"
"has crypto support!\n");
- return -ENOMEM;
+ return PTR_ERR(tfm);
}
keylen = alg->ha_keylen;
+ sg_init_table(&sl, 1);
sg_set_page(&sl, virt_to_page(capa),
offsetof(struct lustre_capa, lc_hmac),
(unsigned long)(capa) % PAGE_CACHE_SIZE);
GOTO(out, rc);
}
+ sg_init_table(&sd, 1);
sg_set_page(&sd, virt_to_page(d), 16,
(unsigned long)(d) % PAGE_CACHE_SIZE);
+ sg_init_table(&ss, 1);
sg_set_page(&ss, virt_to_page(s), 16,
(unsigned long)(s) % PAGE_CACHE_SIZE);
desc.tfm = tfm;
GOTO(out, rc);
}
+ sg_init_table(&sd, 1);
sg_set_page(&sd, virt_to_page(d), 16,
(unsigned long)(d) % PAGE_CACHE_SIZE);
+ sg_init_table(&ss, 1);
sg_set_page(&ss, virt_to_page(s), 16,
(unsigned long)(s) % PAGE_CACHE_SIZE);
return rc;
}
EXPORT_SYMBOL(capa_decrypt_id);
-#endif
void capa_cpy(void *capa, struct obd_capa *ocapa)
{