Whamcloud - gitweb
b=21877 protect modification of request flag's bitfield with rq_lock
authorMikhail Pershin <tappro@sun.com>
Thu, 1 Apr 2010 22:40:41 +0000 (15:40 -0700)
committerRobert Read <rread@sun.com>
Thu, 1 Apr 2010 22:40:41 +0000 (15:40 -0700)
lustre/ptlrpc/client.c
lustre/ptlrpc/pack_generic.c
lustre/ptlrpc/sec.c
lustre/ptlrpc/service.c

index 654394d..eb69133 100644 (file)
@@ -1312,7 +1312,9 @@ int ptlrpc_check_set(const struct lu_env *env, struct ptlrpc_request_set *set)
                 }
 
                 if (req->rq_err) {
                 }
 
                 if (req->rq_err) {
+                        cfs_spin_lock(&req->rq_lock);
                         req->rq_replied = 0;
                         req->rq_replied = 0;
+                        cfs_spin_unlock(&req->rq_lock);
                         if (req->rq_status == 0)
                                 req->rq_status = -EIO;
                         ptlrpc_rqphase_move(req, RQ_PHASE_INTERPRET);
                         if (req->rq_status == 0)
                                 req->rq_status = -EIO;
                         ptlrpc_rqphase_move(req, RQ_PHASE_INTERPRET);
@@ -1376,12 +1378,16 @@ int ptlrpc_check_set(const struct lu_env *env, struct ptlrpc_request_set *set)
 
                                 cfs_spin_unlock(&imp->imp_lock);
 
 
                                 cfs_spin_unlock(&imp->imp_lock);
 
+                                cfs_spin_lock(&req->rq_lock);
                                 req->rq_waiting = 0;
                                 req->rq_waiting = 0;
+                                cfs_spin_unlock(&req->rq_lock);
 
                                 if (req->rq_timedout||req->rq_resend) {
                                         /* This is re-sending anyways,
                                          * let's mark req as resend. */
 
                                 if (req->rq_timedout||req->rq_resend) {
                                         /* This is re-sending anyways,
                                          * let's mark req as resend. */
+                                        cfs_spin_lock(&req->rq_lock);
                                         req->rq_resend = 1;
                                         req->rq_resend = 1;
+                                        cfs_spin_unlock(&req->rq_lock);
                                         if (req->rq_bulk) {
                                                 __u64 old_xid;
 
                                         if (req->rq_bulk) {
                                                 __u64 old_xid;
 
@@ -1405,15 +1411,21 @@ int ptlrpc_check_set(const struct lu_env *env, struct ptlrpc_request_set *set)
                                 if (status) {
                                         if (req->rq_err) {
                                                 req->rq_status = status;
                                 if (status) {
                                         if (req->rq_err) {
                                                 req->rq_status = status;
+                                                cfs_spin_lock(&req->rq_lock);
                                                 req->rq_wait_ctx = 0;
                                                 req->rq_wait_ctx = 0;
+                                                cfs_spin_unlock(&req->rq_lock);
                                                 force_timer_recalc = 1;
                                         } else {
                                                 force_timer_recalc = 1;
                                         } else {
+                                                cfs_spin_lock(&req->rq_lock);
                                                 req->rq_wait_ctx = 1;
                                                 req->rq_wait_ctx = 1;
+                                                cfs_spin_unlock(&req->rq_lock);
                                         }
 
                                         continue;
                                 } else {
                                         }
 
                                         continue;
                                 } else {
+                                        cfs_spin_lock(&req->rq_lock);
                                         req->rq_wait_ctx = 0;
                                         req->rq_wait_ctx = 0;
+                                        cfs_spin_unlock(&req->rq_lock);
                                 }
 
                                 rc = ptl_send_rpc(req, 0);
                                 }
 
                                 rc = ptl_send_rpc(req, 0);
@@ -1421,7 +1433,9 @@ int ptlrpc_check_set(const struct lu_env *env, struct ptlrpc_request_set *set)
                                         DEBUG_REQ(D_HA, req, "send failed (%d)",
                                                   rc);
                                         force_timer_recalc = 1;
                                         DEBUG_REQ(D_HA, req, "send failed (%d)",
                                                   rc);
                                         force_timer_recalc = 1;
+                                        cfs_spin_lock(&req->rq_lock);
                                         req->rq_net_err = 1;
                                         req->rq_net_err = 1;
+                                        cfs_spin_unlock(&req->rq_lock);
                                 }
                                 /* need to reset the timeout */
                                 force_timer_recalc = 1;
                                 }
                                 /* need to reset the timeout */
                                 force_timer_recalc = 1;
index 5149f1f..5af3db6 100644 (file)
@@ -320,8 +320,11 @@ int lustre_pack_reply_v2(struct ptlrpc_request *req, int count,
 
         LASSERT(req->rq_reply_state == NULL);
 
 
         LASSERT(req->rq_reply_state == NULL);
 
-        if ((flags & LPRFL_EARLY_REPLY) == 0)
+        if ((flags & LPRFL_EARLY_REPLY) == 0) {
+                cfs_spin_lock(&req->rq_lock);
                 req->rq_packed_final = 1;
                 req->rq_packed_final = 1;
+                cfs_spin_unlock(&req->rq_lock);
+        }
 
         msg_len = lustre_msg_size_v2(count, lens);
         rc = sptlrpc_svc_alloc_rs(req, msg_len);
 
         msg_len = lustre_msg_size_v2(count, lens);
         rc = sptlrpc_svc_alloc_rs(req, msg_len);
index 84669c3..defe085 100644 (file)
@@ -667,7 +667,9 @@ again:
         }
 
         if (unlikely(cfs_test_bit(PTLRPC_CTX_ERROR_BIT, &ctx->cc_flags))) {
         }
 
         if (unlikely(cfs_test_bit(PTLRPC_CTX_ERROR_BIT, &ctx->cc_flags))) {
+                cfs_spin_lock(&req->rq_lock);
                 req->rq_err = 1;
                 req->rq_err = 1;
+                cfs_spin_unlock(&req->rq_lock);
                 req_off_ctx_list(req, ctx);
                 RETURN(-EPERM);
         }
                 req_off_ctx_list(req, ctx);
                 RETURN(-EPERM);
         }
@@ -709,7 +711,9 @@ again:
                  * don't switch ctx if import was deactivated
                  */
                 if (req->rq_import->imp_deactive) {
                  * don't switch ctx if import was deactivated
                  */
                 if (req->rq_import->imp_deactive) {
+                        cfs_spin_lock(&req->rq_lock);
                         req->rq_err = 1;
                         req->rq_err = 1;
+                        cfs_spin_unlock(&req->rq_lock);
                         RETURN(-EINTR);
                 }
 
                         RETURN(-EINTR);
                 }
 
@@ -718,7 +722,9 @@ again:
                         LASSERT(ctx == req->rq_cli_ctx);
                         CERROR("req %p: failed to replace dead ctx %p: %d\n",
                                 req, ctx, rc);
                         LASSERT(ctx == req->rq_cli_ctx);
                         CERROR("req %p: failed to replace dead ctx %p: %d\n",
                                 req, ctx, rc);
+                        cfs_spin_lock(&req->rq_lock);
                         req->rq_err = 1;
                         req->rq_err = 1;
+                        cfs_spin_unlock(&req->rq_lock);
                         RETURN(rc);
                 }
 
                         RETURN(rc);
                 }
 
