openzfs / zfs

OpenZFS on Linux and FreeBSD
https://openzfs.github.io/openzfs-docs
Other
10.42k stars 1.72k forks source link

Snapshots range with zfs holds #13306

Open rightaway opened 2 years ago

rightaway commented 2 years ago

Describe the feature would like to see added to OpenZFS

zfs holds should allow the same % notation like zfs destroy, so zfs holds pool/dataset@% should show holds for all snapshots just like zfs destroy pool/dataset@% destroys all snapshots.

How will this feature improve OpenZFS?

When tags are used with replication the most common pattern is create a tag from the last replication snapshot and remove the tag from the previous one. But when resuming a replication with receive_resume_token there's no way to tell which both of those snapshots were, so you don't know what to run zfs release on. To find out which one you have to pass a list of all the snapshots to zfs holds, but how many you can pass is limited by the shell. Or you can run zfs holds for every snapshot which is inefficient and slow especially if it's over ssh.

And it will be useful when zfs release fails for any reason like due to a bad ssh connection. Since zfs hold and zfs release can't be combined into an atomic operation there are times when you'll have a leftover tag that you don't know about, and replication will fail in the future when it tries to destroy a snapshot with a tag on it. By passing a range with % you can efficiently see the holds on all snapshots you're interested in and do clean up if necessary.

Additional context

It will make zfs holds more consistent with zfs destroy.

dawidmachon commented 10 months ago

+1 fot this