From 19fff6ccfbd2889bc140fb5a8ee74902f8a35cc0 Mon Sep 17 00:00:00 2001 From: James Simmons Date: Wed, 11 Dec 2013 14:00:56 -0500 Subject: [PATCH] LU-3963 libcfs: convert obdecho,obdclass code to atomics This patch converts all cfs_atomic primitives in target, obdclass and obdecho. Signed-off-by: Liu Xuezhao Signed-off-by: Peng Tao Signed-off-by: James Simmons Change-Id: I6ab6d7a476f5192e6bdfb39d4956361ce2b3e987 Reviewed-on: http://review.whamcloud.com/7075 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Yang Sheng Reviewed-by: Oleg Drokin --- lustre/obdclass/capa.c | 2 +- lustre/obdclass/cl_io.c | 20 +++++------ lustre/obdclass/cl_lock.c | 30 ++++++++--------- lustre/obdclass/cl_object.c | 20 +++++------ lustre/obdclass/cl_page.c | 22 ++++++------- lustre/obdclass/class_obd.c | 12 +++---- lustre/obdclass/debug.c | 2 +- lustre/obdclass/genops.c | 64 ++++++++++++++++++------------------ lustre/obdclass/idmap.c | 4 +-- lustre/obdclass/linux/linux-module.c | 2 +- lustre/obdclass/llog.c | 8 ++--- lustre/obdclass/llog_obd.c | 8 ++--- lustre/obdclass/local_storage.c | 22 ++++++------- lustre/obdclass/local_storage.h | 2 +- lustre/obdclass/lprocfs_jobstats.c | 6 ++-- lustre/obdclass/lprocfs_status.c | 46 +++++++++++++------------- lustre/obdclass/lu_object.c | 38 ++++++++++----------- lustre/obdclass/obd_config.c | 16 ++++----- lustre/obdclass/obd_mount.c | 18 +++++----- lustre/obdclass/obd_mount_server.c | 6 ++-- lustre/obdecho/echo.c | 16 ++++----- lustre/obdecho/echo_client.c | 20 +++++------ 22 files changed, 192 insertions(+), 192 deletions(-) diff --git a/lustre/obdclass/capa.c b/lustre/obdclass/capa.c index 8f67dc7..5f5bc1b 100644 --- a/lustre/obdclass/capa.c +++ b/lustre/obdclass/capa.c @@ -184,7 +184,7 @@ static inline void capa_delete_lru(cfs_list_t *head) while (count++ < LRU_CAPA_DELETE_COUNT) { ocapa = cfs_list_entry(node, struct obd_capa, c_list); node = node->next; - if (cfs_atomic_read(&ocapa->c_refc)) + if (atomic_read(&ocapa->c_refc)) continue; DEBUG_CAPA(D_SEC, &ocapa->c_capa, "free lru"); diff --git a/lustre/obdclass/cl_io.c b/lustre/obdclass/cl_io.c index 0f1cb2c..e64cabe 100644 --- a/lustre/obdclass/cl_io.c +++ b/lustre/obdclass/cl_io.c @@ -1584,8 +1584,8 @@ void cl_sync_io_init(struct cl_sync_io *anchor, int nrpages) { ENTRY; init_waitqueue_head(&anchor->csi_waitq); - cfs_atomic_set(&anchor->csi_sync_nr, nrpages); - cfs_atomic_set(&anchor->csi_barrier, nrpages > 0); + atomic_set(&anchor->csi_sync_nr, nrpages); + atomic_set(&anchor->csi_barrier, nrpages > 0); anchor->csi_sync_rc = 0; EXIT; } @@ -1607,27 +1607,27 @@ int cl_sync_io_wait(const struct lu_env *env, struct cl_io *io, LASSERT(timeout >= 0); rc = l_wait_event(anchor->csi_waitq, - cfs_atomic_read(&anchor->csi_sync_nr) == 0, + atomic_read(&anchor->csi_sync_nr) == 0, &lwi); if (rc < 0) { CERROR("SYNC IO failed with error: %d, try to cancel " "%d remaining pages\n", - rc, cfs_atomic_read(&anchor->csi_sync_nr)); + rc, atomic_read(&anchor->csi_sync_nr)); (void)cl_io_cancel(env, io, queue); lwi = (struct l_wait_info) { 0 }; (void)l_wait_event(anchor->csi_waitq, - cfs_atomic_read(&anchor->csi_sync_nr) == 0, + atomic_read(&anchor->csi_sync_nr) == 0, &lwi); } else { rc = anchor->csi_sync_rc; } - LASSERT(cfs_atomic_read(&anchor->csi_sync_nr) == 0); + LASSERT(atomic_read(&anchor->csi_sync_nr) == 0); cl_page_list_assume(env, io, queue); /* wait until cl_sync_io_note() has done wakeup */ - while (unlikely(cfs_atomic_read(&anchor->csi_barrier) != 0)) { + while (unlikely(atomic_read(&anchor->csi_barrier) != 0)) { #ifdef __KERNEL__ cpu_relax(); #endif @@ -1651,11 +1651,11 @@ void cl_sync_io_note(struct cl_sync_io *anchor, int ioret) * ->{prepare,commit}_write(). Completion is used to signal the end of * IO. */ - LASSERT(cfs_atomic_read(&anchor->csi_sync_nr) > 0); - if (cfs_atomic_dec_and_test(&anchor->csi_sync_nr)) { + LASSERT(atomic_read(&anchor->csi_sync_nr) > 0); + if (atomic_dec_and_test(&anchor->csi_sync_nr)) { wake_up_all(&anchor->csi_waitq); /* it's safe to nuke or reuse anchor now */ - cfs_atomic_set(&anchor->csi_barrier, 0); + atomic_set(&anchor->csi_barrier, 0); } EXIT; } diff --git a/lustre/obdclass/cl_lock.c b/lustre/obdclass/cl_lock.c index 2a71cc3..d440da9 100644 --- a/lustre/obdclass/cl_lock.c +++ b/lustre/obdclass/cl_lock.c @@ -65,13 +65,13 @@ static struct lu_kmem_descr cl_lock_caches[] = { #ifdef CONFIG_DEBUG_PAGESTATE_TRACKING #define CS_LOCK_INC(o, item) \ - cfs_atomic_inc(&cl_object_site(o)->cs_locks.cs_stats[CS_##item]) + atomic_inc(&cl_object_site(o)->cs_locks.cs_stats[CS_##item]) #define CS_LOCK_DEC(o, item) \ - cfs_atomic_dec(&cl_object_site(o)->cs_locks.cs_stats[CS_##item]) + atomic_dec(&cl_object_site(o)->cs_locks.cs_stats[CS_##item]) #define CS_LOCKSTATE_INC(o, state) \ - cfs_atomic_inc(&cl_object_site(o)->cs_locks_state[state]) + atomic_inc(&cl_object_site(o)->cs_locks_state[state]) #define CS_LOCKSTATE_DEC(o, state) \ - cfs_atomic_dec(&cl_object_site(o)->cs_locks_state[state]) + atomic_dec(&cl_object_site(o)->cs_locks_state[state]) #else #define CS_LOCK_INC(o, item) #define CS_LOCK_DEC(o, item) @@ -89,7 +89,7 @@ static int cl_lock_invariant_trusted(const struct lu_env *env, const struct cl_lock *lock) { return ergo(lock->cll_state == CLS_FREEING, lock->cll_holds == 0) && - cfs_atomic_read(&lock->cll_ref) >= lock->cll_holds && + atomic_read(&lock->cll_ref) >= lock->cll_holds && lock->cll_holds >= lock->cll_users && lock->cll_holds >= 0 && lock->cll_users >= 0 && @@ -106,7 +106,7 @@ static int cl_lock_invariant(const struct lu_env *env, { int result; - result = cfs_atomic_read(&lock->cll_ref) > 0 && + result = atomic_read(&lock->cll_ref) > 0 && cl_lock_invariant_trusted(env, lock); if (!result && env != NULL) CL_LOCK_DEBUG(D_ERROR, env, lock, "invariant broken"); @@ -143,7 +143,7 @@ static void cl_lock_trace0(int level, const struct lu_env *env, struct cl_object_header *h = cl_object_header(lock->cll_descr.cld_obj); CDEBUG(level, "%s: %p@(%d %p %d %d %d %d %d %lx)" "(%p/%d/%d) at %s():%d\n", - prefix, lock, cfs_atomic_read(&lock->cll_ref), + prefix, lock, atomic_read(&lock->cll_ref), lock->cll_guarder, lock->cll_depth, lock->cll_state, lock->cll_error, lock->cll_holds, lock->cll_users, lock->cll_flags, @@ -306,9 +306,9 @@ void cl_lock_put(const struct lu_env *env, struct cl_lock *lock) LINVRNT(obj != NULL); CDEBUG(D_TRACE, "releasing reference: %d %p %lu\n", - cfs_atomic_read(&lock->cll_ref), lock, RETIP); + atomic_read(&lock->cll_ref), lock, RETIP); - if (cfs_atomic_dec_and_test(&lock->cll_ref)) { + if (atomic_dec_and_test(&lock->cll_ref)) { if (lock->cll_state == CLS_FREEING) { LASSERT(cfs_list_empty(&lock->cll_linkage)); cl_lock_free(env, lock); @@ -331,8 +331,8 @@ void cl_lock_get(struct cl_lock *lock) { LINVRNT(cl_lock_invariant(NULL, lock)); CDEBUG(D_TRACE, "acquiring reference: %d %p %lu\n", - cfs_atomic_read(&lock->cll_ref), lock, RETIP); - cfs_atomic_inc(&lock->cll_ref); + atomic_read(&lock->cll_ref), lock, RETIP); + atomic_inc(&lock->cll_ref); } EXPORT_SYMBOL(cl_lock_get); @@ -348,8 +348,8 @@ EXPORT_SYMBOL(cl_lock_get); void cl_lock_get_trust(struct cl_lock *lock) { CDEBUG(D_TRACE, "acquiring trusted reference: %d %p %lu\n", - cfs_atomic_read(&lock->cll_ref), lock, RETIP); - if (cfs_atomic_inc_return(&lock->cll_ref) == 1) + atomic_read(&lock->cll_ref), lock, RETIP); + if (atomic_inc_return(&lock->cll_ref) == 1) CS_LOCK_INC(lock->cll_descr.cld_obj, busy); } EXPORT_SYMBOL(cl_lock_get_trust); @@ -380,7 +380,7 @@ static struct cl_lock *cl_lock_alloc(const struct lu_env *env, ENTRY; OBD_SLAB_ALLOC_PTR_GFP(lock, cl_lock_kmem, __GFP_IO); if (lock != NULL) { - cfs_atomic_set(&lock->cll_ref, 1); + atomic_set(&lock->cll_ref, 1); lock->cll_descr = *descr; lock->cll_state = CLS_NEW; cl_object_get(obj); @@ -2157,7 +2157,7 @@ void cl_lock_print(const struct lu_env *env, void *cookie, { const struct cl_lock_slice *slice; (*printer)(env, cookie, "lock@%p[%d %d %d %d %d %08lx] ", - lock, cfs_atomic_read(&lock->cll_ref), + lock, atomic_read(&lock->cll_ref), lock->cll_state, lock->cll_error, lock->cll_holds, lock->cll_users, lock->cll_flags); cl_lock_descr_print(env, cookie, printer, &lock->cll_descr); diff --git a/lustre/obdclass/cl_object.c b/lustre/obdclass/cl_object.c index 1984836..57bb6cd 100644 --- a/lustre/obdclass/cl_object.c +++ b/lustre/obdclass/cl_object.c @@ -397,7 +397,7 @@ void cache_stats_init(struct cache_stats *cs, const char *name) cs->cs_name = name; for (i = 0; i < CS_NR; i++) - cfs_atomic_set(&cs->cs_stats[i], 0); + atomic_set(&cs->cs_stats[i], 0); } int cache_stats_print(const struct cache_stats *cs, @@ -422,7 +422,7 @@ int cache_stats_print(const struct cache_stats *cs, nob += snprintf(page + nob, count - nob, "%5.5s:", cs->cs_name); for (i = 0; i < CS_NR; i++) nob += snprintf(page + nob, count - nob, "%8u", - cfs_atomic_read(&cs->cs_stats[i])); + atomic_read(&cs->cs_stats[i])); return nob; } @@ -444,9 +444,9 @@ int cl_site_init(struct cl_site *s, struct cl_device *d) cache_stats_init(&s->cs_pages, "pages"); cache_stats_init(&s->cs_locks, "locks"); for (i = 0; i < ARRAY_SIZE(s->cs_pages_state); ++i) - cfs_atomic_set(&s->cs_pages_state[0], 0); + atomic_set(&s->cs_pages_state[0], 0); for (i = 0; i < ARRAY_SIZE(s->cs_locks_state); ++i) - cfs_atomic_set(&s->cs_locks_state[i], 0); + atomic_set(&s->cs_locks_state[i], 0); cl_env_percpu_refill(); } return result; @@ -464,7 +464,7 @@ EXPORT_SYMBOL(cl_site_fini); static struct cache_stats cl_env_stats = { .cs_name = "envs", - .cs_stats = { CFS_ATOMIC_INIT(0), } + .cs_stats = { ATOMIC_INIT(0), } }; /** @@ -503,14 +503,14 @@ locks: ...... ...... ...... ...... ...... [...... ...... ...... ...... ......] for (i = 0; i < ARRAY_SIZE(site->cs_pages_state); ++i) nob += snprintf(page + nob, count - nob, "%s: %u ", pstate[i], - cfs_atomic_read(&site->cs_pages_state[i])); + atomic_read(&site->cs_pages_state[i])); nob += snprintf(page + nob, count - nob, "]\n"); nob += cache_stats_print(&site->cs_locks, page + nob, count - nob, 0); nob += snprintf(page + nob, count - nob, " ["); for (i = 0; i < ARRAY_SIZE(site->cs_locks_state); ++i) nob += snprintf(page + nob, count - nob, "%s: %u ", lstate[i], - cfs_atomic_read(&site->cs_locks_state[i])); + atomic_read(&site->cs_locks_state[i])); nob += snprintf(page + nob, count - nob, "]\n"); nob += cache_stats_print(&cl_env_stats, page + nob, count - nob, 0); nob += snprintf(page + nob, count - nob, "\n"); @@ -592,11 +592,11 @@ struct cl_env { }; #ifdef CONFIG_DEBUG_PAGESTATE_TRACKING -#define CL_ENV_INC(counter) cfs_atomic_inc(&cl_env_stats.cs_stats[CS_##counter]) +#define CL_ENV_INC(counter) atomic_inc(&cl_env_stats.cs_stats[CS_##counter]) #define CL_ENV_DEC(counter) do { \ - LASSERT(cfs_atomic_read(&cl_env_stats.cs_stats[CS_##counter]) > 0); \ - cfs_atomic_dec(&cl_env_stats.cs_stats[CS_##counter]); \ + LASSERT(atomic_read(&cl_env_stats.cs_stats[CS_##counter]) > 0); \ + atomic_dec(&cl_env_stats.cs_stats[CS_##counter]); \ } while (0) #else #define CL_ENV_INC(counter) diff --git a/lustre/obdclass/cl_page.c b/lustre/obdclass/cl_page.c index a42d12f..2d19693 100644 --- a/lustre/obdclass/cl_page.c +++ b/lustre/obdclass/cl_page.c @@ -80,13 +80,13 @@ static void cl_page_delete0(const struct lu_env *env, struct cl_page *pg); /* Disable page statistic by default due to huge performance penalty. */ #ifdef CONFIG_DEBUG_PAGESTATE_TRACKING #define CS_PAGE_INC(o, item) \ - cfs_atomic_inc(&cl_object_site(o)->cs_pages.cs_stats[CS_##item]) + atomic_inc(&cl_object_site(o)->cs_pages.cs_stats[CS_##item]) #define CS_PAGE_DEC(o, item) \ - cfs_atomic_dec(&cl_object_site(o)->cs_pages.cs_stats[CS_##item]) + atomic_dec(&cl_object_site(o)->cs_pages.cs_stats[CS_##item]) #define CS_PAGESTATE_INC(o, state) \ - cfs_atomic_inc(&cl_object_site(o)->cs_pages_state[state]) + atomic_inc(&cl_object_site(o)->cs_pages_state[state]) #define CS_PAGESTATE_DEC(o, state) \ - cfs_atomic_dec(&cl_object_site(o)->cs_pages_state[state]) + atomic_dec(&cl_object_site(o)->cs_pages_state[state]) #else #define CS_PAGE_INC(o, item) #define CS_PAGE_DEC(o, item) @@ -106,8 +106,8 @@ static void cl_page_delete0(const struct lu_env *env, struct cl_page *pg); */ static void cl_page_get_trust(struct cl_page *page) { - LASSERT(cfs_atomic_read(&page->cp_ref) > 0); - cfs_atomic_inc(&page->cp_ref); + LASSERT(atomic_read(&page->cp_ref) > 0); + atomic_inc(&page->cp_ref); } /** @@ -182,7 +182,7 @@ struct cl_page *cl_page_alloc(const struct lu_env *env, __GFP_IO); if (page != NULL) { int result = 0; - cfs_atomic_set(&page->cp_ref, 1); + atomic_set(&page->cp_ref, 1); page->cp_obj = o; cl_object_get(o); lu_object_ref_add_at(&o->co_lu, &page->cp_obj_ref, "cl_page", @@ -382,12 +382,12 @@ void cl_page_put(const struct lu_env *env, struct cl_page *page) { ENTRY; CL_PAGE_HEADER(D_TRACE, env, page, "%d\n", - cfs_atomic_read(&page->cp_ref)); + atomic_read(&page->cp_ref)); - if (cfs_atomic_dec_and_test(&page->cp_ref)) { + if (atomic_dec_and_test(&page->cp_ref)) { LASSERT(page->cp_state == CPS_FREEING); - LASSERT(cfs_atomic_read(&page->cp_ref) == 0); + LASSERT(atomic_read(&page->cp_ref) == 0); PASSERT(env, page, page->cp_owner == NULL); PASSERT(env, page, cfs_list_empty(&page->cp_batch)); /* @@ -1068,7 +1068,7 @@ void cl_page_header_print(const struct lu_env *env, void *cookie, { (*printer)(env, cookie, "page@%p[%d %p %d %d %d %p %p %#x]\n", - pg, cfs_atomic_read(&pg->cp_ref), pg->cp_obj, + pg, atomic_read(&pg->cp_ref), pg->cp_obj, pg->cp_state, pg->cp_error, pg->cp_type, pg->cp_owner, pg->cp_req, pg->cp_flags); } diff --git a/lustre/obdclass/class_obd.c b/lustre/obdclass/class_obd.c index cb0ea79..71b479a 100644 --- a/lustre/obdclass/class_obd.c +++ b/lustre/obdclass/class_obd.c @@ -57,7 +57,7 @@ #ifndef __KERNEL__ /* liblustre workaround */ -cfs_atomic_t libcfs_kmemory = {0}; +atomic_t libcfs_kmemory = {0}; #endif struct obd_device *obd_devs[MAX_OBD_DEVICES]; @@ -84,9 +84,9 @@ unsigned int obd_dump_on_eviction; EXPORT_SYMBOL(obd_dump_on_eviction); unsigned int obd_max_dirty_pages = 256; EXPORT_SYMBOL(obd_max_dirty_pages); -cfs_atomic_t obd_unstable_pages; +atomic_t obd_unstable_pages; EXPORT_SYMBOL(obd_unstable_pages); -cfs_atomic_t obd_dirty_pages; +atomic_t obd_dirty_pages; EXPORT_SYMBOL(obd_dirty_pages); unsigned int obd_timeout = OBD_TIMEOUT_DEFAULT; /* seconds */ EXPORT_SYMBOL(obd_timeout); @@ -108,7 +108,7 @@ EXPORT_SYMBOL(at_early_margin); int at_extra = 30; EXPORT_SYMBOL(at_extra); -cfs_atomic_t obd_dirty_transit_pages; +atomic_t obd_dirty_transit_pages; EXPORT_SYMBOL(obd_dirty_transit_pages); char obd_jobid_var[JOBSTATS_JOBID_VAR_MAX_LEN + 1] = JOBSTATS_DISABLE; @@ -191,7 +191,7 @@ int obd_alloc_fail(const void *ptr, const char *name, const char *type, obd_memory_sum(), obd_pages_sum() << PAGE_CACHE_SHIFT, obd_pages_sum(), - cfs_atomic_read(&libcfs_kmemory)); + atomic_read(&libcfs_kmemory)); return 1; } return 0; @@ -392,7 +392,7 @@ int class_handle_ioctl(unsigned int cmd, unsigned long arg) snprintf(str, len - sizeof(*data), "%3d %s %s %s %s %d", (int)index, status, obd->obd_type->typ_name, obd->obd_name, obd->obd_uuid.uuid, - cfs_atomic_read(&obd->obd_refcount)); + atomic_read(&obd->obd_refcount)); err = obd_ioctl_popdata((void *)arg, data, len); GOTO(out, err = 0); diff --git a/lustre/obdclass/debug.c b/lustre/obdclass/debug.c index 055fe0e..2754af9 100644 --- a/lustre/obdclass/debug.c +++ b/lustre/obdclass/debug.c @@ -66,7 +66,7 @@ void dump_lsm(int level, struct lov_stripe_md *lsm) " layout_gen %u, pool ["LOV_POOLNAMEF"]\n", lsm, POSTID(&lsm->lsm_oi), lsm->lsm_maxbytes, lsm->lsm_magic, lsm->lsm_stripe_size, lsm->lsm_stripe_count, - cfs_atomic_read(&lsm->lsm_refc), lsm->lsm_layout_gen, + atomic_read(&lsm->lsm_refc), lsm->lsm_layout_gen, lsm->lsm_pool_name); } EXPORT_SYMBOL(dump_lsm); diff --git a/lustre/obdclass/genops.c b/lustre/obdclass/genops.c index 9d577f9..b832620 100644 --- a/lustre/obdclass/genops.c +++ b/lustre/obdclass/genops.c @@ -549,7 +549,7 @@ void class_obd_list(void) LCONSOLE(D_CONFIG, "%3d %s %s %s %s %d\n", i, status, obd->obd_type->typ_name, obd->obd_name, obd->obd_uuid.uuid, - cfs_atomic_read(&obd->obd_refcount)); + atomic_read(&obd->obd_refcount)); } read_unlock(&obd_dev_lock); return; @@ -824,9 +824,9 @@ static struct portals_handle_ops export_handle_ops = { struct obd_export *class_export_get(struct obd_export *exp) { - cfs_atomic_inc(&exp->exp_refcount); + atomic_inc(&exp->exp_refcount); CDEBUG(D_INFO, "GETting export %p : new refcount %d\n", exp, - cfs_atomic_read(&exp->exp_refcount)); + atomic_read(&exp->exp_refcount)); return exp; } EXPORT_SYMBOL(class_export_get); @@ -836,9 +836,9 @@ void class_export_put(struct obd_export *exp) LASSERT(exp != NULL); LASSERT_ATOMIC_GT_LT(&exp->exp_refcount, 0, LI_POISON); CDEBUG(D_INFO, "PUTting export %p : new refcount %d\n", exp, - cfs_atomic_read(&exp->exp_refcount) - 1); + atomic_read(&exp->exp_refcount) - 1); - if (cfs_atomic_dec_and_test(&exp->exp_refcount)) { + if (atomic_dec_and_test(&exp->exp_refcount)) { LASSERT(!cfs_list_empty(&exp->exp_obd_chain)); CDEBUG(D_IOCTL, "final put %p/%s\n", exp, exp->exp_client_uuid.uuid); @@ -869,15 +869,15 @@ struct obd_export *class_new_export(struct obd_device *obd, export->exp_conn_cnt = 0; export->exp_lock_hash = NULL; export->exp_flock_hash = NULL; - cfs_atomic_set(&export->exp_refcount, 2); - cfs_atomic_set(&export->exp_rpc_count, 0); - cfs_atomic_set(&export->exp_cb_count, 0); - cfs_atomic_set(&export->exp_locks_count, 0); + atomic_set(&export->exp_refcount, 2); + atomic_set(&export->exp_rpc_count, 0); + atomic_set(&export->exp_cb_count, 0); + atomic_set(&export->exp_locks_count, 0); #if LUSTRE_TRACKS_LOCK_EXP_REFS CFS_INIT_LIST_HEAD(&export->exp_locks_list); spin_lock_init(&export->exp_locks_list_guard); #endif - cfs_atomic_set(&export->exp_replay_count, 0); + atomic_set(&export->exp_replay_count, 0); export->exp_obd = obd; CFS_INIT_LIST_HEAD(&export->exp_outstanding_replies); spin_lock_init(&export->exp_uncommitted_replies_lock); @@ -1006,9 +1006,9 @@ static struct portals_handle_ops import_handle_ops = { struct obd_import *class_import_get(struct obd_import *import) { - cfs_atomic_inc(&import->imp_refcount); + atomic_inc(&import->imp_refcount); CDEBUG(D_INFO, "import %p refcount=%d obd=%s\n", import, - cfs_atomic_read(&import->imp_refcount), + atomic_read(&import->imp_refcount), import->imp_obd->obd_name); return import; } @@ -1022,10 +1022,10 @@ void class_import_put(struct obd_import *imp) LASSERT_ATOMIC_GT_LT(&imp->imp_refcount, 0, LI_POISON); CDEBUG(D_INFO, "import %p refcount=%d obd=%s\n", imp, - cfs_atomic_read(&imp->imp_refcount) - 1, + atomic_read(&imp->imp_refcount) - 1, imp->imp_obd->obd_name); - if (cfs_atomic_dec_and_test(&imp->imp_refcount)) { + if (atomic_dec_and_test(&imp->imp_refcount)) { CDEBUG(D_INFO, "final put import %p\n", imp); obd_zombie_import_add(imp); } @@ -1070,11 +1070,11 @@ struct obd_import *class_new_import(struct obd_device *obd) mutex_init(&imp->imp_sec_mutex); init_waitqueue_head(&imp->imp_recovery_waitq); - cfs_atomic_set(&imp->imp_refcount, 2); - cfs_atomic_set(&imp->imp_unregistering, 0); - cfs_atomic_set(&imp->imp_inflight, 0); - cfs_atomic_set(&imp->imp_replay_inflight, 0); - cfs_atomic_set(&imp->imp_inval_count, 0); + atomic_set(&imp->imp_refcount, 2); + atomic_set(&imp->imp_unregistering, 0); + atomic_set(&imp->imp_inflight, 0); + atomic_set(&imp->imp_replay_inflight, 0); + atomic_set(&imp->imp_inval_count, 0); CFS_INIT_LIST_HEAD(&imp->imp_conn_list); CFS_INIT_LIST_HEAD(&imp->imp_handle.h_link); class_handle_hash(&imp->imp_handle, &import_handle_ops); @@ -1185,7 +1185,7 @@ void class_export_recovery_cleanup(struct obd_export *exp) exp->exp_in_recovery = 0; spin_unlock(&exp->exp_lock); LASSERT_ATOMIC_POS(&obd->obd_connected_clients); - cfs_atomic_dec(&obd->obd_connected_clients); + atomic_dec(&obd->obd_connected_clients); } /* if called during recovery then should update @@ -1201,16 +1201,16 @@ void class_export_recovery_cleanup(struct obd_export *exp) spin_lock(&exp->exp_lock); exp->exp_req_replay_needed = 0; spin_unlock(&exp->exp_lock); - LASSERT(cfs_atomic_read(&obd->obd_req_replay_clients)); - cfs_atomic_dec(&obd->obd_req_replay_clients); + LASSERT(atomic_read(&obd->obd_req_replay_clients)); + atomic_dec(&obd->obd_req_replay_clients); } /** Cleanup lock replay data */ if (exp->exp_lock_replay_needed) { spin_lock(&exp->exp_lock); exp->exp_lock_replay_needed = 0; spin_unlock(&exp->exp_lock); - LASSERT(cfs_atomic_read(&obd->obd_lock_replay_clients)); - cfs_atomic_dec(&obd->obd_lock_replay_clients); + LASSERT(atomic_read(&obd->obd_lock_replay_clients)); + atomic_dec(&obd->obd_lock_replay_clients); } } @@ -1554,10 +1554,10 @@ static void print_export_data(struct obd_export *exp, const char *status, CDEBUG(D_HA, "%s: %s %p %s %s %d (%d %d %d) %d %d %d %d: %p %s "LPU64"\n", exp->exp_obd->obd_name, status, exp, exp->exp_client_uuid.uuid, - obd_export_nid2str(exp), cfs_atomic_read(&exp->exp_refcount), - cfs_atomic_read(&exp->exp_rpc_count), - cfs_atomic_read(&exp->exp_cb_count), - cfs_atomic_read(&exp->exp_locks_count), + obd_export_nid2str(exp), atomic_read(&exp->exp_refcount), + atomic_read(&exp->exp_rpc_count), + atomic_read(&exp->exp_cb_count), + atomic_read(&exp->exp_locks_count), exp->exp_disconnected, exp->exp_delayed, exp->exp_failed, nreplies, first_reply, nreplies > 3 ? "..." : "", exp->exp_last_committed); @@ -1600,7 +1600,7 @@ void obd_exports_barrier(struct obd_device *obd) "more than %d seconds. " "The obd refcount = %d. Is it stuck?\n", obd->obd_name, waited, - cfs_atomic_read(&obd->obd_refcount)); + atomic_read(&obd->obd_refcount)); dump_exports(obd, 1); } waited *= 2; @@ -1792,7 +1792,7 @@ static int obd_zombie_impexp_thread(void *unused) #else /* ! KERNEL */ -static cfs_atomic_t zombie_recur = CFS_ATOMIC_INIT(0); +static atomic_t zombie_recur = ATOMIC_INIT(0); static void *obd_zombie_impexp_work_cb; static void *obd_zombie_impexp_idle_cb; @@ -1800,11 +1800,11 @@ int obd_zombie_impexp_kill(void *arg) { int rc = 0; - if (cfs_atomic_inc_return(&zombie_recur) == 1) { + if (atomic_inc_return(&zombie_recur) == 1) { obd_zombie_impexp_cull(); rc = 1; } - cfs_atomic_dec(&zombie_recur); + atomic_dec(&zombie_recur); return rc; } diff --git a/lustre/obdclass/idmap.c b/lustre/obdclass/idmap.c index 4ee3685..6313ec8 100644 --- a/lustre/obdclass/idmap.c +++ b/lustre/obdclass/idmap.c @@ -47,11 +47,11 @@ #include #define lustre_get_group_info(group_info) do { \ - cfs_atomic_inc(&(group_info)->usage); \ + atomic_inc(&(group_info)->usage); \ } while (0) #define lustre_put_group_info(group_info) do { \ - if (cfs_atomic_dec_and_test(&(group_info)->usage)) \ + if (atomic_dec_and_test(&(group_info)->usage)) \ groups_free(group_info); \ } while (0) diff --git a/lustre/obdclass/linux/linux-module.c b/lustre/obdclass/linux/linux-module.c index 4e9e3f9..e96802d 100644 --- a/lustre/obdclass/linux/linux-module.c +++ b/lustre/obdclass/linux/linux-module.c @@ -378,7 +378,7 @@ static int obd_device_list_seq_show(struct seq_file *p, void *v) return seq_printf(p, "%3d %s %s %s %s %d\n", (int)index, status, obd->obd_type->typ_name, obd->obd_name, obd->obd_uuid.uuid, - cfs_atomic_read(&obd->obd_refcount)); + atomic_read(&obd->obd_refcount)); } struct seq_operations obd_device_list_sops = { diff --git a/lustre/obdclass/llog.c b/lustre/obdclass/llog.c index a690233..e77eb63 100644 --- a/lustre/obdclass/llog.c +++ b/lustre/obdclass/llog.c @@ -70,7 +70,7 @@ struct llog_handle *llog_alloc_handle(void) init_rwsem(&loghandle->lgh_lock); spin_lock_init(&loghandle->lgh_hdr_lock); CFS_INIT_LIST_HEAD(&loghandle->u.phd.phd_entry); - cfs_atomic_set(&loghandle->lgh_refcount, 1); + atomic_set(&loghandle->lgh_refcount, 1); return loghandle; } @@ -98,13 +98,13 @@ out: void llog_handle_get(struct llog_handle *loghandle) { - cfs_atomic_inc(&loghandle->lgh_refcount); + atomic_inc(&loghandle->lgh_refcount); } void llog_handle_put(struct llog_handle *loghandle) { - LASSERT(cfs_atomic_read(&loghandle->lgh_refcount) > 0); - if (cfs_atomic_dec_and_test(&loghandle->lgh_refcount)) + LASSERT(atomic_read(&loghandle->lgh_refcount) > 0); + if (atomic_dec_and_test(&loghandle->lgh_refcount)) llog_free_handle(loghandle); } diff --git a/lustre/obdclass/llog_obd.c b/lustre/obdclass/llog_obd.c index ded9dc6..20866c3 100644 --- a/lustre/obdclass/llog_obd.c +++ b/lustre/obdclass/llog_obd.c @@ -54,7 +54,7 @@ static struct llog_ctxt* llog_new_ctxt(struct obd_device *obd) return NULL; ctxt->loc_obd = obd; - cfs_atomic_set(&ctxt->loc_refcount, 1); + atomic_set(&ctxt->loc_refcount, 1); return ctxt; } @@ -79,7 +79,7 @@ int __llog_ctxt_put(const struct lu_env *env, struct llog_ctxt *ctxt) int rc = 0; spin_lock(&olg->olg_lock); - if (!cfs_atomic_dec_and_test(&ctxt->loc_refcount)) { + if (!atomic_dec_and_test(&ctxt->loc_refcount)) { spin_unlock(&olg->olg_lock); return rc; } @@ -127,8 +127,8 @@ int llog_cleanup(const struct lu_env *env, struct llog_ctxt *ctxt) /* * Banlance the ctxt get when calling llog_cleanup() */ - LASSERT(cfs_atomic_read(&ctxt->loc_refcount) < LI_POISON); - LASSERT(cfs_atomic_read(&ctxt->loc_refcount) > 1); + LASSERT(atomic_read(&ctxt->loc_refcount) < LI_POISON); + LASSERT(atomic_read(&ctxt->loc_refcount) > 1); llog_ctxt_put(ctxt); /* diff --git a/lustre/obdclass/local_storage.c b/lustre/obdclass/local_storage.c index 2799aba..ff3334f 100644 --- a/lustre/obdclass/local_storage.c +++ b/lustre/obdclass/local_storage.c @@ -110,7 +110,7 @@ static struct ls_device *__ls_find_dev(struct dt_device *dev) cfs_list_for_each_entry(ls, &ls_list_head, ls_linkage) { if (ls->ls_osd == dev) { - cfs_atomic_inc(&ls->ls_refcount); + atomic_inc(&ls->ls_refcount); ret = ls; break; } @@ -155,7 +155,7 @@ struct ls_device *ls_device_get(struct dt_device *dev) if (ls == NULL) GOTO(out_ls, ls = ERR_PTR(-ENOMEM)); - cfs_atomic_set(&ls->ls_refcount, 1); + atomic_set(&ls->ls_refcount, 1); CFS_INIT_LIST_HEAD(&ls->ls_los_list); mutex_init(&ls->ls_los_mutex); @@ -176,11 +176,11 @@ out_ls: void ls_device_put(const struct lu_env *env, struct ls_device *ls) { LASSERT(env); - if (!cfs_atomic_dec_and_test(&ls->ls_refcount)) + if (!atomic_dec_and_test(&ls->ls_refcount)) return; mutex_lock(&ls_list_mutex); - if (cfs_atomic_read(&ls->ls_refcount) == 0) { + if (atomic_read(&ls->ls_refcount) == 0) { LASSERT(cfs_list_empty(&ls->ls_los_list)); cfs_list_del(&ls->ls_linkage); lu_site_purge(env, ls->ls_top_dev.dd_lu_dev.ld_site, ~0); @@ -642,7 +642,7 @@ struct local_oid_storage *dt_los_find(struct ls_device *ls, __u64 seq) cfs_list_for_each_entry(los, &ls->ls_los_list, los_list) { if (los->los_seq == seq) { - cfs_atomic_inc(&los->los_refcount); + atomic_inc(&los->los_refcount); ret = los; break; } @@ -652,7 +652,7 @@ struct local_oid_storage *dt_los_find(struct ls_device *ls, __u64 seq) void dt_los_put(struct local_oid_storage *los) { - if (cfs_atomic_dec_and_test(&los->los_refcount)) + if (atomic_dec_and_test(&los->los_refcount)) /* should never happen, only local_oid_storage_fini should * drop refcount to zero */ LBUG(); @@ -777,10 +777,10 @@ int local_oid_storage_init(const struct lu_env *env, struct dt_device *dev, if (*los == NULL) GOTO(out, rc = -ENOMEM); - cfs_atomic_set(&(*los)->los_refcount, 1); + atomic_set(&(*los)->los_refcount, 1); mutex_init(&(*los)->los_id_lock); (*los)->los_dev = &ls->ls_top_dev; - cfs_atomic_inc(&ls->ls_refcount); + atomic_inc(&ls->ls_refcount); cfs_list_add(&(*los)->los_list, &ls->ls_los_list); /* Use {seq, 0, 0} to create the LAST_ID file for every @@ -858,7 +858,7 @@ out_trans: out_los: if (rc != 0) { cfs_list_del(&(*los)->los_list); - cfs_atomic_dec(&ls->ls_refcount); + atomic_dec(&ls->ls_refcount); OBD_FREE_PTR(*los); *los = NULL; if (o != NULL && !IS_ERR(o)) @@ -886,7 +886,7 @@ void local_oid_storage_fini(const struct lu_env *env, { struct ls_device *ls; - if (!cfs_atomic_dec_and_test(&los->los_refcount)) + if (!atomic_dec_and_test(&los->los_refcount)) return; LASSERT(env); @@ -894,7 +894,7 @@ void local_oid_storage_fini(const struct lu_env *env, ls = dt2ls_dev(los->los_dev); mutex_lock(&ls->ls_los_mutex); - if (cfs_atomic_read(&los->los_refcount) > 0) { + if (atomic_read(&los->los_refcount) > 0) { mutex_unlock(&ls->ls_los_mutex); return; } diff --git a/lustre/obdclass/local_storage.h b/lustre/obdclass/local_storage.h index f7d6c9a..4471877 100644 --- a/lustre/obdclass/local_storage.h +++ b/lustre/obdclass/local_storage.h @@ -42,7 +42,7 @@ struct ls_device { /* all initialized ls_devices on this node linked by this */ cfs_list_t ls_linkage; /* how many handle's reference this local storage */ - cfs_atomic_t ls_refcount; + atomic_t ls_refcount; /* underlaying OSD device */ struct dt_device *ls_osd; /* list of all local OID storages */ diff --git a/lustre/obdclass/lprocfs_jobstats.c b/lustre/obdclass/lprocfs_jobstats.c index f67e426..36c6e1e 100644 --- a/lustre/obdclass/lprocfs_jobstats.c +++ b/lustre/obdclass/lprocfs_jobstats.c @@ -69,7 +69,7 @@ struct job_stat { cfs_hlist_node_t js_hash; cfs_list_t js_list; - cfs_atomic_t js_refcount; + atomic_t js_refcount; char js_jobid[JOBSTATS_JOBID_SIZE]; time_t js_timestamp; /* seconds */ struct lprocfs_stats *js_stats; @@ -105,7 +105,7 @@ static void job_stat_get(cfs_hash_t *hs, cfs_hlist_node_t *hnode) { struct job_stat *job; job = cfs_hlist_entry(hnode, struct job_stat, js_hash); - cfs_atomic_inc(&job->js_refcount); + atomic_inc(&job->js_refcount); } static void job_free(struct job_stat *job) @@ -204,7 +204,7 @@ static struct job_stat *job_alloc(char *jobid, struct obd_job_stats *jobs) job->js_jobstats = jobs; CFS_INIT_HLIST_NODE(&job->js_hash); CFS_INIT_LIST_HEAD(&job->js_list); - cfs_atomic_set(&job->js_refcount, 1); + atomic_set(&job->js_refcount, 1); return job; } diff --git a/lustre/obdclass/lprocfs_status.c b/lustre/obdclass/lprocfs_status.c index 9b39be3..6e9423a 100644 --- a/lustre/obdclass/lprocfs_status.c +++ b/lustre/obdclass/lprocfs_status.c @@ -291,7 +291,7 @@ int lprocfs_evict_client_open(struct inode *inode, struct file *f) struct proc_dir_entry *dp = PDE(f->f_dentry->d_inode); struct obd_device *obd = dp->data; - cfs_atomic_inc(&obd->obd_evict_inprogress); + atomic_inc(&obd->obd_evict_inprogress); return 0; } @@ -301,7 +301,7 @@ int lprocfs_evict_client_release(struct inode *inode, struct file *f) struct proc_dir_entry *dp = PDE(f->f_dentry->d_inode); struct obd_device *obd = dp->data; - cfs_atomic_dec(&obd->obd_evict_inprogress); + atomic_dec(&obd->obd_evict_inprogress); wake_up(&obd->obd_evict_inprogress_waitq); return 0; @@ -652,7 +652,7 @@ EXPORT_SYMBOL(lprocfs_u64_seq_show); int lprocfs_atomic_seq_show(struct seq_file *m, void *data) { - cfs_atomic_t *atom = data; + atomic_t *atom = data; LASSERT(atom != NULL); return seq_printf(m, "%d\n", atomic_read(atom)); } @@ -662,7 +662,7 @@ ssize_t lprocfs_atomic_seq_write(struct file *file, const char *buffer, size_t count, loff_t *off) { - cfs_atomic_t *atm = ((struct seq_file *)file->private_data)->private; + atomic_t *atm = ((struct seq_file *)file->private_data)->private; int val = 0; int rc; @@ -673,7 +673,7 @@ lprocfs_atomic_seq_write(struct file *file, const char *buffer, if (val <= 0) return -ERANGE; - cfs_atomic_set(atm, val); + atomic_set(atm, val); return count; } EXPORT_SYMBOL(lprocfs_atomic_seq_write); @@ -1301,17 +1301,17 @@ EXPORT_SYMBOL(lprocfs_rd_u64); int lprocfs_rd_atomic(char *page, char **start, off_t off, int count, int *eof, void *data) { - cfs_atomic_t *atom = data; + atomic_t *atom = data; LASSERT(atom != NULL); *eof = 1; - return snprintf(page, count, "%d\n", cfs_atomic_read(atom)); + return snprintf(page, count, "%d\n", atomic_read(atom)); } EXPORT_SYMBOL(lprocfs_rd_atomic); int lprocfs_wr_atomic(struct file *file, const char *buffer, unsigned long count, void *data) { - cfs_atomic_t *atm = data; + atomic_t *atm = data; int val = 0; int rc; @@ -1322,7 +1322,7 @@ int lprocfs_wr_atomic(struct file *file, const char *buffer, if (val <= 0) return -ERANGE; - cfs_atomic_set(atm, val); + atomic_set(atm, val); return count; } EXPORT_SYMBOL(lprocfs_wr_atomic); @@ -1589,7 +1589,7 @@ int lprocfs_rd_import(char *page, char **start, off_t off, int count, libcfs_nid2str(imp->imp_connection->c_peer.nid), imp->imp_conn_cnt, imp->imp_generation, - cfs_atomic_read(&imp->imp_inval_count)); + atomic_read(&imp->imp_inval_count)); spin_unlock(&imp->imp_lock); if (obd->obd_svc_stats == NULL) @@ -1610,9 +1610,9 @@ int lprocfs_rd_import(char *page, char **start, off_t off, int count, " unregistering: %u\n" " timeouts: %u\n" " avg_waittime: "LPU64" %s\n", - cfs_atomic_read(&imp->imp_inflight), - cfs_atomic_read(&imp->imp_unregistering), - cfs_atomic_read(&imp->imp_timeouts), + atomic_read(&imp->imp_inflight), + atomic_read(&imp->imp_unregistering), + atomic_read(&imp->imp_timeouts), ret.lc_sum, header->lc_units); k = 0; @@ -1881,7 +1881,7 @@ static void lprocfs_free_client_stats(struct nid_stat *client_stat) CDEBUG(D_CONFIG, "stat %p - data %p/%p\n", client_stat, client_stat->nid_proc, client_stat->nid_stats); - LASSERTF(cfs_atomic_read(&client_stat->nid_exp_ref_count) == 0, + LASSERTF(atomic_read(&client_stat->nid_exp_ref_count) == 0, "nid %s:count %d\n", libcfs_nid2str(client_stat->nid), atomic_read(&client_stat->nid_exp_ref_count)); @@ -2594,8 +2594,8 @@ static int lprocfs_nid_stats_clear_write_cb(void *obj, void *data) struct nid_stat *stat = obj; ENTRY; - CDEBUG(D_INFO,"refcnt %d\n", cfs_atomic_read(&stat->nid_exp_ref_count)); - if (cfs_atomic_read(&stat->nid_exp_ref_count) == 1) { + CDEBUG(D_INFO,"refcnt %d\n", atomic_read(&stat->nid_exp_ref_count)); + if (atomic_read(&stat->nid_exp_ref_count) == 1) { /* object has only hash references. */ spin_lock(&stat->nid_obd->obd_nid_lock); cfs_list_move(&stat->nid_list, data); @@ -2670,13 +2670,13 @@ int lprocfs_exp_setup(struct obd_export *exp, lnet_nid_t *nid, int *newnid) new_stat->nid = *nid; new_stat->nid_obd = exp->exp_obd; /* we need set default refcount to 1 to balance obd_disconnect */ - cfs_atomic_set(&new_stat->nid_exp_ref_count, 1); + atomic_set(&new_stat->nid_exp_ref_count, 1); old_stat = cfs_hash_findadd_unique(obd->obd_nid_stats_hash, nid, &new_stat->nid_hash); CDEBUG(D_INFO, "Found stats %p for nid %s - ref %d\n", old_stat, libcfs_nid2str(*nid), - cfs_atomic_read(&new_stat->nid_exp_ref_count)); + atomic_read(&new_stat->nid_exp_ref_count)); /* Return -EALREADY here so that we know that the /proc * entry already has been created */ @@ -3224,21 +3224,21 @@ int lprocfs_obd_rd_recovery_status(char *page, char **start, off_t off, cfs_time_current_sec()) <= 0) goto out; if (lprocfs_obd_snprintf(&page, size, &len,"connected_clients: %d/%d\n", - cfs_atomic_read(&obd->obd_connected_clients), + atomic_read(&obd->obd_connected_clients), obd->obd_max_recoverable_clients) <= 0) goto out; /* Number of clients that have completed recovery */ if (lprocfs_obd_snprintf(&page, size, &len,"req_replay_clients: %d\n", - cfs_atomic_read(&obd->obd_req_replay_clients)) + atomic_read(&obd->obd_req_replay_clients)) <= 0) goto out; if (lprocfs_obd_snprintf(&page, size, &len,"lock_repay_clients: %d\n", - cfs_atomic_read(&obd->obd_lock_replay_clients)) + atomic_read(&obd->obd_lock_replay_clients)) <=0) goto out; if (lprocfs_obd_snprintf(&page, size, &len,"completed_clients: %d\n", - cfs_atomic_read(&obd->obd_connected_clients) - - cfs_atomic_read(&obd->obd_lock_replay_clients)) + atomic_read(&obd->obd_connected_clients) - + atomic_read(&obd->obd_lock_replay_clients)) <=0) goto out; if (lprocfs_obd_snprintf(&page, size, &len,"evicted_clients: %d\n", diff --git a/lustre/obdclass/lu_object.c b/lustre/obdclass/lu_object.c index 28a18ef..449c560 100644 --- a/lustre/obdclass/lu_object.c +++ b/lustre/obdclass/lu_object.c @@ -90,7 +90,7 @@ void lu_object_put(const struct lu_env *env, struct lu_object *o) LASSERT(top->loh_hash.next == NULL && top->loh_hash.pprev == NULL); LASSERT(cfs_list_empty(&top->loh_lru)); - if (!cfs_atomic_dec_and_test(&top->loh_ref)) + if (!atomic_dec_and_test(&top->loh_ref)) return; cfs_list_for_each_entry_reverse(o, &top->loh_layers, lo_linkage) { if (o->lo_ops->loo_object_release != NULL) @@ -344,7 +344,7 @@ int lu_site_purge(const struct lu_env *env, struct lu_site *s, int nr) bkt = cfs_hash_bd_extra_get(s->ls_obj_hash, &bd); cfs_list_for_each_entry_safe(h, temp, &bkt->lsb_lru, loh_lru) { - LASSERT(cfs_atomic_read(&h->loh_ref) == 0); + LASSERT(atomic_read(&h->loh_ref) == 0); cfs_hash_bd_get(s->ls_obj_hash, &h->loh_fid, &bd2); LASSERT(bd.bd_bucket == bd2.bd_bucket); @@ -479,7 +479,7 @@ void lu_object_header_print(const struct lu_env *env, void *cookie, const struct lu_object_header *hdr) { (*printer)(env, cookie, "header@%p[%#lx, %d, "DFID"%s%s%s]", - hdr, hdr->loh_flags, cfs_atomic_read(&hdr->loh_ref), + hdr, hdr->loh_flags, atomic_read(&hdr->loh_ref), PFID(&hdr->loh_fid), cfs_hlist_unhashed(&hdr->loh_hash) ? "" : " hash", cfs_list_empty((cfs_list_t *)&hdr->loh_lru) ? \ @@ -979,7 +979,7 @@ static void lu_obj_hop_get(cfs_hash_t *hs, cfs_hlist_node_t *hnode) struct lu_object_header *h; h = cfs_hlist_entry(hnode, struct lu_object_header, loh_hash); - if (cfs_atomic_add_return(1, &h->loh_ref) == 1) { + if (atomic_add_return(1, &h->loh_ref) == 1) { struct lu_site_bkt_data *bkt; cfs_hash_bd_t bd; @@ -1150,7 +1150,7 @@ EXPORT_SYMBOL(lu_site_init_finish); */ void lu_device_get(struct lu_device *d) { - cfs_atomic_inc(&d->ld_ref); + atomic_inc(&d->ld_ref); } EXPORT_SYMBOL(lu_device_get); @@ -1159,8 +1159,8 @@ EXPORT_SYMBOL(lu_device_get); */ void lu_device_put(struct lu_device *d) { - LASSERT(cfs_atomic_read(&d->ld_ref) > 0); - cfs_atomic_dec(&d->ld_ref); + LASSERT(atomic_read(&d->ld_ref) > 0); + atomic_dec(&d->ld_ref); } EXPORT_SYMBOL(lu_device_put); @@ -1172,7 +1172,7 @@ int lu_device_init(struct lu_device *d, struct lu_device_type *t) if (t->ldt_device_nr++ == 0 && t->ldt_ops->ldto_start != NULL) t->ldt_ops->ldto_start(t); memset(d, 0, sizeof *d); - cfs_atomic_set(&d->ld_ref, 0); + atomic_set(&d->ld_ref, 0); d->ld_type = t; lu_ref_init(&d->ld_reference); CFS_INIT_LIST_HEAD(&d->ld_linkage); @@ -1194,8 +1194,8 @@ void lu_device_fini(struct lu_device *d) } lu_ref_fini(&d->ld_reference); - LASSERTF(cfs_atomic_read(&d->ld_ref) == 0, - "Refcount is %u\n", cfs_atomic_read(&d->ld_ref)); + LASSERTF(atomic_read(&d->ld_ref) == 0, + "Refcount is %u\n", atomic_read(&d->ld_ref)); LASSERT(t->ldt_device_nr > 0); if (--t->ldt_device_nr == 0 && t->ldt_ops->ldto_stop != NULL) t->ldt_ops->ldto_stop(t); @@ -1268,7 +1268,7 @@ EXPORT_SYMBOL(lu_object_add); int lu_object_header_init(struct lu_object_header *h) { memset(h, 0, sizeof *h); - cfs_atomic_set(&h->loh_ref, 1); + atomic_set(&h->loh_ref, 1); CFS_INIT_HLIST_NODE(&h->loh_hash); CFS_INIT_LIST_HEAD(&h->loh_lru); CFS_INIT_LIST_HEAD(&h->loh_layers); @@ -1382,7 +1382,7 @@ int lu_context_key_register(struct lu_context_key *key) for (i = 0; i < ARRAY_SIZE(lu_keys); ++i) { if (lu_keys[i] == NULL) { key->lct_index = i; - cfs_atomic_set(&key->lct_used, 1); + atomic_set(&key->lct_used, 1); lu_keys[i] = key; lu_ref_init(&key->lct_reference); result = 0; @@ -1403,11 +1403,11 @@ static void key_fini(struct lu_context *ctx, int index) key = lu_keys[index]; LASSERT(key != NULL); LASSERT(key->lct_fini != NULL); - LASSERT(cfs_atomic_read(&key->lct_used) > 1); + LASSERT(atomic_read(&key->lct_used) > 1); key->lct_fini(ctx, key, ctx->lc_value[index]); lu_ref_del(&key->lct_reference, "ctx", ctx); - cfs_atomic_dec(&key->lct_used); + atomic_dec(&key->lct_used); LASSERT(key->lct_owner != NULL); if ((ctx->lc_tags & LCT_NOREF) == 0) { @@ -1423,7 +1423,7 @@ static void key_fini(struct lu_context *ctx, int index) */ void lu_context_key_degister(struct lu_context_key *key) { - LASSERT(cfs_atomic_read(&key->lct_used) >= 1); + LASSERT(atomic_read(&key->lct_used) >= 1); LINVRNT(0 <= key->lct_index && key->lct_index < ARRAY_SIZE(lu_keys)); lu_context_key_quiesce(key); @@ -1437,9 +1437,9 @@ void lu_context_key_degister(struct lu_context_key *key) } spin_unlock(&lu_keys_guard); - LASSERTF(cfs_atomic_read(&key->lct_used) == 1, + LASSERTF(atomic_read(&key->lct_used) == 1, "key has instances: %d\n", - cfs_atomic_read(&key->lct_used)); + atomic_read(&key->lct_used)); } EXPORT_SYMBOL(lu_context_key_degister); @@ -1621,7 +1621,7 @@ static int keys_fill(struct lu_context *ctx) if (!(ctx->lc_tags & LCT_NOREF)) try_module_get(key->lct_owner); lu_ref_add_atomic(&key->lct_reference, "ctx", ctx); - cfs_atomic_inc(&key->lct_used); + atomic_inc(&key->lct_used); /* * This is the only place in the code, where an * element of ctx->lc_value[] array is set to non-NULL @@ -1995,7 +1995,7 @@ void lu_context_keys_dump(void) CERROR("[%d]: %p %x (%p,%p,%p) %d %d \"%s\"@%p\n", i, key, key->lct_tags, key->lct_init, key->lct_fini, key->lct_exit, - key->lct_index, cfs_atomic_read(&key->lct_used), + key->lct_index, atomic_read(&key->lct_used), key->lct_owner ? key->lct_owner->name : "", key->lct_owner); lu_ref_print(&key->lct_reference); diff --git a/lustre/obdclass/obd_config.c b/lustre/obdclass/obd_config.c index 286fb8a..83465e2 100644 --- a/lustre/obdclass/obd_config.c +++ b/lustre/obdclass/obd_config.c @@ -432,14 +432,14 @@ int class_attach(struct lustre_cfg *lcfg) /* Detach drops this */ spin_lock(&obd->obd_dev_lock); - cfs_atomic_set(&obd->obd_refcount, 1); + atomic_set(&obd->obd_refcount, 1); spin_unlock(&obd->obd_dev_lock); lu_ref_init(&obd->obd_reference); lu_ref_add(&obd->obd_reference, "attach", obd); obd->obd_attached = 1; CDEBUG(D_IOCTL, "OBD: dev %d attached type %s with refcount %d\n", - obd->obd_minor, typename, cfs_atomic_read(&obd->obd_refcount)); + obd->obd_minor, typename, atomic_read(&obd->obd_refcount)); RETURN(0); out: if (obd != NULL) { @@ -666,12 +666,12 @@ int class_cleanup(struct obd_device *obd, struct lustre_cfg *lcfg) /* The three references that should be remaining are the * obd_self_export and the attach and setup references. */ - if (cfs_atomic_read(&obd->obd_refcount) > 3) { + if (atomic_read(&obd->obd_refcount) > 3) { /* refcounf - 3 might be the number of real exports (excluding self export). But class_incref is called by other things as well, so don't count on it. */ CDEBUG(D_IOCTL, "%s: forcing exports to disconnect: %d\n", - obd->obd_name, cfs_atomic_read(&obd->obd_refcount) - 3); + obd->obd_name, atomic_read(&obd->obd_refcount) - 3); dump_exports(obd, 0); class_disconnect_exports(obd); } @@ -711,9 +711,9 @@ struct obd_device *class_incref(struct obd_device *obd, const char *scope, const void *source) { lu_ref_add_atomic(&obd->obd_reference, scope, source); - cfs_atomic_inc(&obd->obd_refcount); + atomic_inc(&obd->obd_refcount); CDEBUG(D_INFO, "incref %s (%p) now %d\n", obd->obd_name, obd, - cfs_atomic_read(&obd->obd_refcount)); + atomic_read(&obd->obd_refcount)); return obd; } @@ -725,8 +725,8 @@ void class_decref(struct obd_device *obd, const char *scope, const void *source) int refs; spin_lock(&obd->obd_dev_lock); - cfs_atomic_dec(&obd->obd_refcount); - refs = cfs_atomic_read(&obd->obd_refcount); + atomic_dec(&obd->obd_refcount); + refs = atomic_read(&obd->obd_refcount); spin_unlock(&obd->obd_dev_lock); lu_ref_del(&obd->obd_reference, scope, source); diff --git a/lustre/obdclass/obd_mount.c b/lustre/obdclass/obd_mount.c index 272bf2e..309080e 100644 --- a/lustre/obdclass/obd_mount.c +++ b/lustre/obdclass/obd_mount.c @@ -279,7 +279,7 @@ int lustre_start_mgc(struct super_block *sb) GOTO(out_free, rc); /* Re-using an existing MGC */ - cfs_atomic_inc(&obd->u.cli.cl_mgc_refcount); + atomic_inc(&obd->u.cli.cl_mgc_refcount); /* IR compatibility check, only for clients */ if (lmd_is_client(lsi->lsi_lmd)) { @@ -442,7 +442,7 @@ int lustre_start_mgc(struct super_block *sb) /* Keep a refcount of servers/clients who started with "mount", so we know when we can get rid of the mgc. */ - cfs_atomic_set(&obd->u.cli.cl_mgc_refcount, 1); + atomic_set(&obd->u.cli.cl_mgc_refcount, 1); /* Try all connections, but only once. */ recov_bk = 1; @@ -509,12 +509,12 @@ static int lustre_stop_mgc(struct super_block *sb) lsi->lsi_mgc = NULL; mutex_lock(&mgc_start_lock); - LASSERT(cfs_atomic_read(&obd->u.cli.cl_mgc_refcount) > 0); - if (!cfs_atomic_dec_and_test(&obd->u.cli.cl_mgc_refcount)) { + LASSERT(atomic_read(&obd->u.cli.cl_mgc_refcount) > 0); + if (!atomic_dec_and_test(&obd->u.cli.cl_mgc_refcount)) { /* This is not fatal, every client that stops will call in here. */ CDEBUG(D_MOUNT, "mgc still has %d references.\n", - cfs_atomic_read(&obd->u.cli.cl_mgc_refcount)); + atomic_read(&obd->u.cli.cl_mgc_refcount)); GOTO(out, rc = -EBUSY); } @@ -585,7 +585,7 @@ struct lustre_sb_info *lustre_init_lsi(struct super_block *sb) lsi->lsi_lmd->lmd_recovery_time_hard = 0; s2lsi_nocast(sb) = lsi; /* we take 1 extra ref for our setup */ - cfs_atomic_set(&lsi->lsi_mounts, 1); + atomic_set(&lsi->lsi_mounts, 1); /* Default umount style */ lsi->lsi_flags = LSI_UMOUNT_FAILOVER; @@ -602,7 +602,7 @@ static int lustre_free_lsi(struct super_block *sb) CDEBUG(D_MOUNT, "Freeing lsi %p\n", lsi); /* someone didn't call server_put_mount. */ - LASSERT(cfs_atomic_read(&lsi->lsi_mounts) == 0); + LASSERT(atomic_read(&lsi->lsi_mounts) == 0); if (lsi->lsi_lmd != NULL) { if (lsi->lsi_lmd->lmd_dev != NULL) @@ -649,8 +649,8 @@ int lustre_put_lsi(struct super_block *sb) LASSERT(lsi != NULL); - CDEBUG(D_MOUNT, "put %p %d\n", sb, cfs_atomic_read(&lsi->lsi_mounts)); - if (cfs_atomic_dec_and_test(&lsi->lsi_mounts)) { + CDEBUG(D_MOUNT, "put %p %d\n", sb, atomic_read(&lsi->lsi_mounts)); + if (atomic_dec_and_test(&lsi->lsi_mounts)) { if (IS_SERVER(lsi) && lsi->lsi_osd_exp) { lu_device_put(&lsi->lsi_dt_dev->dd_lu_dev); lsi->lsi_osd_exp->exp_obd->obd_lvfs_ctxt.dt = NULL; diff --git a/lustre/obdclass/obd_mount_server.c b/lustre/obdclass/obd_mount_server.c index b617d4c..cff3d80 100644 --- a/lustre/obdclass/obd_mount_server.c +++ b/lustre/obdclass/obd_mount_server.c @@ -163,10 +163,10 @@ struct lustre_mount_info *server_get_mount(const char *name) } lsi = s2lsi(lmi->lmi_sb); - cfs_atomic_inc(&lsi->lsi_mounts); + atomic_inc(&lsi->lsi_mounts); CDEBUG(D_MOUNT, "get mount %p from %s, refs=%d\n", lmi->lmi_sb, - name, cfs_atomic_read(&lsi->lsi_mounts)); + name, atomic_read(&lsi->lsi_mounts)); RETURN(lmi); } @@ -209,7 +209,7 @@ int server_put_mount(const char *name) lsi = s2lsi(lmi->lmi_sb); CDEBUG(D_MOUNT, "put mount %p from %s, refs=%d\n", - lmi->lmi_sb, name, cfs_atomic_read(&lsi->lsi_mounts)); + lmi->lmi_sb, name, atomic_read(&lsi->lsi_mounts)); if (lustre_put_lsi(lmi->lmi_sb)) CDEBUG(D_MOUNT, "Last put of mount %p from %s\n", diff --git a/lustre/obdecho/echo.c b/lustre/obdecho/echo.c index ee854f1..6d63aff 100644 --- a/lustre/obdecho/echo.c +++ b/lustre/obdecho/echo.c @@ -445,7 +445,7 @@ static int echo_preprw(const struct lu_env *env, int cmd, } } - cfs_atomic_add(*pages, &obd->u.echo.eo_prep); + atomic_add(*pages, &obd->u.echo.eo_prep); if (cmd & OBD_BRW_READ) lprocfs_counter_add(obd->obd_stats, LPROC_ECHO_READ_BYTES, @@ -455,7 +455,7 @@ static int echo_preprw(const struct lu_env *env, int cmd, tot_bytes); CDEBUG(D_PAGE, "%d pages allocated after prep\n", - cfs_atomic_read(&obd->u.echo.eo_prep)); + atomic_read(&obd->u.echo.eo_prep)); RETURN(0); @@ -472,7 +472,7 @@ preprw_cleanup: * lose the extra ref gained above */ OBD_PAGE_FREE(res[i].page); res[i].page = NULL; - cfs_atomic_dec(&obd->u.echo.eo_prep); + atomic_dec(&obd->u.echo.eo_prep); } return rc; @@ -534,14 +534,14 @@ static int echo_commitrw(const struct lu_env *env, int cmd, } - cfs_atomic_sub(pgs, &obd->u.echo.eo_prep); + atomic_sub(pgs, &obd->u.echo.eo_prep); CDEBUG(D_PAGE, "%d pages remain after commit\n", - cfs_atomic_read(&obd->u.echo.eo_prep)); + atomic_read(&obd->u.echo.eo_prep)); RETURN(rc); commitrw_cleanup: - cfs_atomic_sub(pgs, &obd->u.echo.eo_prep); + atomic_sub(pgs, &obd->u.echo.eo_prep); CERROR("cleaning up %d pages (%d obdos)\n", niocount - pgs - 1, objcount); @@ -554,7 +554,7 @@ commitrw_cleanup: /* NB see comment above regarding persistent pages */ OBD_PAGE_FREE(page); - cfs_atomic_dec(&obd->u.echo.eo_prep); + atomic_dec(&obd->u.echo.eo_prep); } return rc; } @@ -626,7 +626,7 @@ static int echo_cleanup(struct obd_device *obd) ldlm_namespace_free(obd->obd_namespace, NULL, obd->obd_force); obd->obd_namespace = NULL; - leaked = cfs_atomic_read(&obd->u.echo.eo_prep); + leaked = atomic_read(&obd->u.echo.eo_prep); if (leaked != 0) CERROR("%d prep/commitrw pages leaked\n", leaked); diff --git a/lustre/obdecho/echo_client.c b/lustre/obdecho/echo_client.c index 4bea4aa..bd0ccdc 100644 --- a/lustre/obdecho/echo_client.c +++ b/lustre/obdecho/echo_client.c @@ -78,7 +78,7 @@ struct echo_object { struct echo_device *eo_dev; cfs_list_t eo_obj_chain; struct lov_stripe_md *eo_lsm; - cfs_atomic_t eo_npages; + atomic_t eo_npages; int eo_deleted; }; @@ -97,7 +97,7 @@ struct echo_lock { cfs_list_t el_chain; struct echo_object *el_object; __u64 el_cookie; - cfs_atomic_t el_refcount; + atomic_t el_refcount; }; static int echo_client_setup(const struct lu_env *env, @@ -293,7 +293,7 @@ static void echo_page_fini(const struct lu_env *env, struct echo_object *eco = cl2echo_obj(slice->cpl_obj); ENTRY; - cfs_atomic_dec(&eco->eo_npages); + atomic_dec(&eco->eo_npages); page_cache_release(slice->cpl_page->cp_vmpage); EXIT; } @@ -392,7 +392,7 @@ static int echo_page_init(const struct lu_env *env, struct cl_object *obj, page_cache_get(page->cp_vmpage); mutex_init(&ep->ep_lock); cl_page_slice_add(page, &ep->ep_cl, obj, &echo_page_ops); - cfs_atomic_inc(&eco->eo_npages); + atomic_inc(&eco->eo_npages); RETURN(0); } @@ -414,7 +414,7 @@ static int echo_lock_init(const struct lu_env *env, cl_lock_slice_add(lock, &el->el_cl, obj, &echo_lock_ops); el->el_object = cl2echo_obj(obj); CFS_INIT_LIST_HEAD(&el->el_chain); - cfs_atomic_set(&el->el_refcount, 0); + atomic_set(&el->el_refcount, 0); } RETURN(el == NULL ? -ENOMEM : 0); } @@ -472,7 +472,7 @@ static int echo_object_init(const struct lu_env *env, struct lu_object *obj, } eco->eo_dev = ed; - cfs_atomic_set(&eco->eo_npages, 0); + atomic_set(&eco->eo_npages, 0); cl_object_page_init(lu2cl(obj), sizeof(struct echo_page)); spin_lock(&ec->ec_lock); @@ -539,7 +539,7 @@ static void echo_object_free(const struct lu_env *env, struct lu_object *obj) struct echo_client_obd *ec = eco->eo_dev->ed_ec; ENTRY; - LASSERT(cfs_atomic_read(&eco->eo_npages) == 0); + LASSERT(atomic_read(&eco->eo_npages) == 0); spin_lock(&ec->ec_lock); cfs_list_del_init(&eco->eo_obj_chain); @@ -1185,7 +1185,7 @@ static int cl_echo_enqueue0(struct lu_env *env, struct echo_object *eco, cfs_list_add(&el->el_chain, &ec->ec_locks); el->el_cookie = ++ec->ec_unique; } - cfs_atomic_inc(&el->el_refcount); + atomic_inc(&el->el_refcount); *cookie = el->el_cookie; spin_unlock(&ec->ec_lock); } else { @@ -1243,7 +1243,7 @@ static int cl_echo_cancel0(struct lu_env *env, struct echo_device *ed, CDEBUG(D_INFO, "ecl: %p, cookie: "LPX64"\n", ecl, ecl->el_cookie); found = (ecl->el_cookie == cookie); if (found) { - if (cfs_atomic_dec_and_test(&ecl->el_refcount)) + if (atomic_dec_and_test(&ecl->el_refcount)) cfs_list_del_init(&ecl->el_chain); else still_used = 1; @@ -3117,7 +3117,7 @@ static int echo_client_cleanup(struct obd_device *obddev) RETURN(-EBUSY); } - LASSERT(cfs_atomic_read(&ec->ec_exp->exp_refcount) > 0); + LASSERT(atomic_read(&ec->ec_exp->exp_refcount) > 0); rc = obd_disconnect(ec->ec_exp); if (rc != 0) CERROR("fail to disconnect device: %d\n", rc); -- 1.8.3.1