From 16b9e913b378fcf6ce17b8337beae93b8ec1fbb1 Mon Sep 17 00:00:00 2001 From: nikita Date: Sun, 23 Nov 2008 20:27:27 +0000 Subject: [PATCH] use LASSERT_SPIN_LOCKED() in LASSERT(spin_is_locked()) stead as the latter does not work correctly with the uniprocessor kernels. b=17664; i=robert.read --- libcfs/include/libcfs/linux/kp30.h | 4 +++- libcfs/include/libcfs/user-lock.h | 5 +++-- lustre/obdclass/cl_lock.c | 2 +- lustre/obdclass/cl_object.c | 4 ++-- lustre/obdclass/cl_page.c | 9 ++++++--- lustre/ptlrpc/service.c | 4 +--- 6 files changed, 16 insertions(+), 12 deletions(-) diff --git a/libcfs/include/libcfs/linux/kp30.h b/libcfs/include/libcfs/linux/kp30.h index 40f15b9..1f0badd 100644 --- a/libcfs/include/libcfs/linux/kp30.h +++ b/libcfs/include/libcfs/linux/kp30.h @@ -133,8 +133,10 @@ static inline void our_cond_resched(void) #ifdef CONFIG_SMP #define LASSERT_SPIN_LOCKED(lock) LASSERT(spin_is_locked(lock)) +#define LINVRNT_SPIN_LOCKED(lock) LINVRNT(spin_is_locked(lock)) #else -#define LASSERT_SPIN_LOCKED(lock) do {} while(0) +#define LASSERT_SPIN_LOCKED(lock) do {(void)sizeof(lock);} while(0) +#define LINVRNT_SPIN_LOCKED(lock) do {(void)sizeof(lock);} while(0) #endif #define LASSERT_SEM_LOCKED(sem) LASSERT(down_trylock(sem) != 0) diff --git a/libcfs/include/libcfs/user-lock.h b/libcfs/include/libcfs/user-lock.h index c81c208..729f600 100644 --- a/libcfs/include/libcfs/user-lock.h +++ b/libcfs/include/libcfs/user-lock.h @@ -85,8 +85,9 @@ struct spin_lock {int foo;}; typedef struct spin_lock spinlock_t; #define SPIN_LOCK_UNLOCKED (spinlock_t) { } -#define LASSERT_SPIN_LOCKED(lock) do {} while(0) -#define LASSERT_SEM_LOCKED(sem) do {} while(0) +#define LASSERT_SPIN_LOCKED(lock) do {(void)sizeof(lock);} while(0) +#define LINVRNT_SPIN_LOCKED(lock) do {(void)sizeof(lock);} while(0) +#define LASSERT_SEM_LOCKED(sem) do {(void)sizeof(sem);} while(0) void spin_lock_init(spinlock_t *lock); void spin_lock(spinlock_t *lock); diff --git a/lustre/obdclass/cl_lock.c b/lustre/obdclass/cl_lock.c index 7c9a465..fca3f16 100644 --- a/lustre/obdclass/cl_lock.c +++ b/lustre/obdclass/cl_lock.c @@ -403,7 +403,7 @@ static struct cl_lock *cl_lock_lookup(const struct lu_env *env, head = cl_object_header(obj); site = cl_object_site(obj); - LINVRNT(spin_is_locked(&head->coh_lock_guard)); + LINVRNT_SPIN_LOCKED(&head->coh_lock_guard); atomic_inc(&site->cs_locks.cs_lookup); list_for_each_entry(lock, &head->coh_locks, cll_linkage) { int matched; diff --git a/lustre/obdclass/cl_object.c b/lustre/obdclass/cl_object.c index 84d14af..0310b75 100644 --- a/lustre/obdclass/cl_object.c +++ b/lustre/obdclass/cl_object.c @@ -223,7 +223,7 @@ int cl_object_attr_get(const struct lu_env *env, struct cl_object *obj, struct lu_object_header *top; int result; - LASSERT(spin_is_locked(cl_object_attr_guard(obj))); + LASSERT_SPIN_LOCKED(cl_object_attr_guard(obj)); ENTRY; top = obj->co_lu.lo_header; @@ -255,7 +255,7 @@ int cl_object_attr_set(const struct lu_env *env, struct cl_object *obj, struct lu_object_header *top; int result; - LASSERT(spin_is_locked(cl_object_attr_guard(obj))); + LASSERT_SPIN_LOCKED(cl_object_attr_guard(obj)); ENTRY; top = obj->co_lu.lo_header; diff --git a/lustre/obdclass/cl_page.c b/lustre/obdclass/cl_page.c index 6371a73..feac1ff 100644 --- a/lustre/obdclass/cl_page.c +++ b/lustre/obdclass/cl_page.c @@ -137,11 +137,14 @@ cl_page_at_trusted(const struct cl_page *page, const struct lu_device_type *dtype) { const struct cl_page_slice *slice; + +#ifdef INVARIANT_CHECK struct cl_object_header *ch = cl_object_header(page->cp_obj); + if (!atomic_read(&page->cp_ref)) + LASSERT_SPIN_LOCKED(&ch->coh_page_guard); +#endif ENTRY; - LINVRNT(ergo(!atomic_read(&page->cp_ref), - spin_is_locked(&ch->coh_page_guard))); page = cl_page_top_trusted((struct cl_page *)page); do { @@ -164,7 +167,7 @@ struct cl_page *cl_page_lookup(struct cl_object_header *hdr, pgoff_t index) { struct cl_page *page; - LASSERT(spin_is_locked(&hdr->coh_page_guard)); + LASSERT_SPIN_LOCKED(&hdr->coh_page_guard); page = radix_tree_lookup(&hdr->coh_tree, index); if (page != NULL) { diff --git a/lustre/ptlrpc/service.c b/lustre/ptlrpc/service.c index a0bf907..fb0d8d0 100644 --- a/lustre/ptlrpc/service.c +++ b/lustre/ptlrpc/service.c @@ -190,9 +190,7 @@ ptlrpc_schedule_difficult_reply (struct ptlrpc_reply_state *rs) struct ptlrpc_service *svc = rs->rs_service; ENTRY; -#ifdef CONFIG_SMP - LASSERT (spin_is_locked (&svc->srv_lock)); -#endif + LASSERT_SPIN_LOCKED(&svc->srv_lock); LASSERT (rs->rs_difficult); rs->rs_scheduled_ever = 1; /* flag any notification attempt */ -- 1.8.3.1