From ae2838c1c6019f5bbf727be671ec97fc6f40546a Mon Sep 17 00:00:00 2001
From: Nikitas Angelinas <nikitas_angelinas@xyratex.com>
Date: Tue, 9 Aug 2011 16:29:54 +0100
Subject: [PATCH 2/4] Add assertions where svc::srv_rq_lock is meant to be
 held

---
 lustre/include/lustre_net.h |    2 +-
 lustre/ptlrpc/ptlrpc_nrs.c  |   15 +++++++++------
 2 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/lustre/include/lustre_net.h b/lustre/include/lustre_net.h
index ed7eaad..eaa7c8c 100644
--- a/lustre/include/lustre_net.h
+++ b/lustre/include/lustre_net.h
@@ -529,7 +529,7 @@ typedef struct ptlrpc_nrs {
 #define NRS_NAME_LEN            16
 
 /**
- * NRS policy registering descritpor
+ * NRS policy registering descriptor
  */
 typedef struct ptlrpc_nrs_policy_desc {
         char                    pd_name[NRS_NAME_LEN];
diff --git a/lustre/ptlrpc/ptlrpc_nrs.c b/lustre/ptlrpc/ptlrpc_nrs.c
index bbee6a6..f41eb31 100644
--- a/lustre/ptlrpc/ptlrpc_nrs.c
+++ b/lustre/ptlrpc/ptlrpc_nrs.c
@@ -391,7 +391,7 @@ nrs_request_enqueue(ptlrpc_nrs_request_t *nrq)
                         return;
                 }
         }
-        LBUG(); /* shouldn never be here */
+        LBUG(); /* should never be here */
 }
 
 ptlrpc_nrs_policy_t *
@@ -583,7 +583,7 @@ nrs_policy_register(ptlrpc_nrs_t *nrs,
         if (tmp != NULL) {
                 cfs_spin_unlock(&nrs->nrs_lock);
 
-                CERROR("NRS type %d (%s) has been registered, can't"
+                CERROR("NRS type %d (%s) has been registered, can't "
                        "register it for %s\n",
                        tmp->pol_type, tmp->pol_name, policy->pol_name);
 
@@ -613,7 +613,7 @@ ptlrpc_nrs_req_initialize(struct ptlrpc_service *svc,
         memset(&req->rq_nrq, 0, sizeof(req->rq_nrq));
         nrs_resource_get_safe(ptlrpc_server_nrs(svc, req->rq_hp),
                               &req->rq_nrq, req->rq_nrq.nr_res_ptrs);
-        /* no pretection on bit nr_initialized because no contention
+        /* no protection on bit nr_initialized because no contention
          * at this early stage */
         req->rq_nrq.nr_initialized = 1;
 }
@@ -623,7 +623,7 @@ ptlrpc_nrs_req_finalize(struct ptlrpc_request *req)
 {
         if (req->rq_nrq.nr_initialized) {
                 nrs_resource_put_safe(req->rq_nrq.nr_res_ptrs);
-                /* no pretection on bit nr_initialized because no
+                /* no protection on bit nr_initialized because no
                  * contention at this late stage */
                 req->rq_nrq.nr_finalized = 1;
         }
@@ -636,6 +636,7 @@ ptlrpc_nrs_req_add_nolock(struct ptlrpc_service *svc,
         ptlrpc_nrs_policy_t *policy;
 
         /* NB: must call with hold svc::srv_rq_lock */
+        LASSERT_SPIN_LOCKED(&svc->srv_rq_lock);
         LASSERT(req->rq_nrq.nr_initialized);
         LASSERT(!req->rq_nrq.nr_enqueued);
 
@@ -699,6 +700,7 @@ ptlrpc_nrs_req_poll_nolock(struct ptlrpc_service *svc, int hp)
                 return NULL;
 
         /* NB: must call with hold svc::srv_rq_lock */
+        LASSERT_SPIN_LOCKED(&svc->srv_rq_lock);
         /* always try to drain requests from all NRS polices even they are
          * inactive, because user can change policy status at runtime */
         cfs_list_for_each_entry(policy, &(nrs)->nrs_policy_queued,
@@ -716,6 +718,7 @@ ptlrpc_nrs_req_del_nolock(struct ptlrpc_request *req)
         ptlrpc_nrs_policy_t  *policy;
 
         /* NB: must call with hold svc::srv_rq_lock */
+        LASSERT_SPIN_LOCKED(&svc->srv_rq_lock);
         LASSERT(req->rq_nrq.nr_enqueued);
 
         policy = nrs_request_policy(&req->rq_nrq);
@@ -1078,7 +1081,7 @@ nrs_crr_start(ptlrpc_nrs_policy_t *policy)
         if (cdat == NULL)
                 return -ENOMEM;
 
-        /* XXX we might want to move this allocation to op_poilicy_start()
+        /* XXX we might want to move this allocation to op_policy_start()
          * in the future FIXME */
         cdat->cd_binheap = cfs_binheap_create(&nrs_crr_heap_ops,
                                               CBH_FLAG_ATOMIC_GROW,
@@ -1317,7 +1320,7 @@ nrs_crr2_start(ptlrpc_nrs_policy_t *policy)
         if (net == NULL)
                 return -ENOMEM;
 
-        /* XXX we might want to move these allocations to op_poilicy_start()
+        /* XXX we might want to move these allocations to op_policy_start()
          * in the future FIXME */
         net->cn_binheap = cfs_binheap_create(&nrs_crr_heap_ops,
                                              CBH_FLAG_ATOMIC_GROW, 4096, NULL);
-- 
1.7.5

