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@lysator.liu.se
MFC after:	2 weeks
This commit is contained in:
rmacklem 2020-04-06 23:21:39 +00:00
parent e08f7da384
commit 856a745f37
3 changed files with 42 additions and 9 deletions

View File

@ -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 *,

View File

@ -393,8 +393,7 @@ nfs_proc(struct nfsrv_descript *nd, u_int32_t xid, SVCXPRT *xprt,
} 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;

View File

@ -6294,22 +6294,56 @@ nfsrv_checkreclaimcomplete(struct nfsrv_descript *nd, int onefs)
* 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);
}