From f2c027bd6a003ec5793f8716e6189c389c60f47a Mon Sep 17 00:00:00 2001 From: Mariusz Zaborski Date: Thu, 20 Aug 2020 02:19:42 +0200 Subject: [PATCH] FreeBSD: Add option to rewind checkpoint while importing root pool This option is used by FreeBSD boot loader. Reviewed-by: Ryan Moeller Reviewed-by: Brian Behlendorf Signed-off-by: Mariusz Zaborski Closes #10738 --- include/os/freebsd/zfs/sys/zfs_context_os.h | 2 +- module/os/freebsd/zfs/spa_os.c | 5 ++++- module/os/freebsd/zfs/zfs_vfsops.c | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/include/os/freebsd/zfs/sys/zfs_context_os.h b/include/os/freebsd/zfs/sys/zfs_context_os.h index 7dd298564d..0a2f0bfaaa 100644 --- a/include/os/freebsd/zfs/sys/zfs_context_os.h +++ b/include/os/freebsd/zfs/sys/zfs_context_os.h @@ -87,5 +87,5 @@ typedef int fstrans_cookie_t; #define cv_wait_io(cv, mp) cv_wait(cv, mp) typedef struct opensolaris_utsname utsname_t; extern utsname_t *utsname(void); -extern int spa_import_rootpool(const char *name); +extern int spa_import_rootpool(const char *name, bool checkpointrewind); #endif diff --git a/module/os/freebsd/zfs/spa_os.c b/module/os/freebsd/zfs/spa_os.c index a84b8532ea..2bc78cb451 100644 --- a/module/os/freebsd/zfs/spa_os.c +++ b/module/os/freebsd/zfs/spa_os.c @@ -185,7 +185,7 @@ spa_generate_rootconf(const char *name) } int -spa_import_rootpool(const char *name) +spa_import_rootpool(const char *name, bool checkpointrewind) { spa_t *spa; vdev_t *rvd; @@ -244,6 +244,9 @@ spa_import_rootpool(const char *name) } spa->spa_is_root = B_TRUE; spa->spa_import_flags = ZFS_IMPORT_VERBATIM; + if (checkpointrewind) { + spa->spa_import_flags |= ZFS_IMPORT_CHECKPOINT; + } /* * Build up a vdev tree based on the boot device's label config. diff --git a/module/os/freebsd/zfs/zfs_vfsops.c b/module/os/freebsd/zfs/zfs_vfsops.c index 78968ed8d0..f94ea44335 100644 --- a/module/os/freebsd/zfs/zfs_vfsops.c +++ b/module/os/freebsd/zfs/zfs_vfsops.c @@ -1580,7 +1580,7 @@ zfs_mount(vfs_t *vfsp) error = getpoolname(osname, pname); if (error == 0) - error = spa_import_rootpool(pname); + error = spa_import_rootpool(pname, false); if (error) goto out; }