From b1854ceb41c4e8e701038ebdf228de2bd48151bc Mon Sep 17 00:00:00 2001 From: Sebastien Buisson Date: Thu, 6 Jun 2013 14:42:37 +0200 Subject: [PATCH] LU-2744 build: fix 'data race condition' issues 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 Change-Id: Ib5477c494feedd0b4ab052ccd9db9ea99f47101b Reviewed-on: http://review.whamcloud.com/6575 Reviewed-by: Andreas Dilger Tested-by: Jenkins Tested-by: Maloo --- lustre/ptlrpc/client.c | 12 +++++++++--- lustre/ptlrpc/niobuf.c | 8 ++++++-- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/lustre/ptlrpc/client.c b/lustre/ptlrpc/client.c index 7018182..2cc2c95 100644 --- a/lustre/ptlrpc/client.c +++ b/lustre/ptlrpc/client.c @@ -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); diff --git a/lustre/ptlrpc/niobuf.c b/lustre/ptlrpc/niobuf.c index 0f425dd..3acca9c 100644 --- a/lustre/ptlrpc/niobuf.c +++ b/lustre/ptlrpc/niobuf.c @@ -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); } -- 1.8.3.1