/* * caller must hold spinlock */ static void ctx_unhash_pf(struct ptlrpc_cli_ctx *ctx, cfs_hlist_head_t *freelist) { LASSERT_SPIN_LOCKED(&ctx->cc_sec->ps_lock); LASSERT(cfs_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)) { __cfs_hlist_del(&ctx->cc_cache); cfs_hlist_add_head(&ctx->cc_cache, freelist); } else { cfs_hlist_del_init(&ctx->cc_cache); } }
static 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); cli_ctx_expire(ctx); spin_lock(&ctx->cc_sec->ps_lock); 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); cfs_hlist_del_init(&ctx->cc_cache); if (cfs_atomic_dec_and_test(&ctx->cc_refcount)) LBUG(); } spin_unlock(&ctx->cc_sec->ps_lock); }
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)) llog_free_handle(loghandle); }