From: NeilBrown <neilb@suse.de>
Date: Mon, 8 Jul 2013 09:56:04 +1000
Subject: [PATCH] NFS: support "nosharetransport" option
Patch-mainline: Never, upstream doesn't want this.
References: bnc#807502, bnc#828192, FATE#315593
This patch adds a "nosharetransport" option to allow two different
mounts from the same server to use different transports.
This only works for NFSv3 (and v2), not NFSv4.
As an alternate to "-o nosharetransport" you can set the module parameter
nfs.always_nosharetransport=1
To impose the option on all mounts.
There are at least two circumstances where it might be desirable
to use separate transports:
1/ If the NFS server can get into a state where it will ignore
requests for one filesystem while servicing request for another,
then using separate connections for the separate filesystems can
stop problems with one affecting access to the other.
This is particularly relevant for NetApp filers where one filesystem
has been "suspended". Requests to that filesystem will be dropped
(rather than the more correct NFS3ERR_JUKEBOX). This currently
interferes with other filesystems.
Upstream thinks NetApp should fix their end.
2/ If a very fast network is used with a many-processor client, a
single TCP connection can present a bottle neck which reduces total
throughput. Using multiple TCP connections (one per mount) removes
the bottleneck.
An alternate workaround is to configure multiple virtual IP
addresses on the server and mount each filesystem from a different
IP. This is effective (throughput goes up) but an unnecessary
administrative burden.
Upstream wants to know exactly where the bottle neck is.
Signed-off-by: NeilBrown <neilb@suse.de>
Acked-by: NeilBrown <neilb@suse.de>
---
fs/nfs/client.c | 7 +++++++
fs/nfs/super.c | 17 +++++++++++++++++
include/linux/nfs_fs_sb.h | 1 +
include/uapi/linux/nfs_mount.h | 1 +
4 files changed, 26 insertions(+)
--- a/fs/nfs/client.c
+++ b/fs/nfs/client.c
@@ -293,9 +293,14 @@ static struct nfs_client *nfs_match_clie
struct nfs_net *nn = net_generic(data->net, nfs_net_id);
int error;
+ if (test_bit(NFS_CS_NO_SHARE, &data->init_flags))
+ return NULL;
+
again:
list_for_each_entry(clp, &nn->nfs_client_list, cl_share_link) {
const struct sockaddr *clap = (struct sockaddr *)&clp->cl_addr;
+ if (test_bit(NFS_CS_NO_SHARE,&clp->cl_flags))
+ continue;
/* Don't match clients that failed to initialise properly */
if (clp->cl_cons_state < 0)
continue;
@@ -676,6 +681,8 @@ static int nfs_init_server(struct nfs_se
if (data->flags & NFS_MOUNT_NORESVPORT)
set_bit(NFS_CS_NORESVPORT, &cl_init.init_flags);
+ if (data->flags & NFS_MOUNT_NOSHARE_XPRT)
+ set_bit(NFS_CS_NO_SHARE, &cl_init.init_flags);
/* Allocate or find a client reference we can use */
clp = nfs_get_client(&cl_init);
if (IS_ERR(clp))
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -99,6 +99,7 @@ enum {
Opt_acl, Opt_noacl,
Opt_rdirplus, Opt_nordirplus,
Opt_sharecache, Opt_nosharecache,
+ Opt_sharetransport, Opt_nosharetransport,
Opt_resvport, Opt_noresvport,
Opt_fscache, Opt_nofscache,
Opt_migration, Opt_nomigration,
@@ -158,6 +159,8 @@ static const match_table_t nfs_mount_opt
{ Opt_nordirplus, "nordirplus" },
{ Opt_sharecache, "sharecache" },
{ Opt_nosharecache, "nosharecache" },
+ { Opt_sharetransport, "sharetransport"},
+ { Opt_nosharetransport, "nosharetransport"},
{ Opt_resvport, "resvport" },
{ Opt_noresvport, "noresvport" },
{ Opt_fscache, "fsc" },
@@ -651,6 +654,7 @@ static void nfs_show_mount_options(struc
{ NFS_MOUNT_NOACL, ",noacl", "" },
{ NFS_MOUNT_NORDIRPLUS, ",nordirplus", "" },
{ NFS_MOUNT_UNSHARED, ",nosharecache", "" },
+ { NFS_MOUNT_NOSHARE_XPRT, ",nosharetransport", ""},
{ NFS_MOUNT_NORESVPORT, ",noresvport", "" },
{ 0, NULL, NULL }
};
@@ -1329,6 +1333,12 @@ static int nfs_parse_mount_options(char
case Opt_nosharecache:
mnt->flags |= NFS_MOUNT_UNSHARED;
break;
+ case Opt_sharetransport:
+ mnt->flags &= ~NFS_MOUNT_NOSHARE_XPRT;
+ break;
+ case Opt_nosharetransport:
+ mnt->flags |= NFS_MOUNT_NOSHARE_XPRT;
+ break;
case Opt_resvport:
mnt->flags &= ~NFS_MOUNT_NORESVPORT;
break;
@@ -2258,6 +2268,9 @@ nfs_compare_remount_data(struct nfs_serv
return 0;
}
+static bool always_nosharetransport = 0;
+module_param(always_nosharetransport, bool, 0644);
+
int
nfs_remount(struct super_block *sb, int *flags, char *raw_data)
{
@@ -2308,6 +2321,8 @@ nfs_remount(struct super_block *sb, int
error = -EINVAL;
if (!nfs_parse_mount_options((char *)options, data))
goto out;
+ if (always_nosharetransport)
+ data->flags |= NFS_MOUNT_NOSHARE_XPRT;
/*
* noac is a special case. It implies -o sync, but that's not
@@ -2684,6 +2699,8 @@ struct dentry *nfs_fs_mount(struct file_
mntroot = ERR_PTR(error);
goto out;
}
+ if (always_nosharetransport)
+ mount_info.parsed->flags |= NFS_MOUNT_NOSHARE_XPRT;
nfs_mod = get_nfs_version(mount_info.parsed->version);
if (IS_ERR(nfs_mod)) {
--- a/include/linux/nfs_fs_sb.h
+++ b/include/linux/nfs_fs_sb.h
@@ -42,6 +42,7 @@ struct nfs_client {
#define NFS_CS_MIGRATION 2 /* - transparent state migr */
#define NFS_CS_INFINITE_SLOTS 3 /* - don't limit TCP slots */
#define NFS_CS_NO_RETRANS_TIMEOUT 4 /* - Disable retransmit timeouts */
+#define NFS_CS_NO_SHARE 5 /* - don't share across mounts */
struct sockaddr_storage cl_addr; /* server identifier */
size_t cl_addrlen;
char * cl_hostname; /* hostname of server */
--- a/include/uapi/linux/nfs_mount.h
+++ b/include/uapi/linux/nfs_mount.h
@@ -73,5 +73,6 @@ struct nfs_mount_data {
#define NFS_MOUNT_LOCAL_FLOCK 0x100000
#define NFS_MOUNT_LOCAL_FCNTL 0x200000
+#define NFS_MOUNT_NOSHARE_XPRT 0x400000
#endif