policy->pol_state = NRS_POL_STATE_STOPPED;
- if (cfs_atomic_dec_and_test(&policy->pol_desc->pd_refs))
+ if (atomic_dec_and_test(&policy->pol_desc->pd_refs))
module_put(policy->pol_desc->pd_owner);
EXIT;
* Increase the module usage count for policies registering from other
* modules.
*/
- if (cfs_atomic_inc_return(&policy->pol_desc->pd_refs) == 1 &&
+ if (atomic_inc_return(&policy->pol_desc->pd_refs) == 1 &&
!try_module_get(policy->pol_desc->pd_owner)) {
- cfs_atomic_dec(&policy->pol_desc->pd_refs);
+ atomic_dec(&policy->pol_desc->pd_refs);
CERROR("NRS: cannot get module for policy %s; is it alive?\n",
policy->pol_desc->pd_name);
RETURN(-ENODEV);
spin_lock(&nrs->nrs_lock);
if (rc != 0) {
- if (cfs_atomic_dec_and_test(&policy->pol_desc->pd_refs))
+ if (atomic_dec_and_test(&policy->pol_desc->pd_refs))
module_put(policy->pol_desc->pd_owner);
policy->pol_state = NRS_POL_STATE_STOPPED;
LASSERT(desc->pd_compat != NULL);
OBD_CPT_ALLOC_GFP(policy, svcpt->scp_service->srv_cptable,
- svcpt->scp_cpt, sizeof(*policy), __GFP_IO);
+ svcpt->scp_cpt, sizeof(*policy), GFP_NOFS);
if (policy == NULL)
RETURN(-ENOMEM);
LASSERT(mutex_is_locked(&nrs_core.nrs_mutex));
again:
- nrs = nrs_svcpt2nrs(svcpt, hp);
+ /* scp_nrs_hp could be NULL due to short of memory. */
+ nrs = hp ? svcpt->scp_nrs_hp : &svcpt->scp_nrs_reg;
+ /* check the nrs_svcpt to see if nrs is initialized. */
+ if (!nrs || !nrs->nrs_svcpt) {
+ EXIT;
+ return;
+ }
nrs->nrs_stopping = 1;
cfs_list_for_each_entry_safe(policy, tmp, &nrs->nrs_policy_list,
if ((conf->nc_flags & PTLRPC_NRS_FL_REG_EXTERN) != 0)
desc->pd_owner = conf->nc_owner;
desc->pd_flags = conf->nc_flags;
- cfs_atomic_set(&desc->pd_refs, 0);
+ atomic_set(&desc->pd_refs, 0);
/**
* For policies that are held in the same module as NRS (currently