a24ef7b
commit e916e9e47a6a932872641d0da1f7bd4927b63fee
a24ef7b
Author: Steve Dickson <steved@redhat.com>
a24ef7b
Date:   Mon Aug 13 11:04:02 2007 -0400
a24ef7b
a24ef7b
    Adds support for the 'nosharecache' mount option to nfs-utils.
a24ef7b
    
a24ef7b
    Signed-off-by: Steve Dickson <steved@redhat.com>
a24ef7b
a24ef7b
diff --git a/utils/mount/nfs.man b/utils/mount/nfs.man
a24ef7b
index 673556c..e66daba 100644
a24ef7b
--- a/utils/mount/nfs.man
a24ef7b
+++ b/utils/mount/nfs.man
a24ef7b
@@ -288,6 +288,23 @@ Mount the NFS filesystem using the UDP protocol.
a24ef7b
 Disables NFSv3 READDIRPLUS RPCs. Use this option when
a24ef7b
 mounting servers that don't support or have broken
a24ef7b
 READDIRPLUS implementations.
a24ef7b
+.TP 1.5i
a24ef7b
+.I nosharecache
a24ef7b
+As of kernel 2.6.18, it is no longer possible to mount the same
a24ef7b
+same filesystem with different mount options to a new mountpoint.
a24ef7b
+It was deemed unsafe to do so, since cached data cannot be shared
a24ef7b
+between the two mountpoints. In consequence, files or directories
a24ef7b
+that were common to both mountpoint subtrees could often be seen to
a24ef7b
+be out of sync following an update.
a24ef7b
+.br
a24ef7b
+This option allows administrators to select the pre-2.6.18 behaviour,
a24ef7b
+permitting the same filesystem to be mounted with different mount
a24ef7b
+options.
a24ef7b
+.br
a24ef7b
+.B Beware:
a24ef7b
+Use of this option is not recommended unless you are certain that there
a24ef7b
+are no hard links or subtrees of this mountpoint that are mounted
a24ef7b
+elsewhere.
a24ef7b
 .P
a24ef7b
 All of the non-value options have corresponding nooption forms.
a24ef7b
 For example, nointr means don't allow file operations to be
a24ef7b
@@ -444,6 +461,23 @@ This extracts a
a24ef7b
 server performance penalty but it allows two different NFS clients
a24ef7b
 to get reasonable good results when both clients are actively
a24ef7b
 writing to common filesystem on the server.
a24ef7b
+.TP 1.5i
a24ef7b
+.I nosharecache
a24ef7b
+As of kernel 2.6.18, it is no longer possible to mount the same
a24ef7b
+same filesystem with different mount options to a new mountpoint.
a24ef7b
+It was deemed unsafe to do so, since cached data cannot be shared
a24ef7b
+between the two mountpoints. In consequence, files or directories
a24ef7b
+that were common to both mountpoint subtrees could often be seen to
a24ef7b
+be out of sync following an update.
a24ef7b
+.br
a24ef7b
+This option allows administrators to select the pre-2.6.18 behaviour,
a24ef7b
+permitting the same filesystem to be mounted with different mount
a24ef7b
+options.
a24ef7b
+.br
a24ef7b
+.B Beware:
a24ef7b
+Use of this option is not recommended unless you are certain that there
a24ef7b
+are no hard links or subtrees of this mountpoint that are mounted
a24ef7b
+elsewhere.
a24ef7b
 .P
a24ef7b
 All of the non-value options have corresponding nooption forms.
a24ef7b
 For example, nointr means don't allow file operations to be
