rpms/kernel/F-7 linux-2.6-nfs-nosharecache.patch, NONE, 1.1 kernel-2.6.spec, 1.3271, 1.3272

Dave Jones (davej) fedora-extras-commits at redhat.com
Wed Jul 11 19:48:10 UTC 2007


Author: davej

Update of /cvs/pkgs/rpms/kernel/F-7
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv3999

Modified Files:
	kernel-2.6.spec 
Added Files:
	linux-2.6-nfs-nosharecache.patch 
Log Message:
* Wed Jul 11 2007 Dave Jones <davej at redhat.com>
- NFS: Add the mount option "nosharecache"


linux-2.6-nfs-nosharecache.patch:

--- NEW FILE linux-2.6-nfs-nosharecache.patch ---
>From davej  Wed Jul 11 14:22:41 2007
Return-Path: <SteveD at redhat.com>
X-Spam-Checker-Version: SpamAssassin 3.2.1 (2007-05-02) on
	gelk.kernelslacker.org
X-Spam-Level: 
X-Spam-Status: No, score=-2.5 required=5.0 tests=AWL,BAYES_00,
	UNPARSEABLE_RELAY autolearn=ham version=3.2.1
Received: from pobox.devel.redhat.com [10.11.255.8]
	by gelk.kernelslacker.org with IMAP (fetchmail-6.3.7)
	for <davej at localhost> (single-drop); Wed, 11 Jul 2007 14:22:41 -0400 (EDT)
Received: from pobox.devel.redhat.com ([unix socket])
	 by pobox.devel.redhat.com (Cyrus v2.2.12-Invoca-RPM-2.2.12-8.1.RHEL4) with LMTPA;
	 Wed, 11 Jul 2007 14:21:13 -0400
X-Sieve: CMU Sieve 2.2
Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254])
	by pobox.devel.redhat.com (8.13.1/8.13.1) with ESMTP id l6BILDWJ008889
	for <davej at pobox.devel.redhat.com>; Wed, 11 Jul 2007 14:21:13 -0400
Received: from lacrosse.corp.redhat.com (lacrosse.corp.redhat.com [172.16.52.154])
	by int-mx1.corp.redhat.com (8.13.1/8.13.1) with ESMTP id l6BILD3S006518
	for <davej at RedHat.com>; Wed, 11 Jul 2007 14:21:13 -0400
Received: from [10.12.32.32] (dickson.boston.devel.redhat.com [10.12.32.32])
	by lacrosse.corp.redhat.com (8.12.11.20060308/8.11.6) with ESMTP id l6BILC2j031702
	for <davej at redhat.com>; Wed, 11 Jul 2007 14:21:13 -0400
Message-ID: <46951F98.9040601 at RedHat.com>
Date: Wed, 11 Jul 2007 14:21:12 -0400
From: Steve Dickson <SteveD at redhat.com>
User-Agent: Thunderbird 1.5.0.12 (X11/20070529)
MIME-Version: 1.0
To: Dave Jone <davej at redhat.com>
Subject: Bug 207670: wrong access rights on NFS mount
Content-Type: multipart/mixed;
 boundary="------------050700040900010008040302"
Status: RO
Content-Length: 10636
Lines: 307

This is a multi-part message in MIME format.
--------------050700040900010008040302
Content-Type: text/plain; charset=ISO-8859-1; format=flawed
Content-Transfer-Encoding: 7bit

If possible, could you include the two patches in:
https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=207670
in both the next fc6 and f7 kernel release?

I was hoping they would make in to -22 but they didn't
and I've asked Trond why without a response...

These patches fix the problem of mount -o ro /mnt/ro and
mount -o rw server:/mnt/rw which cause /mntro to be
writable...

I've adds these to RHEL5 so it would be good to get
these in to FC so we can see how well they work...

tia,

steved

--------------050700040900010008040302
Content-Type: text/x-patch;
 name="linux-2.6.22-nfs-nosharecache-mounts.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="linux-2.6.22-nfs-nosharecache-mounts.patch"

