#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>
*
* Protected by lu_ref_refs_guard.
*/
-static CFS_LIST_HEAD(lu_ref_refs);
+static struct list_head lu_ref_refs;
static spinlock_t lu_ref_refs_guard;
static struct lu_ref lu_ref_marker = {
.lf_guard = __SPIN_LOCK_UNLOCKED(lu_ref_marker.lf_guard),
- .lf_list = CFS_LIST_HEAD_INIT(lu_ref_marker.lf_list),
- .lf_linkage = CFS_LIST_HEAD_INIT(lu_ref_marker.lf_linkage)
+ .lf_list = LIST_HEAD_INIT(lu_ref_marker.lf_list),
+ .lf_linkage = LIST_HEAD_INIT(lu_ref_marker.lf_linkage)
};
void lu_ref_print(const struct lu_ref *ref)
CERROR("lu_ref: %p %d %d %s:%d\n",
ref, ref->lf_refs, ref->lf_failed, ref->lf_func, ref->lf_line);
- cfs_list_for_each_entry(link, &ref->lf_list, ll_linkage) {
+ list_for_each_entry(link, &ref->lf_list, ll_linkage) {
CERROR(" link: %s %p\n", link->ll_scope, link->ll_source);
}
}
struct lu_ref *ref;
spin_lock(&lu_ref_refs_guard);
- cfs_list_for_each_entry(ref, &lu_ref_refs, lf_linkage) {
+ list_for_each_entry(ref, &lu_ref_refs, lf_linkage) {
if (lu_ref_is_marker(ref))
continue;
ref->lf_func = func;
ref->lf_line = line;
spin_lock_init(&ref->lf_guard);
- CFS_INIT_LIST_HEAD(&ref->lf_list);
+ INIT_LIST_HEAD(&ref->lf_list);
spin_lock(&lu_ref_refs_guard);
- cfs_list_add(&ref->lf_linkage, &lu_ref_refs);
+ list_add(&ref->lf_linkage, &lu_ref_refs);
spin_unlock(&lu_ref_refs_guard);
}
EXPORT_SYMBOL(lu_ref_init_loc);
void lu_ref_fini(struct lu_ref *ref)
{
- REFASSERT(ref, cfs_list_empty(&ref->lf_list));
+ REFASSERT(ref, list_empty(&ref->lf_list));
REFASSERT(ref, ref->lf_refs == 0);
spin_lock(&lu_ref_refs_guard);
- cfs_list_del_init(&ref->lf_linkage);
+ list_del_init(&ref->lf_linkage);
spin_unlock(&lu_ref_refs_guard);
}
EXPORT_SYMBOL(lu_ref_fini);
link->ll_scope = scope;
link->ll_source = source;
spin_lock(&ref->lf_guard);
- cfs_list_add_tail(&link->ll_linkage, &ref->lf_list);
+ list_add_tail(&link->ll_linkage, &ref->lf_list);
ref->lf_refs++;
spin_unlock(&ref->lf_guard);
}
link->ll_scope = scope;
link->ll_source = source;
spin_lock(&ref->lf_guard);
- cfs_list_add_tail(&link->ll_linkage, &ref->lf_list);
+ list_add_tail(&link->ll_linkage, &ref->lf_list);
ref->lf_refs++;
spin_unlock(&ref->lf_guard);
}
unsigned iterations;
iterations = 0;
- cfs_list_for_each_entry(link, &ref->lf_list, ll_linkage) {
+ list_for_each_entry(link, &ref->lf_list, ll_linkage) {
++iterations;
if (lu_ref_link_eq(link, scope, source)) {
if (iterations > lu_ref_chain_max_length) {
spin_lock(&ref->lf_guard);
link = lu_ref_find(ref, scope, source);
if (link != NULL) {
- cfs_list_del(&link->ll_linkage);
+ list_del(&link->ll_linkage);
ref->lf_refs--;
spin_unlock(&ref->lf_guard);
OBD_SLAB_FREE(link, lu_ref_link_kmem, sizeof(*link));
spin_lock(&ref->lf_guard);
REFASSERT(ref, link->ll_ref == ref);
REFASSERT(ref, lu_ref_link_eq(link, scope, source));
- cfs_list_del(&link->ll_linkage);
+ list_del(&link->ll_linkage);
ref->lf_refs--;
spin_unlock(&ref->lf_guard);
}
EXPORT_SYMBOL(lu_ref_del_at);
-#if defined(__KERNEL__) && defined(LPROCFS)
+#ifdef LPROCFS
static void *lu_ref_seq_start(struct seq_file *seq, loff_t *pos)
{
struct lu_ref *ref = seq->private;
spin_lock(&lu_ref_refs_guard);
- if (cfs_list_empty(&ref->lf_linkage))
+ if (list_empty(&ref->lf_linkage))
ref = NULL;
spin_unlock(&lu_ref_refs_guard);
struct lu_ref *next;
LASSERT(seq->private == p);
- LASSERT(!cfs_list_empty(&ref->lf_linkage));
+ LASSERT(!list_empty(&ref->lf_linkage));
spin_lock(&lu_ref_refs_guard);
- next = cfs_list_entry(ref->lf_linkage.next, struct lu_ref, lf_linkage);
+ next = list_entry(ref->lf_linkage.next, struct lu_ref, lf_linkage);
if (&next->lf_linkage == &lu_ref_refs) {
p = NULL;
} else {
(*pos)++;
- cfs_list_move(&ref->lf_linkage, &next->lf_linkage);
+ list_move(&ref->lf_linkage, &next->lf_linkage);
}
spin_unlock(&lu_ref_refs_guard);
return p;
struct lu_ref *next;
spin_lock(&lu_ref_refs_guard);
- next = cfs_list_entry(ref->lf_linkage.next, struct lu_ref, lf_linkage);
+ next = list_entry(ref->lf_linkage.next, struct lu_ref, lf_linkage);
if ((&next->lf_linkage == &lu_ref_refs) || lu_ref_is_marker(next)) {
spin_unlock(&lu_ref_refs_guard);
return 0;
struct lu_ref_link *link;
int i = 0;
- cfs_list_for_each_entry(link, &next->lf_list, ll_linkage)
+ list_for_each_entry(link, &next->lf_list, ll_linkage)
seq_printf(seq, " #%d link: %s %p\n",
i++, link->ll_scope, link->ll_source);
}
result = seq_open(file, &lu_ref_seq_ops);
if (result == 0) {
spin_lock(&lu_ref_refs_guard);
- if (!cfs_list_empty(&marker->lf_linkage))
+ if (!list_empty(&marker->lf_linkage))
result = -EAGAIN;
else
- cfs_list_add(&marker->lf_linkage, &lu_ref_refs);
+ list_add(&marker->lf_linkage, &lu_ref_refs);
spin_unlock(&lu_ref_refs_guard);
if (result == 0) {
struct lu_ref *ref = ((struct seq_file *)file->private_data)->private;
spin_lock(&lu_ref_refs_guard);
- cfs_list_del_init(&ref->lf_linkage);
+ list_del_init(&ref->lf_linkage);
spin_unlock(&lu_ref_refs_guard);
return seq_release(inode, file);
.release = lu_ref_seq_release
};
-#endif
+#endif /* LPROCFS */
int lu_ref_global_init(void)
{
CDEBUG(D_CONSOLE,
"lu_ref tracking is enabled. Performance isn't.\n");
+ INIT_LIST_HEAD(&lu_ref_refs);
spin_lock_init(&lu_ref_refs_guard);
result = lu_kmem_init(lu_ref_caches);
-#if defined(__KERNEL__) && defined(LPROCFS)
+#ifdef LPROCFS
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 /* LPROCFS */
return result;
}
void lu_ref_global_fini(void)
{
-#if defined(__KERNEL__) && defined(LPROCFS)
+#ifdef LPROCFS
lprocfs_remove_proc_entry("lu_refs", proc_lustre_root);
-#endif
+#endif /* LPROCFS */
lu_kmem_fini(lu_ref_caches);
}