Whamcloud - gitweb
LU-4405 mdc: use ibits_known mask for lock match
[fs/lustre-release.git] / lustre / ofd / ofd_fmd.c
index 8663f9e..f25ce93 100644 (file)
@@ -27,7 +27,7 @@
  * Copyright  2008 Sun Microsystems, Inc. All rights reserved
  * Use is subject to license terms.
  *
- * Copyright (c) 2011, 2012, Whamcloud, Inc.
+ * Copyright (c) 2012, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -40,7 +40,7 @@
 
 #include "ofd_internal.h"
 
-static cfs_mem_cache_t *ll_fmd_cachep;
+static struct kmem_cache *ll_fmd_cachep;
 
 /* drop fmd reference, free it if last ref. must be called with fed_lock held.*/
 static inline void ofd_fmd_put_nolock(struct obd_export *exp,
@@ -48,7 +48,7 @@ static inline void ofd_fmd_put_nolock(struct obd_export *exp,
 {
        struct filter_export_data *fed = &exp->exp_filter_data;
 
-       LASSERT_SPIN_LOCKED(&fed->fed_lock);
+       LASSERT(spin_is_locked(&fed->fed_lock));
        if (--fmd->fmd_refcount == 0) {
                /* XXX when we have persistent reservations and the handle
                 * is stored herein we need to drop it here. */
@@ -66,9 +66,9 @@ void ofd_fmd_put(struct obd_export *exp, struct ofd_mod_data *fmd)
        if (fmd == NULL)
                return;
 
-       cfs_spin_lock(&fed->fed_lock);
+       spin_lock(&fed->fed_lock);
        ofd_fmd_put_nolock(exp, fmd); /* caller reference */
-       cfs_spin_unlock(&fed->fed_lock);
+       spin_unlock(&fed->fed_lock);
 }
 
 /* expire entries from the end of the list if there are too many
@@ -99,9 +99,9 @@ void ofd_fmd_expire(struct obd_export *exp)
 {
        struct filter_export_data *fed = &exp->exp_filter_data;
 
-       cfs_spin_lock(&fed->fed_lock);
+       spin_lock(&fed->fed_lock);
        ofd_fmd_expire_nolock(exp, NULL);
-       cfs_spin_unlock(&fed->fed_lock);
+       spin_unlock(&fed->fed_lock);
 }
 
 /* find specified fid in fed_fmd_list.
@@ -115,7 +115,7 @@ static struct ofd_mod_data *ofd_fmd_find_nolock(struct obd_export *exp,
 
        cfs_time_t now = cfs_time_current();
 
-       LASSERT_SPIN_LOCKED(&fed->fed_lock);
+       LASSERT(spin_is_locked(&fed->fed_lock));
 
        cfs_list_for_each_entry_reverse(fmd, &fed->fed_mod_list, fmd_list) {
                if (lu_fid_eq(&fmd->fmd_fid, fid)) {
@@ -139,11 +139,11 @@ struct ofd_mod_data *ofd_fmd_find(struct obd_export *exp,
        struct filter_export_data       *fed = &exp->exp_filter_data;
        struct ofd_mod_data             *fmd;
 
-       cfs_spin_lock(&fed->fed_lock);
+       spin_lock(&fed->fed_lock);
        fmd = ofd_fmd_find_nolock(exp, fid);
        if (fmd)
                fmd->fmd_refcount++;    /* caller reference */
-       cfs_spin_unlock(&fed->fed_lock);
+       spin_unlock(&fed->fed_lock);
 
        return fmd;
 }
@@ -163,7 +163,7 @@ struct ofd_mod_data *ofd_fmd_get(struct obd_export *exp, struct lu_fid *fid)
 
        OBD_SLAB_ALLOC_PTR(fmd_new, ll_fmd_cachep);
 
-       cfs_spin_lock(&fed->fed_lock);
+       spin_lock(&fed->fed_lock);
        found = ofd_fmd_find_nolock(exp, fid);
        if (fmd_new) {
                if (found == NULL) {
@@ -182,7 +182,7 @@ struct ofd_mod_data *ofd_fmd_get(struct obd_export *exp, struct lu_fid *fid)
                found->fmd_expire = cfs_time_add(now, ofd->ofd_fmd_max_age);
        }
 
-       cfs_spin_unlock(&fed->fed_lock);
+       spin_unlock(&fed->fed_lock);
 
        return found;
 }
@@ -197,13 +197,13 @@ void ofd_fmd_drop(struct obd_export *exp, struct lu_fid *fid)
        struct filter_export_data       *fed = &exp->exp_filter_data;
        struct ofd_mod_data             *found = NULL;
 
-       cfs_spin_lock(&fed->fed_lock);
+       spin_lock(&fed->fed_lock);
        found = ofd_fmd_find_nolock(exp, fid);
        if (found) {
                cfs_list_del_init(&found->fmd_list);
                ofd_fmd_put_nolock(exp, found);
        }
-       cfs_spin_unlock(&fed->fed_lock);
+       spin_unlock(&fed->fed_lock);
 }
 #endif
 
@@ -213,7 +213,7 @@ void ofd_fmd_cleanup(struct obd_export *exp)
        struct filter_export_data       *fed = &exp->exp_filter_data;
        struct ofd_mod_data             *fmd = NULL, *tmp;
 
-       cfs_spin_lock(&fed->fed_lock);
+       spin_lock(&fed->fed_lock);
        cfs_list_for_each_entry_safe(fmd, tmp, &fed->fed_mod_list, fmd_list) {
                cfs_list_del_init(&fmd->fmd_list);
                if (fmd->fmd_refcount > 1) {
@@ -222,14 +222,14 @@ void ofd_fmd_cleanup(struct obd_export *exp)
                }
                ofd_fmd_put_nolock(exp, fmd);
        }
-       cfs_spin_unlock(&fed->fed_lock);
+       spin_unlock(&fed->fed_lock);
 }
 
 int ofd_fmd_init(void)
 {
-       ll_fmd_cachep = cfs_mem_cache_create("ll_fmd_cache",
-                                            sizeof(struct ofd_mod_data),
-                                            0, 0);
+       ll_fmd_cachep = kmem_cache_create("ll_fmd_cache",
+                                         sizeof(struct ofd_mod_data),
+                                         0, 0, NULL);
        if (!ll_fmd_cachep)
                return -ENOMEM;
        else
@@ -239,9 +239,7 @@ int ofd_fmd_init(void)
 void ofd_fmd_exit(void)
 {
        if (ll_fmd_cachep) {
-               int rc = cfs_mem_cache_destroy(ll_fmd_cachep);
-
-               LASSERTF(rc == 0, "Cannot destroy ll_fmd_cachep: rc %d\n", rc);
+               kmem_cache_destroy(ll_fmd_cachep);
                ll_fmd_cachep = NULL;
        }
 }