commit 0e1675c09fe57d41c4b8e60182cb924e8736ff41
Author: Trond Myklebust <Trond.Myklebust at netapp.com>
Date:   Wed May 16 16:53:28 2007 -0400

    NFS: Add the mount option "nosharecache"
    
    Prior to David Howell's mount changes in 2.6.18, users who mounted
    different directories which happened to be from the same filesystem on the
    server would get different super blocks, and hence could choose different
    mount options. As long as there were no hard linked files that crossed from
    one subtree to another, this was quite safe.
    Post the changes, if the two directories are on the same filesystem (have
    the same 'fsid'), they will share the same super block, and hence the same
    mount options.
    
    Add a flag to allow users to elect not to share the NFS super block with
    another mount point, even if the fsids are the same. This will allow
    users to set different mount options for the two different super blocks, as
    was previously possible. It is still up to the user to ensure that there
    are no cache coherency issues when doing this, however the default
    behaviour will be to share super blocks whenever two paths result in
    the same fsid.
    
    Signed-off-by: Trond Myklebust <Trond.Myklebust at netapp.com>

diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index ca20d3c..c03120a 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -291,6 +291,7 @@ static void nfs_show_mount_options(struct seq_file *m, struct nfs_server *nfss,
 		{ NFS_MOUNT_NONLM, ",nolock", "" },
 		{ NFS_MOUNT_NOACL, ",noacl", "" },
 		{ NFS_MOUNT_NORDIRPLUS, ",nordirplus", "" },
+		{ NFS_MOUNT_UNSHARED, ",nosharecache", ""},
 		{ 0, NULL, NULL }
 	};
 	const struct proc_nfs_info *nfs_infop;
@@ -602,6 +603,9 @@ static int nfs_compare_super(struct super_block *sb, void *data)
 
 	if (old->nfs_client != server->nfs_client)
 		return 0;
+	/* Note: NFS_MOUNT_UNSHARED == NFS4_MOUNT_UNSHARED */
+	if (old->flags & NFS_MOUNT_UNSHARED)
+		return 0;
 	if (memcmp(&old->fsid, &server->fsid, sizeof(old->fsid)) != 0)
 		return 0;
 	return 1;
