X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=blobdiff_plain;f=lustre%2Fobdclass%2Flu_ref.c;h=2a44e56aea39bf6c58dee0d694c7282c53183493;hp=6deddf783142e8bb2f1d47407acdf890f6d1b78d;hb=72057a3af19ee02d9a686bd7e7d074917e381310;hpb=2711e4428bc9b1574202ccd8c566557fb102424a diff --git a/lustre/obdclass/lu_ref.c b/lustre/obdclass/lu_ref.c index 6deddf7..2a44e56 100644 --- a/lustre/obdclass/lu_ref.c +++ b/lustre/obdclass/lu_ref.c @@ -15,11 +15,7 @@ * * 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, 2013, Intel Corporation. */ /* * This file is part of Lustre, http://www.lustre.org/ @@ -42,12 +38,7 @@ #define DEBUG_SUBSYSTEM S_CLASS -#ifdef __KERNEL__ -# include -#else -# include -#endif - +#include #include #include #include @@ -71,7 +62,7 @@ } \ } while (0) -static cfs_mem_cache_t *lu_ref_link_kmem; +static struct kmem_cache *lu_ref_link_kmem; static struct lu_kmem_descr lu_ref_caches[] = { { @@ -89,12 +80,12 @@ static struct lu_kmem_descr lu_ref_caches[] = { * * 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) @@ -103,11 +94,10 @@ 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); } } -EXPORT_SYMBOL(lu_ref_print); static int lu_ref_is_marker(const struct lu_ref *ref) { @@ -119,7 +109,7 @@ void lu_ref_print_all(void) 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; @@ -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) { @@ -137,25 +126,27 @@ void lu_ref_init_loc(struct lu_ref *ref, const char *func, const int line) 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)); + 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); - cfs_list_del_init(&ref->lf_linkage); + list_del_init(&ref->lf_linkage); spin_unlock(&lu_ref_refs_guard); } EXPORT_SYMBOL(lu_ref_fini); static struct lu_ref_link *lu_ref_add_context(struct lu_ref *ref, - enum cfs_alloc_flags flags, + int flags, const char *scope, const void *source) { @@ -169,7 +160,7 @@ static struct lu_ref_link *lu_ref_add_context(struct lu_ref *ref, 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); } @@ -187,8 +178,8 @@ 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) { - cfs_might_sleep(); - lu_ref_add_context(ref, CFS_ALLOC_STD, scope, source); + might_sleep(); + lu_ref_add_context(ref, GFP_NOFS, scope, source); } EXPORT_SYMBOL(lu_ref_add); @@ -199,7 +190,7 @@ void lu_ref_add_at(struct lu_ref *ref, struct lu_ref_link *link, 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); } @@ -211,7 +202,7 @@ EXPORT_SYMBOL(lu_ref_add_at); void lu_ref_add_atomic(struct lu_ref *ref, const char *scope, const void *source) { - lu_ref_add_context(ref, CFS_ALLOC_ATOMIC, scope, source); + lu_ref_add_context(ref, GFP_ATOMIC, scope, source); } EXPORT_SYMBOL(lu_ref_add_atomic); @@ -236,7 +227,7 @@ static struct lu_ref_link *lu_ref_find(struct lu_ref *ref, const char *scope, 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) { @@ -257,7 +248,7 @@ void lu_ref_del(struct lu_ref *ref, const char *scope, const void *source) 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)); @@ -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,24 +276,24 @@ 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)); - 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 CONFIG_PROC_FS 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); @@ -316,15 +306,15 @@ static void *lu_ref_seq_next(struct seq_file *seq, void *p, loff_t *pos) 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; @@ -342,7 +332,7 @@ static int lu_ref_seq_show(struct seq_file *seq, void *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; @@ -359,7 +349,7 @@ static int lu_ref_seq_show(struct seq_file *seq, void *p) 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); } @@ -384,10 +374,10 @@ static int lu_ref_seq_open(struct inode *inode, struct file *file) 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) { @@ -406,7 +396,7 @@ static int lu_ref_seq_release(struct inode *inode, struct file *file) 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); @@ -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) { @@ -429,26 +419,27 @@ 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 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); }