From owner-dev-commits-src-branches@freebsd.org Wed Jul 7 11:10:57 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E5983653D11; Wed, 7 Jul 2021 11:10:57 +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 4GKcDK4YYGz4fs0; Wed, 7 Jul 2021 11:10:57 +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 6C63345C0; Wed, 7 Jul 2021 11:10:57 +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 167BAv4s040828; Wed, 7 Jul 2021 11:10:57 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 167BAvce040827; Wed, 7 Jul 2021 11:10:57 GMT (envelope-from git) Date: Wed, 7 Jul 2021 11:10:57 GMT Message-Id: <202107071110.167BAvce040827@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: eee344ccd142 - stable/13 - unionfs: do not use bare struct componentname MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: eee344ccd1420498eb7860999d115ea1de8c68e6 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Jul 2021 11:10:58 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=eee344ccd1420498eb7860999d115ea1de8c68e6 commit eee344ccd1420498eb7860999d115ea1de8c68e6 Author: Konstantin Belousov AuthorDate: 2021-06-14 18:45:23 +0000 Commit: Konstantin Belousov CommitDate: 2021-07-07 10:23:30 +0000 unionfs: do not use bare struct componentname (cherry picked from commit 190110f2eba1551793f290a9f01e52ffe015a5da) --- sys/fs/unionfs/union_subr.c | 70 ++++++++++++++++++++++++--------------------- 1 file changed, 38 insertions(+), 32 deletions(-) diff --git a/sys/fs/unionfs/union_subr.c b/sys/fs/unionfs/union_subr.c index 30b637171021..93e4f50d98c5 100644 --- a/sys/fs/unionfs/union_subr.c +++ b/sys/fs/unionfs/union_subr.c @@ -760,7 +760,7 @@ unionfs_mkshadowdir(struct unionfs_mount *ump, struct vnode *udvp, struct vnode *uvp; struct vattr va; struct vattr lva; - struct componentname cn; + struct nameidata nd; struct mount *mp; struct ucred *cred; struct ucred *credbk; @@ -787,12 +787,14 @@ unionfs_mkshadowdir(struct unionfs_mount *ump, struct vnode *udvp, uifree(rootinfo); cnp->cn_cred = cred; - memset(&cn, 0, sizeof(cn)); + memset(&nd.ni_cnd, 0, sizeof(struct componentname)); + NDPREINIT(&nd); if ((error = VOP_GETATTR(lvp, &lva, cnp->cn_cred))) goto unionfs_mkshadowdir_abort; - if ((error = unionfs_relookup(udvp, &uvp, cnp, &cn, td, cnp->cn_nameptr, cnp->cn_namelen, CREATE))) + if ((error = unionfs_relookup(udvp, &uvp, cnp, &nd.ni_cnd, td, + cnp->cn_nameptr, cnp->cn_namelen, CREATE))) goto unionfs_mkshadowdir_abort; if (uvp != NULLVP) { if (udvp == uvp) @@ -808,7 +810,7 @@ unionfs_mkshadowdir(struct unionfs_mount *ump, struct vnode *udvp, goto unionfs_mkshadowdir_free_out; unionfs_create_uppervattr_core(ump, &lva, &va, td); - error = VOP_MKDIR(udvp, &uvp, &cn, &va); + error = VOP_MKDIR(udvp, &uvp, &nd.ni_cnd, &va); if (!error) { unionfs_node_update(unp, uvp, td); @@ -818,14 +820,14 @@ unionfs_mkshadowdir(struct unionfs_mount *ump, struct vnode *udvp, * Ignore errors. */ va.va_type = VNON; - VOP_SETATTR(uvp, &va, cn.cn_cred); + VOP_SETATTR(uvp, &va, nd.ni_cnd.cn_cred); } vn_finished_write(mp); unionfs_mkshadowdir_free_out: - if (cn.cn_flags & HASBUF) { - uma_zfree(namei_zone, cn.cn_pnbuf); - cn.cn_flags &= ~HASBUF; + if (nd.ni_cnd.cn_flags & HASBUF) { + uma_zfree(namei_zone, nd.ni_cnd.cn_pnbuf); + nd.ni_cnd.cn_flags &= ~HASBUF; } unionfs_mkshadowdir_abort: @@ -847,19 +849,21 @@ unionfs_mkwhiteout(struct vnode *dvp, struct componentname *cnp, { int error; struct vnode *wvp; - struct componentname cn; + struct nameidata nd; struct mount *mp; if (path == NULL) path = cnp->cn_nameptr; wvp = NULLVP; - if ((error = unionfs_relookup(dvp, &wvp, cnp, &cn, td, path, strlen(path), CREATE))) + NDPREINIT(&nd); + if ((error = unionfs_relookup(dvp, &wvp, cnp, &nd.ni_cnd, td, path, + strlen(path), CREATE))) return (error); if (wvp != NULLVP) { - if (cn.cn_flags & HASBUF) { - uma_zfree(namei_zone, cn.cn_pnbuf); - cn.cn_flags &= ~HASBUF; + if (nd.ni_cnd.cn_flags & HASBUF) { + uma_zfree(namei_zone, nd.ni_cnd.cn_pnbuf); + nd.ni_cnd.cn_flags &= ~HASBUF; } if (dvp == wvp) vrele(wvp); @@ -871,14 +875,14 @@ unionfs_mkwhiteout(struct vnode *dvp, struct componentname *cnp, if ((error = vn_start_write(dvp, &mp, V_WAIT | PCATCH))) goto unionfs_mkwhiteout_free_out; - error = VOP_WHITEOUT(dvp, &cn, CREATE); + error = VOP_WHITEOUT(dvp, &nd.ni_cnd, CREATE); vn_finished_write(mp); unionfs_mkwhiteout_free_out: - if (cn.cn_flags & HASBUF) { - uma_zfree(namei_zone, cn.cn_pnbuf); - cn.cn_flags &= ~HASBUF; + if (nd.ni_cnd.cn_flags & HASBUF) { + uma_zfree(namei_zone, nd.ni_cnd.cn_pnbuf); + nd.ni_cnd.cn_flags &= ~HASBUF; } return (error); @@ -904,7 +908,7 @@ unionfs_vn_create_on_upper(struct vnode **vpp, struct vnode *udvp, struct vattr lva; int fmode; int error; - struct componentname cn; + struct nameidata nd; ump = MOUNTTOUNIONFSMOUNT(UNIONFSTOV(unp)->v_mount); vp = NULLVP; @@ -920,18 +924,20 @@ unionfs_vn_create_on_upper(struct vnode **vpp, struct vnode *udvp, if (unp->un_path == NULL) panic("unionfs: un_path is null"); - cn.cn_namelen = strlen(unp->un_path); - cn.cn_pnbuf = uma_zalloc(namei_zone, M_WAITOK); - bcopy(unp->un_path, cn.cn_pnbuf, cn.cn_namelen + 1); - cn.cn_nameiop = CREATE; - cn.cn_flags = (LOCKPARENT | LOCKLEAF | HASBUF | SAVENAME | ISLASTCN); - cn.cn_lkflags = LK_EXCLUSIVE; - cn.cn_thread = td; - cn.cn_cred = cred; - cn.cn_nameptr = cn.cn_pnbuf; + nd.ni_cnd.cn_namelen = strlen(unp->un_path); + nd.ni_cnd.cn_pnbuf = uma_zalloc(namei_zone, M_WAITOK); + bcopy(unp->un_path, nd.ni_cnd.cn_pnbuf, nd.ni_cnd.cn_namelen + 1); + nd.ni_cnd.cn_nameiop = CREATE; + nd.ni_cnd.cn_flags = LOCKPARENT | LOCKLEAF | HASBUF | SAVENAME | + ISLASTCN; + nd.ni_cnd.cn_lkflags = LK_EXCLUSIVE; + nd.ni_cnd.cn_thread = td; + nd.ni_cnd.cn_cred = cred; + nd.ni_cnd.cn_nameptr = nd.ni_cnd.cn_pnbuf; + NDPREINIT(&nd); vref(udvp); - if ((error = relookup(udvp, &vp, &cn)) != 0) + if ((error = relookup(udvp, &vp, &nd.ni_cnd)) != 0) goto unionfs_vn_create_on_upper_free_out2; vrele(udvp); @@ -944,7 +950,7 @@ unionfs_vn_create_on_upper(struct vnode **vpp, struct vnode *udvp, goto unionfs_vn_create_on_upper_free_out1; } - if ((error = VOP_CREATE(udvp, &vp, &cn, uvap)) != 0) + if ((error = VOP_CREATE(udvp, &vp, &nd.ni_cnd, uvap)) != 0) goto unionfs_vn_create_on_upper_free_out1; if ((error = VOP_OPEN(vp, fmode, cred, td, NULL)) != 0) { @@ -964,9 +970,9 @@ unionfs_vn_create_on_upper_free_out1: VOP_UNLOCK(udvp); unionfs_vn_create_on_upper_free_out2: - if (cn.cn_flags & HASBUF) { - uma_zfree(namei_zone, cn.cn_pnbuf); - cn.cn_flags &= ~HASBUF; + if (nd.ni_cnd.cn_flags & HASBUF) { + uma_zfree(namei_zone, nd.ni_cnd.cn_pnbuf); + nd.ni_cnd.cn_flags &= ~HASBUF; } return (error);