Whamcloud - gitweb
LU-812 compat: SPIN/RW_LOCK_UNLOCKED no longer exist
authorJames Simmons <uja.ornl@gmail.com>
Tue, 7 Aug 2012 13:55:49 +0000 (09:55 -0400)
committerOleg Drokin <green@whamcloud.com>
Thu, 9 Aug 2012 02:02:02 +0000 (22:02 -0400)
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 <uja.ornl@gmail.com>
Signed-off-by: Wally Wang <wang@cray.com>
Change-Id: Ie294e817c850c35e561987f6ab46c6d12d6d018d
Reviewed-on: http://review.whamcloud.com/1942
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
19 files changed:
libcfs/include/libcfs/linux/linux-lock.h
libcfs/include/libcfs/user-lock.h
libcfs/include/libcfs/winnt/winnt-lock.h
libcfs/libcfs/watchdog.c
lustre/llite/llite_lib.c
lustre/llite/statahead.c
lustre/lmv/lmv_object.c
lustre/lvfs/lvfs_linux.c
lustre/mgc/mgc_request.c
lustre/obdclass/capa.c
lustre/obdclass/cl_object.c
lustre/obdclass/class_obd.c
lustre/obdclass/lu_object.c
lustre/obdclass/lu_ref.c
lustre/ptlrpc/gss/gss_mech_switch.c
lustre/ptlrpc/pinger.c
lustre/quota/quota_context.c
lustre/quota/quota_interface.c
lustre/quota/quota_master.c

index 8a9f66c..cc2ca51 100644 (file)
@@ -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)
index 4d35823..dbb97ff 100644 (file)
@@ -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)
 
index f0d7b96..169cc02 100644 (file)
@@ -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)
 {
index 6ce41c3..a394794 100644 (file)
@@ -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;
index bdb94d9..a42c6d8 100644 (file)
@@ -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;
index e231cd2..ce04b27 100644 (file)
@@ -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)
 {
index dc1a63e..f54f7b3 100644 (file)
@@ -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,
index 6661280..f206e7e 100644 (file)
@@ -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 */
index a693f79..bfeedc3 100644 (file)
@@ -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)
index b121449..4fc3fff 100644 (file)
@@ -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];
 
index 1912d70..5ab8a92 100644 (file)
@@ -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;
index f8c5f9c..e2a0521 100644 (file)
@@ -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;
index 507b4f2..caa2c01 100644 (file)
@@ -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,
index 3471bd3..73f8cc5 100644 (file)
@@ -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)
 };
index e1b340a..33f7773 100644 (file)
@@ -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)
 {
index 1b3038c..3490b9d 100644 (file)
@@ -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)
 {
index e345a8f..05ba43a 100644 (file)
@@ -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;
index 3cb5cf2..3eab618 100644 (file)
@@ -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)
 {
index 337d984..efd323d 100644 (file)
@@ -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;