truenas / py-libzfs

Python libzfs bindings

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Dataset property 'mounted' not updated after mount()

1pav opened this issue · comments

commented

After successfully mounting a ZFS dataset, the value of its 'mounted' property doesn't get updated from 'no' to 'yes'.

I think this is a bug, but if it's an expected behaviour, please close this issue.

Here's a minimal working example to demonstrate the issue:

#!/usr/bin/env python3

from libzfs import ZFS, DatasetType

zfs = ZFS()
pool = zfs.get("tank")
ds_name = "tank/mydataset"

# Create dataset
pool.create(ds_name, {}, fstype=DatasetType.FILESYSTEM, sparse_vol=False, create_ancestors=False)
ds = zfs.get_dataset(ds_name)

# Print 'mounted' property before mount
print(f"BEFORE mount: ds.properties['mounted'].value = {ds.properties['mounted'].value}")

# Mount dataset
ds.mount()

# Optional: force properties refresh
ds.properties['mounted'].refresh()
ds.properties.refresh()

# Print 'mounted' property after mount
print(f"AFTER mount:  ds.properties['mounted'].value = {ds.properties['mounted'].value}")

The output is the following:

BEFORE mount: ds.properties['mounted'].value = no
AFTER mount:  ds.properties['mounted'].value = no

I'm not even sure if those refresh() methods actually do what I think they do, but I added them anyway. Even so, they don't seem to affect the 'mounted' property state.

I can reproduce the issue in the following environment:

  • OS: Rocky Linux 8.8
  • Python: 3.8.16
  • py-libzfs: built from 'master' (commit 91dcc96)
  • ZFS: 2.1.12 (kABI-tracking kmod) (installed from here)