From nobody Thu Nov 30 12:31:20 2023 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 4SgwXm6Vqpz53GWf; Thu, 30 Nov 2023 12:31:20 +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 4SgwXm63YYz3Vqg; Thu, 30 Nov 2023 12:31:20 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1701347480; 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=piL6QEVUDW5a2pAUMjGF6arVKypEXL93ugaFTikitwI=; b=MwatO2CPNxumdvQbOBfDRzJF+EYlopAdHtexneiQN9BxMGt7wntlz3ESBPN5t1hPG6jNsR jehw3wasAxFYwDXjEUwF5Sv4wMdhqSnWWAFgY4y+iFP8h3t/w5Eou6W4btebPDz4oObeDO d0Gv7LtK/xuBD8fblbIQhQnKQ6C2y8U4w1aydiaypoD9JWjuZvYTtlap9sZrj6IUnZDNsD 4Ar/bjKAwn/bou9IzYh1JkqaGQd0dWFdAQ/kTsKOhpajS+UF17vmjtac0qm6njV8tuqfyx lvLFu0PjJqLTMUIeASfG1vHoft0aJ+tb9Fy+3kGEJ0Mrw58WEFqaadPgi98DYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1701347480; 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=piL6QEVUDW5a2pAUMjGF6arVKypEXL93ugaFTikitwI=; b=W9sYJxgZKZIvJS43SARzoHCwtPe8iHeECdxIu3J4zf+FAslrAYESEizSMAVWQHyTgSVfRU AUWCqv8yMe/H9ARe19pA8MgX2cCshdBNGJOajmGxJNP/GiPq/nc+wo8h/ie8IpnMalFH3Z w78ubq1YZgpnbpQqeLLM3nV+f7SRfrbv0iIXlD7ocKufRg4q7Gr4WV8zC/HFncofRH+6Kr iRwCAY6qLDclnt2hl4C/L+oWpwh9DHKjFqxOPe2x2mjaMzQhIf8/f4/tl4Qa7MIuMAZuU7 7yEFUp/6IkteIVPrJmoNuJ0d9WGOlsLJSEggK8Yy548lXPsCct8Kc0GPTPcQkg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1701347480; a=rsa-sha256; cv=none; b=jL/IgGypK4e5BdFlsTiwQ0Ekz2yRCfwIhSuqxaDzJOhw7U34rvOrA0xJl7KlpnE1IRds85 19jB6O4fAjZEU5dL0Vxbh3gtmik6ezAHblprlEsaoB2OyL3JJfhtr2t5LqbbryQXvedNAi 1oRBuvTTHfMSykYpUZZj4ZNXcBTSd6N5RPHIerDG61xTzriyfVOYrh24/VUKk9Mdgsv5Uc v4pzylXpP3OXEzaE+ZqDeD1kNQH9J48/cwC6AnNadYKqzpg7un8z1ycXEHHOK7u+T/Ns07 rtcV5WQIOxg9v7QH/nEyBviJ6g0vKMcPpZQYtAJvJSVTycdhTp1c0wbdp+bhEQ== 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 4SgwXm56XRzq96; Thu, 30 Nov 2023 12:31:20 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 3AUCVK5B048633; Thu, 30 Nov 2023 12:31:20 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3AUCVK7E048630; Thu, 30 Nov 2023 12:31:20 GMT (envelope-from git) Date: Thu, 30 Nov 2023 12:31:20 GMT Message-Id: <202311301231.3AUCVK7E048630@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Rick Macklem Subject: git: 7aaf39f6b3b0 - stable/13 - nfsd: Fix NFS access to .zfs/snapshot snapshots 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: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@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/stable/13 X-Git-Reftype: branch X-Git-Commit: 7aaf39f6b3b0bc5cc171eac7ca118d17460ea5db Auto-Submitted: auto-generated The branch stable/13 has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=7aaf39f6b3b0bc5cc171eac7ca118d17460ea5db commit 7aaf39f6b3b0bc5cc171eac7ca118d17460ea5db Author: Rick Macklem AuthorDate: 2023-11-23 15:23:33 +0000 Commit: Rick Macklem CommitDate: 2023-11-30 12:28:50 +0000 nfsd: Fix NFS access to .zfs/snapshot snapshots When a process attempts to access a snapshot under //.zfs/snapshot, the snapshot is automounted. However, without this patch, the automount does not set mnt_exjail, which results in the snapshot not being accessible over NFS. This patch defines a new function called vfs_exjail_clone() which sets mnt_exjail from another mount point and then uses that function to set mnt_exjail in the snapshot automount. A separate patch that is currently a pull request for OpenZFS, calls this function to fix the problem. PR: 275200 (cherry picked from commit f5f277728adec4c5b3e840a1fb16bd16f8cc956d) --- sys/kern/vfs_mount.c | 35 +++++++++++++++++++++++++++++++++++ sys/sys/mount.h | 4 ++++ 2 files changed, 39 insertions(+) diff --git a/sys/kern/vfs_mount.c b/sys/kern/vfs_mount.c index 4597ae09a831..cefadf75a3a8 100644 --- a/sys/kern/vfs_mount.c +++ b/sys/kern/vfs_mount.c @@ -2824,6 +2824,41 @@ suspend_all_fs(void) mtx_unlock(&mountlist_mtx); } +/* + * Clone the mnt_exjail field to a new mount point. + */ +void +vfs_exjail_clone(struct mount *inmp, struct mount *outmp) +{ + struct ucred *cr; + struct prison *pr; + + MNT_ILOCK(inmp); + cr = inmp->mnt_exjail; + if (cr != NULL) { + crhold(cr); + MNT_IUNLOCK(inmp); + pr = cr->cr_prison; + sx_slock(&allprison_lock); + if (!prison_isalive(pr)) { + sx_sunlock(&allprison_lock); + crfree(cr); + return; + } + MNT_ILOCK(outmp); + if (outmp->mnt_exjail == NULL) { + outmp->mnt_exjail = cr; + atomic_add_int(&pr->pr_exportcnt, 1); + cr = NULL; + } + MNT_IUNLOCK(outmp); + sx_sunlock(&allprison_lock); + if (cr != NULL) + crfree(cr); + } else + MNT_IUNLOCK(inmp); +} + void resume_all_fs(void) { diff --git a/sys/sys/mount.h b/sys/sys/mount.h index 2d9ee8d78bdd..9c1862956812 100644 --- a/sys/sys/mount.h +++ b/sys/sys/mount.h @@ -947,6 +947,9 @@ vfs_statfs_t __vfs_statfs; * exported vnode operations */ +/* Define this to indicate that vfs_exjail_clone() exists for ZFS to use. */ +#define VFS_SUPPORTS_EXJAIL_CLONE 1 + int dounmount(struct mount *, int, struct thread *); int kernel_mount(struct mntarg *ma, uint64_t flags); @@ -984,6 +987,7 @@ int vfs_setpublicfs /* set publicly exported fs */ (struct mount *, struct netexport *, struct export_args *); void vfs_periodic(struct mount *, int); int vfs_busy(struct mount *, int); +void vfs_exjail_clone(struct mount *, struct mount *); int vfs_export /* process mount export info */ (struct mount *, struct export_args *, int); void vfs_free_addrlist(struct netexport *);