Add 'zfs rename -u' to rename without remounting
authorRyan Moeller <freqlabs@FreeBSD.org>
Tue, 1 Sep 2020 23:14:16 +0000 (19:14 -0400)
committerGitHub <noreply@github.com>
Tue, 1 Sep 2020 23:14:16 +0000 (16:14 -0700)
commit7b4e27232dec4595ef842ce7c0e31aafd255a20a
treee96bac7203b11fa82a0c2dad1177dfc78540ddcc
parent88d19d7cc2586fbb4fe917b16763e88bcdf62d98
Add 'zfs rename -u' to rename without remounting

Allow to rename file systems without remounting if it is possible.
It is possible for file systems with 'mountpoint' property set to
'legacy' or 'none' - we don't have to change mount directory for them.
Currently such file systems are unmounted on rename and not even
mounted back.

This introduces layering violation, as we need to update
'f_mntfromname' field in statfs structure related to mountpoint (for
the dataset we are renaming and all its children).

In my opinion it is worth it, as it allow to update FreeBSD in even
cleaner way - in ZFS-only configuration root file system is ZFS file
system with 'mountpoint' property set to 'legacy'. If root dataset is
named system/rootfs, we can snapshot it (system/rootfs@upgrade), clone
it (system/oldrootfs), update FreeBSD and if it doesn't boot we can
boot back from system/oldrootfs and rename it back to system/rootfs
while it is mounted as /. Before it was not possible, because
unmounting / was not possible.

Authored by: Pawel Jakub Dawidek <pjd@FreeBSD.org>
Reviewed-by: Allan Jude <allan@klarasystems.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Ported by: Matt Macy <mmacy@freebsd.org>
Signed-off-by: Ryan Moeller <ryan@iXsystems.com>
Closes #10839
21 files changed:
cmd/zfs/zfs_main.c
include/libzfs.h
include/libzfs_impl.h
include/os/freebsd/zfs/sys/Makefile.am
include/os/freebsd/zfs/sys/zfs_vfsops_os.h [moved from include/os/freebsd/zfs/sys/zfs_vfsops.h with 98% similarity]
include/os/linux/zfs/sys/Makefile.am
include/os/linux/zfs/sys/zfs_vfsops_os.h [moved from include/os/linux/zfs/sys/zfs_vfsops.h with 100% similarity]
include/sys/Makefile.am
include/sys/zfs_vfsops.h [new file with mode: 0644]
lib/libzfs/libzfs_changelist.c
lib/libzfs/libzfs_dataset.c
lib/libzpool/kernel.c
man/man8/zfs-rename.8
module/os/linux/zfs/zfs_vfsops.c
module/os/linux/zfs/zpl_super.c
module/zfs/dsl_dir.c
module/zfs/zfs_ioctl.c
tests/runfiles/common.run
tests/zfs-tests/tests/functional/cli_root/zfs_rename/Makefile.am
tests/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename_mountpoint.ksh
tests/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename_nounmount.ksh [new file with mode: 0755]