All of lore.kernel.org
 help / color / mirror / Atom feed
From: Neil Brown <neilb@suse.de>
To: Steve Dickson <SteveD@redhat.com>
Cc: linux-nfs@vger.kernel.org
Subject: [PATCH 1/4] nfsd: add -r and --rdma options to request rdma service.
Date: Thu, 20 Feb 2014 17:36:48 +1100	[thread overview]
Message-ID: <20140220063648.6548.10041.stgit@notabene.brown> (raw)
In-Reply-To: <20140220063616.6548.42556.stgit@notabene.brown>

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(-)

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);



  parent reply	other threads:[~2014-02-20  6:38 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-20  6:36 [nfs-utils RPC-PATCH 0/4] Add options to nfsd etc to avoid needing to write to /proc Neil Brown
2014-02-20  6:36 ` [PATCH 2/4] nfsd: alloc nfsv4leasetime and nfsv4gracetime to be set Neil Brown
2014-02-20  6:36 ` [PATCH 4/4] statd: add options to set port number of lockd Neil Brown
2014-02-20  6:36 ` Neil Brown [this message]
2014-03-08 15:20   ` [PATCH 1/4] nfsd: add -r and --rdma options to request rdma service Steve Dickson
2014-03-10  0:10     ` NeilBrown
2014-02-20  6:36 ` [PATCH 3/4] nfsd: set nlm grace time to make NFSv4 grace time Neil Brown
2014-02-20 16:40   ` J. Bruce Fields
2014-02-20 13:11 ` [nfs-utils RPC-PATCH 0/4] Add options to nfsd etc to avoid needing to write to /proc Trond Myklebust
2014-02-20 14:32   ` Chuck Lever
2014-02-25  1:37   ` NeilBrown
2014-02-25  1:44     ` Trond Myklebust
2014-02-25  1:47       ` Trond Myklebust
2014-03-08 16:56 ` Steve Dickson
2014-03-10  0:47   ` NeilBrown
2014-03-10 16:58     ` Steve Dickson
2014-03-12  5:43       ` NeilBrown
2014-03-11 16:05 ` Steve Dickson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140220063648.6548.10041.stgit@notabene.brown \
    --to=neilb@suse.de \
    --cc=SteveD@redhat.com \
    --cc=linux-nfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.