index f6e6a65..07cd10d 100644 (file)
@@ -658,7 +658,9 @@ void ptlrpc_server_drop_request(struct ptlrpc_request *req)
 
                 LASSERT(!cfs_list_empty(&req->rq_timed_list));
                 cfs_list_del_init(&req->rq_timed_list);
 
                 LASSERT(!cfs_list_empty(&req->rq_timed_list));
                 cfs_list_del_init(&req->rq_timed_list);
+                cfs_spin_lock(&req->rq_lock);
                 req->rq_at_linked = 0;
                 req->rq_at_linked = 0;
+                cfs_spin_unlock(&req->rq_lock);
                 array->paa_reqs_count[index]--;
                 array->paa_count--;
         } else
                 array->paa_reqs_count[index]--;
                 array->paa_count--;
         } else
@@ -919,7 +921,9 @@ static int ptlrpc_at_add_timed(struct ptlrpc_request *req)
                 cfs_list_add(&req->rq_timed_list,
                              &array->paa_reqs_array[index]);
 
                 cfs_list_add(&req->rq_timed_list,
                              &array->paa_reqs_array[index]);
 
+        cfs_spin_lock(&req->rq_lock);
         req->rq_at_linked = 1;
         req->rq_at_linked = 1;
+        cfs_spin_unlock(&req->rq_lock);
         req->rq_at_index = index;
         array->paa_reqs_count[index]++;
         array->paa_count++;
         req->rq_at_index = index;
         array->paa_reqs_count[index]++;
         array->paa_count++;
@@ -1130,7 +1134,9 @@ static int ptlrpc_at_check_timed(struct ptlrpc_service *svc)
                                 counter++;
                                 array->paa_reqs_count[index]--;
                                 array->paa_count--;
                                 counter++;
                                 array->paa_reqs_count[index]--;
                                 array->paa_count--;
+                                cfs_spin_lock(&rq->rq_lock);
                                 rq->rq_at_linked = 0;
                                 rq->rq_at_linked = 0;
+                                cfs_spin_unlock(&rq->rq_lock);
                                 continue;
                         }
 
                                 continue;
                         }