From nobody Sat Jul 13 01:39:51 2024 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 4WLWNl3WhQz5RFFK; Sat, 13 Jul 2024 01:39:51 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4WLWNl2pN2z4SMy; Sat, 13 Jul 2024 01:39:51 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1720834791; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=cnVFHnC05goEPxwAA1/bKcO1sNQy7AhJGm3uvYM8tS4=; b=qtM/npk9/K87sIdLlfjMDJMCUuwHAduQreO/VClyuFPVpPbWGbjhbRxS9IZKKCoPgkW2NR JWsueF79XKDa+4urcAIZ4Qs9xCbPeySCJD4rwFciMe2UcGO7zlfgQevtKZQj/SWbRouyQn 29GHymAxh99TQv4oID7h8I3id7pSETnkH1trRhkyEa0HROfF88kBwg6wYIbScxFLMo562q WrKs66LSlwxEVVjpc8jW8SlP/x78C34/imwKse+YHxyIqKVunf4q+eN3mj+fBZFcK9761k sneNrCook6tIKNX5gyuPiuSrOv8S6fp29wFDZ0ffyl1+ZmHRZDVIhHf3do4Qhw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1720834791; a=rsa-sha256; cv=none; b=chTLTPI6Y4/fG4QfwuqzcmgUTsTI8177fFdbejHS9hj6S9P5Rs+fBehV+UO9PYZ0aRPVCe Q6KBOzKHCEzzpGvydSkuW4bop+mFo3EgXqB+oSDKS3gsmreizFXtA9b5+bScDW03IZoAeI 9Y3uuQ3q0qx4E6lQ1bDa+9SVPpV289lj16F7oXNTR58L1foHwC/vNSG+wreJuZkdC/NuBA z0nhCRdkd5FgPVua5s2L/UZzxONXlwfnLgeZJ0qrglzT1UPp7RDGIta2VYOn1NbySgRJON FBF2FljuPfh8b1CawfAu1ZRoc6is+atAQ5uIk5EYOb2qxPMnPrj6zHS6PVz6vw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1720834791; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=cnVFHnC05goEPxwAA1/bKcO1sNQy7AhJGm3uvYM8tS4=; b=Xe30NWTaNKfJ3IfEfvWbG/MlLH6004ApqC/lkguuusrcj4NNDMvLq1AXdH/ri8AQ6dcbUy 2qnkeVg8nbvkgSwC3pshQPOtV5N6IyGos7rUuvTswE4b6kQ02GnpL9Ru6Fl0TvKRLUm3Dk zhZ+C/ws2NDUc7YDjmabubRnqZU7ZdiHlQ+sy0unjth8GCfAVoB70IoUuUZxY3lp70BIcn IAVh3bbEH4MIBMHMhwPD+x3vCW/R9eWn11XnAdQQWg+n5HTau6E3dwmjR+P/ZU+61unNKl zm+1y5H5hq2cfx4Hjr5sCNAu6eR8MFM4sLHJA7PttfTvZQ9bOIPBPShSonBVOA== 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 4WLWNl2Q2vz15vh; Sat, 13 Jul 2024 01:39:51 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 46D1dppI038850; Sat, 13 Jul 2024 01:39:51 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 46D1dplR038847; Sat, 13 Jul 2024 01:39:51 GMT (envelope-from git) Date: Sat, 13 Jul 2024 01:39:51 GMT Message-Id: <202407130139.46D1dplR038847@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Jason A. Harmening" Subject: git: 53a777bb52e3 - main - unionfs: do not create a new status object during vop_close() 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: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jah X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 53a777bb52e3f1e8a29fa0cbea9b991daf7ba01e Auto-Submitted: auto-generated The branch main has been updated by jah: URL: https://cgit.FreeBSD.org/src/commit/?id=53a777bb52e3f1e8a29fa0cbea9b991daf7ba01e commit 53a777bb52e3f1e8a29fa0cbea9b991daf7ba01e Author: Jason A. Harmening AuthorDate: 2024-06-14 21:01:22 +0000 Commit: Jason A. Harmening CommitDate: 2024-07-12 22:05:16 +0000 unionfs: do not create a new status object during vop_close() Split the portion of unionfs_get_node_status() that searches for an existing status object into a new helper function, unionfs_find_node_status(), and use that in unionfs_close(). Additionally, modify unionfs_close() to accept a NULL status object if unionfs_find_node_status() does not find a matching status object. This can happen due to the unconditional VOP_CLOSE() operation issued by vgonel(). Differential Revision: https://reviews.freebsd.org/D45398 Reviewed by: olce Tested by: pho --- sys/fs/unionfs/union.h | 2 ++ sys/fs/unionfs/union_subr.c | 45 ++++++++++++++++++++++++++++++-------------- sys/fs/unionfs/union_vnops.c | 9 +++++++-- 3 files changed, 40 insertions(+), 16 deletions(-) diff --git a/sys/fs/unionfs/union.h b/sys/fs/unionfs/union.h index c535a3b288b8..0bd1894a2195 100644 --- a/sys/fs/unionfs/union.h +++ b/sys/fs/unionfs/union.h @@ -133,6 +133,8 @@ int unionfs_uninit(struct vfsconf *); int unionfs_nodeget(struct mount *, struct vnode *, struct vnode *, struct vnode *, struct vnode **, struct componentname *); void unionfs_noderem(struct vnode *); +struct unionfs_node_status * unionfs_find_node_status(struct unionfs_node *, + struct thread *td); void unionfs_get_node_status(struct unionfs_node *, struct thread *, struct unionfs_node_status **); void unionfs_tryrem_node_status(struct unionfs_node *, diff --git a/sys/fs/unionfs/union_subr.c b/sys/fs/unionfs/union_subr.c index 671322704dc5..e02dd547f249 100644 --- a/sys/fs/unionfs/union_subr.c +++ b/sys/fs/unionfs/union_subr.c @@ -578,35 +578,52 @@ unionfs_noderem(struct vnode *vp) } /* - * Get the unionfs node status object for the vnode corresponding to unp, - * for the process that owns td. Allocate a new status object if one - * does not already exist. + * Find the unionfs node status object for the vnode corresponding to unp, + * for the process that owns td. Return NULL if no such object exists. */ -void -unionfs_get_node_status(struct unionfs_node *unp, struct thread *td, - struct unionfs_node_status **unspp) +struct unionfs_node_status * +unionfs_find_node_status(struct unionfs_node *unp, struct thread *td) { struct unionfs_node_status *unsp; pid_t pid; pid = td->td_proc->p_pid; - KASSERT(NULL != unspp, ("%s: NULL status", __func__)); ASSERT_VOP_ELOCKED(UNIONFSTOV(unp), __func__); LIST_FOREACH(unsp, &(unp->un_unshead), uns_list) { if (unsp->uns_pid == pid) { - *unspp = unsp; - return; + return (unsp); } } - /* create a new unionfs node status */ - unsp = malloc(sizeof(struct unionfs_node_status), - M_TEMP, M_WAITOK | M_ZERO); + return (NULL); +} + +/* + * Get the unionfs node status object for the vnode corresponding to unp, + * for the process that owns td. Allocate a new status object if one + * does not already exist. + */ +void +unionfs_get_node_status(struct unionfs_node *unp, struct thread *td, + struct unionfs_node_status **unspp) +{ + struct unionfs_node_status *unsp; + pid_t pid; + + pid = td->td_proc->p_pid; - unsp->uns_pid = pid; - LIST_INSERT_HEAD(&(unp->un_unshead), unsp, uns_list); + KASSERT(NULL != unspp, ("%s: NULL status", __func__)); + unsp = unionfs_find_node_status(unp, td); + if (unsp == NULL) { + /* create a new unionfs node status */ + unsp = malloc(sizeof(struct unionfs_node_status), + M_TEMP, M_WAITOK | M_ZERO); + + unsp->uns_pid = pid; + LIST_INSERT_HEAD(&(unp->un_unshead), unsp, uns_list); + } *unspp = unsp; } diff --git a/sys/fs/unionfs/union_vnops.c b/sys/fs/unionfs/union_vnops.c index ae1d3946266d..3f39352ea5c0 100644 --- a/sys/fs/unionfs/union_vnops.c +++ b/sys/fs/unionfs/union_vnops.c @@ -793,9 +793,14 @@ unionfs_close(struct vop_close_args *ap) unp = VTOUNIONFS(vp); lvp = unp->un_lowervp; uvp = unp->un_uppervp; - unionfs_get_node_status(unp, td, &unsp); + unsp = unionfs_find_node_status(unp, td); - if (unsp->uns_lower_opencnt <= 0 && unsp->uns_upper_opencnt <= 0) { + if (unsp == NULL || + (unsp->uns_lower_opencnt <= 0 && unsp->uns_upper_opencnt <= 0)) { +#ifdef DIAGNOSTIC + if (unsp != NULL) + printf("unionfs_close: warning: open count is 0\n"); +#endif if (uvp != NULLVP) ovp = uvp; else