public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Peng Tao <bergwolf@gmail.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-kernel@vger.kernel.org,
	Sebastien Buisson <sebastien.buisson@bull.net>,
	Peng Tao <tao.peng@emc.com>,
	Andreas Dilger <andreas.dilger@intel.com>
Subject: [PATCH-RESEND 4/8] staging/lustre/llite: fix 'data race condition' issues of lli_flags
Date: Thu, 25 Jul 2013 01:17:27 +0800	[thread overview]
Message-ID: <1374686251-3152-5-git-send-email-bergwolf@gmail.com> (raw)
In-Reply-To: <1374686251-3152-1-git-send-email-bergwolf@gmail.com>

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.

lli->lli_flags need to be protected by lli->lli_lock.

Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-2744
Lustre-change: http://review.whamcloud.com/6571
Signed-off-by: Sebastien Buisson <sebastien.buisson@bull.net>
Reviewed-by: Fan Yong <fan.yong@intel.com>
Reviewed-by: Keith Mannthey <keith.mannthey@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
Signed-off-by: Peng Tao <tao.peng@emc.com>
Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
---
 drivers/staging/lustre/lustre/llite/llite_lib.c |    4 ++++
 drivers/staging/lustre/lustre/llite/namei.c     |    5 ++++-
 2 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c
index d7d87b1..36a07fa 100644
--- a/drivers/staging/lustre/lustre/llite/llite_lib.c
+++ b/drivers/staging/lustre/lustre/llite/llite_lib.c
@@ -1190,7 +1190,9 @@ void ll_clear_inode(struct inode *inode)
 		LASSERT(lli->lli_opendir_pid == 0);
 	}
 
+	spin_lock(&lli->lli_lock);
 	ll_i2info(inode)->lli_flags &= ~LLIF_MDS_SIZE_LOCK;
+	spin_unlock(&lli->lli_lock);
 	md_null_inode(sbi->ll_md_exp, ll_inode2fid(inode));
 
 	LASSERT(!lli->lli_open_fd_write_count);
@@ -1757,7 +1759,9 @@ void ll_update_inode(struct inode *inode, struct lustre_md *md)
 					/* Use old size assignment to avoid
 					 * deadlock bz14138 & bz14326 */
 					i_size_write(inode, body->size);
+					spin_lock(&lli->lli_lock);
 					lli->lli_flags |= LLIF_MDS_SIZE_LOCK;
+					spin_unlock(&lli->lli_lock);
 				}
 				ldlm_lock_decref(&lockh, mode);
 			}
diff --git a/drivers/staging/lustre/lustre/llite/namei.c b/drivers/staging/lustre/lustre/llite/namei.c
index 8e948a7..333e55f 100644
--- a/drivers/staging/lustre/lustre/llite/namei.c
+++ b/drivers/staging/lustre/lustre/llite/namei.c
@@ -275,8 +275,11 @@ int ll_md_blocking_ast(struct ldlm_lock *lock, struct ldlm_lock_desc *desc,
 				CDEBUG(D_INODE, "invaliding layout %d.\n", rc);
 		}
 
-		if (bits & MDS_INODELOCK_UPDATE)
+		if (bits & MDS_INODELOCK_UPDATE) {
+			spin_lock(&lli->lli_lock);
 			lli->lli_flags &= ~LLIF_MDS_SIZE_LOCK;
+			spin_unlock(&lli->lli_lock);
+		}
 
 		if (S_ISDIR(inode->i_mode) &&
 		     (bits & MDS_INODELOCK_UPDATE)) {
-- 
1.7.1


  parent reply	other threads:[~2013-07-24 17:21 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-24 17:17 [PATCH-RESEND 0/8] staging/lustre: Intel tree sync and two fixups Peng Tao
2013-07-24 17:17 ` [PATCH-RESEND 1/8] staging/lustre/lmv: support DNE with HSM Peng Tao
2013-07-24 17:17 ` [PATCH-RESEND 2/8] staging/lustre/llite: handle io init failure in ll_fault_io_init() Peng Tao
2013-07-24 17:17 ` [PATCH-RESEND 3/8] staging/lustre: fix 'data race condition' issues in at_reset() Peng Tao
2013-07-24 17:17 ` Peng Tao [this message]
2013-07-24 17:17 ` [PATCH-RESEND 5/8] staging/lustre/obdclass: add obd_target.h Peng Tao
2013-07-24 17:33   ` Greg Kroah-Hartman
2013-07-24 17:17 ` [PATCH-RESEND 6/8] staging/lustre: fix Kconfig bool defaults Peng Tao
2013-07-24 17:17 ` [PATCH-RESEND 7/8] staging/lustre/obdclass: use a dummy structure for lu_ref_link Peng Tao
2013-07-24 17:17 ` [PATCH-RESEND 8/8] staging/lustre: fix errno translate code on non-x86 Peng Tao
2013-07-24 17:28   ` Greg Kroah-Hartman
2013-07-24 17:36 ` [PATCH-RESEND 0/8] staging/lustre: Intel tree sync and two fixups Greg Kroah-Hartman

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=1374686251-3152-5-git-send-email-bergwolf@gmail.com \
    --to=bergwolf@gmail.com \
    --cc=andreas.dilger@intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sebastien.buisson@bull.net \
    --cc=tao.peng@emc.com \
    /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