Whamcloud - gitweb
LU-2744 build: fix 'data race condition' issues 75/6575/8
authorSebastien Buisson <sebastien.buisson@bull.net>
Thu, 6 Jun 2013 12:42:37 +0000 (14:42 +0200)
committerOleg Drokin <oleg.drokin@intel.com>
Mon, 18 Nov 2013 12:33:41 +0000 (12:33 +0000)
Fix 'data race condition' defects found by Coverity version
6.5.0:
Data race condition (MISSING_LOCK)
Accessing variable without holding lock. Elsewhere,
this variable is accessed with lock held.

Signed-off-by: Sebastien Buisson <sebastien.buisson@bull.net>
Change-Id: Ib5477c494feedd0b4ab052ccd9db9ea99f47101b
Reviewed-on: http://review.whamcloud.com/6575
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
lustre/ptlrpc/client.c
lustre/ptlrpc/niobuf.c

index 7018182..2cc2c95 100644 (file)
@@ -1237,7 +1237,9 @@ static int after_reply(struct ptlrpc_request *req)
                  * will roundup it */
                 req->rq_replen       = req->rq_nob_received;
                 req->rq_nob_received = 0;
-                req->rq_resend       = 1;
+               spin_lock(&req->rq_lock);
+               req->rq_resend       = 1;
+               spin_unlock(&req->rq_lock);
                 RETURN(0);
         }
 
@@ -1456,7 +1458,9 @@ static int ptlrpc_send_new_req(struct ptlrpc_request *req)
                         req->rq_status = rc;
                         RETURN(1);
                 } else {
-                        req->rq_wait_ctx = 1;
+                       spin_lock(&req->rq_lock);
+                       req->rq_wait_ctx = 1;
+                       spin_unlock(&req->rq_lock);
                         RETURN(0);
                 }
         }
@@ -1471,7 +1475,9 @@ static int ptlrpc_send_new_req(struct ptlrpc_request *req)
         rc = ptl_send_rpc(req, 0);
         if (rc) {
                 DEBUG_REQ(D_HA, req, "send failed (%d); expect timeout", rc);
-                req->rq_net_err = 1;
+               spin_lock(&req->rq_lock);
+               req->rq_net_err = 1;
+               spin_unlock(&req->rq_lock);
                 RETURN(rc);
         }
         RETURN(0);
index 0f425dd..3acca9c 100644 (file)
@@ -696,7 +696,9 @@ int ptl_send_rpc(struct ptlrpc_request *request, int noreply)
                 CDEBUG(D_HA, "muting rpc for failed imp obd %s\n",
                        request->rq_import->imp_obd->obd_name);
                 /* this prevents us from waiting in ptlrpc_queue_wait */
-                request->rq_err = 1;
+               spin_lock(&request->rq_lock);
+               request->rq_err = 1;
+               spin_unlock(&request->rq_lock);
                 request->rq_status = -ENODEV;
                 RETURN(-ENODEV);
         }
@@ -738,7 +740,9 @@ int ptl_send_rpc(struct ptlrpc_request *request, int noreply)
                         if (rc) {
                                 /* this prevents us from looping in
                                  * ptlrpc_queue_wait */
-                                request->rq_err = 1;
+                               spin_lock(&request->rq_lock);
+                               request->rq_err = 1;
+                               spin_unlock(&request->rq_lock);
                                 request->rq_status = rc;
                                 GOTO(cleanup_bulk, rc);
                         }