@@ -615,6 +619,7 @@ static int nfs_get_sb(struct file_system_type *fs_type,
 	struct nfs_fh mntfh;
 	struct nfs_mount_data *data = raw_data;
 	struct dentry *mntroot;
+	int (*compare_super)(struct super_block *,void *) = nfs_compare_super;
 	int error;
 
 	/* Validate the mount data */
@@ -629,8 +634,11 @@ static int nfs_get_sb(struct file_system_type *fs_type,
 		goto out_err_noserver;
 	}
 
+	if (server->flags & NFS_MOUNT_UNSHARED)
+		compare_super = NULL;
+
 	/* Get a superblock - note that we may end up sharing one that already exists */
-	s = sget(fs_type, nfs_compare_super, nfs_set_super, server);
+	s = sget(fs_type, compare_super, nfs_set_super, server);
 	if (IS_ERR(s)) {
 		error = PTR_ERR(s);
 		goto out_err_nosb;
@@ -691,6 +699,7 @@ static int nfs_xdev_get_sb(struct file_system_type *fs_type, int flags,
 	struct super_block *s;
 	struct nfs_server *server;
 	struct dentry *mntroot;
+	int (*compare_super)(struct super_block *,void *) = nfs_compare_super;
 	int error;
 
 	dprintk("--> nfs_xdev_get_sb()\n");
@@ -702,8 +711,11 @@ static int nfs_xdev_get_sb(struct file_system_type *fs_type, int flags,
 		goto out_err_noserver;
 	}
 
+	if (server->flags & NFS_MOUNT_UNSHARED)
+		compare_super = NULL;
+
 	/* Get a superblock - note that we may end up sharing one that already exists */
-	s = sget(&nfs_fs_type, nfs_compare_super, nfs_set_super, server);
+	s = sget(&nfs_fs_type, compare_super, nfs_set_super, server);
 	if (IS_ERR(s)) {
 		error = PTR_ERR(s);
 		goto out_err_nosb;
@@ -808,6 +820,7 @@ static int nfs4_get_sb(struct file_system_type *fs_type,
 	struct dentry *mntroot;
 	char *mntpath = NULL, *hostname = NULL, ip_addr[16];
 	void *p;
+	int (*compare_super)(struct super_block *,void *) = nfs_compare_super;
 	int error;
 
 	if (data == NULL) {
@@ -879,8 +892,11 @@ static int nfs4_get_sb(struct file_system_type *fs_type,
 		goto out_err_noserver;
 	}
 
+	if (server->flags & NFS4_MOUNT_UNSHARED)
+		compare_super = NULL;
+
 	/* Get a superblock - note that we may end up sharing one that already exists */
-	s = sget(fs_type, nfs_compare_super, nfs_set_super, server);
+	s = sget(fs_type, compare_super, nfs_set_super, server);
 	if (IS_ERR(s)) {
 		error = PTR_ERR(s);
 		goto out_free;
@@ -949,6 +965,7 @@ static int nfs4_xdev_get_sb(struct file_system_type *fs_type, int flags,
 	struct super_block *s;
 	struct nfs_server *server;
 	struct dentry *mntroot;
+	int (*compare_super)(struct super_block *,void *) = nfs_compare_super;
 	int error;
 
 	dprintk("--> nfs4_xdev_get_sb()\n");
@@ -960,8 +977,11 @@ static int nfs4_xdev_get_sb(struct file_system_type *fs_type, int flags,
 		goto out_err_noserver;
 	}
 
+	if (server->flags & NFS4_MOUNT_UNSHARED)
+		compare_super = NULL;
+
 	/* Get a superblock - note that we may end up sharing one that already exists */
-	s = sget(&nfs_fs_type, nfs_compare_super, nfs_set_super, server);
+	s = sget(&nfs_fs_type, compare_super, nfs_set_super, server);
 	if (IS_ERR(s)) {
 		error = PTR_ERR(s);
 		goto out_err_nosb;
@@ -1016,6 +1036,7 @@ static int nfs4_referral_get_sb(struct file_system_type *fs_type, int flags,
 	struct nfs_server *server;
 	struct dentry *mntroot;
 	struct nfs_fh mntfh;
+	int (*compare_super)(struct super_block *,void *) = nfs_compare_super;
 	int error;
 
 	dprintk("--> nfs4_referral_get_sb()\n");
@@ -1027,8 +1048,11 @@ static int nfs4_referral_get_sb(struct file_system_type *fs_type, int flags,
 		goto out_err_noserver;
 	}
 
+	if (server->flags & NFS4_MOUNT_UNSHARED)
+		compare_super = NULL;
+
 	/* Get a superblock - note that we may end up sharing one that already exists */
-	s = sget(&nfs_fs_type, nfs_compare_super, nfs_set_super, server);
+	s = sget(&nfs_fs_type, compare_super, nfs_set_super, server);
 	if (IS_ERR(s)) {
 		error = PTR_ERR(s);
 		goto out_err_nosb;
diff --git a/include/linux/nfs4_mount.h b/include/linux/nfs4_mount.h
index 26b4c83..ad1bd4a 100644
--- a/include/linux/nfs4_mount.h
+++ b/include/linux/nfs4_mount.h
@@ -65,6 +65,7 @@ struct nfs4_mount_data {
 #define NFS4_MOUNT_NOCTO	0x0010	/* 1 */
 #define NFS4_MOUNT_NOAC		0x0020	/* 1 */
 #define NFS4_MOUNT_STRICTLOCK	0x1000	/* 1 */
+#define NFS4_MOUNT_UNSHARED	0x8000	/* 1 */
 #define NFS4_MOUNT_FLAGMASK	0xFFFF
 
 #endif
diff --git a/include/linux/nfs_mount.h b/include/linux/nfs_mount.h
index cc8b9c5..3e3b521 100644
--- a/include/linux/nfs_mount.h
+++ b/include/linux/nfs_mount.h
@@ -62,6 +62,7 @@ struct nfs_mount_data {
 #define NFS_MOUNT_STRICTLOCK	0x1000	/* reserved for NFSv4 */
 #define NFS_MOUNT_SECFLAVOUR	0x2000	/* 5 */
 #define NFS_MOUNT_NORDIRPLUS	0x4000	/* 5 */
+#define NFS_MOUNT_UNSHARED	0x8000	/* 5 */
 #define NFS_MOUNT_FLAGMASK	0xFFFF
 
 #endif

--------------050700040900010008040302
Content-Type: text/x-patch;
 name="linux-2.6.22-nfs-conflict-mounts.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="linux-2.6.22-nfs-conflict-mounts.patch"

commit 608a2896d6d9079b97715820ae8a5469e70bdecc
Author: Trond Myklebust <Trond.Myklebust at netapp.com>
Date:   Wed May 16 16:53:28 2007 -0400

    NFS: Error when mounting the same filesystem with different options
    
    Unless the user sets the NFS_MOUNT_NOSHAREDCACHE mount flag, we should
    return EBUSY if the filesystem is already mounted on a superblock that
    has set conflicting mount options.
    
    Signed-off-by: Trond Myklebust <Trond.Myklebust at netapp.com>

diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index c03120a..f7f8844 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -601,7 +601,9 @@ static int nfs_compare_super(struct super_block *sb, void *data)
 {
 	struct nfs_server *server = data, *old = NFS_SB(sb);
 
-	if (old->nfs_client != server->nfs_client)
+	if (memcmp(&old->nfs_client->cl_addr,
+				&server->nfs_client->cl_addr,
+				sizeof(old->nfs_client->cl_addr)) != 0)
 		return 0;
 	/* Note: NFS_MOUNT_UNSHARED == NFS4_MOUNT_UNSHARED */
 	if (old->flags & NFS_MOUNT_UNSHARED)
@@ -611,6 +613,39 @@ static int nfs_compare_super(struct super_block *sb, void *data)
 	return 1;
 }
 
+#define NFS_MS_MASK (MS_RDONLY|MS_NOSUID|MS_NODEV|MS_NOEXEC|MS_SYNCHRONOUS)
+
+static int nfs_compare_mount_options(const struct super_block *s, const struct nfs_server *b, int flags)
+{
+	const struct nfs_server *a = s->s_fs_info;
+	const struct rpc_clnt *clnt_a = a->client;
+	const struct rpc_clnt *clnt_b = b->client;
+
+	if ((s->s_flags & NFS_MS_MASK) != (flags & NFS_MS_MASK))
+		goto Ebusy;
+	if (a->nfs_client != b->nfs_client)
+		goto Ebusy;
+	if (a->flags != b->flags)
+		goto Ebusy;
+	if (a->wsize != b->wsize)
+		goto Ebusy;
+	if (a->rsize != b->rsize)
+		goto Ebusy;
+	if (a->acregmin != b->acregmin)
+		goto Ebusy;
+	if (a->acregmax != b->acregmax)
+		goto Ebusy;
+	if (a->acdirmin != b->acdirmin)
+		goto Ebusy;
+	if (a->acdirmax != b->acdirmax)
+		goto Ebusy;
+	if (clnt_a->cl_auth->au_flavor != clnt_b->cl_auth->au_flavor)
+		goto Ebusy;
+	return 0;
+Ebusy:
+	return -EBUSY;
+}
+
 static int nfs_get_sb(struct file_system_type *fs_type,
 	int flags, const char *dev_name, void *raw_data, struct vfsmount *mnt)
 {
@@ -645,8 +680,11 @@ static int nfs_get_sb(struct file_system_type *fs_type,
 	}
 
 	if (s->s_fs_info != server) {
+		error = nfs_compare_mount_options(s, server, flags);
 		nfs_free_server(server);
 		server = NULL;
+		if (error < 0)
+			goto error_splat_super;
 	}
 
 	if (!s->s_root) {
@@ -903,8 +941,11 @@ static int nfs4_get_sb(struct file_system_type *fs_type,
 	}
 
 	if (s->s_fs_info != server) {
+		error = nfs_compare_mount_options(s, server, flags);
 		nfs_free_server(server);
 		server = NULL;
+		if (error < 0)
+			goto error_splat_super;
 	}
 
 	if (!s->s_root) {

--------------050700040900010008040302--



Index: kernel-2.6.spec
===================================================================
RCS file: /cvs/pkgs/rpms/kernel/F-7/kernel-2.6.spec,v
retrieving revision 1.3271
retrieving revision 1.3272
diff -u -r1.3271 -r1.3272
--- kernel-2.6.spec	11 Jul 2007 19:41:16 -0000	1.3271
+++ kernel-2.6.spec	11 Jul 2007 19:47:36 -0000	1.3272
@@ -568,6 +568,7 @@
 Patch1000: linux-2.6-dmi-based-module-autoloading.patch
 Patch1010: linux-2.6-ondemand-timer.patch
 Patch1020: linux-2.6-usb-autosuspend-default-disable.patch
+Patch1030: linux-2.6-nfs-nosharecache.patch
 
 %endif
 
@@ -1182,6 +1183,9 @@
 # DMI based module autoloading.
 ApplyPatch linux-2.6-dmi-based-module-autoloading.patch
 
+# NFS: Add the mount option "nosharecache"
+ApplyPatch linux-2.6-nfs-nosharecache.patch
+
 # END OF PATCH APPLICATIONS
 
 # Any further pre-build tree manipulations happen here.
@@ -2097,6 +2101,9 @@
 
 %changelog
 * Wed Jul 11 2007 Dave Jones <davej at redhat.com>
+- NFS: Add the mount option "nosharecache"
+
+* Wed Jul 11 2007 Dave Jones <davej at redhat.com>
 - Revert mkinitrd requires: bump to what's in FC7.
 
 * Wed Jul 11 2007 Dave Jones <davej at redhat.com>




More information about the scm-commits mailing list