LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Dave Hansen <haveblue@us.ibm.com>
To: linux-kernel@vger.kernel.org
Cc: miklos@szeredi.hu, hch@infradead.org, serue@us.ibm.com,
	Dave Hansen <haveblue@us.ibm.com>
Subject: [RFC][PATCH 1/4] use helper to set mnt_sb
Date: Thu, 10 Jan 2008 11:06:58 -0800	[thread overview]
Message-ID: <20080110190658.4BF4421A@kernel> (raw)
In-Reply-To: <20080110190657.92A8B61F@kernel>


We need to make sure that all mounts get into the
sb list.  So, require that new setters of mnt->mnt_sb
use simple_set_mnt() instead of doing it themselves.

NFS does the same thing a few times in a row, so give
it a nice little helper.

---

 linux-2.6.git-dave/fs/namespace.c |    3 +--
 linux-2.6.git-dave/fs/nfs/super.c |   31 ++++++++++++++++---------------
 2 files changed, 17 insertions(+), 17 deletions(-)

diff -puN fs/namespace.c~make-mnt_sb-off-limits fs/namespace.c
--- linux-2.6.git/fs/namespace.c~make-mnt_sb-off-limits	2008-01-10 10:36:37.000000000 -0800
+++ linux-2.6.git-dave/fs/namespace.c	2008-01-10 10:36:37.000000000 -0800
@@ -486,8 +486,7 @@ static struct vfsmount *clone_mnt(struct
 	if (mnt) {
 		mnt->mnt_flags = old->mnt_flags;
 		atomic_inc(&sb->s_active);
-		mnt->mnt_sb = sb;
-		mnt->mnt_root = dget(root);
+		simple_set_mnt(mnt, sb);
 		mnt->mnt_mountpoint = mnt->mnt_root;
 		mnt->mnt_parent = mnt;
 
diff -puN fs/nfs/super.c~make-mnt_sb-off-limits fs/nfs/super.c
--- linux-2.6.git/fs/nfs/super.c~make-mnt_sb-off-limits	2008-01-10 10:36:37.000000000 -0800
+++ linux-2.6.git-dave/fs/nfs/super.c	2008-01-10 10:36:37.000000000 -0800
@@ -1364,6 +1364,17 @@ static int nfs_compare_super(struct supe
 	return nfs_compare_mount_options(sb, server, mntflags);
 }
 
+static void nfs_set_mnt(struct vfsmount *mnt, struct super_block *s)
+{
+	s->s_flags |= MS_ACTIVE;
+	simple_set_mnt(mnt, s);
+	/*
+	 * simple_set_mnt() does a dput, which we already did
+	 * in nfs_get_root().
+	 */
+	dput(s->s_root);
+}
+
 static int nfs_get_sb(struct file_system_type *fs_type,
 	int flags, const char *dev_name, void *raw_data, struct vfsmount *mnt)
 {
@@ -1417,9 +1428,7 @@ static int nfs_get_sb(struct file_system
 		goto error_splat_super;
 	}
 
-	s->s_flags |= MS_ACTIVE;
-	mnt->mnt_sb = s;
-	mnt->mnt_root = mntroot;
+	nfs_set_mnt(mnt, s);
 	error = 0;
 
 out:
@@ -1505,9 +1514,7 @@ static int nfs_xdev_get_sb(struct file_s
 		goto error_splat_super;
 	}
 
-	s->s_flags |= MS_ACTIVE;
-	mnt->mnt_sb = s;
-	mnt->mnt_root = mntroot;
+	nfs_set_mnt(mnt, s);
 
 	dprintk("<-- nfs_xdev_get_sb() = 0\n");
 	return 0;
@@ -1766,9 +1773,7 @@ static int nfs4_get_sb(struct file_syste
 		goto error_splat_super;
 	}
 
-	s->s_flags |= MS_ACTIVE;
-	mnt->mnt_sb = s;
-	mnt->mnt_root = mntroot;
+	nfs_set_mnt(mnt, s);
 	error = 0;
 
 out:
@@ -1851,9 +1856,7 @@ static int nfs4_xdev_get_sb(struct file_
 		goto error_splat_super;
 	}
 
-	s->s_flags |= MS_ACTIVE;
-	mnt->mnt_sb = s;
-	mnt->mnt_root = mntroot;
+	nfs_set_mnt(mnt, s);
 
 	dprintk("<-- nfs4_xdev_get_sb() = 0\n");
 	return 0;
@@ -1925,9 +1928,7 @@ static int nfs4_referral_get_sb(struct f
 		goto error_splat_super;
 	}
 
-	s->s_flags |= MS_ACTIVE;
-	mnt->mnt_sb = s;
-	mnt->mnt_root = mntroot;
+	nfs_set_mnt(mnt, s);
 
 	dprintk("<-- nfs4_referral_get_sb() = 0\n");
 	return 0;
_

  reply	other threads:[~2008-01-10 19:07 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-10 19:06 [RFC][PATCH 0/4] kill open files traverse on remount ro Dave Hansen
2008-01-10 19:06 ` Dave Hansen [this message]
2008-01-10 19:07 ` [RFC][PATCH 2/4] change mnt_writers underflow protection logic Dave Hansen
2008-01-10 19:07 ` [RFC][PATCH 3/4] change mnt_writers[] spinlock to mutex Dave Hansen
2008-01-10 19:10   ` Dave Hansen
2008-01-10 19:07 ` [RFC][PATCH 4/4] check mount writers at superblock remount Dave Hansen
2008-01-10 21:47 ` [RFC][PATCH 0/4] kill open files traverse on remount ro Serge E. Hallyn

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=20080110190658.4BF4421A@kernel \
    --to=haveblue@us.ibm.com \
    --cc=hch@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=miklos@szeredi.hu \
    --cc=serue@us.ibm.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).