From 5f1984f2f83624b30dbdaa5d906a6253d78efb66 Mon Sep 17 00:00:00 2001 From: Matthew Macy Date: Mon, 17 Aug 2020 14:43:47 -0700 Subject: [PATCH] FreeBSD: fallback to /boot/ to look for zpool.cache Up until now zpool.cache has always lived in /boot on FreeBSD. For the sake of compatibility fallback to /boot if zpool.cache isn't found in /etc/zfs. Reviewed-by: Brian Behlendorf Signed-off-by: Matt Macy Closes #10720 --- include/sys/fs/zfs.h | 2 +- module/zfs/spa_config.c | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/include/sys/fs/zfs.h b/include/sys/fs/zfs.h index 07c277622..001893b71 100644 --- a/include/sys/fs/zfs.h +++ b/include/sys/fs/zfs.h @@ -829,8 +829,8 @@ typedef struct zpool_load_policy { * The location of the pool configuration repository, shared between kernel and * userland. */ +#define ZPOOL_CACHE_BOOT "/boot/zfs/zpool.cache" #define ZPOOL_CACHE "/etc/zfs/zpool.cache" - /* * vdev states are ordered from least to most healthy. * A vdev that's CANT_OPEN or below is considered unusable. diff --git a/module/zfs/spa_config.c b/module/zfs/spa_config.c index b30c65e71..95dd19844 100644 --- a/module/zfs/spa_config.c +++ b/module/zfs/spa_config.c @@ -100,6 +100,10 @@ spa_config_load(void) err = zfs_file_open(pathname, O_RDONLY, 0, &fp); +#ifdef __FreeBSD__ + if (err) + err = zfs_file_open(ZPOOL_CACHE_BOOT, O_RDONLY, 0, &fp); +#endif kmem_free(pathname, MAXPATHLEN); if (err)