Skip to content

Commit

Permalink
FreeBSD: Fix ZFS so that snapshots under .zfs/snapshot are NFS visible
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Rick Macklem <[email protected]>
Closes #15563
  • Loading branch information
rmacklem authored and tonyhutter committed Nov 29, 2023
1 parent a8c2560 commit 522414d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion include/os/freebsd/spl/sys/vfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,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;

Expand Down
9 changes: 8 additions & 1 deletion module/os/freebsd/spl/spl_vfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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.
Expand Down
3 changes: 2 additions & 1 deletion module/os/freebsd/zfs/zfs_ctldir.c
Original file line number Diff line number Diff line change
Expand Up @@ -1026,7 +1026,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) {
/*
Expand Down

0 comments on commit 522414d

Please sign in to comment.