diff options
author | David Howells <dhowells@redhat.com> | 2009-04-03 11:42:48 -0400 |
---|---|---|
committer | David Howells <dhowells@redhat.com> | 2009-04-03 11:42:48 -0400 |
commit | b797cac7487dee6bfddeb161631c1bbc54fa3cdb (patch) | |
tree | daf0770b33d5705d527e34193480f7eeae58a326 /fs | |
parent | 5d1acff159730770cbab68b19443518c92ab1000 (diff) |
NFS: Add mount options to enable local caching on NFS
Add NFS mount options to allow the local caching support to be enabled.
The attached patch makes it possible for the NFS filesystem to be told to make
use of the network filesystem local caching service (FS-Cache).
To be able to use this, a recent nfsutils package is required.
There are three variant NFS mount options that can be added to a mount command
to control caching for a mount. Only the last one specified takes effect:
(*) Adding "fsc" will request caching.
(*) Adding "fsc=<string>" will request caching and also specify a uniquifier.
(*) Adding "nofsc" will disable caching.
For example:
mount warthog:/ /a -o fsc
The cache of a particular superblock (NFS FSID) will be shared between all
mounts of that volume, provided they have the same connection parameters and
are not marked 'nosharecache'.
Where it is otherwise impossible to distinguish superblocks because all the
parameters are identical, but the 'nosharecache' option is supplied, a
uniquifying string must be supplied, else only the first mount will be
permitted to use the cache.
If there's a key collision, then the second mount will disable caching and give
a warning into the kernel log.
Signed-off-by: David Howells <dhowells@redhat.com>
Acked-by: Steve Dickson <steved@redhat.com>
Acked-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Acked-by: Al Viro <viro@zeniv.linux.org.uk>
Tested-by: Daire Byrne <Daire.Byrne@framestore.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/nfs/client.c | 2 | ||||
-rw-r--r-- | fs/nfs/internal.h | 1 | ||||
-rw-r--r-- | fs/nfs/super.c | 25 |
3 files changed, 28 insertions, 0 deletions
diff --git a/fs/nfs/client.c b/fs/nfs/client.c index 726fe5a845b4..75c9cd2aa119 100644 --- a/fs/nfs/client.c +++ b/fs/nfs/client.c | |||
@@ -765,6 +765,7 @@ static int nfs_init_server(struct nfs_server *server, | |||
765 | 765 | ||
766 | /* Initialise the client representation from the mount data */ | 766 | /* Initialise the client representation from the mount data */ |
767 | server->flags = data->flags; | 767 | server->flags = data->flags; |
768 | server->options = data->options; | ||
768 | 769 | ||
769 | if (data->rsize) | 770 | if (data->rsize) |
770 | server->rsize = nfs_block_size(data->rsize, NULL); | 771 | server->rsize = nfs_block_size(data->rsize, NULL); |
@@ -1153,6 +1154,7 @@ static int nfs4_init_server(struct nfs_server *server, | |||
1153 | /* Initialise the client representation from the mount data */ | 1154 | /* Initialise the client representation from the mount data */ |
1154 | server->flags = data->flags; | 1155 | server->flags = data->flags; |
1155 | server->caps |= NFS_CAP_ATOMIC_OPEN; | 1156 | server->caps |= NFS_CAP_ATOMIC_OPEN; |
1157 | server->options = data->options; | ||
1156 | 1158 | ||
1157 | /* Get a client record */ | 1159 | /* Get a client record */ |
1158 | error = nfs4_set_client(server, | 1160 | error = nfs4_set_client(server, |
diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h index 013070000c38..e4d6a8348adf 100644 --- a/fs/nfs/internal.h +++ b/fs/nfs/internal.h | |||
@@ -39,6 +39,7 @@ struct nfs_parsed_mount_data { | |||
39 | int acregmin, acregmax, | 39 | int acregmin, acregmax, |
40 | acdirmin, acdirmax; | 40 | acdirmin, acdirmax; |
41 | int namlen; | 41 | int namlen; |
42 | unsigned int options; | ||
42 | unsigned int bsize; | 43 | unsigned int bsize; |
43 | unsigned int auth_flavor_len; | 44 | unsigned int auth_flavor_len; |
44 | rpc_authflavor_t auth_flavors[1]; | 45 | rpc_authflavor_t auth_flavors[1]; |
diff --git a/fs/nfs/super.c b/fs/nfs/super.c index b5fea776a0dc..82eaadbff408 100644 --- a/fs/nfs/super.c +++ b/fs/nfs/super.c | |||
@@ -77,6 +77,7 @@ enum { | |||
77 | Opt_rdirplus, Opt_nordirplus, | 77 | Opt_rdirplus, Opt_nordirplus, |
78 | Opt_sharecache, Opt_nosharecache, | 78 | Opt_sharecache, Opt_nosharecache, |
79 | Opt_resvport, Opt_noresvport, | 79 | Opt_resvport, Opt_noresvport, |
80 | Opt_fscache, Opt_nofscache, | ||
80 | 81 | ||
81 | /* Mount options that take integer arguments */ | 82 | /* Mount options that take integer arguments */ |
82 | Opt_port, | 83 | Opt_port, |
@@ -94,6 +95,7 @@ enum { | |||
94 | Opt_sec, Opt_proto, Opt_mountproto, Opt_mounthost, | 95 | Opt_sec, Opt_proto, Opt_mountproto, Opt_mounthost, |
95 | Opt_addr, Opt_mountaddr, Opt_clientaddr, | 96 | Opt_addr, Opt_mountaddr, Opt_clientaddr, |
96 | Opt_lookupcache, | 97 | Opt_lookupcache, |
98 | Opt_fscache_uniq, | ||
97 | 99 | ||
98 | /* Special mount options */ | 100 | /* Special mount options */ |
99 | Opt_userspace, Opt_deprecated, Opt_sloppy, | 101 | Opt_userspace, Opt_deprecated, Opt_sloppy, |
@@ -133,6 +135,9 @@ static const match_table_t nfs_mount_option_tokens = { | |||
133 | { Opt_nosharecache, "nosharecache" }, | 135 | { Opt_nosharecache, "nosharecache" }, |
134 | { Opt_resvport, "resvport" }, | 136 | { Opt_resvport, "resvport" }, |
135 | { Opt_noresvport, "noresvport" }, | 137 | { Opt_noresvport, "noresvport" }, |
138 | { Opt_fscache, "fsc" }, | ||
139 | { Opt_fscache_uniq, "fsc=%s" }, | ||
140 | { Opt_nofscache, "nofsc" }, | ||
136 | 141 | ||
137 | { Opt_port, "port=%u" }, | 142 | { Opt_port, "port=%u" }, |
138 | { Opt_rsize, "rsize=%u" }, | 143 | { Opt_rsize, "rsize=%u" }, |
@@ -564,6 +569,8 @@ static void nfs_show_mount_options(struct seq_file *m, struct nfs_server *nfss, | |||
564 | if (clp->rpc_ops->version == 4) | 569 | if (clp->rpc_ops->version == 4) |
565 | seq_printf(m, ",clientaddr=%s", clp->cl_ipaddr); | 570 | seq_printf(m, ",clientaddr=%s", clp->cl_ipaddr); |
566 | #endif | 571 | #endif |
572 | if (nfss->options & NFS_OPTION_FSCACHE) | ||
573 | seq_printf(m, ",fsc"); | ||
567 | } | 574 | } |
568 | 575 | ||
569 | /* | 576 | /* |
@@ -1056,6 +1063,24 @@ static int nfs_parse_mount_options(char *raw, | |||
1056 | case Opt_noresvport: | 1063 | case Opt_noresvport: |
1057 | mnt->flags |= NFS_MOUNT_NORESVPORT; | 1064 | mnt->flags |= NFS_MOUNT_NORESVPORT; |
1058 | break; | 1065 | break; |
1066 | case Opt_fscache: | ||
1067 | mnt->options |= NFS_OPTION_FSCACHE; | ||
1068 | kfree(mnt->fscache_uniq); | ||
1069 | mnt->fscache_uniq = NULL; | ||
1070 | break; | ||
1071 | case Opt_nofscache: | ||
1072 | mnt->options &= ~NFS_OPTION_FSCACHE; | ||
1073 | kfree(mnt->fscache_uniq); | ||
1074 | mnt->fscache_uniq = NULL; | ||
1075 | break; | ||
1076 | case Opt_fscache_uniq: | ||
1077 | string = match_strdup(args); | ||
1078 | if (!string) | ||
1079 | goto out_nomem; | ||
1080 | kfree(mnt->fscache_uniq); | ||
1081 | mnt->fscache_uniq = string; | ||
1082 | mnt->options |= NFS_OPTION_FSCACHE; | ||
1083 | break; | ||
1059 | 1084 | ||
1060 | /* | 1085 | /* |
1061 | * options that take numeric values | 1086 | * options that take numeric values |