linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Oleg Drokin <green@linuxhacker.ru>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-kernel@vger.kernel.org, devel@driverdev.osuosl.org
Cc: Sebastien Buisson <sebastien.buisson@bull.net>,
	Oeg Drokin <oleg.drokin@intel.com>
Subject: [PATCH 13/17] lustre/ptlrpc: fix 'data race condition' issues
Date: Fri, 28 Feb 2014 21:16:42 -0500	[thread overview]
Message-ID: <1393640206-20286-14-git-send-email-green@linuxhacker.ru> (raw)
In-Reply-To: <1393640206-20286-1-git-send-email-green@linuxhacker.ru>

From: Sebastien Buisson <sebastien.buisson@bull.net>

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>
Reviewed-on: http://review.whamcloud.com/6575
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-2744
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Signed-off-by: Oeg Drokin <oleg.drokin@intel.com>
---
 drivers/staging/lustre/lustre/ptlrpc/client.c | 6 ++++++
 drivers/staging/lustre/lustre/ptlrpc/niobuf.c | 4 ++++
 2 files changed, 10 insertions(+)

diff --git a/drivers/staging/lustre/lustre/ptlrpc/client.c b/drivers/staging/lustre/lustre/ptlrpc/client.c
index 98041e8..7b97c64 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/client.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/client.c
@@ -1190,7 +1190,9 @@ static int after_reply(struct ptlrpc_request *req)
 		 * will roundup it */
 		req->rq_replen       = req->rq_nob_received;
 		req->rq_nob_received = 0;
+		spin_lock(&req->rq_lock);
 		req->rq_resend       = 1;
+		spin_unlock(&req->rq_lock);
 		return 0;
 	}
 
@@ -1412,7 +1414,9 @@ static int ptlrpc_send_new_req(struct ptlrpc_request *req)
 			req->rq_status = rc;
 			return 1;
 		} else {
+			spin_lock(&req->rq_lock);
 			req->rq_wait_ctx = 1;
+			spin_unlock(&req->rq_lock);
 			return 0;
 		}
 	}
@@ -1427,7 +1431,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);
+		spin_lock(&req->rq_lock);
 		req->rq_net_err = 1;
+		spin_unlock(&req->rq_lock);
 		return rc;
 	}
 	return 0;
diff --git a/drivers/staging/lustre/lustre/ptlrpc/niobuf.c b/drivers/staging/lustre/lustre/ptlrpc/niobuf.c
index 1e94597..a47a8d8 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/niobuf.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/niobuf.c
@@ -511,7 +511,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 */
+		spin_lock(&request->rq_lock);
 		request->rq_err = 1;
+		spin_unlock(&request->rq_lock);
 		request->rq_status = -ENODEV;
 		return -ENODEV;
 	}
@@ -553,7 +555,9 @@ int ptl_send_rpc(struct ptlrpc_request *request, int noreply)
 			if (rc) {
 				/* this prevents us from looping in
 				 * ptlrpc_queue_wait */
+				spin_lock(&request->rq_lock);
 				request->rq_err = 1;
+				spin_unlock(&request->rq_lock);
 				request->rq_status = rc;
 				GOTO(cleanup_bulk, rc);
 			}
-- 
1.8.5.3


  parent reply	other threads:[~2014-03-01  2:17 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-01  2:16 [PATCH 00/17] Lustre stability patches Oleg Drokin
2014-03-01  2:16 ` [PATCH 01/17] staging/lustre/llite: fix open lock matching in ll_md_blocking_ast() Oleg Drokin
2014-03-03 10:01   ` Dan Carpenter
2014-03-01  2:16 ` [PATCH 02/17] lustre/mdc: Check for all attributes validity in revalidate Oleg Drokin
2014-03-01  2:16 ` [PATCH 03/17] lustre/llite: Do not send parent dir fid in getattr by fid Oleg Drokin
2014-03-01  2:16 ` [PATCH 04/17] lustre/mdc: comments on LOOKUP and PERM lock Oleg Drokin
2014-03-01  2:16 ` [PATCH 05/17] lustre/mdc: use ibits_known mask for lock match Oleg Drokin
2014-03-01  2:16 ` [PATCH 06/17] lustre/clio: honor O_NOATIME Oleg Drokin
2014-03-01  2:16 ` [PATCH 07/17] lustre/mdc: fix bad ERR_PTR usage in mdc_locks.c Oleg Drokin
2014-03-01  2:16 ` [PATCH 08/17] lustre/recovery: free open/close request promptly Oleg Drokin
2014-03-01  2:16 ` [PATCH 09/17] lustre/llite: simplify dentry revalidate Oleg Drokin
2014-03-01  2:16 ` [PATCH 10/17] lustre/ldlm: set l_lvb_type coherent when layout is returned Oleg Drokin
2014-03-01  2:16 ` [PATCH 11/17] lustre/ptlrpc: rq_commit_cb is called for twice Oleg Drokin
2014-03-01  2:16 ` [PATCH 12/17] lustre/ptlrpc: skip rpcs that fail ptl_send_rpc Oleg Drokin
2014-03-01  2:16 ` Oleg Drokin [this message]
2014-03-01  2:16 ` [PATCH 14/17] lustre/ptlrpc: re-enqueue ptlrpcd worker Oleg Drokin
2014-03-01  2:16 ` [PATCH 15/17] lustre/osc: Don't flush active extents Oleg Drokin
2014-03-01  2:16 ` [PATCH 16/17] lustre/quota: improper assert in osc_quota_chkdq() Oleg Drokin
2014-03-01  2:16 ` [PATCH 17/17] lustre/libcfs: warn if all HTs in a core are gone Oleg Drokin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1393640206-20286-14-git-send-email-green@linuxhacker.ru \
    --to=green@linuxhacker.ru \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oleg.drokin@intel.com \
    --cc=sebastien.buisson@bull.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).