From nobody Mon Dec 19 08:14:40 2022 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 4NbCDK0gKXz1G1Yw; Mon, 19 Dec 2022 08:14:41 +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 4NbCDK01LNz3MDd; Mon, 19 Dec 2022 08:14:41 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1671437681; 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=aAYj+RVIAtIT6BCDjza5pOgs02cr3n/uabG4D7i/5Cg=; b=dO1CSLTyNxQ/AJt+3NijxDcVk+1UMenPaJ7qzas3oPK/xLHK30AaB6ROLqWrYsGnac6CRa HRVH3+6NgFUwDOY5zsdlKc/eB7XI1LqQRcspaJbSVUj6su7RzqiO2+0RdbJtkwjx2b2GQf sGhg5d8qbgHx6poWthTgEJrLfVcrJN+rdVQ80RcfADMSa48uPURU5qIXt+gMz5o45nCqAU ZmSlquE57XI4ta8wpocKYNlaAn/hfwgP3KqaVF0MhExB8TYWVxndj576WO5GIj5DHobMuU SSiWh8ZrTTJUdJXw/UhcZ2mqKU9b4SemqywvPxmZR5zHzSs/MG69ch/7KvdFAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1671437681; 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=aAYj+RVIAtIT6BCDjza5pOgs02cr3n/uabG4D7i/5Cg=; b=YqQvYHLjCbIfT7/OdWWnklPHpWOi39lM0HWmf3nj7bHinH2aDIpvMM66FGpYk44/3j60Tr jGFlH6PSk/67fLZ8nDpMUnlyCSV3YeM3JJmD/W14R31VXNa/BWJuzDHPkgmKDhFOldKewW TpQtNGD+iRyNhTW13dUtt5C4NWkIjduXjPIwUnXbxqSYA9eShuhhKtxLrf9T0k5q+ixwqJ W+Cxa3x9kjT4RB0K7C/5Y6igueg9v+fBO1PY9r1pimekYYudSXv6YGuVSzQZdQdJQiTP25 PraqpOydkMkzIR3+Ljgb8fT+j/0fnAbXFdPn/KXvUImqlUTF/dLZ5RxwoeQv+Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1671437681; a=rsa-sha256; cv=none; b=l8C7TyaPr5fiHDdDzdzwzUwn6X7nJEH4YaqJ/eYTtz+x1dcl9fc/9Pf/VaHJpMkFmSUL5D mmn3NJaKbKQ0GnIe/2TK4S43vlOoXSpG+uD6U+ggNrRd13rtW1A4bv3QJCIksQsrNl3oad oVLEgntCPRP5UeM2zlUqWK+evGiBdDpfSVfRSWh5NrDl51Sv9FM2BLdK66kvIYU9yIA7Cn A1V1l6DohvDTuJeB9HjPeeHWDzdBvkOfojZ885TUujSYI2oxu5N5QGwvT4pqpv3+fT2k/C QIhXCyTjkhTLJietTmQsRO2xadARj9sJ2HnPMvvgB/pgmwwNFL81hGmJF5IFyw== 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 4NbCDJ6F2JzpJd; Mon, 19 Dec 2022 08:14:40 +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 2BJ8Ee1c053020; Mon, 19 Dec 2022 08:14:40 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2BJ8Ee8L053019; Mon, 19 Dec 2022 08:14:40 GMT (envelope-from git) Date: Mon, 19 Dec 2022 08:14:40 GMT Message-Id: <202212190814.2BJ8Ee8L053019@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: 8f874e92ebc9 - main - vfs: make relookup take an additional argument 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: mjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 8f874e92ebc9e75b5dd7935a042cf016be19fb38 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=8f874e92ebc9e75b5dd7935a042cf016be19fb38 commit 8f874e92ebc9e75b5dd7935a042cf016be19fb38 Author: Mateusz Guzik AuthorDate: 2022-11-10 01:45:13 +0000 Commit: Mateusz Guzik CommitDate: 2022-12-19 08:09:00 +0000 vfs: make relookup take an additional argument instead of looking at SAVESTART This is a step towards removing the flag. Reviewed by: mckusick Tested by: pho Differential Revision: https://reviews.freebsd.org/D34468 --- sys/fs/ext2fs/ext2_vnops.c | 4 ++-- sys/fs/unionfs/union_subr.c | 18 +++++++++++------- sys/kern/vfs_lookup.c | 9 +++++---- sys/sys/namei.h | 2 +- 4 files changed, 19 insertions(+), 14 deletions(-) diff --git a/sys/fs/ext2fs/ext2_vnops.c b/sys/fs/ext2fs/ext2_vnops.c index 5948cbd052e3..a7da8249ab4d 100644 --- a/sys/fs/ext2fs/ext2_vnops.c +++ b/sys/fs/ext2fs/ext2_vnops.c @@ -910,7 +910,7 @@ abortit: if (error) goto out; VREF(tdvp); - error = vfs_relookup(tdvp, &tvp, tcnp); + error = vfs_relookup(tdvp, &tvp, tcnp, true); if (error) goto out; vrele(tdvp); @@ -1036,7 +1036,7 @@ abortit: fcnp->cn_flags &= ~MODMASK; fcnp->cn_flags |= LOCKPARENT | LOCKLEAF; VREF(fdvp); - error = vfs_relookup(fdvp, &fvp, fcnp); + error = vfs_relookup(fdvp, &fvp, fcnp, true); if (error == 0) vrele(fdvp); if (fvp != NULL) { diff --git a/sys/fs/unionfs/union_subr.c b/sys/fs/unionfs/union_subr.c index 0b9e8fde4b6a..29e18b355f68 100644 --- a/sys/fs/unionfs/union_subr.c +++ b/sys/fs/unionfs/union_subr.c @@ -662,6 +662,7 @@ unionfs_relookup(struct vnode *dvp, struct vnode **vpp, char *path, int pathlen, u_long nameiop) { int error; + bool refstart; cn->cn_namelen = pathlen; cn->cn_pnbuf = path; @@ -671,17 +672,20 @@ unionfs_relookup(struct vnode *dvp, struct vnode **vpp, cn->cn_cred = cnp->cn_cred; cn->cn_nameptr = cn->cn_pnbuf; - if (nameiop == DELETE) - cn->cn_flags |= (cnp->cn_flags & (DOWHITEOUT | SAVESTART)); - else if (RENAME == nameiop) - cn->cn_flags |= (cnp->cn_flags & SAVESTART); - else if (nameiop == CREATE) + refstart = false; + if (nameiop == DELETE) { + cn->cn_flags |= (cnp->cn_flags & DOWHITEOUT); + refstart = (cnp->cn_flags & SAVESTART) != 0; + } else if (RENAME == nameiop) { + refstart = (cnp->cn_flags & SAVESTART) != 0; + } else if (nameiop == CREATE) { cn->cn_flags |= NOCACHE; + } vref(dvp); VOP_UNLOCK(dvp); - if ((error = vfs_relookup(dvp, vpp, cn))) { + if ((error = vfs_relookup(dvp, vpp, cn, refstart))) { vn_lock(dvp, LK_EXCLUSIVE | LK_RETRY); } else vrele(dvp); @@ -1017,7 +1021,7 @@ unionfs_vn_create_on_upper(struct vnode **vpp, struct vnode *udvp, NDPREINIT(&nd); vref(udvp); - if ((error = vfs_relookup(udvp, &vp, &nd.ni_cnd)) != 0) + if ((error = vfs_relookup(udvp, &vp, &nd.ni_cnd, false)) != 0) goto unionfs_vn_create_on_upper_free_out2; vrele(udvp); diff --git a/sys/kern/vfs_lookup.c b/sys/kern/vfs_lookup.c index ac5617616e30..a5f73676d308 100644 --- a/sys/kern/vfs_lookup.c +++ b/sys/kern/vfs_lookup.c @@ -1435,7 +1435,8 @@ bad_unlocked: * Used by lookup to re-acquire things. */ int -vfs_relookup(struct vnode *dvp, struct vnode **vpp, struct componentname *cnp) +vfs_relookup(struct vnode *dvp, struct vnode **vpp, struct componentname *cnp, + bool refstart) { struct vnode *dp = NULL; /* the directory we are searching */ int rdonly; /* lookup read-only flag bit */ @@ -1479,7 +1480,7 @@ vfs_relookup(struct vnode *dvp, struct vnode **vpp, struct componentname *cnp) VOP_UNLOCK(dp); *vpp = dp; /* XXX This should probably move to the top of function. */ - if (cnp->cn_flags & SAVESTART) + if (refstart) panic("lookup: SAVESTART"); return (0); } @@ -1506,7 +1507,7 @@ vfs_relookup(struct vnode *dvp, struct vnode **vpp, struct componentname *cnp) goto bad; } /* ASSERT(dvp == ndp->ni_startdir) */ - if (cnp->cn_flags & SAVESTART) + if (refstart) VREF(dvp); if ((cnp->cn_flags & LOCKPARENT) == 0) VOP_UNLOCK(dp); @@ -1544,7 +1545,7 @@ vfs_relookup(struct vnode *dvp, struct vnode **vpp, struct componentname *cnp) ("relookup: symlink found.\n")); /* ASSERT(dvp == ndp->ni_startdir) */ - if (cnp->cn_flags & SAVESTART) + if (refstart) VREF(dvp); if ((cnp->cn_flags & LOCKLEAF) == 0) diff --git a/sys/sys/namei.h b/sys/sys/namei.h index d527d4a3bed0..eafb23ed0929 100644 --- a/sys/sys/namei.h +++ b/sys/sys/namei.h @@ -293,7 +293,7 @@ do { \ int namei(struct nameidata *ndp); int vfs_lookup(struct nameidata *ndp); int vfs_relookup(struct vnode *dvp, struct vnode **vpp, - struct componentname *cnp); + struct componentname *cnp, bool refstart); #endif /*