-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reminder to update boot code after zpool upgrade #12104
Conversation
The problem with displaying this message on Linux is that, often, there's not an update available, you just shouldn't enable those features on a pool you boot from. |
In #12099 @allanjude suggested to only show the message if |
You may find the discussion around #8627 relevant. |
Technically, the FreeBSD boot loader doesn't need bootfs either. In general, it seems like this is more important to FreeBSD users, where it's quite common to have a single zroot pool and a boot loader that is updated on every release, than it is to Linux users. So in that respect, this could easily be solved by using |
Honestly, I'd prefer it if there were a nice way to detect and warn people trying to run unconstrained Failing that, I'd prefer it if Given the above, and that I doubt a patch to warn and exit (or even wait a few seconds without passing a flag) would be accepted, I think just not printing it on Linux probably makes the most sense, since "hey btw you may have just ruined your system boot irreversibly (without remaking the pool)" seems unhelpful at best and cruel at worst. |
@rincebrain Thanks for making me smile :) I updated the patch, so the warning only shows up on FreeBSD. Being OS specific, it now also points the user to the two most relevant man pages on how to accomplish updating the boot loader. |
Isn't that the scenario the |
That only helps once people are running 2.1 and, for historical users, if they explicitly go set it on their bpool. |
82eec0e
to
94ea556
Compare
Note: buildbot/FreeBSD main amd64 (TEST) seems to have an unrelated problem at the moment. Checkstyle pending, since I cleaned the commit message yesterday (squashed + shortened + signed-by + force push). |
The two places you've added this message are identical, would you mind factoring that out into one static helper function please? That way we can just ifdef freebsd the body of the function, reducing the number of ifdefs we have to add. Something like static void
show_upgrade_warnings(zpool_handle_t *zhp)
{
#ifdef __FreeBSD__
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("\nPool '%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));
}
#else
(void) printf("\n");
#endif
} |
or move this print per platform because we'd like to do the same for DilOS and add |
I thought about this too, but didn't do it yet, as it seemed like those two functions are kept completely separate on purpose, but are overlapping in functionality a lot. If you diff them, you wonder if it would make more sense to have a static helper function to perform most of what they do (and get rid of the duplicate #ifdef that way): --- /tmp/upgrade_one 2021-05-26 16:10:12.476405000 +0200
+++ /tmp/upgrade_cb 2021-05-26 16:10:27.861114000 +0200
@@ -1,52 +1,44 @@
static int
-upgrade_one(zpool_handle_t *zhp, void *data)
+upgrade_cb(zpool_handle_t *zhp, void *arg)
{
+ upgrade_cbdata_t *cbp = arg;
+ nvlist_t *config;
+ uint64_t version;
boolean_t modified_pool = B_FALSE;
- upgrade_cbdata_t *cbp = data;
- uint64_t cur_version;
int ret;
- if (strcmp("log", zpool_get_name(zhp)) == 0) {
- (void) fprintf(stderr, gettext("'log' is now a reserved word\n"
- "Pool 'log' must be renamed using export and import"
- " to upgrade.\n"));
- return (1);
- }
-
- cur_version = zpool_get_prop_int(zhp, ZPOOL_PROP_VERSION, NULL);
- if (cur_version > cbp->cb_version) {
- (void) printf(gettext("Pool '%s' is already formatted "
- "using more current version '%llu'.\n\n"),
- zpool_get_name(zhp), (u_longlong_t)cur_version);
- return (0);
- }
+ config = zpool_get_config(zhp, NULL);
+ verify(nvlist_lookup_uint64(config, ZPOOL_CONFIG_VERSION,
+ &version) == 0);
- if (cbp->cb_version != SPA_VERSION && cur_version == cbp->cb_version) {
- (void) printf(gettext("Pool '%s' is already formatted "
- "using version %llu.\n\n"), zpool_get_name(zhp),
- (u_longlong_t)cbp->cb_version);
- return (0);
- }
+ assert(SPA_VERSION_IS_SUPPORTED(version));
- if (cur_version != cbp->cb_version) {
- modified_pool = B_TRUE;
+ if (version < cbp->cb_version) {
+ cbp->cb_first = B_FALSE;
ret = upgrade_version(zhp, cbp->cb_version);
if (ret != 0)
return (ret);
+ modified_pool = B_TRUE;
+
+ /*
+ * If they did "zpool upgrade -a", then we could
+ * be doing ioctls to different pools. We need
+ * to log this history once to each pool, and bypass
+ * the normal history logging that happens in main().
+ */
+ (void) zpool_log_history(g_zfs, history_str);
+ log_history = B_FALSE;
}
if (cbp->cb_version >= SPA_VERSION_FEATURES) {
- int count = 0;
+ int count;
ret = upgrade_enable_all(zhp, &count);
if (ret != 0)
return (ret);
- if (count != 0) {
+ if (count > 0) {
+ cbp->cb_first = B_FALSE;
modified_pool = B_TRUE;
- } else if (cur_version == SPA_VERSION) {
- (void) printf(gettext("Pool '%s' already has all "
- "supported and requested features enabled.\n"),
- zpool_get_name(zhp));
}
} Another question is, if reading |
@ikozhukhov @freqlabs Well, it's not just a print, but also a check. I also noticed that my code doesn't println("\n") in case the pool wasn't modified (but I have to touch it again anyway). What about this logic in the functions in if (modified_pool) {
after_zpool_upgrade_check(zhp);
println("\n");
} This would broaden the scope of the review a lot though. |
Sure, the name was just the first thing that popped into my head. Factoring even more out seems a bit more cumbersome, I'm not sure if that's worth it. |
I forgot we had platform specific subdirectories in cmd/zpool/os, that's definitely the way to go. |
I moved this to os specific files now. Open question:
|
@freqlabs Thank you for taking the time to review. Is there anything else I should do (e.g., squash and force-push), or will all of this be handled when (and if) the pull request is merged? |
Yes, please do squash to a single commit. Thank you for your contribution! |
There used to be a warning after upgrading a zpool in FreeBSD, so users won't forget to updating the boot loader in case 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. Closes openzfs#12099 Signed-off-by: Michael Gmelin <grembo@FreeBSD.org>
e4b2300
to
72e48ee
Compare
zloop/tests failure seems unrelated:
|
@freqlabs On the FreeBSD-current mailing list, @bsdimp writes:
What is the best way to approach this without causing a lot of extra effort (given, that this change is *bsd only)? |
@grembo I expect @behlendorf will pull this into the zfs-2.1-release branch, which is what we'll be pulling into FreeBSD stable/13 and eventually releng when the processes for that are ready. |
I'm trying to get the final few items into place... |
@freqlabs @bsdimp Cool, thanks for your quick responses. |
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 <john.kennedy@delphix.com> Reviewed-by: Ryan Moeller <ryan@iXsystems.com> Co-authored-by: Michael Gmelin <grembo@FreeBSD.org> Signed-off-by: Michael Gmelin <grembo@FreeBSD.org> Closes openzfs#12099 Closes openzfs#12104
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 <john.kennedy@delphix.com> Reviewed-by: Ryan Moeller <ryan@iXsystems.com> Co-authored-by: Michael Gmelin <grembo@FreeBSD.org> Signed-off-by: Michael Gmelin <grembo@FreeBSD.org> Closes openzfs#12099 Closes openzfs#12104
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 <john.kennedy@delphix.com> Reviewed-by: Ryan Moeller <ryan@iXsystems.com> Co-authored-by: Michael Gmelin <grembo@FreeBSD.org> Signed-off-by: Michael Gmelin <grembo@FreeBSD.org> Closes openzfs#12099 Closes openzfs#12104
Motivation and Context
In FreeBSD there used to be a warning after upgrading a zpool, so users won't forget about updating the boot loader in case that pool is booted from.
As I've been told that this is also a problem on (at least some) Linux distributions, this patch aims to bring this warning back in a more generic form, that should apply to all systems.Update: Code review resulted in me changing the patch to only display the reminder on FreeBSDAims to address #12099.
See also:
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=256024
Description
When running
zpool upgrade
, check if the pool was actually touched/modified. If so, print a warning for the user not to forget to update the boot code. Re-purposed the existingprintnl
flag in the two affected functions.Update: Only check on FreeBSD and show the warning only if the bootfs property is set on the pool.
How Has This Been Tested?
Manually on FreeBSD 13, by creating a couple of testpools of an older version in images files, "connecting" them using
mdconfig
and importing them into the system. Then run various combinations ofzpool upgrade
to make sure the warning only shows up when intended.Before:
Afterwards:
Also works when upgrading all pools (-a):
And stays silent in case nothing has been upgraded:
Types of changes
Checklist:
Signed-off-by
.