diff mbox

[1/4] nfsd: add -r and --rdma options to request rdma service.

Message ID 20140220063648.6548.10041.stgit@notabene.brown (mailing list archive)
State New, archived
Headers show

Commit Message

NeilBrown Feb. 20, 2014, 6:36 a.m. UTC
As nfsd establishes UDP and TCP ports, it should establish RDMA too.

Signed-off-by: NeilBrown <neilb@suse.de>
---
 utils/nfsd/nfsd.c   |   22 +++++++++++++++++++---
 utils/nfsd/nfsd.man |    9 +++++++++
 utils/nfsd/nfssvc.c |   34 ++++++++++++++++++++++++++++++++++
 utils/nfsd/nfssvc.h |    1 +
 4 files changed, 63 insertions(+), 3 deletions(-)



--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Steve Dickson March 8, 2014, 3:20 p.m. UTC | #1
Hey Neil,

This part did not apply cleanly 

On 02/20/2014 01:36 AM, Neil Brown wrote:
> void
>  nfssvc_setvers(unsigned int ctlbits, int minorvers[])
>  {
> diff --git a/utils/nfsd/nfssvc.h b/utils/nfsd/nfssvc.h
> index 2bbd3d30f92a..bb7fccee7c19 100644
> --- a/utils/nfsd/nfssvc.h
> +++ b/utils/nfsd/nfssvc.h
> @@ -24,5 +24,6 @@ void	nfssvc_mount_nfsdfs(char *progname);
>  int	nfssvc_inuse(void);
>  int	nfssvc_set_sockets(const int family, const unsigned int protobits,
>  			   const char *host, const char *port);
> +int	nfssvc_set_rdmaport(const char *port);
>  void	nfssvc_setvers(unsigned int ctlbits, int minorvers4[]);
^^^ this interface is different that the one I have in my tree

The one I have is 
void    nfssvc_setvers(unsigned int ctlbits, unsigned int minorvers4, unsigned int minorvers4set);

No biggie but I'm just wandering if I'm missing a patch... 

steved.
>  int	nfssvc_threads(unsigned short port, int nrservs);
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
NeilBrown March 10, 2014, 12:10 a.m. UTC | #2
On Sat, 08 Mar 2014 10:20:16 -0500 Steve Dickson <SteveD@redhat.com> wrote:

> Hey Neil,
> 
> This part did not apply cleanly 
> 
> On 02/20/2014 01:36 AM, Neil Brown wrote:
> > void
> >  nfssvc_setvers(unsigned int ctlbits, int minorvers[])
> >  {
> > diff --git a/utils/nfsd/nfssvc.h b/utils/nfsd/nfssvc.h
> > index 2bbd3d30f92a..bb7fccee7c19 100644
> > --- a/utils/nfsd/nfssvc.h
> > +++ b/utils/nfsd/nfssvc.h
> > @@ -24,5 +24,6 @@ void	nfssvc_mount_nfsdfs(char *progname);
> >  int	nfssvc_inuse(void);
> >  int	nfssvc_set_sockets(const int family, const unsigned int protobits,
> >  			   const char *host, const char *port);
> > +int	nfssvc_set_rdmaport(const char *port);
> >  void	nfssvc_setvers(unsigned int ctlbits, int minorvers4[]);
> ^^^ this interface is different that the one I have in my tree
> 
> The one I have is 
> void    nfssvc_setvers(unsigned int ctlbits, unsigned int minorvers4, unsigned int minorvers4set);

The patch which changed that interface to the new one predates my patch by 7
days, so maybe I didn't pull before I did the development.
(I was doing that in my systemd-devel branch which I hadn't rebased recently).

Thanks,
NeilBrown


> 
> No biggie but I'm just wandering if I'm missing a patch... 
> 
> steved.
> >  int	nfssvc_threads(unsigned short port, int nrservs);
diff mbox

Patch

diff --git a/utils/nfsd/nfsd.c b/utils/nfsd/nfsd.c
index a9d77ab5c586..d67d1c3ee050 100644
--- a/utils/nfsd/nfsd.c
+++ b/utils/nfsd/nfsd.c
@@ -45,6 +45,7 @@  static struct option longopts[] =
 	{ "port", 1, 0, 'p' },
 	{ "debug", 0, 0, 'd' },
 	{ "syslog", 0, 0, 's' },
+	{ "rdma", 2, 0, 'R' },
 	{ NULL, 0, 0, 0 }
 };
 
@@ -96,7 +97,7 @@  int
 main(int argc, char **argv)
 {
 	int	count = NFSD_NPROC, c, error = 0, portnum = 0, fd, found_one;
-	char *p, *progname, *port;
+	char *p, *progname, *port, *rdma_port = NULL;
 	char *haddr = NULL;
 	int	socket_up = 0;
 	int minorvers[NFS4_MAXMINOR + 1] = {0};
@@ -120,7 +121,7 @@  main(int argc, char **argv)
 	xlog_syslog(0);
 	xlog_stderr(1);
 
-	while ((c = getopt_long(argc, argv, "dH:hN:V:p:P:sTU", longopts, NULL)) != EOF) {
+	while ((c = getopt_long(argc, argv, "dH:hN:V:p:P:sTUr", longopts, NULL)) != EOF) {
 		switch(c) {
 		case 'd':
 			xlog_config(D_ALL, 1);
@@ -155,6 +156,16 @@  main(int argc, char **argv)
 				exit(1);
 			}
 			break;
+		case 'r':
+			rdma_port = "nfsrdma";
+			break;
+		case 'R': /* --rdma */
+			if (optarg)
+				rdma_port = optarg;
+			else
+				rdma_port = "nfsrdma";
+			break;
+
 		case 'N':
 			switch((c = strtol(optarg, &p, 0))) {
 			case 4:
@@ -294,6 +305,11 @@  main(int argc, char **argv)
 		socket_up = 1;
 #endif /* IPV6_SUPPORTED */
 
+	if (rdma_port) {
+		error = nfssvc_set_rdmaport(rdma_port);
+		if (!error)
+			socket_up = 1;
+	}
 set_threads:
 	/* don't start any threads if unable to hand off any sockets */
 	if (!socket_up) {
@@ -334,7 +350,7 @@  static void
 usage(const char *prog)
 {
 	fprintf(stderr, "Usage:\n"
-		"%s [-d|--debug] [-H hostname] [-p|-P|--port port] [-N|--no-nfs-version version] [-V|--nfs-version version] [-s|--syslog] [-T|--no-tcp] [-U|--no-udp] nrservs\n", 
+		"%s [-d|--debug] [-H hostname] [-p|-P|--port port] [-N|--no-nfs-version version] [-V|--nfs-version version] [-s|--syslog] [-T|--no-tcp] [-U|--no-udp] [-r|--rdma=] nrservs\n", 
 		prog);
 	exit(2);
 }
diff --git a/utils/nfsd/nfsd.man b/utils/nfsd/nfsd.man
index 7de0867e39e8..aedf1409dc53 100644
--- a/utils/nfsd/nfsd.man
+++ b/utils/nfsd/nfsd.man
@@ -42,6 +42,15 @@  specify a different port to listen on for NFS requests. By default,
 .B rpc.nfsd
 will listen on port 2049.
 .TP
+.B \-r " or " \-\-rdma
+specify that NFS requests on the standard RDMA port ("nfsrdma", port
+20049) should be honored.
+.TP
+.BI \-\-rdma= port
+Listen for RDMA requests on an alternate port - may be a number or a
+name listed in
+.BR /etc/services .
+.TP
 .B \-N " or " \-\-no-nfs-version vers
 This option can be used to request that 
 .B rpc.nfsd
diff --git a/utils/nfsd/nfssvc.c b/utils/nfsd/nfssvc.c
index 1b50abaf9ca8..7eaeef3fb476 100644
--- a/utils/nfsd/nfssvc.c
+++ b/utils/nfsd/nfssvc.c
@@ -268,6 +268,40 @@  nfssvc_set_sockets(const int family, const unsigned int protobits,
 	return nfssvc_setfds(&hints, host, port);
 }
 
+int
+nfssvc_set_rdmaport(const char *port)
+{
+	struct servent *sv = getservbyname(port, "tcp");
+	int nport;
+	char buf[20];
+	int ret;
+	int fd;
+
+	if (sv)
+		nport = sv->s_port;
+	else {
+		char *ep;
+		nport = strtol(port, &ep, 10);
+		if (!*port || *ep) {
+			xlog(L_ERROR, "unable to interpret port name %s",
+			     port);
+			return 1;
+		}
+	}
+
+	fd = open(NFSD_PORTS_FILE, O_WRONLY);
+	if (fd < 0)
+		return 1;
+	snprintf(buf, sizeof(buf), "rdma %d", nport);
+	ret = 0;
+	if (write(fd, buf, strlen(buf)) != (ssize_t)strlen(buf)) {
+		ret= errno;
+		xlog(L_ERROR, "Unable to request RDMA services: %m");
+	}
+	close(fd);
+	return ret;
+}
+
 void
 nfssvc_setvers(unsigned int ctlbits, int minorvers[])
 {
diff --git a/utils/nfsd/nfssvc.h b/utils/nfsd/nfssvc.h
index 2bbd3d30f92a..bb7fccee7c19 100644
--- a/utils/nfsd/nfssvc.h
+++ b/utils/nfsd/nfssvc.h
@@ -24,5 +24,6 @@  void	nfssvc_mount_nfsdfs(char *progname);
 int	nfssvc_inuse(void);
 int	nfssvc_set_sockets(const int family, const unsigned int protobits,
 			   const char *host, const char *port);
+int	nfssvc_set_rdmaport(const char *port);
 void	nfssvc_setvers(unsigned int ctlbits, int minorvers4[]);
 int	nfssvc_threads(unsigned short port, int nrservs);