Skip to content

zfs mount -l -a is failing to mount datasets where the encryption root is another dataset #11870

@Davis-A

Description

@Davis-A

System information

Type Version/Name
Distribution Name Debian
Distribution Version Buster/10
Linux Kernel Debian 5.10.19
Architecture x86_64
ZFS Version 2.0.4-1
SPL Version 2.0.4-1

Describe the problem you're observing

zfs mount -l -a returns an error when trying to mount datasets where encryptionroot is a parent dataset

Here are my datasets

# zfs list
NAME           USED  AVAIL     REFER   MOUNTPOINT
tank           3.11G  18.7G     3.10G  /tank
tank/slot2     192K  4.00G      192K   /slot2
tank/slot4     192K  4.00G      192K   /slot4

The encryption setup; tank is encrypted and the child datasets slot2 and slot4 inherit its encryption, example here (note: this was run before loading the key)

# zfs get all tank/slot2 | grep "key\|encryption\|pass"
tank/slot2  encryption            aes-256-gcm            -
tank/slot2  keylocation           none                   default
tank/slot2  keyformat             passphrase             -
tank/slot2  encryptionroot        tank                   -
tank/slot2  keystatus             unavailable            -

What happens when i run zfs mount -l -a

# zfs mount -l -a
Key load error: Keys must be loaded for encryption root of 'tank/slot2' (tank).
Key load error: Keys must be loaded for encryption root of 'tank/slot4' (tank).

tank mounts and running zfs mount -a again (with our without -l) the child datasets mount.

Perhaps some kind of race between loading the key/mounting the tank and then trying to mount the child datasets?

Describe how to reproduce the problem

Create a pool where encryption is set at pool creation time eg

  -O encryption=on \
  -O keylocation=file:///etc/zfs.key \
  -O keyformat=passphrase \

Then create child datasets
EDIT: You also have to set the child dataset mountpoints so they are no longer below their encryption root

zfs create -o mountpoint=/foo tank/foo
zfs create -o mountpoint=/bar tank/bar

Bounce the machine then run zfs mount -l -a

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type: DefectIncorrect behavior (e.g. crash, hang)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions