svn commit: r360142 - in stable/11/sys/fs: nfs nfsserver

Rick Macklem rmacklem at FreeBSD.org
Tue Apr 21 05:00:37 UTC 2020


Author: rmacklem
Date: Tue Apr 21 05:00:35 2020
New Revision: 360142
URL: https://svnweb.freebsd.org/changeset/base/360142

Log:
  MFC: r359679
  Fix noisy NFSv4 server printf.
  
  Peter reported that his dmesg was getting cluttered with
  nfsrv_cache_session: no session
  messages when he rebooted his NFS server and they did not seem useful.
  He was correct, in that these messages are "normal" and expected when
  NFSv4.1 or NFSv4.2 are mounted and the server is rebooted.
  This patch silences the printf() during the grace period after a reboot.
  It also adds the client IP address to the printf(), so that the message
  is more useful if/when it occurs. If this happens outside of the
  server's grace period, it does indicate something is not working correctly.
  Instead of adding yet another nd_XXX argument, the arguments for
  nfsrv_cache_session() were simplified to take a "struct nfsrv_descript *".

Modified:
  stable/11/sys/fs/nfs/nfs_var.h
  stable/11/sys/fs/nfsserver/nfs_nfsdkrpc.c
  stable/11/sys/fs/nfsserver/nfs_nfsdstate.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/fs/nfs/nfs_var.h
==============================================================================
--- stable/11/sys/fs/nfs/nfs_var.h	Tue Apr 21 04:47:42 2020	(r360141)
+++ stable/11/sys/fs/nfs/nfs_var.h	Tue Apr 21 05:00:35 2020	(r360142)
@@ -136,7 +136,7 @@ void nfsrv_throwawayallstate(NFSPROC_T *);
 int nfsrv_checksequence(struct nfsrv_descript *, uint32_t, uint32_t *,
     uint32_t *, int, uint32_t *, NFSPROC_T *);
 int nfsrv_checkreclaimcomplete(struct nfsrv_descript *, int);
-void nfsrv_cache_session(uint8_t *, uint32_t, int, struct mbuf **);
+void nfsrv_cache_session(struct nfsrv_descript *, struct mbuf **);
 void nfsrv_freeallbackchannel_xprts(void);
 
 /* nfs_nfsdserv.c */

Modified: stable/11/sys/fs/nfsserver/nfs_nfsdkrpc.c
==============================================================================
--- stable/11/sys/fs/nfsserver/nfs_nfsdkrpc.c	Tue Apr 21 04:47:42 2020	(r360141)
+++ stable/11/sys/fs/nfsserver/nfs_nfsdkrpc.c	Tue Apr 21 05:00:35 2020	(r360142)
@@ -387,8 +387,7 @@ nfs_proc(struct nfsrv_descript *nd, u_int32_t xid, SVC
 			} else
 				m = NULL;
 			if ((nd->nd_flag & ND_HASSEQUENCE) != 0)
-				nfsrv_cache_session(nd->nd_sessionid,
-				    nd->nd_slotid, nd->nd_repstat, &m);
+				nfsrv_cache_session(nd, &m);
 			if (nd->nd_repstat == NFSERR_REPLYFROMCACHE)
 				nd->nd_repstat = 0;
 			cacherep = RC_REPLY;

Modified: stable/11/sys/fs/nfsserver/nfs_nfsdstate.c
==============================================================================
--- stable/11/sys/fs/nfsserver/nfs_nfsdstate.c	Tue Apr 21 04:47:42 2020	(r360141)
+++ stable/11/sys/fs/nfsserver/nfs_nfsdstate.c	Tue Apr 21 05:00:35 2020	(r360142)
@@ -6156,22 +6156,56 @@ nfsrv_checkreclaimcomplete(struct nfsrv_descript *nd, 
  * Cache the reply in a session slot.
  */
 void
-nfsrv_cache_session(uint8_t *sessionid, uint32_t slotid, int repstat,
-   struct mbuf **m)
+nfsrv_cache_session(struct nfsrv_descript *nd, struct mbuf **m)
 {
 	struct nfsdsession *sep;
 	struct nfssessionhash *shp;
+	char *buf, *cp;
+#ifdef INET
+	struct sockaddr_in *sin;
+#endif
+#ifdef INET6
+	struct sockaddr_in6 *sin6;
+#endif
 
-	shp = NFSSESSIONHASH(sessionid);
+	shp = NFSSESSIONHASH(nd->nd_sessionid);
 	NFSLOCKSESSION(shp);
-	sep = nfsrv_findsession(sessionid);
+	sep = nfsrv_findsession(nd->nd_sessionid);
 	if (sep == NULL) {
 		NFSUNLOCKSESSION(shp);
-		printf("nfsrv_cache_session: no session\n");
+		if ((nfsrv_stablefirst.nsf_flags & NFSNSF_GRACEOVER) != 0) {
+			buf = malloc(INET6_ADDRSTRLEN, M_TEMP, M_WAITOK);
+			switch (nd->nd_nam->sa_family) {
+#ifdef INET
+			case AF_INET:
+				sin = (struct sockaddr_in *)nd->nd_nam;
+				cp = inet_ntop(sin->sin_family,
+				    &sin->sin_addr.s_addr, buf,
+				    INET6_ADDRSTRLEN);
+				break;
+#endif
+#ifdef INET6
+			case AF_INET6:
+				sin6 = (struct sockaddr_in6 *)nd->nd_nam;
+				cp = inet_ntop(sin6->sin6_family,
+				    &sin6->sin6_addr, buf, INET6_ADDRSTRLEN);
+				break;
+#endif
+			default:
+				cp = NULL;
+			}
+			if (cp != NULL)
+				printf("nfsrv_cache_session: no session "
+				    "IPaddr=%s\n", cp);
+			else
+				printf("nfsrv_cache_session: no session\n");
+			free(buf, M_TEMP);
+		}
 		m_freem(*m);
 		return;
 	}
-	nfsv4_seqsess_cacherep(slotid, sep->sess_slots, repstat, m);
+	nfsv4_seqsess_cacherep(nd->nd_slotid, sep->sess_slots, nd->nd_repstat,
+	    m);
 	NFSUNLOCKSESSION(shp);
 }
 


More information about the svn-src-all mailing list