Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-12-SP3:GA
nfs-utils.27825
0202-nfsd-allow-server-scope-to-be-set-with-con...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0202-nfsd-allow-server-scope-to-be-set-with-config-or-com.patch of Package nfs-utils.27825
From 580ac005d11ddb9a9622e380ba8e947ad743a38f Mon Sep 17 00:00:00 2001 From: NeilBrown <neilb@suse.de> Date: Mon, 21 Nov 2022 14:24:00 -0500 Subject: [PATCH] nfsd: allow server scope to be set with config or command line. NFSv4.1 and later require the server to report a "scope". Servers with the same scope are expected to understand each other's state ids etc, though may not accept them - this ensure there can be no misunderstanding. This is helpful for migration. Servers with different scope are known to be different and if a server appears to change scope on a restart, lock recovery must not be attempted. It is important for fail-over configurations to have the same scope for all server instances. Linux NFSD sets scope to host name. It is common for fail-over configurations to use different host names on different server nodes. So the default is not good for these configurations and must be over-ridden. As discussed in https://github.com/ClusterLabs/resource-agents/issues/1644 some HA management tools attempt to address this with calls to "unshare" and "hostname" before running "rpc.nfsd". This is unnecessarily cumbersome. This patch adds a "-S" command-line option and nfsd.scope config value so that the scope can be set easily for nfsd. Signed-off-by: NeilBrown <neilb@suse.de> Signed-off-by: Steve Dickson <steved@redhat.com> --- utils/nfsd/nfsd.c | 16 +++++++++++++++- utils/nfsd/nfsd.man | 10 +++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) --- a/utils/nfsd/nfsd.c +++ b/utils/nfsd/nfsd.c @@ -22,6 +22,7 @@ #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> +#include <sched.h> #include "nfslib.h" #include "nfssvc.h" @@ -36,6 +37,7 @@ static void usage(const char *); static struct option longopts[] = { { "host", 1, 0, 'H' }, + { "scope", 1, 0, 'S'}, { "help", 0, 0, 'h' }, { "no-nfs-version", 1, 0, 'N' }, { "nfs-version", 1, 0, 'V' }, @@ -101,6 +103,7 @@ main(int argc, char **argv) int count = NFSD_NPROC, c, i, error = 0, portnum = 0, fd, found_one; char *p, *progname, *port, *rdma_port = NULL; char **haddr = NULL; + char *scope = NULL; unsigned int hcounter = 0; int socket_up = 0; unsigned int minorvers = 0; @@ -134,7 +137,7 @@ main(int argc, char **argv) xlog_syslog(0); xlog_stderr(1); - while ((c = getopt_long(argc, argv, "dH:hN:V:p:P:sTUrG:L:", longopts, NULL)) != EOF) { + while ((c = getopt_long(argc, argv, "dH:S:hN:V:p:P:sTUrG:L:", longopts, NULL)) != EOF) { switch(c) { case 'd': xlog_config(D_ALL, 1); @@ -156,6 +159,9 @@ main(int argc, char **argv) } hcounter++; break; + case 'S': + scope = optarg; + break; case 'P': /* XXX for nfs-server compatibility */ case 'p': /* only the last -p option has any effect */ @@ -334,6 +340,14 @@ main(int argc, char **argv) if (lease > 0) nfssvc_set_time("lease", lease); + if (scope) { + if (unshare(CLONE_NEWUTS) < 0 || + sethostname(scope, strlen(scope)) < 0) { + xlog(L_ERROR, "Unable to set server scope: %m"); + error = -1; + goto out; + } + } i = 0; do { error = nfssvc_set_sockets(AF_INET, proto4, haddr[i], port); --- a/utils/nfsd/nfsd.man +++ b/utils/nfsd/nfsd.man @@ -35,9 +35,17 @@ Note that .B lockd (which performs file locking services for NFS) may still accept request on all known network addresses. This may change in future -releases of the Linux Kernel. This option can be used multiple time +releases of the Linux Kernel. This option can be used multiple times to listen to more than one interface. .TP +.B \S " or " \-\-scope scope +NFSv4.1 and later require the server to report a "scope" which is used +by the clients to detect if two connections are to the same server. +By default Linux NFSD uses the host name as the scope. +.sp +It is particularly important for high-availablity configurations to ensure +that all potential server nodes report the same server scope. +.TP .B \-p " or " \-\-port port specify a different port to listen on for NFS requests. By default, .B rpc.nfsd
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor