public inbox for linux-nfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] Two more statd patches
@ 2009-12-08 18:08 Chuck Lever
       [not found] ` <20091208180547.3982.31814.stgit-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
  0 siblings, 1 reply; 4+ messages in thread
From: Chuck Lever @ 2009-12-08 18:08 UTC (permalink / raw)
  To: steved; +Cc: linux-nfs, Chris.Mason

Hi Steve-

Here are two patches from my statd IPv6 series.  These are simple
changes that update the sm-notify command.  They shouldn't cause
any behavioral changes.

---

Chuck Lever (2):
      statd: replace smn_{get,set}_port() with the shared equivalents
      statd: squelch compiler warning in sm-notify.c


 utils/statd/sm-notify.c |   50 +++++++++++++----------------------------------
 1 files changed, 14 insertions(+), 36 deletions(-)

-- 
Chuck Lever <chuck.lever@oracle.com>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] statd: squelch compiler warning in sm-notify.c
       [not found] ` <20091208180547.3982.31814.stgit-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
@ 2009-12-08 18:08   ` Chuck Lever
  2009-12-08 18:09   ` [PATCH 2/2] statd: replace smn_{get, set}_port() with the shared equivalents Chuck Lever
  2009-12-12 15:35   ` [PATCH 0/2] Two more statd patches Steve Dickson
  2 siblings, 0 replies; 4+ messages in thread
From: Chuck Lever @ 2009-12-08 18:08 UTC (permalink / raw)
  To: steved; +Cc: linux-nfs, Chris.Mason

Clean up:  Get rid of a false positive compiler warning, seen with
-Wextra.

sm-notify.c: In function =E2=80=98record_pid=E2=80=99:
sm-notify.c:690: warning: comparison between signed and unsigned intege=
r
expressions

Document some ignored return codes while we're here.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---

 utils/statd/sm-notify.c |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/utils/statd/sm-notify.c b/utils/statd/sm-notify.c
index 1d4403a..15d0a92 100644
--- a/utils/statd/sm-notify.c
+++ b/utils/statd/sm-notify.c
@@ -765,17 +765,21 @@ nsm_get_state(int update)
 static int record_pid(void)
 {
 	char pid[20];
+	ssize_t len;
 	int fd;
=20
-	snprintf(pid, 20, "%d\n", getpid());
+	(void)snprintf(pid, sizeof(pid), "%d\n", (int)getpid());
 	fd =3D open("/var/run/sm-notify.pid", O_CREAT|O_EXCL|O_WRONLY, 0600);
 	if (fd < 0)
 		return 0;
-	if (write(fd, pid, strlen(pid)) !=3D strlen(pid))  {
+
+	len =3D write(fd, pid, strlen(pid));
+	if ((len < 0) || ((size_t)len !=3D strlen(pid))) {
 		xlog_warn("Writing to pid file failed: errno %d (%m)",
 				errno);
 	}
-	close(fd);
+
+	(void)close(fd);
 	return 1;
 }
=20


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] statd: replace smn_{get, set}_port() with the shared equivalents
       [not found] ` <20091208180547.3982.31814.stgit-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
  2009-12-08 18:08   ` [PATCH 1/2] statd: squelch compiler warning in sm-notify.c Chuck Lever
@ 2009-12-08 18:09   ` Chuck Lever
  2009-12-12 15:35   ` [PATCH 0/2] Two more statd patches Steve Dickson
  2 siblings, 0 replies; 4+ messages in thread
From: Chuck Lever @ 2009-12-08 18:09 UTC (permalink / raw)
  To: steved; +Cc: linux-nfs, Chris.Mason

Use shared sockaddr port management functions instead of duplicating
this functionality in sm-notify.  This is now easy because sm-notify
is linked with libnfs.a, where nfs_{get,set}_port() reside.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---

 utils/statd/sm-notify.c |   40 +++++++---------------------------------
 1 files changed, 7 insertions(+), 33 deletions(-)

diff --git a/utils/statd/sm-notify.c b/utils/statd/sm-notify.c
index 15d0a92..0dba891 100644
--- a/utils/statd/sm-notify.c
+++ b/utils/statd/sm-notify.c
@@ -29,6 +29,7 @@
 #include <grp.h>
 
 #include "xlog.h"
+#include "nfsrpc.h"
 
 #ifndef BASEDIR
 # ifdef NFS_STATEDIR
@@ -90,33 +91,6 @@ static void		set_kernel_nsm_state(int state);
 
 static struct nsm_host *	hosts = NULL;
 
-/*
- * Address handling utilities
- */
-
-static unsigned short smn_get_port(const struct sockaddr *sap)
-{
-	switch (sap->sa_family) {
-	case AF_INET:
-		return ntohs(((struct sockaddr_in *)sap)->sin_port);
-	case AF_INET6:
-		return ntohs(((struct sockaddr_in6 *)sap)->sin6_port);
-	}
-	return 0;
-}
-
-static void smn_set_port(struct sockaddr *sap, const unsigned short port)
-{
-	switch (sap->sa_family) {
-	case AF_INET:
-		((struct sockaddr_in *)sap)->sin_port = htons(port);
-		break;
-	case AF_INET6:
-		((struct sockaddr_in6 *)sap)->sin6_port = htons(port);
-		break;
-	}
-}
-
 static struct addrinfo *smn_lookup(const char *name)
 {
 	struct addrinfo	*ai, hint = {
@@ -321,7 +295,7 @@ notify(void)
 	/* Use source port if provided on the command line,
 	 * otherwise use bindresvport */
 	if (opt_srcport) {
-		smn_set_port(local_addr, opt_srcport);
+		nfs_set_port(local_addr, opt_srcport);
 		if (bind(sock, local_addr, sizeof(struct sockaddr_in)) < 0) {
 			xlog(L_ERROR, "Failed to bind RPC socket: %m");
 			exit(1);
@@ -455,16 +429,16 @@ notify_host(int sock, struct nsm_host *host)
 						first->ai_addrlen);
 		}
 
-		smn_set_port((struct sockaddr *)&host->addr, 0);
+		nfs_set_port((struct sockaddr *)&host->addr, 0);
 		host->retries = 0;
 	}
 
 	memcpy(dest, &host->addr, destlen);
-	if (smn_get_port(dest) == 0) {
+	if (nfs_get_port(dest) == 0) {
 		/* Build a PMAP packet */
 		xlog(D_GENERAL, "Sending portmap query to %s", host->name);
 
-		smn_set_port(dest, 111);
+		nfs_set_port(dest, 111);
 		*p++ = htonl(100000);
 		*p++ = htonl(2);
 		*p++ = htonl(3);
@@ -540,7 +514,7 @@ recv_reply(int sock)
 		return;
 	sap = (struct sockaddr *)&hp->addr;
 
-	if (smn_get_port(sap) == 0) {
+	if (nfs_get_port(sap) == 0) {
 		/* This was a portmap request */
 		unsigned int	port;
 
@@ -556,7 +530,7 @@ recv_reply(int sock)
 			hp->timeout = NSM_MAX_TIMEOUT;
 			hp->send_next += NSM_MAX_TIMEOUT;
 		} else {
-			smn_set_port(sap, port);
+			nfs_set_port(sap, port);
 			if (hp->timeout >= NSM_MAX_TIMEOUT / 4)
 				hp->timeout = NSM_MAX_TIMEOUT / 4;
 		}


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 0/2] Two more statd patches
       [not found] ` <20091208180547.3982.31814.stgit-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
  2009-12-08 18:08   ` [PATCH 1/2] statd: squelch compiler warning in sm-notify.c Chuck Lever
  2009-12-08 18:09   ` [PATCH 2/2] statd: replace smn_{get, set}_port() with the shared equivalents Chuck Lever
@ 2009-12-12 15:35   ` Steve Dickson
  2 siblings, 0 replies; 4+ messages in thread
From: Steve Dickson @ 2009-12-12 15:35 UTC (permalink / raw)
  To: Chuck Lever; +Cc: linux-nfs, Chris.Mason



On 12/08/2009 01:08 PM, Chuck Lever wrote:
> Hi Steve-
> 
> Here are two patches from my statd IPv6 series.  These are simple
> changes that update the sm-notify command.  They shouldn't cause
> any behavioral changes.
They didn't..... Committed...

steved.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-12-13  1:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-12-08 18:08 [PATCH 0/2] Two more statd patches Chuck Lever
     [not found] ` <20091208180547.3982.31814.stgit-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2009-12-08 18:08   ` [PATCH 1/2] statd: squelch compiler warning in sm-notify.c Chuck Lever
2009-12-08 18:09   ` [PATCH 2/2] statd: replace smn_{get, set}_port() with the shared equivalents Chuck Lever
2009-12-12 15:35   ` [PATCH 0/2] Two more statd patches Steve Dickson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox