summaryrefslogtreecommitdiffstats
path: root/sys/fs/nfsserver/nfs_nfsdkrpc.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/fs/nfsserver/nfs_nfsdkrpc.c')
-rw-r--r--sys/fs/nfsserver/nfs_nfsdkrpc.c39
1 files changed, 28 insertions, 11 deletions
diff --git a/sys/fs/nfsserver/nfs_nfsdkrpc.c b/sys/fs/nfsserver/nfs_nfsdkrpc.c
index 9185b135..96cb833 100644
--- a/sys/fs/nfsserver/nfs_nfsdkrpc.c
+++ b/sys/fs/nfsserver/nfs_nfsdkrpc.c
@@ -97,8 +97,8 @@ static int nfs_maxvers = NFS_VER4;
SYSCTL_INT(_vfs_nfsd, OID_AUTO, server_max_nfsvers, CTLFLAG_RW,
&nfs_maxvers, 0, "The highest version of NFS handled by the server");
-static int nfs_proc(struct nfsrv_descript *, u_int32_t, struct socket *,
- u_int64_t, struct nfsrvcache **);
+static int nfs_proc(struct nfsrv_descript *, u_int32_t, SVCXPRT *xprt,
+ struct nfsrvcache **);
extern u_long sb_max_adj;
extern int newnfs_numnfsd;
@@ -251,8 +251,7 @@ nfssvc_program(struct svc_req *rqst, SVCXPRT *xprt)
}
}
- cacherep = nfs_proc(&nd, rqst->rq_xid, xprt->xp_socket,
- xprt->xp_sockref, &rp);
+ cacherep = nfs_proc(&nd, rqst->rq_xid, xprt, &rp);
NFSLOCKV4ROOTMUTEX();
nfsv4_relref(&nfsd_suspend_lock);
NFSUNLOCKV4ROOTMUTEX();
@@ -287,8 +286,10 @@ nfssvc_program(struct svc_req *rqst, SVCXPRT *xprt)
} else if (!svc_sendreply_mbuf(rqst, nd.nd_mreq)) {
svcerr_systemerr(rqst);
}
- if (rp != NULL)
- nfsrvd_sentcache(rp, xprt->xp_socket, 0);
+ if (rp != NULL) {
+ if (rqst->rq_reply_seq != 0 || SVC_ACK(xprt, NULL))
+ nfsrvd_sentcache(rp, rqst->rq_reply_seq);
+ }
svc_freereq(rqst);
out:
@@ -300,11 +301,12 @@ out:
* Return the appropriate cache response.
*/
static int
-nfs_proc(struct nfsrv_descript *nd, u_int32_t xid, struct socket *so,
- u_int64_t sockref, struct nfsrvcache **rpp)
+nfs_proc(struct nfsrv_descript *nd, u_int32_t xid, SVCXPRT *xprt,
+ struct nfsrvcache **rpp)
{
struct thread *td = curthread;
int cacherep = RC_DOIT, isdgram;
+ uint32_t ack;
*rpp = NULL;
if (nd->nd_nam2 == NULL) {
@@ -336,8 +338,11 @@ nfs_proc(struct nfsrv_descript *nd, u_int32_t xid, struct socket *so,
nd->nd_flag |= ND_SAMETCPCONN;
nd->nd_retxid = xid;
nd->nd_tcpconntime = NFSD_MONOSEC;
- nd->nd_sockref = sockref;
- cacherep = nfsrvd_getcache(nd, so);
+ nd->nd_sockref = xprt->xp_sockref;
+ cacherep = nfsrvd_getcache(nd);
+ ack = 0;
+ SVC_ACK(xprt, &ack);
+ nfsrc_trimcache(xprt->xp_sockref, ack, 0);
}
/*
@@ -352,13 +357,23 @@ nfs_proc(struct nfsrv_descript *nd, u_int32_t xid, struct socket *so,
cacherep = RC_DROPIT;
else
cacherep = RC_REPLY;
- *rpp = nfsrvd_updatecache(nd, so);
+ *rpp = nfsrvd_updatecache(nd);
}
NFSEXITCODE2(0, nd);
return (cacherep);
}
+static void
+nfssvc_loss(SVCXPRT *xprt)
+{
+ uint32_t ack;
+
+ ack = 0;
+ SVC_ACK(xprt, &ack);
+ nfsrc_trimcache(xprt->xp_sockref, ack, 1);
+}
+
/*
* Adds a socket to the list for servicing by nfsds.
*/
@@ -399,6 +414,8 @@ nfsrvd_addsock(struct file *fp)
if (nfs_maxvers >= NFS_VER4)
svc_reg(xprt, NFS_PROG, NFS_VER4, nfssvc_program,
NULL);
+ if (so->so_type == SOCK_STREAM)
+ svc_loss_reg(xprt, nfssvc_loss);
SVC_RELEASE(xprt);
}
OpenPOWER on IntegriCloud