svn commit: r359679 - in head/sys/fs: nfs nfsserver
Rick Macklem
rmacklem at FreeBSD.org
Mon Apr 6 23:21:40 UTC 2020
Author: rmacklem
Date: Mon Apr 6 23:21:39 2020
New Revision: 359679
URL: https://svnweb.freebsd.org/changeset/base/359679
Log:
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 *".
Reported by: pen at lysator.liu.se
MFC after: 2 weeks
Modified:
head/sys/fs/nfs/nfs_var.h
head/sys/fs/nfsserver/nfs_nfsdkrpc.c
head/sys/fs/nfsserver/nfs_nfsdstate.c
Modified: head/sys/fs/nfs/nfs_var.h
==============================================================================
--- head/sys/fs/nfs/nfs_var.h Mon Apr 6 23:20:20 2020 (r359678)
+++ head/sys/fs/nfs/nfs_var.h Mon Apr 6 23:21:39 2020 (r359679)
@@ -143,7 +143,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);
int nfsrv_layoutcommit(struct nfsrv_descript *, vnode_t, int, int, uint64_t,
uint64_t, uint64_t, int, struct timespec *, int, nfsv4stateid_t *,
Modified: head/sys/fs/nfsserver/nfs_nfsdkrpc.c
==============================================================================
--- head/sys/fs/nfsserver/nfs_nfsdkrpc.c Mon Apr 6 23:20:20 2020 (r359678)
+++ head/sys/fs/nfsserver/nfs_nfsdkrpc.c Mon Apr 6 23:21:39 2020 (r359679)
@@ -393,8 +393,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: head/sys/fs/nfsserver/nfs_nfsdstate.c
==============================================================================
--- head/sys/fs/nfsserver/nfs_nfsdstate.c Mon Apr 6 23:20:20 2020 (r359678)
+++ head/sys/fs/nfsserver/nfs_nfsdstate.c Mon Apr 6 23:21:39 2020 (r359679)
@@ -6294,22 +6294,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-head
mailing list