linux-rt-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: john stultz <johnstul@us.ibm.com>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-rt-users@vger.kernel.org,
	Clark Williams <williams@redhat.com>,
	Darren Hart <dvhltc@us.ibm.com>, Nick Piggin <npiggin@suse.de>
Subject: [PATCH 2/2] Resolve mntput_no_expire issues.
Date: Wed, 12 May 2010 17:52:14 -0700	[thread overview]
Message-ID: <1273711934.2856.22.camel@localhost.localdomain> (raw)
In-Reply-To: <1273711544.2856.15.camel@localhost.localdomain>

In testing the mnt_count typo fix, I hit a few BUG_ON/WARN_ON messages
in the mntput_no_expire code.

The first issue was a race against the MNT_MOUNTED flag, where if after
the optimistic lock free check is done, someone changes the value, we
might BUG_ON after getting the lock.  The fix is after getting the lock,
re-check the MNT_MOUNTED bit and drop the lock and try again if its
changed.

The second issue was a call to smp_processor_id() in add_mnt_count()
that was done while preemptable. This was missed in my earlier commit
070976b5b038218900648ea4cc88786d5dfcd58d.

Signed-off-by: John Stultz <johnstul@us.ibm.com>

diff --git a/fs/namespace.c b/fs/namespace.c
index 35c56c2..d8dcabb 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -752,6 +752,7 @@ void mntput_no_expire(struct vfsmount *mnt)
 {
 	int cpu = get_cpu();
 	put_cpu();
+repeat:
 	if (likely(mnt->mnt_flags & MNT_MOUNTED)) {
 		vfsmount_read_lock(cpu);
 		if (unlikely(!(mnt->mnt_flags & MNT_MOUNTED))) {
@@ -766,9 +767,11 @@ void mntput_no_expire(struct vfsmount *mnt)
 		return;
 	}
 
-repeat:
 	vfsmount_write_lock();
-	BUG_ON(mnt->mnt_flags & MNT_MOUNTED);
+	if (unlikely((mnt->mnt_flags & MNT_MOUNTED))) {
+		vfsmount_write_unlock();
+		goto repeat;
+	}
 	preempt_disable();
 	dec_mnt_count(mnt);
 	preempt_enable();
@@ -781,7 +784,9 @@ repeat:
 		__mntput(mnt);
 		return;
 	}
+	preempt_disable();
 	add_mnt_count(mnt, mnt->mnt_pinned + 1);
+	preempt_enable();
 	mnt->mnt_pinned = 0;
 	vfsmount_write_unlock();
 	acct_auto_close_mnt(mnt);



      reply	other threads:[~2010-05-13  0:52 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-13  0:45 [PATCH 1/2] Fix mnt_count typo john stultz
2010-05-13  0:52 ` john stultz [this message]

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=1273711934.2856.22.camel@localhost.localdomain \
    --to=johnstul@us.ibm.com \
    --cc=dvhltc@us.ibm.com \
    --cc=linux-rt-users@vger.kernel.org \
    --cc=npiggin@suse.de \
    --cc=tglx@linutronix.de \
    --cc=williams@redhat.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;
as well as URLs for NNTP newsgroup(s).