kboot: Add support for ZFS volumes

Add the zfs device and filesystem to config and write the hook we need
to probe zfs since there's not a generic mechanism in place to do that
when ZFS is configured.

Sponsored by:		Netflix
Reviewed by:		kevans
Differential Revision:	https://reviews.freebsd.org/D38008
This commit is contained in:
Warner Losh 2023-01-13 14:20:40 -07:00
parent cc82c650a7
commit f20ecce33a
2 changed files with 23 additions and 0 deletions

View file

@ -33,6 +33,9 @@ __FBSDID("$FreeBSD$");
#if defined(LOADER_NET_SUPPORT)
#include "dev_net.h"
#endif
#ifdef LOADER_ZFS_SUPPORT
#include "libzfs.h"
#endif
extern struct devsw hostdisk;
extern struct devsw host_dev;
@ -55,6 +58,9 @@ struct devsw *devsw[] = {
&netdev,
#endif
&host_dev,
#if defined(LOADER_ZFS_SUPPORT)
&zfs_dev, /* Must be last */
#endif
NULL
};
@ -84,6 +90,9 @@ struct fs_ops *file_system[] = {
#endif
#if defined(LOADER_MSDOS_SUPPORT)
&dosfs_fsops,
#endif
#if defined(LOADER_ZFS_SUPPORT)
&zfs_fsops,
#endif
&hostfs_fsops,
NULL

View file

@ -46,6 +46,7 @@ ssize_t kboot_readin(readin_handle_t fd, vm_offset_t dest, const size_t len);
int kboot_autoload(void);
uint64_t kboot_loadaddr(u_int type, void *data, uint64_t addr);
static void kboot_kseg_get(int *nseg, void **ptr);
static void kboot_zfs_probe(void);
extern int command_fdt_internal(int argc, char *argv[]);
@ -160,6 +161,7 @@ main(int argc, const char **argv)
archsw.arch_autoload = kboot_autoload;
archsw.arch_loadaddr = kboot_loadaddr;
archsw.arch_kexec_kseg_get = kboot_kseg_get;
archsw.arch_zfs_probe = kboot_zfs_probe;
/* Give us a sane world if we're running as init */
do_init();
@ -380,6 +382,18 @@ kboot_kseg_get(int *nseg, void **ptr)
*ptr = &loaded_segments[0];
}
static void
kboot_zfs_probe(void)
{
#if defined(LOADER_ZFS_SUPPORT)
/*
* Open all the disks and partitions we can find to see if there are ZFS
* pools on them.
*/
hostdisk_zfs_probe();
#endif
}
/*
* Since proper fdt command handling function is defined in fdt_loader_cmd.c,
* and declaring it as extern is in contradiction with COMMAND_SET() macro