ZFS ensure_filesystem call may race with `zfs list` and `zfs create`

Open
#3,535 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
55/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
rust

Research direction

Start in illumos-utils/src/zfs.rs at ensure_filesystem and trace its use of dataset_exists before invoking ZFS commands. Confirm the ZFS create behavior described in the issue, then verify that completion is successful when the filesystem or its parents already exist without the prior existence check.

Written by the indexing model from the issue text.

Description

Good for new hires

The utility function ensure_filesystem in the illumos-utils ZFS code has the intention of creating a ZFS fileysystem, unless it already exists. It first performs a zfs list via dataset_exists, then a zfs create. This is inherently racy. The zfs create command has a -p flag that will give us the behavior we want here:

       -p  Creates all the non-existing parent datasets.  Datasets created in
           this manner are automatically mounted according to the mountpoint
           property inherited from their parent.  Any property specified on
           the command line using the -o option is ignored.  If the target
           filesystem already exists, the operation completes successfully.

We should switch to using zfs create -p here instead of listing the datasets first.

Per @smklein, this probably isn't a problem yet because we tend to have singletons controlling filesystem allocation. So probably not high priority for now.

Dominant language
Rust
Stars
572
Forks
97
Avg merge
2d 12h
Merged PRs (30d)
96

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from oxidecomputer/omicron

All issues in oxidecomputer/omicron

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.