summaryrefslogtreecommitdiffstats
path: root/xlators/nfs/server/src/nfs.c
diff options
context:
space:
mode:
authorNiels de Vos <ndevos@redhat.com>2013-08-09 14:17:33 +0200
committerAnand Avati <avati@redhat.com>2013-08-28 06:54:44 -0700
commitbbefeffafe9a2a5ba493e4bc0c9c9480d577e881 (patch)
treefa1b0a6bb3dac52a26a773da4d023e37ff2e4608 /xlators/nfs/server/src/nfs.c
parentcd2537541540074a5db452a49f9be220e3d76d32 (diff)
nfs: persistent caching of connected NFS-clients
Introduce /var/lib/glusterfs/nfs/rmtab to contain a list of NFS-clients which have a volume mounted. The volume option 'nfs.mount-rmtab' can be set to an alternative filename. When the file is located on shared storage, multiple gNFS servers can use the same file to present a single NFS-server. This cache is read when a system administrator calls 'showmount -a' and updated when an NFS-client calls MNT or UMNT from the MOUNT protocol. Usage: - create a volume for storing the shared rmtab file - mount the volume on all storage servers, at the same location - make sure that the volume is mounted at boot (add to /etc/fstab) - place the rmtab file on the volume: # gluster volume set <VOLUME> nfs.mount-rmtab <MOUNTPOINT>/<FILENAME> - any subsequent mount requests will add an entry to this file - 'showmount -a' requests will return the NFS-clients using the cluster Note: The NFS-server does currently not support reconfigure(). When a configuration option is set/changed, the NFS-server glusterfs process gets restarted. This causes the active NFS-clients to be forgotten (the entries are saved in the old rmtab, but we do not have a reference to that file any more, so we can't re-add them). Therefor a re-mount done by the NFS-clients is needed before they get listed in the rmtab again. Change-Id: I58f47135d60ad112849d647bea4e1129683dd2b3 BUG: 904065 Signed-off-by: Niels de Vos <ndevos@redhat.com> Reviewed-on: http://review.gluster.org/4430 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Harshavardhana <harsha@harshavardhana.net> Tested-by: Harshavardhana <harsha@harshavardhana.net> Reviewed-by: Rajesh Joseph <rjoseph@redhat.com>
Diffstat (limited to 'xlators/nfs/server/src/nfs.c')
-rw-r--r--xlators/nfs/server/src/nfs.c65
1 files changed, 65 insertions, 0 deletions
diff --git a/xlators/nfs/server/src/nfs.c b/xlators/nfs/server/src/nfs.c
index 49512438e..831e82a8c 100644
--- a/xlators/nfs/server/src/nfs.c
+++ b/xlators/nfs/server/src/nfs.c
@@ -51,6 +51,10 @@
#define OPT_SERVER_AUX_GIDS "nfs.server-aux-gids"
#define OPT_SERVER_GID_CACHE_TIMEOUT "nfs.server.aux-gid-timeout"
+/* TODO: DATADIR should be based on configure's $(localstatedir) */
+#define DATADIR "/var/lib/glusterd"
+#define NFS_DATADIR DATADIR "/nfs"
+
/* Every NFS version must call this function with the init function
* for its particular version.
*/
@@ -696,6 +700,15 @@ nfs_init_state (xlator_t *this)
nfs->mount_udp = 1;
}
+ nfs->rmtab = NFS_DATADIR "/rmtab";
+ if (dict_get(this->options, "nfs.mount-rmtab")) {
+ ret = dict_get_str (this->options, "nfs.mount-rmtab", &nfs->rmtab);
+ if (ret == -1) {
+ gf_log (GF_NFS, GF_LOG_ERROR, "Failed to parse dict");
+ goto free_foppool;
+ }
+ }
+
/* support both options rpc-auth.ports.insecure and
* rpc-auth-allow-insecure for backward compatibility
*/
@@ -816,6 +829,49 @@ nfs_drc_init (xlator_t *this)
return ret;
}
+
+#if 0
+/* reconfigure() is currently not used for the NFS-server. Upon setting an
+ * option for the NFS-xlator, the glusterfs process it restarted.
+ *
+ * This current implementation makes sure to read the currently used rmtab and
+ * merge it with the new rmtab.
+ *
+ * As this function is never called, it is provided for the future, for when
+ * the NFS-server supports reloading.
+ */
+int
+reconfigure (xlator_t *this, dict_t *options)
+{
+ int ret = 0;
+ char *rmtab = NULL;
+ struct nfs_state *nfs = NULL;
+
+ nfs = (struct nfs_state *)this->private;
+
+ if (!nfs) {
+ gf_log_callingfn (this->name, GF_LOG_DEBUG, "conf == null!!!");
+ goto out;
+ }
+
+ ret = dict_get_str (options, "nfs.mount-rmtab", &rmtab);
+ if (ret) {
+ goto out;
+ }
+ gf_path_strip_trailing_slashes (rmtab);
+
+ if (strcmp (nfs->rmtab, rmtab) != 0) {
+ mount_rewrite_rmtab (nfs->mstate, rmtab);
+
+ gf_log (this->name, GF_LOG_INFO,
+ "Reconfigured nfs.mount-rmtab path: %s", nfs->rmtab);
+ }
+
+out:
+ return ret;
+}
+#endif /* glusterfs/nfs is restarted and reconfigure() is never called */
+
int
init (xlator_t *this) {
@@ -1337,6 +1393,15 @@ struct volume_options options[] = {
"The need for enabling this option often depends "
"on the usage of NLM."
},
+ { .key = {"nfs.mount-rmtab"},
+ .type = GF_OPTION_TYPE_PATH,
+ .default_value = DATADIR "/rmtab",
+ .description = "Set the location of the cache file that is used to "
+ "list all the NFS-clients that have connected "
+ "through the MOUNT protocol. If this is on shared "
+ "storage, all GlusterFS servers will update and "
+ "output (with 'showmount') the same list."
+ },
{ .key = {OPT_SERVER_AUX_GIDS},
.type = GF_OPTION_TYPE_BOOL,
.default_value = "off",