a24ef7b
diff --git a/utils/mount/nfs4_mount.h b/utils/mount/nfs4_mount.h
a24ef7b
index 74c9b95..2fcca6d 100644
a24ef7b
--- a/utils/mount/nfs4_mount.h
a24ef7b
+++ b/utils/mount/nfs4_mount.h
a24ef7b
@@ -65,6 +65,7 @@ struct nfs4_mount_data {
a24ef7b
 #define NFS4_MOUNT_NOCTO	0x0010	/* 1 */
a24ef7b
 #define NFS4_MOUNT_NOAC		0x0020	/* 1 */
a24ef7b
 #define NFS4_MOUNT_STRICTLOCK	0x1000	/* 1 */
a24ef7b
+#define NFS4_MOUNT_UNSHARED	0x8000	/* 5 */
a24ef7b
 #define NFS4_MOUNT_FLAGMASK	0xFFFF
a24ef7b
 
a24ef7b
 /* pseudoflavors: */
a24ef7b
diff --git a/utils/mount/nfs4mount.c b/utils/mount/nfs4mount.c
a24ef7b
index 2a58d0a..0376f32 100644
a24ef7b
--- a/utils/mount/nfs4mount.c
a24ef7b
+++ b/utils/mount/nfs4mount.c
a24ef7b
@@ -201,7 +201,7 @@ int nfs4mount(const char *spec, const char *node, int *flags,
a24ef7b
 	char *s;
a24ef7b
 	int val;
a24ef7b
 	int bg, soft, intr;
a24ef7b
-	int nocto, noac;
a24ef7b
+	int nocto, noac, unshared;
a24ef7b
 	int retry;
a24ef7b
 	int retval;
a24ef7b
 	time_t timeout, t;
a24ef7b
@@ -252,6 +252,7 @@ int nfs4mount(const char *spec, const char *node, int *flags,
a24ef7b
 	intr = NFS4_MOUNT_INTR;
a24ef7b
 	nocto = 0;
a24ef7b
 	noac = 0;
a24ef7b
+	unshared = 0;
a24ef7b
 	retry = 10000;		/* 10000 minutes ~ 1 week */
a24ef7b
 
a24ef7b
 	/*
a24ef7b
@@ -336,6 +337,8 @@ int nfs4mount(const char *spec, const char *node, int *flags,
a24ef7b
 				nocto = !val;
a24ef7b
 			else if (!strcmp(opt, "ac"))
a24ef7b
 				noac = !val;
a24ef7b
+			else if (!strcmp(opt, "sharecache"))
a24ef7b
+				unshared = !val;
a24ef7b
 			else if (!sloppy) {
a24ef7b
 				printf(_("unknown nfs mount option: "
a24ef7b
 					 "%s%s\n"), val ? "" : "no", opt);
a24ef7b
@@ -347,7 +350,8 @@ int nfs4mount(const char *spec, const char *node, int *flags,
a24ef7b
 	data.flags = (soft ? NFS4_MOUNT_SOFT : 0)
a24ef7b
 		| (intr ? NFS4_MOUNT_INTR : 0)
a24ef7b
 		| (nocto ? NFS4_MOUNT_NOCTO : 0)
a24ef7b
-		| (noac ? NFS4_MOUNT_NOAC : 0);
a24ef7b
+		| (noac ? NFS4_MOUNT_NOAC : 0)
a24ef7b
+		| (unshared ? NFS4_MOUNT_UNSHARED : 0);
a24ef7b
 
a24ef7b
 	/*
a24ef7b
 	 * Give a warning if the rpc.idmapd daemon is not running
a24ef7b
@@ -388,11 +392,13 @@ int nfs4mount(const char *spec, const char *node, int *flags,
a24ef7b
 	       data.acregmin, data.acregmax, data.acdirmin, data.acdirmax);
a24ef7b
 	printf("port = %d, bg = %d, retry = %d, flags = %.8x\n",
a24ef7b
 	       ntohs(server_addr.sin_port), bg, retry, data.flags);
a24ef7b
-	printf("soft = %d, intr = %d, nocto = %d, noac = %d\n",
a24ef7b
+	printf("soft = %d, intr = %d, nocto = %d, noac = %d, "
a24ef7b
+	       "nosharecache = %d\n",
a24ef7b
 	       (data.flags & NFS4_MOUNT_SOFT) != 0,
a24ef7b
 	       (data.flags & NFS4_MOUNT_INTR) != 0,
a24ef7b
 	       (data.flags & NFS4_MOUNT_NOCTO) != 0,
a24ef7b
-	       (data.flags & NFS4_MOUNT_NOAC) != 0);
a24ef7b
+	       (data.flags & NFS4_MOUNT_NOAC) != 0,
a24ef7b
+	       (data.flags & NFS4_MOUNT_UNSHARED) != 0);
a24ef7b
 
a24ef7b
 	if (num_flavour > 0) {
a24ef7b
 		int pf_cnt, i;
a24ef7b
diff --git a/utils/mount/nfs_mount.h b/utils/mount/nfs_mount.h
a24ef7b
index 4a061d8..50ce2a8 100644
a24ef7b
--- a/utils/mount/nfs_mount.h
a24ef7b
+++ b/utils/mount/nfs_mount.h
a24ef7b
@@ -64,6 +64,7 @@ struct nfs_mount_data {
a24ef7b
 #define NFS_MOUNT_NOACL     0x0800  /* 4 */
a24ef7b
 #define NFS_MOUNT_SECFLAVOUR	0x2000	/* 5 */
a24ef7b
 #define NFS_MOUNT_NORDIRPLUS	0x4000	/* 5 */
a24ef7b
+#define NFS_MOUNT_UNSHARED	0x8000	/* 5 */
a24ef7b
 
a24ef7b
 /* security pseudoflavors */
a24ef7b
 
a24ef7b
diff --git a/utils/mount/nfsmount.c b/utils/mount/nfsmount.c
a24ef7b
index 815064a..f21aaff 100644
a24ef7b
--- a/utils/mount/nfsmount.c
a24ef7b
+++ b/utils/mount/nfsmount.c
a24ef7b
@@ -804,6 +804,10 @@ parse_options(char *old_opts, struct nfs_mount_data *data,
a24ef7b
 				data->flags &= ~NFS_MOUNT_NORDIRPLUS;
a24ef7b
 				if (!val)
a24ef7b
 					data->flags |= NFS_MOUNT_NORDIRPLUS;
a24ef7b
+			} else if (!strcmp(opt, "sharecache")) {
a24ef7b
+				data->flags &= ~NFS_MOUNT_UNSHARED;
a24ef7b
+				if (!val)
a24ef7b
+					data->flags |= NFS_MOUNT_UNSHARED;
a24ef7b
 #endif
a24ef7b
 			} else {
a24ef7b
 			bad_option: