Whamcloud - gitweb
LU-4423 gss: Fix typo in sec_gss.c
[fs/lustre-release.git] / lustre / ptlrpc / nrs.c
index 4a3c976..6a5182d 100644 (file)
@@ -110,7 +110,7 @@ static void nrs_policy_stop0(struct ptlrpc_nrs_policy *policy)
 
        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;
@@ -252,9 +252,9 @@ static int nrs_policy_start_locked(struct ptlrpc_nrs_policy *policy, char *arg)
         * 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);
@@ -274,7 +274,7 @@ static int nrs_policy_start_locked(struct ptlrpc_nrs_policy *policy, char *arg)
 
                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;
@@ -763,7 +763,7 @@ static int nrs_policy_register(struct ptlrpc_nrs *nrs,
        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);
 
@@ -1019,7 +1019,13 @@ static void nrs_svcpt_cleanup_locked(struct ptlrpc_service_part *svcpt)
        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,
@@ -1200,7 +1206,7 @@ int ptlrpc_nrs_policy_register(struct ptlrpc_nrs_pol_conf *conf)
        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