Skip to content

ZFS ensure_filesystem call may race with zfs list and zfs create #3535

@jordanhendricks

Description

@jordanhendricks

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issueIssues that are good for learning the codebase

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions