aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrmacklem <64620010+rmacklem@users.noreply.github.com>2023-11-28 00:31:03 +0000
committerEd Maste <emaste@FreeBSD.org>2023-12-04 21:03:30 +0000
commit00f0b99e63c3b27174b89dae426a2d87435d991a (patch)
treeafefba8ee2743d916fa9dc6afdb9399d8952c9f7
parent9b2326333e884bc239d06be7cbd8a4eef571c5eb (diff)
downloadsrc-00f0b99e63c3b27174b89dae426a2d87435d991a.tar.gz
src-00f0b99e63c3b27174b89dae426a2d87435d991a.zip
OpenZFS: Fix ZFS so that snapshots under .zfs/snapshot are NFS visible
Call vfs_exjail_clone() for mounts created under .zfs/snapshot to fill in the mnt_exjail field for the mount. If this is not done, the snapshots under .zfs/snapshot with not be accessible over NFS. This version has the argument name in vfs.h fixed to match that of the name in spl_vfs.c, although it really does not matter. External-issue: https://reviews.freebsd.org/D42672 Reviewed-by: Alexander Motin <mav@FreeBSD.org> Signed-off-by: Rick Macklem <rmacklem@uoguelph.ca> Closes #15563 (cherry picked from commit 522414da3b283dada175161e49ea7f3fe46436ff)
-rw-r--r--sys/contrib/openzfs/include/os/freebsd/spl/sys/vfs.h2
-rw-r--r--sys/contrib/openzfs/module/os/freebsd/spl/spl_vfs.c9
-rw-r--r--sys/contrib/openzfs/module/os/freebsd/zfs/zfs_ctldir.c3
3 files changed, 11 insertions, 3 deletions
diff --git a/sys/contrib/openzfs/include/os/freebsd/spl/sys/vfs.h b/sys/contrib/openzfs/include/os/freebsd/spl/sys/vfs.h
index a432f6c56739..62986b7fc525 100644
--- a/sys/contrib/openzfs/include/os/freebsd/spl/sys/vfs.h
+++ b/sys/contrib/openzfs/include/os/freebsd/spl/sys/vfs.h
@@ -103,7 +103,7 @@ void vfs_setmntopt(vfs_t *vfsp, const char *name, const char *arg,
void vfs_clearmntopt(vfs_t *vfsp, const char *name);
int vfs_optionisset(const vfs_t *vfsp, const char *opt, char **argp);
int mount_snapshot(kthread_t *td, vnode_t **vpp, const char *fstype,
- char *fspath, char *fspec, int fsflags);
+ char *fspath, char *fspec, int fsflags, vfs_t *parent_vfsp);
typedef uint64_t vfs_feature_t;
diff --git a/sys/contrib/openzfs/module/os/freebsd/spl/spl_vfs.c b/sys/contrib/openzfs/module/os/freebsd/spl/spl_vfs.c
index 53ef46fb8ce5..177a059e88a1 100644
--- a/sys/contrib/openzfs/module/os/freebsd/spl/spl_vfs.c
+++ b/sys/contrib/openzfs/module/os/freebsd/spl/spl_vfs.c
@@ -120,7 +120,7 @@ vfs_optionisset(const vfs_t *vfsp, const char *opt, char **argp)
int
mount_snapshot(kthread_t *td, vnode_t **vpp, const char *fstype, char *fspath,
- char *fspec, int fsflags)
+ char *fspec, int fsflags, vfs_t *parent_vfsp)
{
struct vfsconf *vfsp;
struct mount *mp;
@@ -220,6 +220,13 @@ mount_snapshot(kthread_t *td, vnode_t **vpp, const char *fstype, char *fspath,
mp->mnt_opt = mp->mnt_optnew;
(void) VFS_STATFS(mp, &mp->mnt_stat);
+#ifdef VFS_SUPPORTS_EXJAIL_CLONE
+ /*
+ * Clone the mnt_exjail credentials of the parent, as required.
+ */
+ vfs_exjail_clone(parent_vfsp, mp);
+#endif
+
/*
* Prevent external consumers of mount options from reading
* mnt_optnew.
diff --git a/sys/contrib/openzfs/module/os/freebsd/zfs/zfs_ctldir.c b/sys/contrib/openzfs/module/os/freebsd/zfs/zfs_ctldir.c
index cfc4bab2fa96..3c9311098696 100644
--- a/sys/contrib/openzfs/module/os/freebsd/zfs/zfs_ctldir.c
+++ b/sys/contrib/openzfs/module/os/freebsd/zfs/zfs_ctldir.c
@@ -1025,7 +1025,8 @@ zfsctl_snapdir_lookup(struct vop_lookup_args *ap)
"%s/" ZFS_CTLDIR_NAME "/snapshot/%s",
dvp->v_vfsp->mnt_stat.f_mntonname, name);
- err = mount_snapshot(curthread, vpp, "zfs", mountpoint, fullname, 0);
+ err = mount_snapshot(curthread, vpp, "zfs", mountpoint, fullname, 0,
+ dvp->v_vfsp);
kmem_free(mountpoint, mountpoint_len);
if (err == 0) {
/*