From nobody Fri Dec 26 07:38:31 2025 X-Original-To: dev-commits-src-all@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 4dcyCW59b7z6L8H5 for ; Fri, 26 Dec 2025 07:38:31 +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 "R13" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4dcyCW36Wbz47mg for ; Fri, 26 Dec 2025 07:38:31 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1766734711; 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=cYNYPVCA2evFqUEmrh7jOgXWqmD9iKR8BgYCHnCp2UQ=; b=WNWatssPtj/NAWCtQttOjWDwQgCD9hDIKauOe2FrCKl/dFgXWjGF5G3tpgm48VxaLeRgXY QuwIxVXE01UMJTQmFWshMLUMh1ofwqyEhsSzB1g2wXjkKHj/8zIFO38QYXfpbgS53egHmp NWCpwPagS2N4SogQHFd5/ipcWeNIPZ8DbiyoLdOkFQopciIgVR0IFNPQziDdrxJ9Cl+Rgq wZF5slqSDc2oDAsPnTduNrvcSub98cokqh4Xg339R66+DrAs1U2BU6gFdI0zkbEuZxFQb3 pXMcbsu52re5jk8wjwd5NNCgm6BFHGZ+Xbd0B2pPTdZS/IRbafN1CctgDEK4Rw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1766734711; 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=cYNYPVCA2evFqUEmrh7jOgXWqmD9iKR8BgYCHnCp2UQ=; b=hJKrMQRF8fyRT35j4U5KYRJwk+a4yyCtYwsWMBT1NkP2kWZsL62WLW4jbOegphyX+162wQ oR/dyOSD5FjspNoHP7UCqjNIfCSH8zl1VaM81Ue4HMQZSjDC1mA3t2t8dzn1sUDLDpbVpE nMDyrZiVTpGa/on1mnkZSWoQfq0OdtB5hBfx6VJfx2nk/5pRUqNa2YDPnMBYpSVBSCa3nW EUUdCs5ne8jo1/QfOdP5gMRQ4DWo10rM0FBmGpUSYbKPffNCDJqMVzvSiLTgwQV8CvLWAn +noeaZjdhvphoZ1HGrwtC5pkgyOhAcE4WxK8j6WLSnHiNrGVBMVvJmoTcHo7bA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1766734711; a=rsa-sha256; cv=none; b=yEU3ADp4vX8J5l38AzYuUF/9Fq7B38utC8GRw98PRmOwq/fv4hiECMrY0NJe2KCGx4jBoH 4im7YE5mwZ+C7EYXGy2/Np/K1KHnVmBVMm63q9XezvGEVYIb8C1sdBEqetCzUlxnwIBAuB HqStA3WWSVJIO14YS5IRBLSAL1RF2UxnpApYIvW4mDP5fgJFCt+9Mrp8TanlJRRInEd6Wy yDIEdmk8Jfar4XZcu3zgJbOP1yWTrPSCxZJho5qty2wE8EdTTrxSpn1guHhqJNPp3XJDpV LYg+gOAPJtgVPaBlRmH4r0c/3UvaCibycVZp9SNwO3Y4nKRLPoLwqEslpNAEuw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4dcyCW2h5Rz148Y for ; Fri, 26 Dec 2025 07:38:31 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 32fea by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Fri, 26 Dec 2025 07:38:31 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Jason A. Harmening Subject: git: 177e0097b93f - stable/15 - unionfs: Implement VOP_GETLOWVNODE List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@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/stable/15 X-Git-Reftype: branch X-Git-Commit: 177e0097b93fbcb470c90fc20b7121531f304da4 Auto-Submitted: auto-generated Date: Fri, 26 Dec 2025 07:38:31 +0000 Message-Id: <694e3b77.32fea.34868fb0@gitrepo.freebsd.org> The branch stable/15 has been updated by jah: URL: https://cgit.FreeBSD.org/src/commit/?id=177e0097b93fbcb470c90fc20b7121531f304da4 commit 177e0097b93fbcb470c90fc20b7121531f304da4 Author: Jason A. Harmening AuthorDate: 2025-11-28 07:36:24 +0000 Commit: Jason A. Harmening CommitDate: 2025-12-26 06:34:13 +0000 unionfs: Implement VOP_GETLOWVNODE This function returns the vnode that will be used to resolve the access type specified in the 'flags' argument, and is useful for optimal behavior of vn_copy_file_range(). While most filesystems can simply use the default implementation which returns the passed- in vnode, unionfs (like nullfs) ideally should resolve the access request to whichever base layer vnode will be used for the I/O. For unionfs, write accesses must be resolved through the upper vnode, while read accesses will be resolved through the upper vnode if present or the lower vnode otherwise. Provide a simple unionfs_getlowvnode() implementation that reflects this policy. Reviewed by: kib, olce Tested by: pho Differential Revision: https://reviews.freebsd.org/D53988 (cherry picked from commit 5c025978fc3649730329994eecc56ada119e6717) --- sys/fs/unionfs/union_vnops.c | 45 ++++++++++++++++++++++++++++++++++++++++++++ sys/kern/vfs_default.c | 3 +-- sys/sys/vnode.h | 1 + 3 files changed, 47 insertions(+), 2 deletions(-) diff --git a/sys/fs/unionfs/union_vnops.c b/sys/fs/unionfs/union_vnops.c index 8e6b11548a36..602d5fdfcb97 100644 --- a/sys/fs/unionfs/union_vnops.c +++ b/sys/fs/unionfs/union_vnops.c @@ -2115,6 +2115,49 @@ unionfs_getwritemount(struct vop_getwritemount_args *ap) return (error); } +static int +unionfs_getlowvnode(struct vop_getlowvnode_args *ap) +{ + struct unionfs_node *unp; + struct vnode *vp, *basevp; + + vp = ap->a_vp; + VI_LOCK(vp); + unp = VTOUNIONFS(vp); + if (unp == NULL) { + VI_UNLOCK(vp); + return (EBADF); + } + + if (ap->a_flags & FWRITE) { + basevp = unp->un_uppervp; + /* + * If write access is being requested, we expect the unionfs + * vnode has already been opened for write access and thus any + * necessary copy-up has already been performed. Return an + * error if that expectation is not met and an upper vnode has + * not been instantiated. We could proactively do a copy-up + * here, but that would require additional locking as well as + * the addition of a 'cred' argument to VOP_GETLOWVNODE(). + */ + if (basevp == NULL) { + VI_UNLOCK(vp); + return (EACCES); + } + } else { + basevp = (unp->un_uppervp != NULL) ? + unp->un_uppervp : unp->un_lowervp; + } + + VNASSERT(basevp != NULL, vp, ("%s: no upper/lower vnode", __func__)); + + vholdnz(basevp); + VI_UNLOCK(vp); + VOP_GETLOWVNODE(basevp, ap->a_vplp, ap->a_flags); + vdrop(basevp); + return (0); +} + static int unionfs_inactive(struct vop_inactive_args *ap) { @@ -3010,6 +3053,7 @@ struct vop_vector unionfs_vnodeops = { .vop_getattr = unionfs_getattr, .vop_getextattr = unionfs_getextattr, .vop_getwritemount = unionfs_getwritemount, + .vop_getlowvnode = unionfs_getlowvnode, .vop_inactive = unionfs_inactive, .vop_need_inactive = vop_stdneed_inactive, .vop_islocked = vop_stdislocked, @@ -3049,5 +3093,6 @@ struct vop_vector unionfs_vnodeops = { .vop_unp_bind = unionfs_unp_bind, .vop_unp_connect = unionfs_unp_connect, .vop_unp_detach = unionfs_unp_detach, + .vop_copy_file_range = vop_stdcopy_file_range, }; VFS_VOP_VECTOR_REGISTER(unionfs_vnodeops); diff --git a/sys/kern/vfs_default.c b/sys/kern/vfs_default.c index 71fe0e62d076..e04f328c0b37 100644 --- a/sys/kern/vfs_default.c +++ b/sys/kern/vfs_default.c @@ -77,7 +77,6 @@ static int dirent_exists(struct vnode *vp, const char *dirname, static int vop_stdis_text(struct vop_is_text_args *ap); static int vop_stdunset_text(struct vop_unset_text_args *ap); static int vop_stdadd_writecount(struct vop_add_writecount_args *ap); -static int vop_stdcopy_file_range(struct vop_copy_file_range_args *ap); static int vop_stdfdatasync(struct vop_fdatasync_args *ap); static int vop_stdgetpages_async(struct vop_getpages_async_args *ap); static int vop_stdread_pgcache(struct vop_read_pgcache_args *ap); @@ -1426,7 +1425,7 @@ vfs_stdnosync(struct mount *mp, int waitfor) return (0); } -static int +int vop_stdcopy_file_range(struct vop_copy_file_range_args *ap) { int error; diff --git a/sys/sys/vnode.h b/sys/sys/vnode.h index 9e0f02465067..8bcf2d43ff51 100644 --- a/sys/sys/vnode.h +++ b/sys/sys/vnode.h @@ -915,6 +915,7 @@ int vop_stdunp_bind(struct vop_unp_bind_args *ap); int vop_stdunp_connect(struct vop_unp_connect_args *ap); int vop_stdunp_detach(struct vop_unp_detach_args *ap); int vop_stdadd_writecount_nomsync(struct vop_add_writecount_args *ap); +int vop_stdcopy_file_range(struct vop_copy_file_range_args *ap); int vop_eopnotsupp(struct vop_generic_args *ap); int vop_ebadf(struct vop_generic_args *ap); int vop_einval(struct vop_generic_args *ap);