Skip to content

sled-agent / illumos-utils: refactor PathInPool - #11495

Merged
jgallagher merged 8 commits into
mainfrom
john/path-in-pool-refactor
Oct 20, 2026
Merged

jgallagher merged 8 commits into
mainfrom
john/path-in-pool-refactor

Conversation

@jgallagher

Copy link
Copy Markdown
Contributor

(This is stacked on top of #11492.)

I thought about opening this as a stack of PRs, but the total diff is still pretty small and mostly churns on itself, so instead it's just one PR with a stack of commits. Feel free to review those individually if "how did we get from A to B" is useful.

The major changes are:

  • RunningZone::root_zpool() is gone. The two callers of this (the instance and probe managers in sled-agent) now remember the zpool they chose for the zones they start.
  • illumos-util's zone-starting functions now take the zone root path as a Utf8PathBuf instead of a PathInPool. (illumos-utils itself only ever needed the path, except to return the pool in root_zpool(), which is now removed.)
  • PathInPool::pool is now a ZpoolName, not a ZpoolOrRamdisk. ZpoolOrRamdisk is removed. This let us drop some awkward "what if we have a zone on a ramdisk that can never be on a ramdisk in practice" handling bits in a few different places.

@jgallagher
jgallagher requested review from bnaecker and hawkw October 14, 2026 19:00

@bnaecker bnaecker left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, makes more sense that the instance's pool is never optional. Thanks!

@hawkw

hawkw commented Oct 14, 2026

Copy link
Copy Markdown
Member

@jgallagher while I'm in favor of this change overall, I think I'd rather it be based on #11497 rather than #11492, since I'm hoping we can use that approach for terminating the Propolis zone when the zpool goes away.

pub struct PathInPool {
pub pool: ZpoolName,
pub path: Utf8PathBuf,
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we might consider making the fields private, and having a constructor that validates that the path actually is in the pool. But, that might make the existing uses of this kinda painful, so I dunno...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I had both of those same thoughts too. I know the consumers of this end up destructuring it to get path without cloning, but I guess it could have an .into_parts() that returned both fields too? I'll give this a whirl after rebasong onto #11497.

@jgallagher
jgallagher force-pushed the john/path-in-pool-refactor branch from 9c5079f to 286a167 Compare October 15, 2026 16:57
…disk`

`illumos-utils` supports running zones with a root filesystem on a zpool
(most zones) or a ramdisk (the switch zone). Prior to this change, it
exposed a `PathInPool` type that could represent both. That type was
used in several places where the only possible value was "on a zpool",
but the type still allowed the representation of "on a ramdisk".

This change adds a second type, `PathInPoolOrRamdisk`, and reserves
`PathInPool` for those spots where we know the only option is "on a
zpool".
This returned a `ZpoolOrRamdisk`, but its only two callers (sled-agent's
instance and probe manager subsystems) only ever start zones on zpools.
They now remember which zpool they picked and no longer call this
method, allowing us to delete it and removing the internal
unrepresentable state of "an instance or probe with a root on a
ramdisk".
This formerly took a struct containing the path and its parent zpool,
but we no longer need the parent zpool. Take the path directly.
@jgallagher
jgallagher force-pushed the john/path-in-pool-refactor branch from 286a167 to 119267d Compare October 15, 2026 16:58
@jgallagher
jgallagher changed the base branch from eliza/filesystem-zpool-setonce to main October 15, 2026 16:59
@jgallagher

Copy link
Copy Markdown
Contributor Author

Ok, this is rebased onto main after the #11497 merge and ready for another look. I had to touch up the instance unit tests a bit to keep them from terminating themselves due to no zpools being available from our fake setup, and 6825e4b makes the fields of PathInPool private. Other bits are basically the same as before.

@jgallagher
jgallagher requested a review from hawkw October 15, 2026 17:01

@hawkw hawkw left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry it took me a minute to review this one, but this looks great --- it's nice to see a bunch of error variants being removed because they're now unrepresentable!

&self.path
}

pub fn into_path(self) -> Utf8PathBuf {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose we don't really need an into_parts that returns both because ZpoolName is Copy and you can just get it from pool() first?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, exactly 👍

Comment on lines -219 to +218
_zpool_monitor_handle: Option<AbortOnDropHandle<()>>,
_zpool_monitor_handle: AbortOnDropHandle<()>,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yay!

@jgallagher
jgallagher merged commit 0b0721f into main Oct 20, 2026
19 checks passed
@jgallagher
jgallagher deleted the john/path-in-pool-refactor branch October 20, 2026 21:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants