Whamcloud - gitweb
land clio.
[fs/lustre-release.git] / lustre / obdclass / capa.c
index b47b58b..421df58 100644 (file)
@@ -1,27 +1,45 @@
 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
  * vim:expandtab:shiftwidth=8:tabstop=8:
  *
- *  lustre/obdclass/capa.c
- *  Lustre Capability Hash Management
+ * GPL HEADER START
  *
- *  Copyright (c) 2005 Cluster File Systems, Inc.
- *   Author: Lai Siyao<lsy@clusterfs.com>
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
- *   This file is part of Lustre, http://www.lustre.org.
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 only,
+ * as published by the Free Software Foundation.
  *
- *   Lustre is free software; you can redistribute it and/or
- *   modify it under the terms of version 2 of the GNU General Public
- *   License as published by the Free Software Foundation.
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License version 2 for more details (a copy is included
+ * in the LICENSE file that accompanied this code).
  *
- *   Lustre is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
+ * You should have received a copy of the GNU General Public License
+ * version 2 along with this program; If not, see
+ * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
  *
- *   You should have received a copy of the GNU General Public License
- *   along with Lustre; if not, write to the Free Software
- *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ * GPL HEADER END
+ */
+/*
+ * Copyright  2008 Sun Microsystems, Inc. All rights reserved
+ * Use is subject to license terms.
  */
+/*
+ * This file is part of Lustre, http://www.lustre.org/
+ * Lustre is a trademark of Sun Microsystems, Inc.
+ *
+ * lustre/obdclass/capa.c
+ *
+ * Lustre Capability Hash Management
+ *
+ * Author: Lai Siyao<lsy@clusterfs.com>
+ */
+
 #ifndef EXPORT_SYMTAB
 # define EXPORT_SYMTAB
 #endif
@@ -56,13 +74,13 @@ cfs_mem_cache_t *capa_cachep = NULL;
 spinlock_t capa_lock = SPIN_LOCK_UNLOCKED;
 
 struct list_head capa_list[CAPA_SITE_MAX];
-#endif
-/* capa count */
-int capa_count[CAPA_SITE_MAX] = { 0, };
 
 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_cachep);
 EXPORT_SYMBOL(capa_list);
@@ -74,11 +92,11 @@ struct hlist_head *init_capa_hash(void)
         struct hlist_head *hash;
         int nr_hash, i;
 
-        OBD_ALLOC(hash, PAGE_SIZE);
+        OBD_ALLOC(hash, CFS_PAGE_SIZE);
         if (!hash)
                 return NULL;
 
-        nr_hash = PAGE_SIZE / sizeof(struct hlist_head);
+        nr_hash = CFS_PAGE_SIZE / sizeof(struct hlist_head);
         LASSERT(nr_hash > NR_CAPAHASH);
 
         for (i = 0; i < NR_CAPAHASH; i++)
@@ -114,10 +132,10 @@ void cleanup_capa_hash(struct hlist_head *hash)
         }
         spin_unlock(&capa_lock);
 
-        OBD_FREE(hash, PAGE_SIZE);
+        OBD_FREE(hash, CFS_PAGE_SIZE);
 }
 
-static inline int const capa_hashfn(struct lu_fid *fid)
+static inline int capa_hashfn(struct lu_fid *fid)
 {
         return (fid_oid(fid) ^ fid_ver(fid)) *
                (unsigned long)(fid_seq(fid) + 1) % NR_CAPAHASH;
@@ -231,12 +249,12 @@ struct obd_capa *capa_lookup(struct hlist_head *hash, struct lustre_capa *capa,
 
 int capa_hmac(__u8 *hmac, struct lustre_capa *capa, __u8 *key)
 {
-        struct crypto_tfm *tfm;
-        struct capa_hmac_alg *alg;
+        struct ll_crypto_hash *tfm;
+        struct capa_hmac_alg  *alg;
         int keylen;
         struct scatterlist sl = {
                 .page   = virt_to_page(capa),
-                .offset = (unsigned long)(capa) % PAGE_SIZE,
+                .offset = (unsigned long)(capa) % CFS_PAGE_SIZE,
                 .length = offsetof(struct lustre_capa, lc_hmac),
         };
 
@@ -247,7 +265,7 @@ int capa_hmac(__u8 *hmac, struct lustre_capa *capa, __u8 *key)
 
         alg = &capa_hmac_algs[capa_alg(capa)];
 
-        tfm = crypto_alloc_tfm(alg->ha_name, 0);
+        tfm = ll_crypto_alloc_hash(alg->ha_name, 0, 0);
         if (!tfm) {
                 CERROR("crypto_alloc_tfm failed, check whether your kernel"
                        "has crypto support!\n");
@@ -255,8 +273,8 @@ int capa_hmac(__u8 *hmac, struct lustre_capa *capa, __u8 *key)
         }
         keylen = alg->ha_keylen;
 
-        crypto_hmac(tfm, key, &keylen, &sl, 1, hmac);
-        crypto_free_tfm(tfm);
+        ll_crypto_hmac(tfm, key, &keylen, &sl, sl.length, hmac);
+        ll_crypto_free_hash(tfm);
 
         return 0;
 }