This patch convers all cfs_atomic primitives in
mdd, mdt, mgc and mgs.
Signed-off-by: Liu Xuezhao <xuezhao.liu@emc.com>
Signed-off-by: Peng Tao <tao.peng@emc.com>
Signed-off-by: James Simmons <uja.ornl@gmail.com>
Change-Id: I052ca4da80b0cbd36df02a50f2ae0651eec28ea8
Reviewed-on: http://review.whamcloud.com/7074
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: Bob Glossman <bob.glossman@intel.com>
struct mdd_device *m = lu2mdd_dev(lu);
ENTRY;
struct mdd_device *m = lu2mdd_dev(lu);
ENTRY;
- LASSERT(cfs_atomic_read(&lu->ld_ref) == 0);
+ LASSERT(atomic_read(&lu->ld_ref) == 0);
md_device_fini(&m->mdd_md_dev);
OBD_FREE_PTR(m);
RETURN(NULL);
md_device_fini(&m->mdd_md_dev);
OBD_FREE_PTR(m);
RETURN(NULL);
*/
mdt_stack_fini(env, m, md2lu_dev(m->mdt_child));
*/
mdt_stack_fini(env, m, md2lu_dev(m->mdt_child));
- LASSERT(cfs_atomic_read(&d->ld_ref) == 0);
+ LASSERT(atomic_read(&d->ld_ref) == 0);
server_put_mount(mdt_obd_name(m));
server_put_mount(mdt_obd_name(m));
/* Take a reference to a config log */
static int config_log_get(struct config_llog_data *cld)
{
/* Take a reference to a config log */
static int config_log_get(struct config_llog_data *cld)
{
- ENTRY;
- cfs_atomic_inc(&cld->cld_refcount);
- CDEBUG(D_INFO, "log %s refs %d\n", cld->cld_logname,
- cfs_atomic_read(&cld->cld_refcount));
- RETURN(0);
+ ENTRY;
+ atomic_inc(&cld->cld_refcount);
+ CDEBUG(D_INFO, "log %s refs %d\n", cld->cld_logname,
+ atomic_read(&cld->cld_refcount));
+ RETURN(0);
}
/* Drop a reference to a config log. When no longer referenced,
we can free the config log data */
static void config_log_put(struct config_llog_data *cld)
{
}
/* Drop a reference to a config log. When no longer referenced,
we can free the config log data */
static void config_log_put(struct config_llog_data *cld)
{
- CDEBUG(D_INFO, "log %s refs %d\n", cld->cld_logname,
- cfs_atomic_read(&cld->cld_refcount));
- LASSERT(cfs_atomic_read(&cld->cld_refcount) > 0);
+ CDEBUG(D_INFO, "log %s refs %d\n", cld->cld_logname,
+ atomic_read(&cld->cld_refcount));
+ LASSERT(atomic_read(&cld->cld_refcount) > 0);
- /* spinlock to make sure no item with 0 refcount in the list */
- if (cfs_atomic_dec_and_lock(&cld->cld_refcount, &config_list_lock)) {
- cfs_list_del(&cld->cld_list_chain);
+ /* spinlock to make sure no item with 0 refcount in the list */
+ if (atomic_dec_and_lock(&cld->cld_refcount, &config_list_lock)) {
+ cfs_list_del(&cld->cld_list_chain);
spin_unlock(&config_list_lock);
CDEBUG(D_MGC, "dropping config log %s\n", cld->cld_logname);
spin_unlock(&config_list_lock);
CDEBUG(D_MGC, "dropping config log %s\n", cld->cld_logname);
if (instance != cld->cld_cfg.cfg_instance)
continue;
if (instance != cld->cld_cfg.cfg_instance)
continue;
- /* instance may be NULL, should check name */
- if (strcmp(logname, cld->cld_logname) == 0) {
- found = cld;
- break;
- }
- }
- if (found) {
- cfs_atomic_inc(&found->cld_refcount);
- LASSERT(found->cld_stopping == 0 || cld_is_sptlrpc(found) == 0);
- }
+ /* instance may be NULL, should check name */
+ if (strcmp(logname, cld->cld_logname) == 0) {
+ found = cld;
+ break;
+ }
+ }
+ if (found) {
+ atomic_inc(&found->cld_refcount);
+ LASSERT(found->cld_stopping == 0 || cld_is_sptlrpc(found) == 0);
+ }
spin_unlock(&config_list_lock);
RETURN(found);
}
spin_unlock(&config_list_lock);
RETURN(found);
}
if (!cld)
RETURN(ERR_PTR(-ENOMEM));
if (!cld)
RETURN(ERR_PTR(-ENOMEM));
- strcpy(cld->cld_logname, logname);
- if (cfg)
- cld->cld_cfg = *cfg;
+ strcpy(cld->cld_logname, logname);
+ if (cfg)
+ cld->cld_cfg = *cfg;
else
cld->cld_cfg.cfg_callback = class_config_llog_handler;
mutex_init(&cld->cld_lock);
else
cld->cld_cfg.cfg_callback = class_config_llog_handler;
mutex_init(&cld->cld_lock);
- cld->cld_cfg.cfg_last_idx = 0;
- cld->cld_cfg.cfg_flags = 0;
- cld->cld_cfg.cfg_sb = sb;
- cld->cld_type = type;
- cfs_atomic_set(&cld->cld_refcount, 1);
+ cld->cld_cfg.cfg_last_idx = 0;
+ cld->cld_cfg.cfg_flags = 0;
+ cld->cld_cfg.cfg_sb = sb;
+ cld->cld_type = type;
+ atomic_set(&cld->cld_refcount, 1);
/* Keep the mgc around until we are done */
cld->cld_mgcexp = class_export_get(obd->obd_self_export);
/* Keep the mgc around until we are done */
cld->cld_mgcexp = class_export_get(obd->obd_self_export);
static void do_requeue(struct config_llog_data *cld)
{
int rc = 0;
static void do_requeue(struct config_llog_data *cld)
{
int rc = 0;
- ENTRY;
- LASSERT(cfs_atomic_read(&cld->cld_refcount) > 0);
- /* Do not run mgc_process_log on a disconnected export or an
- export which is being disconnected. Take the client
- semaphore to make the check non-racy. */
+ LASSERT(atomic_read(&cld->cld_refcount) > 0);
+
+ /* Do not run mgc_process_log on a disconnected export or an
+ * export which is being disconnected. Take the client
+ * semaphore to make the check non-racy. */
down_read(&cld->cld_mgcexp->exp_obd->u.cli.cl_sem);
if (cld->cld_mgcexp->exp_obd->u.cli.cl_conn_count != 0) {
CDEBUG(D_MGC, "updating log %s\n", cld->cld_logname);
down_read(&cld->cld_mgcexp->exp_obd->u.cli.cl_sem);
if (cld->cld_mgcexp->exp_obd->u.cli.cl_conn_count != 0) {
CDEBUG(D_MGC, "updating log %s\n", cld->cld_logname);
spin_unlock(&config_list_lock);
spin_unlock(&config_list_lock);
- LASSERT(cfs_atomic_read(&cld->cld_refcount) > 0);
+ LASSERT(atomic_read(&cld->cld_refcount) > 0);
- /* Whether we enqueued again or not in mgc_process_log,
- * we're done with the ref from the old enqueue */
- if (cld_prev)
- config_log_put(cld_prev);
- cld_prev = cld;
+ /* Whether we enqueued again or not in mgc_process_log,
+ * we're done with the ref from the old enqueue */
+ if (cld_prev)
+ config_log_put(cld_prev);
+ cld_prev = cld;
cld->cld_lostlock = 0;
if (likely(!stopped))
cld->cld_lostlock = 0;
if (likely(!stopped))
We are responsible for dropping the config log reference from here on out. */
static void mgc_requeue_add(struct config_llog_data *cld)
{
We are responsible for dropping the config log reference from here on out. */
static void mgc_requeue_add(struct config_llog_data *cld)
{
- CDEBUG(D_INFO, "log %s: requeue (r=%d sp=%d st=%x)\n",
- cld->cld_logname, cfs_atomic_read(&cld->cld_refcount),
- cld->cld_stopping, rq_state);
- LASSERT(cfs_atomic_read(&cld->cld_refcount) > 0);
+ CDEBUG(D_INFO, "log %s: requeue (r=%d sp=%d st=%x)\n",
+ cld->cld_logname, atomic_read(&cld->cld_refcount),
+ cld->cld_stopping, rq_state);
+ LASSERT(atomic_read(&cld->cld_refcount) > 0);
mutex_lock(&cld->cld_lock);
if (cld->cld_stopping || cld->cld_lostlock) {
mutex_lock(&cld->cld_lock);
if (cld->cld_stopping || cld->cld_lostlock) {
-static cfs_atomic_t mgc_count = CFS_ATOMIC_INIT(0);
+static atomic_t mgc_count = ATOMIC_INIT(0);
static int mgc_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage)
{
static int mgc_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage)
{
- switch (stage) {
- case OBD_CLEANUP_EARLY:
- break;
- case OBD_CLEANUP_EXPORTS:
- if (cfs_atomic_dec_and_test(&mgc_count)) {
- int running;
- /* stop requeue thread */
+ switch (stage) {
+ case OBD_CLEANUP_EARLY:
+ break;
+ case OBD_CLEANUP_EXPORTS:
+ if (atomic_dec_and_test(&mgc_count)) {
+ int running;
+ /* stop requeue thread */
spin_lock(&config_list_lock);
running = rq_state & RQ_RUNNING;
if (running)
spin_lock(&config_list_lock);
running = rq_state & RQ_RUNNING;
if (running)
if (running) {
wake_up(&rq_waitq);
wait_for_completion(&rq_exit);
if (running) {
wake_up(&rq_waitq);
wait_for_completion(&rq_exit);
- }
- }
- obd_cleanup_client_import(obd);
+ }
+ }
+ obd_cleanup_client_import(obd);
rc = mgc_llog_fini(NULL, obd);
rc = mgc_llog_fini(NULL, obd);
- if (rc != 0)
- CERROR("failed to cleanup llogging subsystems\n");
- break;
- }
- RETURN(rc);
+ if (rc != 0)
+ CERROR("failed to cleanup llogging subsystems\n");
+ break;
+ }
+ RETURN(rc);
}
static int mgc_cleanup(struct obd_device *obd)
}
static int mgc_cleanup(struct obd_device *obd)
#endif
sptlrpc_lprocfs_cliobd_attach(obd);
#endif
sptlrpc_lprocfs_cliobd_attach(obd);
- if (cfs_atomic_inc_return(&mgc_count) == 1) {
+ if (atomic_inc_return(&mgc_count) == 1) {
rq_state = 0;
init_waitqueue_head(&rq_waitq);
rq_state = 0;
init_waitqueue_head(&rq_waitq);
PLDLMRES(lock->l_resource),
(char *)&lock->l_resource->lr_name.name[0]);
PLDLMRES(lock->l_resource),
(char *)&lock->l_resource->lr_name.name[0]);
- if (!cld) {
- CDEBUG(D_INFO, "missing data, won't requeue\n");
- break;
- }
+ if (!cld) {
+ CDEBUG(D_INFO, "missing data, won't requeue\n");
+ break;
+ }
- /* held at mgc_process_log(). */
- LASSERT(cfs_atomic_read(&cld->cld_refcount) > 0);
- /* Are we done with this log? */
- if (cld->cld_stopping) {
- CDEBUG(D_MGC, "log %s: stopping, won't requeue\n",
- cld->cld_logname);
- config_log_put(cld);
- break;
- }
- /* Make sure not to re-enqueue when the mgc is stopping
- (we get called from client_disconnect_export) */
- if (!lock->l_conn_export ||
- !lock->l_conn_export->exp_obd->u.cli.cl_conn_count) {
- CDEBUG(D_MGC, "log %.8s: disconnecting, won't requeue\n",
- cld->cld_logname);
- config_log_put(cld);
- break;
- }
+ /* held at mgc_process_log(). */
+ LASSERT(atomic_read(&cld->cld_refcount) > 0);
+ /* Are we done with this log? */
+ if (cld->cld_stopping) {
+ CDEBUG(D_MGC, "log %s: stopping, won't requeue\n",
+ cld->cld_logname);
+ config_log_put(cld);
+ break;
+ }
+ /* Make sure not to re-enqueue when the mgc is stopping
+ (we get called from client_disconnect_export) */
+ if (!lock->l_conn_export ||
+ !lock->l_conn_export->exp_obd->u.cli.cl_conn_count) {
+ CDEBUG(D_MGC, "log %.8s: disconnecting, won't requeue\n",
+ cld->cld_logname);
+ config_log_put(cld);
+ break;
+ }
/* Re-enqueue now */
mgc_requeue_add(cld);
/* Re-enqueue now */
mgc_requeue_add(cld);
wait_queue_head_t fsdb_notify_waitq;
struct completion fsdb_notify_comp;
cfs_time_t fsdb_notify_start;
wait_queue_head_t fsdb_notify_waitq;
struct completion fsdb_notify_comp;
cfs_time_t fsdb_notify_start;
- cfs_atomic_t fsdb_notify_phase;
+ atomic_t fsdb_notify_phase;
volatile unsigned int fsdb_notify_async:1,
fsdb_notify_stop:1;
/* statistic data */
volatile unsigned int fsdb_notify_async:1,
fsdb_notify_stop:1;
/* statistic data */
/* --------- Imperative Recovery relies on nidtbl stuff ------- */
void mgs_ir_notify_complete(struct fs_db *fsdb)
{
/* --------- Imperative Recovery relies on nidtbl stuff ------- */
void mgs_ir_notify_complete(struct fs_db *fsdb)
{
- struct timeval tv;
- cfs_duration_t delta;
+ struct timeval tv;
+ cfs_duration_t delta;
- cfs_atomic_set(&fsdb->fsdb_notify_phase, 0);
+ atomic_set(&fsdb->fsdb_notify_phase, 0);
/* do statistic */
fsdb->fsdb_notify_count++;
/* do statistic */
fsdb->fsdb_notify_count++;
set_user_nice(current, -2);
set_user_nice(current, -2);
- mgc_fsname2resid(fsdb->fsdb_name, &resid, CONFIG_T_RECOVER);
- while (1) {
- struct l_wait_info lwi = { 0 };
+ mgc_fsname2resid(fsdb->fsdb_name, &resid, CONFIG_T_RECOVER);
+ while (1) {
+ struct l_wait_info lwi = { 0 };
- l_wait_event(fsdb->fsdb_notify_waitq,
- fsdb->fsdb_notify_stop ||
- cfs_atomic_read(&fsdb->fsdb_notify_phase),
- &lwi);
- if (fsdb->fsdb_notify_stop)
- break;
+ l_wait_event(fsdb->fsdb_notify_waitq,
+ fsdb->fsdb_notify_stop ||
+ atomic_read(&fsdb->fsdb_notify_phase),
+ &lwi);
+ if (fsdb->fsdb_notify_stop)
+ break;
- CDEBUG(D_MGS, "%s woken up, phase is %d\n",
- name, cfs_atomic_read(&fsdb->fsdb_notify_phase));
+ CDEBUG(D_MGS, "%s woken up, phase is %d\n",
+ name, atomic_read(&fsdb->fsdb_notify_phase));
- fsdb->fsdb_notify_start = cfs_time_current();
+ fsdb->fsdb_notify_start = cfs_time_current();
mgs_revoke_lock(fsdb->fsdb_mgs, fsdb, CONFIG_T_RECOVER);
mgs_revoke_lock(fsdb->fsdb_mgs, fsdb, CONFIG_T_RECOVER);
complete(&fsdb->fsdb_notify_comp);
complete(&fsdb->fsdb_notify_comp);
}
int mgs_ir_init_fs(const struct lu_env *env, struct mgs_device *mgs,
}
int mgs_ir_init_fs(const struct lu_env *env, struct mgs_device *mgs,
/* start notify thread */
fsdb->fsdb_mgs = mgs;
/* start notify thread */
fsdb->fsdb_mgs = mgs;
- cfs_atomic_set(&fsdb->fsdb_notify_phase, 0);
+ atomic_set(&fsdb->fsdb_notify_phase, 0);
init_waitqueue_head(&fsdb->fsdb_notify_waitq);
init_completion(&fsdb->fsdb_notify_comp);
init_waitqueue_head(&fsdb->fsdb_notify_waitq);
init_completion(&fsdb->fsdb_notify_comp);
if (notify) {
CDEBUG(D_MGS, "Try to revoke recover lock of %s\n",
fsdb->fsdb_name);
if (notify) {
CDEBUG(D_MGS, "Try to revoke recover lock of %s\n",
fsdb->fsdb_name);
- cfs_atomic_inc(&fsdb->fsdb_notify_phase);
+ atomic_inc(&fsdb->fsdb_notify_phase);
wake_up(&fsdb->fsdb_notify_waitq);
}
return 0;
wake_up(&fsdb->fsdb_notify_waitq);
}
return 0;