This patch makes OSv not to try to import extra ZFS (beyond the root one) unless specifically requested by passing new '--extra-zfs-pools' boot parameter.
This improves the OSv boot time with ZFS image by ~50% (around 200ms on QEMU - down from ~400ms, and ~40ms on firecracker - down from 60m). Signed-off-by: Waldemar Kozaczuk <jwkozac...@gmail.com> --- fs/vfs/main.cc | 6 ++++-- loader.cc | 12 +++++++++--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/fs/vfs/main.cc b/fs/vfs/main.cc index a5bbf087..6f224347 100644 --- a/fs/vfs/main.cc +++ b/fs/vfs/main.cc @@ -2358,7 +2358,7 @@ extern "C" int mount_rofs_rootfs(bool pivot_root) return 0; } -extern "C" void mount_zfs_rootfs(bool pivot_root) +extern "C" void mount_zfs_rootfs(bool pivot_root, bool extra_zfs_pools) { if (mkdir("/zfs", 0755) < 0) kprintf("failed to create /zfs, error = %s\n", strerror(errno)); @@ -2374,7 +2374,9 @@ extern "C" void mount_zfs_rootfs(bool pivot_root) pivot_rootfs("/zfs"); - import_extra_zfs_pools(); + if (extra_zfs_pools) { + import_extra_zfs_pools(); + } } extern "C" void unmount_rootfs(void) diff --git a/loader.cc b/loader.cc index 324d30c1..758e4bf9 100644 --- a/loader.cc +++ b/loader.cc @@ -86,7 +86,7 @@ extern "C" { void premain(); void vfs_init(void); void unmount_devfs(); - void mount_zfs_rootfs(bool); + void mount_zfs_rootfs(bool,bool); int mount_rofs_rootfs(bool); void rofs_disable_cache(); } @@ -125,6 +125,7 @@ int main(int loader_argc, char **loader_argv) sched::init([=] { main_cont(loader_argc, loader_argv); }); } +static bool opt_extra_zfs_pools = false; static bool opt_disable_rofs_cache = false; static bool opt_leak = false; static bool opt_noshutdown = false; @@ -178,7 +179,8 @@ static void usage() std::cout << " --delay=arg (=0) delay in seconds before boot\n"; std::cout << " --redirect=arg redirect stdout and stderr to file\n"; std::cout << " --disable_rofs_cache disable ROFS memory cache\n"; - std::cout << " --nopci disable PCI enumeration\n\n"; + std::cout << " --nopci disable PCI enumeration\n"; + std::cout << " --extra-zfs-pools import extra ZFS pools\n\n"; } static void handle_parse_error(const std::string &message) @@ -209,6 +211,10 @@ static void parse_options(int loader_argc, char** loader_argv) opt_disable_rofs_cache = true; } + if (extract_option_flag(options_values, "extra-zfs-pools")) { + opt_extra_zfs_pools = true; + } + if (extract_option_flag(options_values, "noshutdown")) { opt_noshutdown = true; } @@ -374,7 +380,7 @@ void* do_main_thread(void *_main_args) // // Failed -> try to mount zfs zfsdev::zfsdev_init(); - mount_zfs_rootfs(opt_pivot); + mount_zfs_rootfs(opt_pivot, opt_extra_zfs_pools); bsd_shrinker_init(); boot_time.event("ZFS mounted"); -- 2.20.1 -- You received this message because you are subscribed to the Google Groups "OSv Development" group. To unsubscribe from this group and stop receiving emails from it, send an email to osv-dev+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/osv-dev/20191222150433.10883-1-jwkozaczuk%40gmail.com.