static
void ctx_destroy_pf(struct ptlrpc_sec *sec, struct ptlrpc_cli_ctx *ctx)
{
- struct gss_cli_ctx *gctx = ctx2gctx(ctx);
+ struct gss_cli_ctx *gctx = ctx2gctx(ctx);
- if (gss_cli_ctx_fini_common(sec, ctx))
- return;
+ if (gss_cli_ctx_fini_common(sec, ctx))
+ return;
- OBD_FREE_PTR(gctx);
+ OBD_FREE_PTR(gctx);
- cfs_atomic_dec(&sec->ps_nctx);
- sptlrpc_sec_put(sec);
+ atomic_dec(&sec->ps_nctx);
+ sptlrpc_sec_put(sec);
}
static
void ctx_enhash_pf(struct ptlrpc_cli_ctx *ctx, cfs_hlist_head_t *hash)
{
set_bit(PTLRPC_CTX_CACHED_BIT, &ctx->cc_flags);
- cfs_atomic_inc(&ctx->cc_refcount);
- cfs_hlist_add_head(&ctx->cc_cache, hash);
+ atomic_inc(&ctx->cc_refcount);
+ cfs_hlist_add_head(&ctx->cc_cache, hash);
}
/*
void ctx_unhash_pf(struct ptlrpc_cli_ctx *ctx, cfs_hlist_head_t *freelist)
{
LASSERT(spin_is_locked(&ctx->cc_sec->ps_lock));
- LASSERT(cfs_atomic_read(&ctx->cc_refcount) > 0);
+ LASSERT(atomic_read(&ctx->cc_refcount) > 0);
LASSERT(test_bit(PTLRPC_CTX_CACHED_BIT, &ctx->cc_flags));
LASSERT(!cfs_hlist_unhashed(&ctx->cc_cache));
clear_bit(PTLRPC_CTX_CACHED_BIT, &ctx->cc_flags);
- if (cfs_atomic_dec_and_test(&ctx->cc_refcount)) {
+ if (atomic_dec_and_test(&ctx->cc_refcount)) {
__cfs_hlist_del(&ctx->cc_cache);
cfs_hlist_add_head(&ctx->cc_cache, freelist);
} else {
int ctx_check_death_locked_pf(struct ptlrpc_cli_ctx *ctx,
cfs_hlist_head_t *freelist)
{
- LASSERT(ctx->cc_sec);
- LASSERT(cfs_atomic_read(&ctx->cc_refcount) > 0);
+ LASSERT(ctx->cc_sec);
+ LASSERT(atomic_read(&ctx->cc_refcount) > 0);
LASSERT(test_bit(PTLRPC_CTX_CACHED_BIT, &ctx->cc_flags));
- return ctx_check_death_pf(ctx, freelist);
+ return ctx_check_death_pf(ctx, freelist);
}
static inline
static
void ctx_list_destroy_pf(cfs_hlist_head_t *head)
{
- struct ptlrpc_cli_ctx *ctx;
+ struct ptlrpc_cli_ctx *ctx;
- while (!cfs_hlist_empty(head)) {
- ctx = cfs_hlist_entry(head->first, struct ptlrpc_cli_ctx,
- cc_cache);
+ while (!cfs_hlist_empty(head)) {
+ ctx = cfs_hlist_entry(head->first, struct ptlrpc_cli_ctx,
+ cc_cache);
- LASSERT(cfs_atomic_read(&ctx->cc_refcount) == 0);
+ LASSERT(atomic_read(&ctx->cc_refcount) == 0);
LASSERT(test_bit(PTLRPC_CTX_CACHED_BIT,
- &ctx->cc_flags) == 0);
+ &ctx->cc_flags) == 0);
- cfs_hlist_del_init(&ctx->cc_cache);
- ctx_destroy_pf(ctx->cc_sec, ctx);
- }
+ cfs_hlist_del_init(&ctx->cc_cache);
+ ctx_destroy_pf(ctx->cc_sec, ctx);
+ }
}
/****************************************
void gss_cli_ctx_die_pf(struct ptlrpc_cli_ctx *ctx, int grace)
{
LASSERT(ctx->cc_sec);
- LASSERT(cfs_atomic_read(&ctx->cc_refcount) > 0);
+ LASSERT(atomic_read(&ctx->cc_refcount) > 0);
cli_ctx_expire(ctx);
if (test_and_clear_bit(PTLRPC_CTX_CACHED_BIT, &ctx->cc_flags)) {
LASSERT(!cfs_hlist_unhashed(&ctx->cc_cache));
- LASSERT(cfs_atomic_read(&ctx->cc_refcount) > 1);
+ LASSERT(atomic_read(&ctx->cc_refcount) > 1);
cfs_hlist_del_init(&ctx->cc_cache);
- if (cfs_atomic_dec_and_test(&ctx->cc_refcount))
+ if (atomic_dec_and_test(&ctx->cc_refcount))
LBUG();
}
/* hold a ref */
if (ctx)
- cfs_atomic_inc(&ctx->cc_refcount);
+ atomic_inc(&ctx->cc_refcount);
spin_unlock(&sec->ps_lock);
- /* the allocator of the context must give the first push to refresh */
- if (new) {
- LASSERT(new == ctx);
- gss_cli_ctx_refresh_pf(new);
- }
+ /* the allocator of the context must give the first push to refresh */
+ if (new) {
+ LASSERT(new == ctx);
+ gss_cli_ctx_refresh_pf(new);
+ }
- ctx_list_destroy_pf(&freelist);
- RETURN(ctx);
+ ctx_list_destroy_pf(&freelist);
+ RETURN(ctx);
}
static
gsec_pf = container_of(gsec, struct gss_sec_pipefs, gsp_base);
spin_lock(&sec->ps_lock);
- for (i = 0; i < gsec_pf->gsp_chash_size; i++) {
- cfs_hlist_for_each_entry_safe(ctx, pos, next,
- &gsec_pf->gsp_chash[i],
- cc_cache) {
- LASSERT(cfs_atomic_read(&ctx->cc_refcount) > 0);
-
- if (uid != -1 && uid != ctx->cc_vcred.vc_uid)
- continue;
-
- if (cfs_atomic_read(&ctx->cc_refcount) > 1) {
- busy++;
- if (!force)
- continue;
-
- CWARN("flush busy(%d) ctx %p(%u->%s) by force, "
- "grace %d\n",
- cfs_atomic_read(&ctx->cc_refcount),
- ctx, ctx->cc_vcred.vc_uid,
- sec2target_str(ctx->cc_sec), grace);
- }
- ctx_unhash_pf(ctx, &freelist);
+ for (i = 0; i < gsec_pf->gsp_chash_size; i++) {
+ cfs_hlist_for_each_entry_safe(ctx, pos, next,
+ &gsec_pf->gsp_chash[i],
+ cc_cache) {
+ LASSERT(atomic_read(&ctx->cc_refcount) > 0);
+
+ if (uid != -1 && uid != ctx->cc_vcred.vc_uid)
+ continue;
+
+ if (atomic_read(&ctx->cc_refcount) > 1) {
+ busy++;
+ if (!force)
+ continue;
+
+ CWARN("flush busy(%d) ctx %p(%u->%s) by force, "
+ "grace %d\n",
+ atomic_read(&ctx->cc_refcount),
+ ctx, ctx->cc_vcred.vc_uid,
+ sec2target_str(ctx->cc_sec), grace);
+ }
+ ctx_unhash_pf(ctx, &freelist);
set_bit(PTLRPC_CTX_DEAD_BIT, &ctx->cc_flags);
if (!grace)
};
struct gss_upcall_msg {
- struct rpc_pipe_msg gum_base;
- cfs_atomic_t gum_refcount;
- cfs_list_t gum_list;
- __u32 gum_mechidx;
- struct gss_sec *gum_gsec;
- struct gss_cli_ctx *gum_gctx;
- struct gss_upcall_msg_data gum_data;
+ struct rpc_pipe_msg gum_base;
+ atomic_t gum_refcount;
+ cfs_list_t gum_list;
+ __u32 gum_mechidx;
+ struct gss_sec *gum_gsec;
+ struct gss_cli_ctx *gum_gctx;
+ struct gss_upcall_msg_data gum_data;
};
-static cfs_atomic_t upcall_seq = CFS_ATOMIC_INIT(0);
+static atomic_t upcall_seq = ATOMIC_INIT(0);
static inline
__u32 upcall_get_sequence(void)
{
- return (__u32) cfs_atomic_inc_return(&upcall_seq);
+ return (__u32) atomic_inc_return(&upcall_seq);
}
enum mech_idx_t {
static
void gss_release_msg(struct gss_upcall_msg *gmsg)
{
- ENTRY;
- LASSERT(cfs_atomic_read(&gmsg->gum_refcount) > 0);
+ ENTRY;
+ LASSERT(atomic_read(&gmsg->gum_refcount) > 0);
- if (!cfs_atomic_dec_and_test(&gmsg->gum_refcount)) {
- EXIT;
- return;
- }
+ if (!atomic_dec_and_test(&gmsg->gum_refcount)) {
+ EXIT;
+ return;
+ }
if (gmsg->gum_gctx) {
sptlrpc_cli_ctx_wakeup(&gmsg->gum_gctx->gc_base);
return;
cfs_list_del_init(&gmsg->gum_list);
- LASSERT(cfs_atomic_read(&gmsg->gum_refcount) > 1);
- cfs_atomic_dec(&gmsg->gum_refcount);
+ LASSERT(atomic_read(&gmsg->gum_refcount) > 1);
+ atomic_dec(&gmsg->gum_refcount);
}
static
static
void gss_msg_fail_ctx(struct gss_upcall_msg *gmsg)
{
- if (gmsg->gum_gctx) {
- struct ptlrpc_cli_ctx *ctx = &gmsg->gum_gctx->gc_base;
+ if (gmsg->gum_gctx) {
+ struct ptlrpc_cli_ctx *ctx = &gmsg->gum_gctx->gc_base;
- LASSERT(cfs_atomic_read(&ctx->cc_refcount) > 0);
- sptlrpc_cli_ctx_expire(ctx);
+ LASSERT(atomic_read(&ctx->cc_refcount) > 0);
+ sptlrpc_cli_ctx_expire(ctx);
set_bit(PTLRPC_CTX_ERROR_BIT, &ctx->cc_flags);
- }
+ }
}
static
struct gss_upcall_msg * gss_find_upcall(__u32 mechidx, __u32 seq)
{
- struct gss_upcall_msg *gmsg;
+ struct gss_upcall_msg *gmsg;
- upcall_list_lock(mechidx);
- cfs_list_for_each_entry(gmsg, &upcall_lists[mechidx], gum_list) {
- if (gmsg->gum_data.gum_seq != seq)
- continue;
+ upcall_list_lock(mechidx);
+ cfs_list_for_each_entry(gmsg, &upcall_lists[mechidx], gum_list) {
+ if (gmsg->gum_data.gum_seq != seq)
+ continue;
- LASSERT(cfs_atomic_read(&gmsg->gum_refcount) > 0);
- LASSERT(gmsg->gum_mechidx == mechidx);
+ LASSERT(atomic_read(&gmsg->gum_refcount) > 0);
+ LASSERT(gmsg->gum_mechidx == mechidx);
- cfs_atomic_inc(&gmsg->gum_refcount);
- upcall_list_unlock(mechidx);
- return gmsg;
- }
- upcall_list_unlock(mechidx);
- return NULL;
+ atomic_inc(&gmsg->gum_refcount);
+ upcall_list_unlock(mechidx);
+ return gmsg;
+ }
+ upcall_list_unlock(mechidx);
+ return NULL;
}
static
GOTO(out_free, rc = -EINVAL);
}
- gss_unhash_msg(gss_msg);
- gctx = gss_msg->gum_gctx;
- LASSERT(gctx);
- LASSERT(cfs_atomic_read(&gctx->gc_base.cc_refcount) > 0);
+ gss_unhash_msg(gss_msg);
+ gctx = gss_msg->gum_gctx;
+ LASSERT(gctx);
+ LASSERT(atomic_read(&gctx->gc_base.cc_refcount) > 0);
/* timeout is not in use for now */
if (simple_get_bytes(&data, &datalen, &timeout, sizeof(timeout)))
return;
}
- gmsg = container_of(msg, struct gss_upcall_msg, gum_base);
- gumd = &gmsg->gum_data;
- LASSERT(cfs_atomic_read(&gmsg->gum_refcount) > 0);
+ gmsg = container_of(msg, struct gss_upcall_msg, gum_base);
+ gumd = &gmsg->gum_data;
+ LASSERT(atomic_read(&gmsg->gum_refcount) > 0);
- CERROR("failed msg %p (seq %u, uid %u, svc %u, nid "LPX64", obd %.*s): "
- "errno %d\n", msg, gumd->gum_seq, gumd->gum_uid, gumd->gum_svc,
- gumd->gum_nid, (int) sizeof(gumd->gum_obd),
- gumd->gum_obd, msg->errno);
+ CERROR("failed msg %p (seq %u, uid %u, svc %u, nid "LPX64", obd %.*s): "
+ "errno %d\n", msg, gumd->gum_seq, gumd->gum_uid, gumd->gum_svc,
+ gumd->gum_nid, (int) sizeof(gumd->gum_obd),
+ gumd->gum_obd, msg->errno);
- cfs_atomic_inc(&gmsg->gum_refcount);
- gss_unhash_msg(gmsg);
- if (msg->errno == -ETIMEDOUT || msg->errno == -EPIPE) {
- cfs_time_t now = cfs_time_current_sec();
+ atomic_inc(&gmsg->gum_refcount);
+ gss_unhash_msg(gmsg);
+ if (msg->errno == -ETIMEDOUT || msg->errno == -EPIPE) {
+ cfs_time_t now = cfs_time_current_sec();
- if (cfs_time_after(now, ratelimit)) {
- CWARN("upcall timed out, is lgssd running?\n");
- ratelimit = now + 15;
- }
- }
- gss_msg_fail_ctx(gmsg);
- gss_release_msg(gmsg);
- EXIT;
+ if (cfs_time_after(now, ratelimit)) {
+ CWARN("upcall timed out, is lgssd running?\n");
+ ratelimit = now + 15;
+ }
+ }
+ gss_msg_fail_ctx(gmsg);
+ gss_release_msg(gmsg);
+ EXIT;
}
static
gumd->gum_nid, (int) sizeof(gumd->gum_obd),
gumd->gum_obd);
- gmsg->gum_base.errno = -EPIPE;
- cfs_atomic_inc(&gmsg->gum_refcount);
- gss_unhash_msg_nolock(gmsg);
+ gmsg->gum_base.errno = -EPIPE;
+ atomic_inc(&gmsg->gum_refcount);
+ gss_unhash_msg_nolock(gmsg);
- gss_msg_fail_ctx(gmsg);
+ gss_msg_fail_ctx(gmsg);
- upcall_list_unlock(idx);
- gss_release_msg(gmsg);
- upcall_list_lock(idx);
- }
- upcall_list_unlock(idx);
- EXIT;
+ upcall_list_unlock(idx);
+ gss_release_msg(gmsg);
+ upcall_list_lock(idx);
+ }
+ upcall_list_unlock(idx);
+ EXIT;
}
static struct rpc_pipe_ops gss_upcall_ops = {
gmsg->gum_base.copied = 0;
gmsg->gum_base.errno = 0;
- /* init upcall msg */
- cfs_atomic_set(&gmsg->gum_refcount, 1);
- gmsg->gum_mechidx = mech_name2idx(gsec->gs_mech->gm_name);
- gmsg->gum_gsec = gsec;
- gmsg->gum_gctx = container_of(sptlrpc_cli_ctx_get(ctx),
- struct gss_cli_ctx, gc_base);
- gmsg->gum_data.gum_seq = upcall_get_sequence();
- gmsg->gum_data.gum_uid = ctx->cc_vcred.vc_uid;
- gmsg->gum_data.gum_gid = 0; /* not used for now */
- gmsg->gum_data.gum_svc = import_to_gss_svc(imp);
- gmsg->gum_data.gum_nid = imp->imp_connection->c_peer.nid;
- strncpy(gmsg->gum_data.gum_obd, imp->imp_obd->obd_name,
- sizeof(gmsg->gum_data.gum_obd));
+ /* init upcall msg */
+ atomic_set(&gmsg->gum_refcount, 1);
+ gmsg->gum_mechidx = mech_name2idx(gsec->gs_mech->gm_name);
+ gmsg->gum_gsec = gsec;
+ gmsg->gum_gctx = container_of(sptlrpc_cli_ctx_get(ctx),
+ struct gss_cli_ctx, gc_base);
+ gmsg->gum_data.gum_seq = upcall_get_sequence();
+ gmsg->gum_data.gum_uid = ctx->cc_vcred.vc_uid;
+ gmsg->gum_data.gum_gid = 0; /* not used for now */
+ gmsg->gum_data.gum_svc = import_to_gss_svc(imp);
+ gmsg->gum_data.gum_nid = imp->imp_connection->c_peer.nid;
+ strncpy(gmsg->gum_data.gum_obd, imp->imp_obd->obd_name,
+ sizeof(gmsg->gum_data.gum_obd));
/* This only could happen when sysadmin set it dead/expired
* using lctl by force. */