From nobody Fri Oct 15 00:32:12 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 6595617F6347; Fri, 15 Oct 2021 00:32:12 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HVnK82PGsz4b3k; Fri, 15 Oct 2021 00:32:12 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 329B91CB7A; Fri, 15 Oct 2021 00:32:12 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19F0WCDg022696; Fri, 15 Oct 2021 00:32:12 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19F0WCJ5022695; Fri, 15 Oct 2021 00:32:12 GMT (envelope-from git) Date: Fri, 15 Oct 2021 00:32:12 GMT Message-Id: <202110150032.19F0WCJ5022695@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Rick Macklem Subject: git: 6495766acfb2 - main - nfscl: Restructure nfscl_freeopen() slightly List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rmacklem X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 6495766acfb242048a80d58956b2cebbd885d8cc Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=6495766acfb242048a80d58956b2cebbd885d8cc commit 6495766acfb242048a80d58956b2cebbd885d8cc Author: Rick Macklem AuthorDate: 2021-10-15 00:28:01 +0000 Commit: Rick Macklem CommitDate: 2021-10-15 00:28:01 +0000 nfscl: Restructure nfscl_freeopen() slightly This patch factors the unlinking of the nfsclopen structure out of nfscl_freeopen() into a separate function called nfscl_unlinkopen(). It also adds a new argument to nfscl_freeopen() to conditionally do the unlink. Since this new argument is always passed in as "true" at this time, no semantics change should occur. This is being done to prepare the code for a future patch that fixes the case where an NFSv4.1/4.2 server replies NFSERR_DELAY to a Close operation. MFC after: 2 week --- sys/fs/nfs/nfs_var.h | 2 +- sys/fs/nfsclient/nfs_clrpcops.c | 2 +- sys/fs/nfsclient/nfs_clstate.c | 40 ++++++++++++++++++++++++++-------------- 3 files changed, 28 insertions(+), 16 deletions(-) diff --git a/sys/fs/nfs/nfs_var.h b/sys/fs/nfs/nfs_var.h index c5d164bd1b93..9c5a5ca5c729 100644 --- a/sys/fs/nfs/nfs_var.h +++ b/sys/fs/nfs/nfs_var.h @@ -595,7 +595,7 @@ int nfscl_checkwritelocked(vnode_t, struct flock *, void nfscl_lockrelease(struct nfscllockowner *, int, int); void nfscl_fillclid(u_int64_t, char *, u_int8_t *, u_int16_t); void nfscl_filllockowner(void *, u_int8_t *, int); -void nfscl_freeopen(struct nfsclopen *, int); +void nfscl_freeopen(struct nfsclopen *, int, bool); void nfscl_umount(struct nfsmount *, NFSPROC_T *); void nfscl_renewthread(struct nfsclclient *, NFSPROC_T *); void nfscl_initiate_recovery(struct nfsclclient *); diff --git a/sys/fs/nfsclient/nfs_clrpcops.c b/sys/fs/nfsclient/nfs_clrpcops.c index b550ae832ff4..1c72269dc276 100644 --- a/sys/fs/nfsclient/nfs_clrpcops.c +++ b/sys/fs/nfsclient/nfs_clrpcops.c @@ -850,7 +850,7 @@ nfsrpc_doclose(struct nfsmount *nmp, struct nfsclopen *op, NFSPROC_T *p) LIST_FOREACH_SAFE(lp, &op->nfso_lock, nfsl_list, nlp) nfscl_freelockowner(lp, 0); - nfscl_freeopen(op, 0); + nfscl_freeopen(op, 0, true); NFSUNLOCKCLSTATE(); NFSFREECRED(tcred); } diff --git a/sys/fs/nfsclient/nfs_clstate.c b/sys/fs/nfsclient/nfs_clstate.c index 8fca7734c197..40bf5b41361a 100644 --- a/sys/fs/nfsclient/nfs_clstate.c +++ b/sys/fs/nfsclient/nfs_clstate.c @@ -107,6 +107,7 @@ static bool nfscl_checkown(struct nfsclowner *, struct nfsclopen *, uint8_t *, uint8_t *, struct nfscllockowner **, struct nfsclopen **, struct nfsclopen **); static void nfscl_clrelease(struct nfsclclient *); +static void nfscl_unlinkopen(struct nfsclopen *); static void nfscl_cleanclient(struct nfsclclient *); static void nfscl_expireclient(struct nfsclclient *, struct nfsmount *, struct ucred *, NFSPROC_T *); @@ -846,7 +847,7 @@ nfscl_openrelease(struct nfsmount *nmp, struct nfsclopen *op, int error, nfscl_lockunlock(&owp->nfsow_rwlock); clp = owp->nfsow_clp; if (error && candelete && op->nfso_opencnt == 0) - nfscl_freeopen(op, 0); + nfscl_freeopen(op, 0, true); nfscl_clrelease(clp); NFSUNLOCKCLSTATE(); } @@ -1540,15 +1541,26 @@ nfscl_lockrelease(struct nfscllockowner *lp, int error, int candelete) } /* - * Free up an open structure and any associated byte range lock structures. + * Unlink the open structure. */ -void -nfscl_freeopen(struct nfsclopen *op, int local) +static void +nfscl_unlinkopen(struct nfsclopen *op) { LIST_REMOVE(op, nfso_list); if (op->nfso_hash.le_prev != NULL) LIST_REMOVE(op, nfso_hash); +} + +/* + * Free up an open structure and any associated byte range lock structures. + */ +void +nfscl_freeopen(struct nfsclopen *op, int local, bool unlink) +{ + + if (unlink) + nfscl_unlinkopen(op); nfscl_freealllocks(&op->nfso_lock, local); free(op, M_NFSCLOPEN); if (local) @@ -1619,7 +1631,7 @@ nfscl_expireopen(struct nfsclclient *clp, struct nfsclopen *op, * If a byte range lock or Share deny or couldn't re-open, free it. */ if (mustdelete) - nfscl_freeopen(op, 0); + nfscl_freeopen(op, 0, true); return (mustdelete); } @@ -1686,7 +1698,7 @@ nfscl_cleandeleg(struct nfscldeleg *dp) if (op != NULL) { if (LIST_NEXT(op, nfso_list) != NULL) panic("nfscleandel"); - nfscl_freeopen(op, 1); + nfscl_freeopen(op, 1, true); } nfscl_freeopenowner(owp, 1); } @@ -1728,7 +1740,7 @@ nfscl_cleanclient(struct nfsclclient *clp) /* Now, all the OpenOwners, etc. */ LIST_FOREACH_SAFE(owp, &clp->nfsc_owner, nfsow_list, nowp) { LIST_FOREACH_SAFE(op, &owp->nfsow_open, nfso_list, nop) { - nfscl_freeopen(op, 0); + nfscl_freeopen(op, 0, true); } nfscl_freeopenowner(owp, 0); } @@ -2267,7 +2279,7 @@ nfscl_recover(struct nfsclclient *clp, bool *retokp, struct ucred *cred, } } if (error != 0 && error != NFSERR_BADSESSION) - nfscl_freeopen(op, 0); + nfscl_freeopen(op, 0, true); op = nop; } owp = nowp; @@ -3341,7 +3353,7 @@ nfscl_doclose(vnode_t vp, struct nfsclclient **clpp, NFSPROC_T *p) if (op != NULL) { KASSERT((op->nfso_opencnt == 0), ("nfscl: bad open cnt on deleg")); - nfscl_freeopen(op, 1); + nfscl_freeopen(op, 1, true); } nfscl_freeopenowner(owp, 1); } @@ -4187,7 +4199,7 @@ nfscl_recalldeleg(struct nfsclclient *clp, struct nfsmount *nmp, ret == NFSERR_BADSESSION) return (ret); if (ret) { - nfscl_freeopen(lop, 1); + nfscl_freeopen(lop, 1, true); if (!error) error = ret; } @@ -4216,7 +4228,7 @@ nfscl_recalldeleg(struct nfsclclient *clp, struct nfsmount *nmp, ret == NFSERR_BADSESSION) return (ret); if (ret) { - nfscl_freeopen(lop, 1); + nfscl_freeopen(lop, 1, true); if (!error) error = ret; } @@ -4268,7 +4280,7 @@ nfscl_moveopen(vnode_t vp, struct nfsclclient *clp, struct nfsmount *nmp, op->nfso_fhlen == lop->nfso_fhlen && !NFSBCMP(op->nfso_fh, lop->nfso_fh, op->nfso_fhlen)) { op->nfso_opencnt += lop->nfso_opencnt; - nfscl_freeopen(lop, 1); + nfscl_freeopen(lop, 1, true); return (0); } } @@ -4287,11 +4299,11 @@ nfscl_moveopen(vnode_t vp, struct nfsclclient *clp, struct nfsmount *nmp, NFS4NODENAME(np->n_v4), np->n_v4->n4_namelen, &ndp, 0, 0, cred, p); if (error) { if (newone) - nfscl_freeopen(op, 0); + nfscl_freeopen(op, 0, true); } else { op->nfso_mode |= lop->nfso_mode; op->nfso_opencnt += lop->nfso_opencnt; - nfscl_freeopen(lop, 1); + nfscl_freeopen(lop, 1, true); } if (nop != NULL) free(nop, M_NFSCLOPEN);