Skip to content

CP-11462 ZOA infrastructure for snapshot reference and hold management#121

Open
lyriclake wants to merge 3 commits into
delphix:masterfrom
lyriclake:master
Open

CP-11462 ZOA infrastructure for snapshot reference and hold management#121
lyriclake wants to merge 3 commits into
delphix:masterfrom
lyriclake:master

Conversation

@lyriclake
Copy link
Copy Markdown

Problem

ZOA's snapshot reference-tracking work (CP-11226 / "remote provisioning")
needs a read-only enumeration from the kernel that no existing
libzfs_core symbol provides:

List every snapshot in a pool that carries the
DS_FIELD_SNAPSHOT_REFERENCE ZAP entry, along with its guid and
sender-assigned ref_id. The child reconciler uses this to recover
missing recv-refs and write missing delete-refs.

The corresponding C symbol lzc_get_snapshot_refs is added in
delphix/zfs CP-11462: https://github.com/delphix/zfs/pull/2232. This PR is the matching rust-libzfs side: without
a safe wrapper ZOA cannot call it.

Solution

Add an FFI declaration for lzc_get_snapshot_refs in
zfs-core-sys/src/bindings.rs, plus a matching safe wrapper in
zfs-core/src/lib.rs:

  • Zfs::get_snapshot_refs(fsname) returns a SnapshotRefList whose
    IntoIterator yields SnapshotRef { name, guid, ref_id } triples.

The list type mirrors the shape of the existing HoldList /
HoldListIter pair. The binding is hand-added rather than regenerated
so this PR doesn't churn unrelated bindgen output; the next regen
against an updated libzfs_core.h will pick it up identically because
generate-bindings already whitelists lzc_.*.

Bumps zfs-core and zfs-core-sys to 0.5.1-delphix0.

Testing Done

  • LIBZFS_CORE_LOOKUP_WITH=link cargo check -p zfs-core — clean.
    (The 11 warnings emitted are pre-existing #[cfg(features = ...)]
    typos, untouched by this PR.)
  • Live FFI smoke tested on a Delphix VM with the delphix/zfs CP-11462 build:
    zfs_object_agent list-snapshot-refs child-pool returned one entry with the expected (guid, ref_id)
    after a layered send/recv. The all-pools form (zfs_object_agent list-snapshot-refs with no args,
    using zpool list enumeration) also returned the same entry correctly.
  • No automated tests added in this PR. The wrapper is a thin
    pass-through over the C function plus standard nvlist
    destructuring; the meaningful coverage lives in the kernel side
    and in the consuming reconcilers in zettaobject (CP-11226).

lyriclake and others added 3 commits May 6, 2026 16:07
Adds Rust bindings and safe wrappers for two new libzfs_core symbols
introduced in delphix/zfs CP-11462:

- lzc_list_snapshot_refs: enumerates snapshots in a pool that carry the
  DS_FIELD_SNAPSHOT_REFERENCE ZAP entry, returning each snapshot's guid
  and sender-assigned ref_id. Used by ZOA's child reconciler to recover
  missing recv-refs and write missing delete-refs.

- lzc_list_pool_holds: enumerates user holds across every snapshot in a
  pool, optionally filtered by tag prefix. Used by ZOA's parent
  reconciler with prefix "snapref:" to find and release orphaned holds.

The safe wrappers (Zfs::list_snapshot_refs, Zfs::list_pool_holds)
mirror the existing HoldList iterator pattern. PoolHoldList flattens
the kernel's two-level snap -> { tag -> time } map into a
(snap, tag, created_at) iterator.

Bumps zfs-core and zfs-core-sys to 0.5.1-delphix0.
delphix/rust-libzfs does not have lzc_list_pool_holds in its ZFS kernel
interface, so remove the sys binding and the Rust wrapper.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant