From mboxrd@z Thu Jan 1 00:00:00 1970 From: Miao Xie Subject: [PATCH] vfs, freeze: use ACCESS_ONCE() to guard access to ->mnt_flags Date: Fri, 16 Nov 2012 17:23:50 +0800 Message-ID: <50A60626.4080200@cn.fujitsu.com> Reply-To: miaox@cn.fujitsu.com Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Cc: Jan Kara , Al Viro To: Linux Fsdevel Return-path: Received: from cn.fujitsu.com ([222.73.24.84]:40098 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1750799Ab2KPJXu (ORCPT ); Fri, 16 Nov 2012 04:23:50 -0500 Sender: linux-fsdevel-owner@vger.kernel.org List-ID: The compiler may optimize the while loop and make the check just be done once, so we should use ACCESS_ONCE() to guard access to ->mnt_flags Signed-off-by: Miao Xie --- fs/namespace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/namespace.c b/fs/namespace.c index 7bdf790..6eca68e 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -311,7 +311,7 @@ int __mnt_want_write(struct vfsmount *m) * incremented count after it has set MNT_WRITE_HOLD. */ smp_mb(); - while (mnt->mnt.mnt_flags & MNT_WRITE_HOLD) + while (ACCESS_ONCE(mnt->mnt.mnt_flags) & MNT_WRITE_HOLD) cpu_relax(); /* * After the slowpath clears MNT_WRITE_HOLD, mnt_is_readonly will -- 1.7.11.7