Page MenuHomeFreeBSD

bsdinstall: fix prepopulating the ZFS disk menu with ZFSBOOT_DISKS
ClosedPublic

Authored by dteske on May 26 2022, 10:22 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Apr 26, 6:29 AM
Unknown Object (File)
Fri, Apr 26, 5:52 AM
Unknown Object (File)
Fri, Apr 26, 5:52 AM
Unknown Object (File)
Fri, Apr 26, 5:52 AM
Unknown Object (File)
Fri, Apr 26, 5:52 AM
Unknown Object (File)
Fri, Apr 26, 5:52 AM
Unknown Object (File)
Thu, Apr 25, 9:40 PM
Unknown Object (File)
Apr 2 2024, 7:40 AM
Subscribers

Details

Summary

If the ZFSBOOT_DISKS variable is set to one or more disk names, then
those disks should be preselected in the disk menu. However, the code
wasn't correctly setting the variable, leaving all disks unselected.

MFC after: 2 weeks
Sponsored by: Axcient

Test Plan

manually tested

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

dteske requested changes to this revision.May 26 2022, 10:26 PM

The change to use f_isset in 2 places is a good one, thank you. However, I have issue with the removal of the call to "local" above the second hunk.

usr.sbin/bsdinstall/scripts/zfsboot
670–672

As the comment states above this block, "create temporary locals"

The "f_isset ... || local ..." should remain (and not be removed) while I do agree with the latter part of fixing the ...=... to use setvar since it requires indirection to set.

This revision now requires changes to proceed.May 26 2022, 10:26 PM
  • Restore local variable declaration
This revision is now accepted and ready to land.May 26 2022, 11:41 PM

Do you need me to commit this or do you have a venue/access?

Do you need me to commit this or do you have a venue/access?

I'll commit it myself. Thanks for the prompt review.

This is not what I wanted. The second diff (that I prematurely accepted) that you committed omits the f_isset call

dteske requested changes to this revision.May 27 2022, 9:23 PM
dteske added inline comments.
usr.sbin/bsdinstall/scripts/zfsboot
670–673

This is not correct.

This introduces a memory leak. I am sorry that I approved it, and that was premature. I thought you had committed my suggestion which retains the f_isset test.

The fact is, that "local" should NEVER be used to declare-local a variable that is already local because it leaks memory.

I had not realized you removed the f_isset before I approved.

This revision now requires changes to proceed.May 27 2022, 9:23 PM
dteske edited reviewers, added: asomers; removed: dteske.
This revision now requires review to proceed.May 27 2022, 9:24 PM

Fix a memory leak introduced by previous commit.

Oh, sorry about that. I'll commit the fix. I didn't even realize that it was possible to leak memory in sh.

This revision was not accepted when it landed; it landed in state Needs Review.May 28 2022, 7:19 PM
This revision was automatically updated to reflect the committed changes.

Oh, sorry about that. I'll commit the fix. I didn't even realize that it was possible to leak memory in sh.

Thank you so much.

The quickest way to see this memory leak in action is to:

  1. Execute top, press "o", type "size", press ENTER (to sort on SIZE column)
  2. In another shell, execute: sh -c '_(){ while :;do local a; done; };_'
  3. Observe the SIZE column as the "sh" rises to the top
  4. Press Ctrl-C to kill the sh