From: James Simmons Date: Sat, 26 Jun 2021 18:05:15 +0000 (-0400) Subject: LU-6142 obdclass: resolve lu_ref checkpatch issues X-Git-Tag: 2.14.53~71 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=5c98de856618f301035c7579e61fffa10cc726cc LU-6142 obdclass: resolve lu_ref checkpatch issues Fix up all the checkpatch issues reported for the code handling lu_ref. Also change USE_LU_REF to CONFIG_LUSTRE_DEBUG_LU_REF which will match what will be upstream. Change-Id: I100e2679fc04c97eb67e4d44c4f6a6b530da6fa8 Signed-off-by: James Simmons Reviewed-on: https://review.whamcloud.com/44088 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Arshad Hussain Reviewed-by: Oleg Drokin --- diff --git a/lustre/autoconf/lustre-core.m4 b/lustre/autoconf/lustre-core.m4 index 8598f26..d8755b2 100644 --- a/lustre/autoconf/lustre-core.m4 +++ b/lustre/autoconf/lustre-core.m4 @@ -2863,7 +2863,7 @@ AC_ARG_ENABLE([lu_ref], [], [enable_lu_ref="no"]) AC_MSG_RESULT([$enable_lu_ref]) AS_IF([test "x$enable_lu_ref" = xyes], - [AC_DEFINE([USE_LU_REF], 1, + [AC_DEFINE([CONFIG_LUSTRE_DEBUG_LU_REF], 1, [enable lu_ref reference tracking code])]) AC_MSG_CHECKING([whether to enable page state tracking]) diff --git a/lustre/include/lu_ref.h b/lustre/include/lu_ref.h index c7366c0..7b368c2 100644 --- a/lustre/include/lu_ref.h +++ b/lustre/include/lu_ref.h @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0 /* * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. * Use is subject to license terms. @@ -17,10 +18,6 @@ * 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 - * along with Lustre; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * */ #ifndef __LUSTRE_LU_REF_H @@ -36,11 +33,11 @@ * who acquired references to instance of struct foo, add lu_ref field to it: * * \code - * struct foo { - * atomic_t foo_refcount; - * struct lu_ref foo_reference; - * ... - * }; + * struct foo { + * atomic_t foo_refcount; + * struct lu_ref foo_reference; + * ... + * }; * \endcode * * foo::foo_reference has to be initialized by calling @@ -54,28 +51,28 @@ * usages are: * * \code - * struct bar *bar; + * struct bar *bar; * - * // bar owns a reference to foo. - * bar->bar_foo = foo_get(foo); - * lu_ref_add(&foo->foo_reference, "bar", bar); + * // bar owns a reference to foo. + * bar->bar_foo = foo_get(foo); + * lu_ref_add(&foo->foo_reference, "bar", bar); * - * ... + * ... * - * // reference from bar to foo is released. - * lu_ref_del(&foo->foo_reference, "bar", bar); - * foo_put(bar->bar_foo); + * // reference from bar to foo is released. + * lu_ref_del(&foo->foo_reference, "bar", bar); + * foo_put(bar->bar_foo); * * - * // current thread acquired a temporary reference to foo. - * foo_get(foo); - * lu_ref_add(&foo->reference, __FUNCTION__, current); + * // current thread acquired a temporary reference to foo. + * foo_get(foo); + * lu_ref_add(&foo->reference, __func__, current); * - * ... + * ... * - * // temporary reference is released. - * lu_ref_del(&foo->reference, __FUNCTION__, current); - * foo_put(foo); + * // temporary reference is released. + * lu_ref_del(&foo->reference, __func__, current); + * foo_put(foo); * \endcode * * \e Et \e cetera. Often it makes sense to include lu_ref_add() and @@ -91,15 +88,15 @@ * lu_ref_del_at(): * * \code - * // There is a large number of bar's for a single foo. - * bar->bar_foo = foo_get(foo); - * bar->bar_foo_ref = lu_ref_add(&foo->foo_reference, "bar", bar); + * // There is a large number of bar's for a single foo. + * bar->bar_foo = foo_get(foo); + * bar->bar_foo_ref = lu_ref_add(&foo->foo_reference, "bar", bar); * - * ... + * ... * - * // reference from bar to foo is released. - * lu_ref_del_at(&foo->foo_reference, bar->bar_foo_ref, "bar", bar); - * foo_put(bar->bar_foo); + * // reference from bar to foo is released. + * lu_ref_del_at(&foo->foo_reference, bar->bar_foo_ref, "bar", bar); + * foo_put(bar->bar_foo); * \endcode * * lu_ref interface degrades gracefully in case of memory shortages. @@ -107,7 +104,7 @@ * @{ */ -#ifdef USE_LU_REF +#ifdef CONFIG_LUSTRE_DEBUG_LU_REF /** * Data-structure to keep track of references to a given object. This is used @@ -126,27 +123,27 @@ struct lu_ref { * lu_ref_link), pointing to this object. */ struct list_head lf_list; - /** - * # of links. - */ - short lf_refs; - /** - * Flag set when lu_ref_add() failed to allocate lu_ref_link. It is - * used to mask spurious failure of the following lu_ref_del(). - */ - short lf_failed; - /** - * flags - attribute for the lu_ref, for pad and future use. - */ - short lf_flags; - /** - * Where was I initialized? - */ - short lf_line; - const char *lf_func; - /** - * Linkage into a global list of all lu_ref's (lu_ref_refs). - */ + /** + * # of links. + */ + short lf_refs; + /** + * Flag set when lu_ref_add() failed to allocate lu_ref_link. It is + * used to mask spurious failure of the following lu_ref_del(). + */ + short lf_failed; + /** + * flags - attribute for the lu_ref, for pad and future use. + */ + short lf_flags; + /** + * Where was I initialized? + */ + short lf_line; + const char *lf_func; + /** + * Linkage into a global list of all lu_ref's (lu_ref_refs). + */ struct list_head lf_linkage; }; @@ -158,8 +155,8 @@ struct lu_ref_link { }; void lu_ref_init_loc(struct lu_ref *ref, const char *func, const int line); -void lu_ref_fini (struct lu_ref *ref); -#define lu_ref_init(ref) lu_ref_init_loc(ref, __FUNCTION__, __LINE__) +void lu_ref_fini(struct lu_ref *ref); +#define lu_ref_init(ref) lu_ref_init_loc(ref, __func__, __LINE__) void lu_ref_add(struct lu_ref *ref, const char *scope, const void *source); @@ -185,7 +182,7 @@ int lu_ref_global_init(void); void lu_ref_global_fini(void); -#else /* !USE_LU_REF */ +#else /* !CONFIG_LUSTRE_DEBUG_LU_REF */ struct lu_ref { }; @@ -221,24 +218,24 @@ static inline void lu_ref_add_at(struct lu_ref *ref, } static inline void lu_ref_del(struct lu_ref *ref, const char *scope, - const void *source) + const void *source) { } static inline void lu_ref_set_at(struct lu_ref *ref, struct lu_ref_link *link, - const char *scope, const void *source0, - const void *source1) + const char *scope, const void *source0, + const void *source1) { } static inline void lu_ref_del_at(struct lu_ref *ref, struct lu_ref_link *link, - const char *scope, const void *source) + const char *scope, const void *source) { } static inline int lu_ref_global_init(void) { - return 0; + return 0; } static inline void lu_ref_global_fini(void) @@ -252,7 +249,7 @@ static inline void lu_ref_print(const struct lu_ref *ref) static inline void lu_ref_print_all(void) { } -#endif /* USE_LU_REF */ +#endif /* CONFIG_LUSTRE_DEBUG_LU_REF */ /** @} lu */ diff --git a/lustre/obdclass/lu_ref.c b/lustre/obdclass/lu_ref.c index 43f37e9..ae79b43 100644 --- a/lustre/obdclass/lu_ref.c +++ b/lustre/obdclass/lu_ref.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0 /* * GPL HEADER START * @@ -37,14 +38,12 @@ #define DEBUG_SUBSYSTEM S_CLASS -#include #include #include #include #include -#ifdef USE_LU_REF - +#ifdef CONFIG_LUSTRE_DEBUG_LU_REF /** * Asserts a condition for a given lu_ref. Must be called with * lu_ref::lf_guard held. @@ -152,9 +151,9 @@ static struct lu_ref_link *lu_ref_add_context(struct lu_ref *ref, struct lu_ref_link *link; link = NULL; - if (lu_ref_link_kmem != NULL) { + if (lu_ref_link_kmem) { OBD_SLAB_ALLOC_PTR_GFP(link, lu_ref_link_kmem, flags); - if (link != NULL) { + if (link) { link->ll_ref = ref; link->ll_scope = scope; link->ll_source = source; @@ -165,7 +164,7 @@ static struct lu_ref_link *lu_ref_add_context(struct lu_ref *ref, } } - if (link == NULL) { + if (!link) { spin_lock(&ref->lf_guard); ref->lf_failed++; spin_unlock(&ref->lf_guard); @@ -215,13 +214,13 @@ static inline int lu_ref_link_eq(const struct lu_ref_link *link, /** * Maximal chain length seen so far. */ -static unsigned lu_ref_chain_max_length = 127; +static unsigned int lu_ref_chain_max_length = 127; /** * Searches for a lu_ref_link with given [scope, source] within given lu_ref. */ static struct lu_ref_link *lu_ref_find(struct lu_ref *ref, const char *scope, - const void *source) + const void *source) { struct lu_ref_link *link; unsigned int iterations; @@ -247,7 +246,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) { + if (link) { list_del(&link->ll_linkage); ref->lf_refs--; spin_unlock(&ref->lf_guard); @@ -265,7 +264,7 @@ void lu_ref_set_at(struct lu_ref *ref, struct lu_ref_link *link, const void *source0, const void *source1) { spin_lock(&ref->lf_guard); - REFASSERT(ref, link != NULL && !IS_ERR(link)); + REFASSERT(ref, !IS_ERR_OR_NULL(link)); REFASSERT(ref, link->ll_ref == ref); REFASSERT(ref, lu_ref_link_eq(link, scope, source0)); link->ll_source = source1; @@ -277,7 +276,7 @@ void lu_ref_del_at(struct lu_ref *ref, struct lu_ref_link *link, const char *scope, const void *source) { spin_lock(&ref->lf_guard); - REFASSERT(ref, link != NULL && !IS_ERR(link)); + REFASSERT(ref, !IS_ERR_OR_NULL(link)); REFASSERT(ref, link->ll_ref == ref); REFASSERT(ref, lu_ref_link_eq(link, scope, source)); list_del(&link->ll_linkage); @@ -360,10 +359,10 @@ static int lu_ref_seq_show(struct seq_file *seq, void *p) } static const struct seq_operations lu_ref_seq_ops = { - .start = lu_ref_seq_start, - .stop = lu_ref_seq_stop, - .next = lu_ref_seq_next, - .show = lu_ref_seq_show + .start = lu_ref_seq_start, + .stop = lu_ref_seq_stop, + .next = lu_ref_seq_next, + .show = lu_ref_seq_show }; static int lu_ref_seq_open(struct inode *inode, struct file *file) @@ -443,4 +442,4 @@ void lu_ref_global_fini(void) lu_kmem_fini(lu_ref_caches); } -#endif /* USE_LU_REF */ +#endif /* CONFIG_LUSTRE_DEBUG_LU_REF */ diff --git a/lustre/quota/qsd_request.c b/lustre/quota/qsd_request.c index fd60cfc..ead0adf 100644 --- a/lustre/quota/qsd_request.c +++ b/lustre/quota/qsd_request.c @@ -299,7 +299,7 @@ int qsd_intent_lock(const struct lu_env *env, struct obd_export *exp, switch(it_op) { case IT_QUOTA_CONN: /* grab reference on qqi for new lock */ -#ifdef USE_LU_REF +#ifdef CONFIG_LUSTRE_DEBUG_LU_REF { struct ldlm_lock *lock;