From: James Simmons Date: Tue, 7 Aug 2012 13:55:49 +0000 (-0400) Subject: LU-812 compat: SPIN/RW_LOCK_UNLOCKED no longer exist X-Git-Tag: 2.2.93~21 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=ef6225af104b9138638c71b80e87786b8e5e75e5 LU-812 compat: SPIN/RW_LOCK_UNLOCKED no longer exist SPIN_LOCK_UNLOCKED/RW_LOCK_UNLOCKED were deprecated and no longer exist after 2.6.39. Use DEFINE_SPIN_LOCK/DEFINE_RW_LOCK instead. Signed-off-by: James Simmons Signed-off-by: Wally Wang Change-Id: Ie294e817c850c35e561987f6ab46c6d12d6d018d Reviewed-on: http://review.whamcloud.com/1942 Reviewed-by: Andreas Dilger Tested-by: Hudson Tested-by: Maloo Reviewed-by: Oleg Drokin --- diff --git a/libcfs/include/libcfs/linux/linux-lock.h b/libcfs/include/libcfs/linux/linux-lock.h index 8a9f66c..cc2ca51 100644 --- a/libcfs/include/libcfs/linux/linux-lock.h +++ b/libcfs/include/libcfs/linux/linux-lock.h @@ -75,8 +75,6 @@ * - read_lock_irqsave(lock, f) * - write_lock_irqsave(lock, f) * - write_unlock_irqrestore(lock, f) - * - * - SPIN_LOCK_UNLOCKED */ /* @@ -102,8 +100,6 @@ typedef spinlock_t cfs_spinlock_t; #define cfs_spin_lock_irqsave(lock, f) spin_lock_irqsave(lock, f) #define cfs_spin_unlock_irqrestore(lock, f) spin_unlock_irqrestore(lock, f) -#define CFS_SPIN_LOCK_UNLOCKED SPIN_LOCK_UNLOCKED - /* * rw_semaphore "implementation" (use Linux kernel's primitives) * @@ -153,7 +149,9 @@ typedef rwlock_t cfs_rwlock_t; #define cfs_write_lock_bh(lock) write_lock_bh(lock) #define cfs_write_unlock_bh(lock) write_unlock_bh(lock) -#define CFS_RW_LOCK_UNLOCKED RW_LOCK_UNLOCKED +#ifndef DEFINE_RWLOCK +#define DEFINE_RWLOCK(lock) rwlock_t lock = __RW_LOCK_UNLOCKED(lock) +#endif /* * completion "implementation" (use Linux kernel's primitives) diff --git a/libcfs/include/libcfs/user-lock.h b/libcfs/include/libcfs/user-lock.h index 4d35823..dbb97ff 100644 --- a/libcfs/include/libcfs/user-lock.h +++ b/libcfs/include/libcfs/user-lock.h @@ -86,7 +86,7 @@ struct cfs_spin_lock {int foo;}; typedef struct cfs_spin_lock cfs_spinlock_t; -#define CFS_SPIN_LOCK_UNLOCKED (cfs_spinlock_t) { } +#define DEFINE_SPINLOCK(lock) cfs_spinlock_t lock = { } #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) @@ -205,7 +205,7 @@ void cfs_fini_rwsem(cfs_rw_semaphore_t *s); * - cfs_read_unlock_irqrestore(x) */ typedef cfs_rw_semaphore_t cfs_rwlock_t; -#define CFS_RW_LOCK_UNLOCKED (cfs_rwlock_t) { } +#define DEFINE_RWLOCK(lock) cfs_rwlock_t lock = { } #define cfs_rwlock_init(pl) cfs_init_rwsem(pl) diff --git a/libcfs/include/libcfs/winnt/winnt-lock.h b/libcfs/include/libcfs/winnt/winnt-lock.h index f0d7b96..169cc02 100644 --- a/libcfs/include/libcfs/winnt/winnt-lock.h +++ b/libcfs/include/libcfs/winnt/winnt-lock.h @@ -221,7 +221,7 @@ struct cfs_spin_lock { #define CFS_DECL_SPIN(name) cfs_spinlock_t name; #define CFS_DECL_SPIN_EXTERN(name) extern cfs_spinlock_t name; -#define CFS_SPIN_LOCK_UNLOCKED {0} +#define DEFINE_SPINLOCK {0} static inline void cfs_spin_lock_init(cfs_spinlock_t *lock) { diff --git a/libcfs/libcfs/watchdog.c b/libcfs/libcfs/watchdog.c index 6ce41c3..a394794 100644 --- a/libcfs/libcfs/watchdog.c +++ b/libcfs/libcfs/watchdog.c @@ -91,9 +91,8 @@ static CFS_DEFINE_MUTEX(lcw_refcount_mutex); * dispatcher. */ /* BH lock! */ -static cfs_spinlock_t lcw_pending_timers_lock = CFS_SPIN_LOCK_UNLOCKED; -static cfs_list_t lcw_pending_timers = \ - CFS_LIST_HEAD_INIT(lcw_pending_timers); +static DEFINE_SPINLOCK(lcw_pending_timers_lock); +static cfs_list_t lcw_pending_timers = CFS_LIST_HEAD_INIT(lcw_pending_timers); /* Last time a watchdog expired */ static cfs_time_t lcw_last_watchdog_time; diff --git a/lustre/llite/llite_lib.c b/lustre/llite/llite_lib.c index bdb94d9..a42c6d8 100644 --- a/lustre/llite/llite_lib.c +++ b/lustre/llite/llite_lib.c @@ -59,7 +59,7 @@ cfs_mem_cache_t *ll_file_data_slab; CFS_LIST_HEAD(ll_super_blocks); -cfs_spinlock_t ll_sb_lock = CFS_SPIN_LOCK_UNLOCKED; +DEFINE_SPINLOCK(ll_sb_lock); #ifndef MS_HAS_NEW_AOPS extern struct address_space_operations ll_aops; diff --git a/lustre/llite/statahead.c b/lustre/llite/statahead.c index e231cd2..ce04b27 100644 --- a/lustre/llite/statahead.c +++ b/lustre/llite/statahead.c @@ -83,7 +83,7 @@ struct ll_sa_entry { }; static unsigned int sai_generation = 0; -static cfs_spinlock_t sai_generation_lock = CFS_SPIN_LOCK_UNLOCKED; +static DEFINE_SPINLOCK(sai_generation_lock); static inline int ll_sa_entry_unlinked(struct ll_sa_entry *entry) { diff --git a/lustre/lmv/lmv_object.c b/lustre/lmv/lmv_object.c index dc1a63e..f54f7b3 100644 --- a/lustre/lmv/lmv_object.c +++ b/lustre/lmv/lmv_object.c @@ -60,7 +60,7 @@ extern cfs_mem_cache_t *lmv_object_cache; extern cfs_atomic_t lmv_object_count; static CFS_LIST_HEAD(obj_list); -static cfs_spinlock_t obj_list_lock = CFS_SPIN_LOCK_UNLOCKED; +static DEFINE_SPINLOCK(obj_list_lock); struct lmv_object *lmv_object_alloc(struct obd_device *obd, const struct lu_fid *fid, diff --git a/lustre/lvfs/lvfs_linux.c b/lustre/lvfs/lvfs_linux.c index 6661280..f206e7e 100644 --- a/lustre/lvfs/lvfs_linux.c +++ b/lustre/lvfs/lvfs_linux.c @@ -64,7 +64,7 @@ __u64 obd_max_pages = 0; __u64 obd_max_alloc = 0; struct lprocfs_stats *obd_memory = NULL; EXPORT_SYMBOL(obd_memory); -cfs_spinlock_t obd_updatemax_lock = CFS_SPIN_LOCK_UNLOCKED; +DEFINE_SPINLOCK(obd_updatemax_lock); /* refine later and change to seqlock or simlar from libcfs */ /* Debugging check only needed during development */ diff --git a/lustre/mgc/mgc_request.c b/lustre/mgc/mgc_request.c index a693f79..bfeedc3 100644 --- a/lustre/mgc/mgc_request.c +++ b/lustre/mgc/mgc_request.c @@ -117,7 +117,7 @@ int mgc_logname2resid(char *logname, struct ldlm_res_id *res_id, int type) /********************** config llog list **********************/ static CFS_LIST_HEAD(config_llog_list); -static cfs_spinlock_t config_list_lock = CFS_SPIN_LOCK_UNLOCKED; +static DEFINE_SPINLOCK(config_list_lock); /* Take a reference to a config log */ static int config_log_get(struct config_llog_data *cld) diff --git a/lustre/obdclass/capa.c b/lustre/obdclass/capa.c index b121449..4fc3fff 100644 --- a/lustre/obdclass/capa.c +++ b/lustre/obdclass/capa.c @@ -65,7 +65,7 @@ cfs_mem_cache_t *capa_cachep = NULL; #ifdef __KERNEL__ /* lock for capa hash/capa_list/fo_capa_keys */ -cfs_spinlock_t capa_lock = CFS_SPIN_LOCK_UNLOCKED; +DEFINE_SPINLOCK(capa_lock); cfs_list_t capa_list[CAPA_SITE_MAX]; diff --git a/lustre/obdclass/cl_object.c b/lustre/obdclass/cl_object.c index 1912d70..5ab8a92 100644 --- a/lustre/obdclass/cl_object.c +++ b/lustre/obdclass/cl_object.c @@ -540,7 +540,7 @@ static CFS_LIST_HEAD(cl_envs); static unsigned cl_envs_cached_nr = 0; static unsigned cl_envs_cached_max = 128; /* XXX: prototype: arbitrary limit * for now. */ -static cfs_spinlock_t cl_envs_guard = CFS_SPIN_LOCK_UNLOCKED; +static DEFINE_SPINLOCK(cl_envs_guard); struct cl_env { void *ce_magic; diff --git a/lustre/obdclass/class_obd.c b/lustre/obdclass/class_obd.c index f8c5f9c..e2a0521 100644 --- a/lustre/obdclass/class_obd.c +++ b/lustre/obdclass/class_obd.c @@ -58,7 +58,7 @@ cfs_atomic_t libcfs_kmemory = {0}; struct obd_device *obd_devs[MAX_OBD_DEVICES]; EXPORT_SYMBOL(obd_devs); cfs_list_t obd_types; -cfs_rwlock_t obd_dev_lock = CFS_RW_LOCK_UNLOCKED; +DEFINE_RWLOCK(obd_dev_lock); #ifndef __KERNEL__ __u64 obd_max_pages = 0; diff --git a/lustre/obdclass/lu_object.c b/lustre/obdclass/lu_object.c index 507b4f2..caa2c01 100644 --- a/lustre/obdclass/lu_object.c +++ b/lustre/obdclass/lu_object.c @@ -1245,7 +1245,7 @@ enum { static struct lu_context_key *lu_keys[LU_CONTEXT_KEY_NR] = { NULL, }; -static cfs_spinlock_t lu_keys_guard = CFS_SPIN_LOCK_UNLOCKED; +static DEFINE_SPINLOCK(lu_keys_guard); /** * Global counter incremented whenever key is registered, unregistered, diff --git a/lustre/obdclass/lu_ref.c b/lustre/obdclass/lu_ref.c index 3471bd3..73f8cc5 100644 --- a/lustre/obdclass/lu_ref.c +++ b/lustre/obdclass/lu_ref.c @@ -97,7 +97,7 @@ static struct lu_kmem_descr lu_ref_caches[] = { static CFS_LIST_HEAD(lu_ref_refs); static cfs_spinlock_t lu_ref_refs_guard; static struct lu_ref lu_ref_marker = { - .lf_guard = CFS_SPIN_LOCK_UNLOCKED, + .lf_guard = DEFINE_SPINLOCK(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) }; diff --git a/lustre/ptlrpc/gss/gss_mech_switch.c b/lustre/ptlrpc/gss/gss_mech_switch.c index e1b340a..33f7773 100644 --- a/lustre/ptlrpc/gss/gss_mech_switch.c +++ b/lustre/ptlrpc/gss/gss_mech_switch.c @@ -64,7 +64,7 @@ #include "gss_api.h" static CFS_LIST_HEAD(registered_mechs); -static cfs_spinlock_t registered_mechs_lock = CFS_SPIN_LOCK_UNLOCKED; +static DEFINE_SPINLOCK(registered_mechs_lock); int lgss_mech_register(struct gss_api_mech *gm) { diff --git a/lustre/ptlrpc/pinger.c b/lustre/ptlrpc/pinger.c index 1b3038c..3490b9d 100644 --- a/lustre/ptlrpc/pinger.c +++ b/lustre/ptlrpc/pinger.c @@ -588,7 +588,7 @@ static int pet_refcount = 0; static int pet_state; static cfs_waitq_t pet_waitq; CFS_LIST_HEAD(pet_list); -static cfs_spinlock_t pet_lock = CFS_SPIN_LOCK_UNLOCKED; +static DEFINE_SPINLOCK(pet_lock); int ping_evictor_wake(struct obd_export *exp) { diff --git a/lustre/quota/quota_context.c b/lustre/quota/quota_context.c index e345a8f..05ba43a 100644 --- a/lustre/quota/quota_context.c +++ b/lustre/quota/quota_context.c @@ -69,7 +69,7 @@ unsigned long default_itune_ratio = 50; /* 50 percentage */ cfs_mem_cache_t *qunit_cachep = NULL; cfs_list_t qunit_hash[NR_DQHASH]; -cfs_spinlock_t qunit_hash_lock = CFS_SPIN_LOCK_UNLOCKED; +DEFINE_SPINLOCK(qunit_hash_lock); /* please sync qunit_state with qunit_state_names */ enum qunit_state { @@ -431,7 +431,7 @@ static struct lustre_qunit *alloc_qunit(struct lustre_quota_ctxt *qctxt, qunit->lq_ctxt = qctxt; memcpy(&qunit->lq_data, qdata, sizeof(*qdata)); qunit->lq_opc = opc; - qunit->lq_lock = CFS_SPIN_LOCK_UNLOCKED; + cfs_spin_lock_init(&qunit->lq_lock); QUNIT_SET_STATE_AND_RC(qunit, QUNIT_CREATED, 0); qunit->lq_owner = cfs_curproc_pid(); RETURN(qunit); @@ -529,7 +529,7 @@ void* quota_barrier(struct lustre_quota_ctxt *qctxt, } CFS_INIT_LIST_HEAD(&qunit->lq_hash); - qunit->lq_lock = CFS_SPIN_LOCK_UNLOCKED; + cfs_spin_lock_init(&qunit->lq_lock); cfs_waitq_init(&qunit->lq_waitq); cfs_atomic_set(&qunit->lq_refcnt, 1); qunit->lq_ctxt = qctxt; diff --git a/lustre/quota/quota_interface.c b/lustre/quota/quota_interface.c index 3cb5cf2f..3eab618 100644 --- a/lustre/quota/quota_interface.c +++ b/lustre/quota/quota_interface.c @@ -62,7 +62,7 @@ #ifdef __KERNEL__ static cfs_time_t last_print = 0; -static cfs_spinlock_t last_print_lock = CFS_SPIN_LOCK_UNLOCKED; +static DEFINE_SPINLOCK(last_print_lock); static int filter_quota_setup(struct obd_device *obd) { diff --git a/lustre/quota/quota_master.c b/lustre/quota/quota_master.c index 337d984..efd323d 100644 --- a/lustre/quota/quota_master.c +++ b/lustre/quota/quota_master.c @@ -60,7 +60,7 @@ /* lock ordering: mds->mds_qonoff_sem > dquot->dq_mutex > lqs->lqs_lock */ static cfs_list_t lustre_dquot_hash[NR_DQHASH]; -static cfs_rwlock_t dquot_hash_lock = CFS_RW_LOCK_UNLOCKED; +static DEFINE_RWLOCK(dquot_hash_lock); cfs_mem_cache_t *lustre_dquot_cachep;