Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src Add support for legacy ZFS filesystems, specified by mountpo...



details:   https://anonhg.NetBSD.org/src/rev/52c8dc8e7677
branches:  trunk
changeset: 454388:52c8dc8e7677
user:      brad <brad%NetBSD.org@localhost>
date:      Sun Sep 15 19:38:08 2019 +0000

description:
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.

diffstat:

 distrib/sets/lists/base/mi                  |   3 +-
 distrib/sets/lists/etc/mi                   |   3 +-
 distrib/sets/lists/man/mi                   |   5 +++-
 etc/defaults/rc.conf                        |   5 +++-
 etc/rc.d/Makefile                           |   6 +++-
 etc/rc.d/mountall                           |  24 +++++------------
 etc/rc.d/zfs                                |  38 +++++++++++++++++++++++++++++
 external/cddl/osnet/dist/cmd/zfs/zfs_main.c |   7 ++++-
 external/cddl/osnet/sbin/zfs/Makefile       |   6 +++-
 external/cddl/osnet/sbin/zfs/mount_zfs.8    |  24 ++++++++++++++++++
 10 files changed, 96 insertions(+), 25 deletions(-)

diffs (268 lines):

diff -r 1d85d1f5886c -r 52c8dc8e7677 distrib/sets/lists/base/mi
--- a/distrib/sets/lists/base/mi        Sun Sep 15 17:37:25 2019 +0000
+++ b/distrib/sets/lists/base/mi        Sun Sep 15 19:38:08 2019 +0000
@@ -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
diff -r 1d85d1f5886c -r 52c8dc8e7677 distrib/sets/lists/etc/mi
--- a/distrib/sets/lists/etc/mi Sun Sep 15 17:37:25 2019 +0000
+++ b/distrib/sets/lists/etc/mi Sun Sep 15 19:38:08 2019 +0000
@@ -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
diff -r 1d85d1f5886c -r 52c8dc8e7677 distrib/sets/lists/man/mi
--- a/distrib/sets/lists/man/mi Sun Sep 15 17:37:25 2019 +0000
+++ b/distrib/sets/lists/man/mi Sun Sep 15 19:38:08 2019 +0000
@@ -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
diff -r 1d85d1f5886c -r 52c8dc8e7677 etc/defaults/rc.conf
--- a/etc/defaults/rc.conf      Sun Sep 15 17:37:25 2019 +0000
+++ b/etc/defaults/rc.conf      Sun Sep 15 19:38:08 2019 +0000
@@ -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 @@
 nsd=NO
 nsd_chrootdir=/var/chroot/nsd
 nsd_flags="-t ${nsd_chrootdir}"
+
+# ZFS
+zfs=NO
diff -r 1d85d1f5886c -r 52c8dc8e7677 etc/rc.d/Makefile
--- a/etc/rc.d/Makefile Sun Sep 15 17:37:25 2019 +0000
+++ b/etc/rc.d/Makefile Sun Sep 15 19:38:08 2019 +0000
@@ -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_xfs=        yes
 FILESBUILD_fccache= yes
 
+.if ${MKZFS} != "no"
+CONFIGFILES+=  zfs
+.endif
+
 .SUFFIXES: .in
 .in:
        ${_MKTARGET_CREATE}
diff -r 1d85d1f5886c -r 52c8dc8e7677 etc/rc.d/mountall
--- a/etc/rc.d/mountall Sun Sep 15 17:37:25 2019 +0000
+++ b/etc/rc.d/mountall Sun Sep 15 19:38:08 2019 +0000
@@ -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 @@
 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
diff -r 1d85d1f5886c -r 52c8dc8e7677 etc/rc.d/zfs
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/etc/rc.d/zfs      Sun Sep 15 19:38:08 2019 +0000
@@ -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"
diff -r 1d85d1f5886c -r 52c8dc8e7677 external/cddl/osnet/dist/cmd/zfs/zfs_main.c
--- a/external/cddl/osnet/dist/cmd/zfs/zfs_main.c       Sun Sep 15 17:37:25 2019 +0000
+++ b/external/cddl/osnet/dist/cmd/zfs/zfs_main.c       Sun Sep 15 19:38:08 2019 +0000
@@ -7135,8 +7135,13 @@
         * 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);
diff -r 1d85d1f5886c -r 52c8dc8e7677 external/cddl/osnet/sbin/zfs/Makefile
--- a/external/cddl/osnet/sbin/zfs/Makefile     Sun Sep 15 17:37:25 2019 +0000
+++ b/external/cddl/osnet/sbin/zfs/Makefile     Sun Sep 15 19:38:08 2019 +0000
@@ -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+= -lm -lutil -lpthread
 
+.PATH: ${.CURDIR}
 .PATH: ${ZFSDIR}/dist/cmd/zfs
 
 .include <bsd.prog.mk>
diff -r 1d85d1f5886c -r 52c8dc8e7677 external/cddl/osnet/sbin/zfs/mount_zfs.8
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/external/cddl/osnet/sbin/zfs/mount_zfs.8  Sun Sep 15 19:38:08 2019 +0000
@@ -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 .



Home | Main Index | Thread Index | Old Index