Module Name: src
Committed By: brad
Date: Sun Sep 15 19:38:09 UTC 2019
Modified Files:
src/distrib/sets/lists/base: mi
src/distrib/sets/lists/etc: mi
src/distrib/sets/lists/man: mi
src/etc/defaults: rc.conf
src/etc/rc.d: Makefile mountall
src/external/cddl/osnet/dist/cmd/zfs: zfs_main.c
src/external/cddl/osnet/sbin/zfs: Makefile
Added Files:
src/etc/rc.d: zfs
src/external/cddl/osnet/sbin/zfs: mount_zfs.8
Log Message:
Add support for legacy ZFS filesystems, specified by mountpoint=legacy
in the ZFS properties of the dataset and a simple man page for
mount_zfs. With this, it is possible to put ZFS filesystems in
/etc/fstab as file system type zfs.
Add a rc.d script that kicks the module ZFS load mostly before
mountall runs simular to what LVM does. This allows for any legacy
mounts to be specified in critical_local_filesystems and allows for
ZFS pools on top of cgd (probably among other things). Introduce a
rc.conf variable called zfs which needs to be set to YES, in the usual
manor of things, to get zvols and ZFS dataset support rather then just
assume that 'zfs mount' does that in mountall. Fix a problem in
mountall if ZFS is not compiled into the system.
To generate a diff of this commit:
cvs rdiff -u -r1.1216 -r1.1217 src/distrib/sets/lists/base/mi
cvs rdiff -u -r1.258 -r1.259 src/distrib/sets/lists/etc/mi
cvs rdiff -u -r1.1651 -r1.1652 src/distrib/sets/lists/man/mi
cvs rdiff -u -r1.151 -r1.152 src/etc/defaults/rc.conf
cvs rdiff -u -r1.104 -r1.105 src/etc/rc.d/Makefile
cvs rdiff -u -r1.10 -r1.11 src/etc/rc.d/mountall
cvs rdiff -u -r0 -r1.1 src/etc/rc.d/zfs
cvs rdiff -u -r1.6 -r1.7 src/external/cddl/osnet/dist/cmd/zfs/zfs_main.c
cvs rdiff -u -r1.4 -r1.5 src/external/cddl/osnet/sbin/zfs/Makefile
cvs rdiff -u -r0 -r1.1 src/external/cddl/osnet/sbin/zfs/mount_zfs.8
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/distrib/sets/lists/base/mi
diff -u src/distrib/sets/lists/base/mi:1.1216 src/distrib/sets/lists/base/mi:1.1217
--- src/distrib/sets/lists/base/mi:1.1216 Sun Sep 8 21:04:31 2019
+++ src/distrib/sets/lists/base/mi Sun Sep 15 19:38:08 2019
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1216 2019/09/08 21:04:31 roy Exp $
+# $NetBSD: mi,v 1.1217 2019/09/15 19:38:08 brad Exp $
#
# Note: Don't delete entries from here - mark them as "obsolete" instead,
# unless otherwise stated below.
@@ -569,6 +569,7 @@
./sbin/mount_umap base-miscfs-root
./sbin/mount_union base-miscfs-root
./sbin/mount_v7fs base-sysutil-root
+./sbin/mount_zfs base-zfs-root zfs
./sbin/mountd base-obsolete obsolete
./sbin/newbtconf base-sysutil-root
./sbin/newfs base-sysutil-root
Index: src/distrib/sets/lists/etc/mi
diff -u src/distrib/sets/lists/etc/mi:1.258 src/distrib/sets/lists/etc/mi:1.259
--- src/distrib/sets/lists/etc/mi:1.258 Sat May 11 19:31:03 2019
+++ src/distrib/sets/lists/etc/mi Sun Sep 15 19:38:08 2019
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.258 2019/05/11 19:31:03 maxv Exp $
+# $NetBSD: mi,v 1.259 2019/09/15 19:38:08 brad Exp $
#
# Note: end-user configuration files that are moved to another location
# should not be marked "obsolete"; they should just be removed from
@@ -323,6 +323,7 @@
./etc/rc.d/yppasswdd etc-nis-rc yp
./etc/rc.d/ypserv etc-nis-rc yp
./etc/rc.d/ypset etc-obsolete obsolete
+./etc/rc.d/zfs etc-sys-rc zfs
./etc/rc.lkm etc-obsolete obsolete
./etc/rc.local etc-sys-rc
./etc/rc.shutdown etc-sys-rc
Index: src/distrib/sets/lists/man/mi
diff -u src/distrib/sets/lists/man/mi:1.1651 src/distrib/sets/lists/man/mi:1.1652
--- src/distrib/sets/lists/man/mi:1.1651 Fri Aug 30 08:54:58 2019
+++ src/distrib/sets/lists/man/mi Sun Sep 15 19:38:09 2019
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1651 2019/08/30 08:54:58 mrg Exp $
+# $NetBSD: mi,v 1.1652 2019/09/15 19:38:09 brad Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
#
@@ -2794,6 +2794,7 @@
./usr/share/man/cat8/mount_umap.0 man-miscfs-catman .cat
./usr/share/man/cat8/mount_union.0 man-miscfs-catman .cat
./usr/share/man/cat8/mount_v7fs.0 man-sysutil-catman .cat
+./usr/share/man/cat8/mount_zfs.0 man-sysutil-catman .cat
./usr/share/man/cat8/mountd.0 man-nfsserver-catman .cat
./usr/share/man/cat8/moused.0 man-sysutil-catman .cat
./usr/share/man/cat8/mrinfo.0 man-netutil-catman .cat
@@ -5759,6 +5760,7 @@
./usr/share/man/html8/mount_umap.html man-miscfs-htmlman html
./usr/share/man/html8/mount_union.html man-miscfs-htmlman html
./usr/share/man/html8/mount_v7fs.html man-sysutil-htmlman html
+./usr/share/man/html8/mount_zfs.html man-sysutil-htmlman html
./usr/share/man/html8/mountd.html man-nfsserver-htmlman html
./usr/share/man/html8/moused.html man-sysutil-htmlman html
./usr/share/man/html8/mrinfo.html man-netutil-htmlman html
@@ -8906,6 +8908,7 @@
./usr/share/man/man8/mount_umap.8 man-miscfs-man .man
./usr/share/man/man8/mount_union.8 man-miscfs-man .man
./usr/share/man/man8/mount_v7fs.8 man-sysutil-man .man
+./usr/share/man/man8/mount_zfs.8 man-sysutil-man .man
./usr/share/man/man8/mountd.8 man-nfsserver-man .man
./usr/share/man/man8/moused.8 man-sysutil-man .man
./usr/share/man/man8/mrinfo.8 man-netutil-man .man
Index: src/etc/defaults/rc.conf
diff -u src/etc/defaults/rc.conf:1.151 src/etc/defaults/rc.conf:1.152
--- src/etc/defaults/rc.conf:1.151 Wed Jul 24 02:37:17 2019
+++ src/etc/defaults/rc.conf Sun Sep 15 19:38:09 2019
@@ -1,4 +1,4 @@
-# $NetBSD: rc.conf,v 1.151 2019/07/24 02:37:17 msaitoh Exp $
+# $NetBSD: rc.conf,v 1.152 2019/09/15 19:38:09 brad Exp $
#
# /etc/defaults/rc.conf --
# default configuration of /etc/rc.conf
@@ -405,3 +405,6 @@ unbound_chrootdir=/var/chroot/unbound
nsd=NO
nsd_chrootdir=/var/chroot/nsd
nsd_flags="-t ${nsd_chrootdir}"
+
+# ZFS
+zfs=NO
Index: src/etc/rc.d/Makefile
diff -u src/etc/rc.d/Makefile:1.104 src/etc/rc.d/Makefile:1.105
--- src/etc/rc.d/Makefile:1.104 Sun May 12 01:50:14 2019
+++ src/etc/rc.d/Makefile Sun Sep 15 19:38:09 2019
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.104 2019/05/12 01:50:14 kre Exp $
+# $NetBSD: Makefile,v 1.105 2019/09/15 19:38:09 brad Exp $
.include <bsd.own.mk>
@@ -54,6 +54,10 @@ FILESBUILD_xdm= yes
FILESBUILD_xfs= yes
FILESBUILD_fccache= yes
+.if ${MKZFS} != "no"
+CONFIGFILES+= zfs
+.endif
+
.SUFFIXES: .in
.in:
${_MKTARGET_CREATE}
Index: src/etc/rc.d/mountall
diff -u src/etc/rc.d/mountall:1.10 src/etc/rc.d/mountall:1.11
--- src/etc/rc.d/mountall:1.10 Fri Jun 8 14:44:21 2018
+++ src/etc/rc.d/mountall Sun Sep 15 19:38:09 2019
@@ -1,6 +1,6 @@
#!/bin/sh
#
-# $NetBSD: mountall,v 1.10 2018/06/08 14:44:21 sevan Exp $
+# $NetBSD: mountall,v 1.11 2019/09/15 19:38:09 brad Exp $
#
# REQUIRE: mountcritremote named ypbind
@@ -15,33 +15,23 @@ stop_cmd="mountall_stop"
mountall_start()
{
echo 'Mounting all file systems...'
- if [ -f /etc/zfs/zpool.cache ]; then
- # Get ZFS module loaded (and thereby, zvols created).
- zfs list > /dev/null 2>&1
- # Mount file systems noted in fstab.
- mount -a
+ # Mount file systems noted in fstab.
+ mount -a
+ if checkyesno zfs && [ -x /sbin/zfs -a -f /etc/zfs/zpool.cache ]; then
# Mount ZFS file systems.
zfs mount -a
- else
- # Mount file systems noted in fstab.
- mount -a
fi
}
mountall_stop()
{
echo 'Unmounting all file systems...'
- if [ -f /etc/zfs/zpool.cache ]; then
+ if checkyesno zfs && [ -x /sbin/zfs -a -f /etc/zfs/zpool.cache ]; then
# Unmount ZFS file systems.
zfs unmount -a
- # Unmount file systems noted in fstab.
- umount -a
- # Unload ZFS module, so disk devices are closed.
- modunload zfs
- else
- # Otherwise, just deal with fstab.
- umount -a
fi
+ # Unmount file systems noted in fstab.
+ umount -a
}
load_rc_config $name
Index: src/external/cddl/osnet/dist/cmd/zfs/zfs_main.c
diff -u src/external/cddl/osnet/dist/cmd/zfs/zfs_main.c:1.6 src/external/cddl/osnet/dist/cmd/zfs/zfs_main.c:1.7
--- src/external/cddl/osnet/dist/cmd/zfs/zfs_main.c:1.6 Mon May 28 21:05:04 2018
+++ src/external/cddl/osnet/dist/cmd/zfs/zfs_main.c Sun Sep 15 19:38:09 2019
@@ -7135,8 +7135,13 @@ main(int argc, char **argv)
* This command also doubles as the /etc/fs mount and unmount program.
* Determine if we should take this behavior based on argv[0].
*/
+#ifdef __NetBSD__
+#define LEGACYPROGNAME "mount_zfs"
+#else
+#define LEGACYPROGNAME "mount"
+#endif
progname = basename(argv[0]);
- if (strcmp(progname, "mount") == 0) {
+ if (strcmp(progname, LEGACYPROGNAME) == 0) {
ret = manual_mount(argc, argv);
} else if (strcmp(progname, "umount") == 0) {
ret = manual_unmount(argc, argv);
Index: src/external/cddl/osnet/sbin/zfs/Makefile
diff -u src/external/cddl/osnet/sbin/zfs/Makefile:1.4 src/external/cddl/osnet/sbin/zfs/Makefile:1.5
--- src/external/cddl/osnet/sbin/zfs/Makefile:1.4 Mon May 28 21:05:09 2018
+++ src/external/cddl/osnet/sbin/zfs/Makefile Sun Sep 15 19:38:09 2019
@@ -1,11 +1,12 @@
-# $NetBSD: Makefile,v 1.4 2018/05/28 21:05:09 chs Exp $
+# $NetBSD: Makefile,v 1.5 2019/09/15 19:38:09 brad Exp $
.include "../../Makefile.zfs"
PROG= zfs
-MAN= zfs.8
+MAN= zfs.8 mount_zfs.8
USETBL= yes
SRCS= zfs_main.c zfs_iter.c
+LINKS= ${BINDIR}/zfs ${BINDIR}/mount_zfs
DPADD= ${LIBZFS} ${LIBM} ${LIBNVPAIR} ${LIBUUTIL} ${LIBUTIL}
@@ -26,6 +27,7 @@ LDADD+= -L${LIBUMEM_OBJDIR} -lum
LDADD+= -lm -lutil -lpthread
+.PATH: ${.CURDIR}
.PATH: ${ZFSDIR}/dist/cmd/zfs
.include <bsd.prog.mk>
Added files:
Index: src/etc/rc.d/zfs
diff -u /dev/null src/etc/rc.d/zfs:1.1
--- /dev/null Sun Sep 15 19:38:09 2019
+++ src/etc/rc.d/zfs Sun Sep 15 19:38:09 2019
@@ -0,0 +1,38 @@
+#!/bin/sh
+#
+# $NetBSD: zfs,v 1.1 2019/09/15 19:38:09 brad Exp $
+#
+
+# PROVIDE: zfs
+# REQUIRE: root
+# BEFORE: DISKS
+
+$_rc_subr_loaded . /etc/rc.subr
+
+name="zfs"
+start_cmd="zfs_start"
+stop_cmd="zfs_stop"
+
+zfs_start()
+{
+ if [ -x /sbin/zfs -a -f /etc/zfs/zpool.cache ]; then
+ # Get ZFS module loaded (and thereby, zvols created).
+ /sbin/zfs list > /dev/null 2>&1
+ if [ $? -ne 0 ]; then
+ warn "zfs module may not have loaded, may not be present in the kernel, or /dev/zfs may be missing"
+ return 1;
+ fi
+ fi
+}
+
+zfs_stop()
+{
+ if [ -x /sbin/zfs -a -f /etc/zfs/zpool.cache ]; then
+ zfs unmount -a
+ modunload zfs
+ fi
+ return 0;
+}
+
+load_rc_config $name
+run_rc_command "$1"
Index: src/external/cddl/osnet/sbin/zfs/mount_zfs.8
diff -u /dev/null src/external/cddl/osnet/sbin/zfs/mount_zfs.8:1.1
--- /dev/null Sun Sep 15 19:38:09 2019
+++ src/external/cddl/osnet/sbin/zfs/mount_zfs.8 Sun Sep 15 19:38:09 2019
@@ -0,0 +1,24 @@
+.\" $NetBSD: mount_zfs.8,v 1.1 2019/09/15 19:38:09 brad Exp $
+.\"
+.\"
+.Dd August 29, 2019
+.Dt MOUNT_ZFS 8
+.Os
+.Sh NAME
+.Nm mount_zfs
+.Nd helper utility for mounting legacy ZFS mounts
+.Sh SYNOPSIS
+.Nm
+.Ar ZFS_dataset
+.Ar mount_point
+.Sh DESCRIPTION
+The
+.Nm
+utility supports mounting ZFS filesystems via /etc/fstab where the ZFS property is mountpoint=legacy
+.Sh SEE ALSO
+.Xr zfs 8
+.Sh HISTORY
+The
+.Nm
+utility first appeared in
+.Nx 9.0 .