From c9172fb4f18aa1d5a5b370f70eb3f01a90ff47e6 Mon Sep 17 00:00:00 2001 From: Edward Tomasz Napierala Date: Tue, 19 Feb 2019 12:45:37 +0000 Subject: [PATCH] Work around the "nfscl: bad open cnt on server" assertion that can happen when rerooting into NFSv4 rootfs with kernel built with INVARIANTS. I've talked to rmacklem@ (back in 2017), and while the root cause is still unknown, the case guarded by assertion (nfscl_doclose() being called from VOP_INACTIVE) is believed to be safe, and the whole thing seems to run just fine. Obtained from: CheriBSD MFC after: 2 weeks Sponsored by: DARPA, AFRL --- sys/fs/nfsclient/nfs_clstate.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sys/fs/nfsclient/nfs_clstate.c b/sys/fs/nfsclient/nfs_clstate.c index 0a2e4bc7e82..4a7df72dfa7 100644 --- a/sys/fs/nfsclient/nfs_clstate.c +++ b/sys/fs/nfsclient/nfs_clstate.c @@ -3188,8 +3188,11 @@ lookformore: !NFSBCMP(op->nfso_fh, nfhp->nfh_fh, nfhp->nfh_len)) { /* Found an open, close it. */ +#ifdef DIAGNOSTIC KASSERT((op->nfso_opencnt == 0), - ("nfscl: bad open cnt on server")); + ("nfscl: bad open cnt on server (%d)", + op->nfso_opencnt)); +#endif NFSUNLOCKCLSTATE(); nfsrpc_doclose(VFSTONFS(vnode_mount(vp)), op, p);