Whamcloud - gitweb
LU-4423 mdc: use 64-bit timestamps for mdc
[fs/lustre-release.git] / lustre / obdclass / lu_ref.c
index 94ad740..6edaf9f 100644 (file)
  *
  * 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
- *
- * 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.
+ * http://www.gnu.org/licenses/gpl-2.0.html
  *
  * GPL HEADER END
  */
@@ -27,7 +23,7 @@
  * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2012, Intel Corporation.
+ * Copyright (c) 2012, 2016, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
 
 #define DEBUG_SUBSYSTEM S_CLASS
 
-#ifdef __KERNEL__
-# include <libcfs/libcfs.h>
-#else
-# include <liblustre.h>
-#endif
-
+#include <libcfs/libcfs.h>
 #include <obd.h>
 #include <obd_class.h>
 #include <obd_support.h>
@@ -107,7 +98,6 @@ void lu_ref_print(const struct lu_ref *ref)
                 CERROR("     link: %s %p\n", link->ll_scope, link->ll_source);
         }
 }
-EXPORT_SYMBOL(lu_ref_print);
 
 static int lu_ref_is_marker(const struct lu_ref *ref)
 {
@@ -129,7 +119,6 @@ void lu_ref_print_all(void)
        }
        spin_unlock(&lu_ref_refs_guard);
 }
-EXPORT_SYMBOL(lu_ref_print_all);
 
 void lu_ref_init_loc(struct lu_ref *ref, const char *func, const int line)
 {
@@ -146,8 +135,10 @@ EXPORT_SYMBOL(lu_ref_init_loc);
 
 void lu_ref_fini(struct lu_ref *ref)
 {
+       spin_lock(&ref->lf_guard);
        REFASSERT(ref, list_empty(&ref->lf_list));
        REFASSERT(ref, ref->lf_refs == 0);
+       spin_unlock(&ref->lf_guard);
        spin_lock(&lu_ref_refs_guard);
        list_del_init(&ref->lf_linkage);
        spin_unlock(&lu_ref_refs_guard);
@@ -188,7 +179,7 @@ static struct lu_ref_link *lu_ref_add_context(struct lu_ref *ref,
 void lu_ref_add(struct lu_ref *ref, const char *scope, const void *source)
 {
        might_sleep();
-       lu_ref_add_context(ref, GFP_IOFS, scope, source);
+       lu_ref_add_context(ref, GFP_NOFS, scope, source);
 }
 EXPORT_SYMBOL(lu_ref_add);
 
@@ -273,9 +264,8 @@ void lu_ref_set_at(struct lu_ref *ref, struct lu_ref_link *link,
                   const char *scope,
                   const void *source0, const void *source1)
 {
-       REFASSERT(ref, link != NULL && !IS_ERR(link));
-
        spin_lock(&ref->lf_guard);
+       REFASSERT(ref, link != NULL && !IS_ERR(link));
        REFASSERT(ref, link->ll_ref == ref);
        REFASSERT(ref, lu_ref_link_eq(link, scope, source0));
        link->ll_source = source1;
@@ -286,8 +276,8 @@ EXPORT_SYMBOL(lu_ref_set_at);
 void lu_ref_del_at(struct lu_ref *ref, struct lu_ref_link *link,
                   const char *scope, const void *source)
 {
-       REFASSERT(ref, link != NULL && !IS_ERR(link));
        spin_lock(&ref->lf_guard);
+       REFASSERT(ref, link != NULL && !IS_ERR(link));
        REFASSERT(ref, link->ll_ref == ref);
        REFASSERT(ref, lu_ref_link_eq(link, scope, source));
        list_del(&link->ll_linkage);
@@ -296,7 +286,7 @@ void lu_ref_del_at(struct lu_ref *ref, struct lu_ref_link *link,
 }
 EXPORT_SYMBOL(lu_ref_del_at);
 
-#if defined(__KERNEL__) && defined(LPROCFS)
+#ifdef CONFIG_PROC_FS
 
 static void *lu_ref_seq_start(struct seq_file *seq, loff_t *pos)
 {
@@ -420,7 +410,7 @@ static struct file_operations lu_ref_dump_fops = {
         .release = lu_ref_seq_release
 };
 
-#endif
+#endif /* CONFIG_PROC_FS */
 
 int lu_ref_global_init(void)
 {
@@ -433,23 +423,23 @@ int lu_ref_global_init(void)
        spin_lock_init(&lu_ref_refs_guard);
         result = lu_kmem_init(lu_ref_caches);
 
-#if defined(__KERNEL__) && defined(LPROCFS)
+#ifdef CONFIG_PROC_FS
         if (result == 0) {
                 result = lprocfs_seq_create(proc_lustre_root, "lu_refs",
                                             0444, &lu_ref_dump_fops, NULL);
                 if (result)
                         lu_kmem_fini(lu_ref_caches);
         }
-#endif
+#endif /* CONFIG_PROC_FS */
 
         return result;
 }
 
 void lu_ref_global_fini(void)
 {
-#if defined(__KERNEL__) && defined(LPROCFS)
+#ifdef CONFIG_PROC_FS
         lprocfs_remove_proc_entry("lu_refs", proc_lustre_root);
-#endif
+#endif /* CONFIG_PROC_FS */
         lu_kmem_fini(lu_ref_caches);
 }