From 1fb18c4bdea7442cb94320ee293fea8d3e08a706 Mon Sep 17 00:00:00 2001 From: grembo Date: Tue, 1 Jun 2021 23:03:49 +0200 Subject: [PATCH] FreeBSD boot code reminder after zpool upgrade There used to be a warning after upgrading a zpool in FreeBSD, so users won't forget to update the boot loader that pool is booted from. This change brings this warning back, but only if the bootfs property is set on the pool, which should be sufficient for the vast majority of FreeBSD installations. People running something custom are most likely aware of what to do after an upgrade in their specific environment. Functionality is implemented in an OS specific helper function. Reviewed-by: John Kennedy Reviewed-by: Ryan Moeller Co-authored-by: Michael Gmelin Signed-off-by: Michael Gmelin Closes #12099 Closes #12104 --- cmd/zpool/os/freebsd/zpool_vdev_os.c | 15 +++++++++++++++ cmd/zpool/os/linux/zpool_vdev_os.c | 5 +++++ cmd/zpool/zpool_main.c | 22 ++++++++++++---------- cmd/zpool/zpool_util.h | 1 + 4 files changed, 33 insertions(+), 10 deletions(-) diff --git a/cmd/zpool/os/freebsd/zpool_vdev_os.c b/cmd/zpool/os/freebsd/zpool_vdev_os.c index 7d48f61a0e..aa66d29fa6 100644 --- a/cmd/zpool/os/freebsd/zpool_vdev_os.c +++ b/cmd/zpool/os/freebsd/zpool_vdev_os.c @@ -101,3 +101,18 @@ check_sector_size_database(char *path, int *sector_size) { return (0); } + +void +after_zpool_upgrade(zpool_handle_t *zhp) +{ + char bootfs[ZPOOL_MAXPROPLEN]; + + if (zpool_get_prop(zhp, ZPOOL_PROP_BOOTFS, bootfs, + sizeof (bootfs), NULL, B_FALSE) == 0 && + strcmp(bootfs, "-") != 0) { + (void) printf(gettext("Pool '%s' has the bootfs " + "property set, you might need to update\nthe boot " + "code. See gptzfsboot(8) and loader.efi(8) for " + "details.\n"), zpool_get_name(zhp)); + } +} diff --git a/cmd/zpool/os/linux/zpool_vdev_os.c b/cmd/zpool/os/linux/zpool_vdev_os.c index 55a9367ec1..da87aa79f3 100644 --- a/cmd/zpool/os/linux/zpool_vdev_os.c +++ b/cmd/zpool/os/linux/zpool_vdev_os.c @@ -405,3 +405,8 @@ check_device(const char *path, boolean_t force, return (error); } + +void +after_zpool_upgrade(zpool_handle_t *zhp) +{ +} diff --git a/cmd/zpool/zpool_main.c b/cmd/zpool/zpool_main.c index d7d93c4da3..c915703c09 100644 --- a/cmd/zpool/zpool_main.c +++ b/cmd/zpool/zpool_main.c @@ -8858,7 +8858,7 @@ upgrade_cb(zpool_handle_t *zhp, void *arg) upgrade_cbdata_t *cbp = arg; nvlist_t *config; uint64_t version; - boolean_t printnl = B_FALSE; + boolean_t modified_pool = B_FALSE; int ret; config = zpool_get_config(zhp, NULL); @@ -8872,7 +8872,7 @@ upgrade_cb(zpool_handle_t *zhp, void *arg) ret = upgrade_version(zhp, cbp->cb_version); if (ret != 0) return (ret); - printnl = B_TRUE; + modified_pool = B_TRUE; /* * If they did "zpool upgrade -a", then we could @@ -8892,12 +8892,13 @@ upgrade_cb(zpool_handle_t *zhp, void *arg) if (count > 0) { cbp->cb_first = B_FALSE; - printnl = B_TRUE; + modified_pool = B_TRUE; } } - if (printnl) { - (void) printf(gettext("\n")); + if (modified_pool) { + (void) printf("\n"); + (void) after_zpool_upgrade(zhp); } return (0); @@ -9010,7 +9011,7 @@ upgrade_list_disabled_cb(zpool_handle_t *zhp, void *arg) static int upgrade_one(zpool_handle_t *zhp, void *data) { - boolean_t printnl = B_FALSE; + boolean_t modified_pool = B_FALSE; upgrade_cbdata_t *cbp = data; uint64_t cur_version; int ret; @@ -9038,7 +9039,7 @@ upgrade_one(zpool_handle_t *zhp, void *data) } if (cur_version != cbp->cb_version) { - printnl = B_TRUE; + modified_pool = B_TRUE; ret = upgrade_version(zhp, cbp->cb_version); if (ret != 0) return (ret); @@ -9051,7 +9052,7 @@ upgrade_one(zpool_handle_t *zhp, void *data) return (ret); if (count != 0) { - printnl = B_TRUE; + modified_pool = B_TRUE; } else if (cur_version == SPA_VERSION) { (void) printf(gettext("Pool '%s' already has all " "supported and requested features enabled.\n"), @@ -9059,8 +9060,9 @@ upgrade_one(zpool_handle_t *zhp, void *data) } } - if (printnl) { - (void) printf(gettext("\n")); + if (modified_pool) { + (void) printf("\n"); + (void) after_zpool_upgrade(zhp); } return (0); diff --git a/cmd/zpool/zpool_util.h b/cmd/zpool/zpool_util.h index abaa22d78c..493f8cb980 100644 --- a/cmd/zpool/zpool_util.h +++ b/cmd/zpool/zpool_util.h @@ -129,6 +129,7 @@ int check_device(const char *path, boolean_t force, boolean_t check_sector_size_database(char *path, int *sector_size); void vdev_error(const char *fmt, ...); int check_file(const char *file, boolean_t force, boolean_t isspare); +void after_zpool_upgrade(zpool_handle_t *zhp); #ifdef __cplusplus }