Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'zfs destroy -r' of parent dataset destroys clones of subdatasets, while destroy -r of subdataset throws error/prompts to use -R #17050

Open
maanloper opened this issue Feb 12, 2025 · 5 comments
Labels
Type: Defect Incorrect behavior (e.g. crash, hang)

Comments

@maanloper
Copy link

System information

Type Version/Name
OpenZFS Version zfs-2.2.2-0ubuntu9.1, zfs-kmod-2.2.2-0ubuntu9.1

Describe the problem you're observing

zfs destroy -r pool/dataset will happily destroy pool/dataset/subdataset when it has clones, while zfs destroy -r pool/dataset/subdataset will not destroy the dataset, with the warning that it has clones and -R has to be used to destroy the dataset.

Describe how to reproduce the problem

  1. Create a pool, with pool/dataset and pool/dataset/subdataset
  2. Take a recursive snapshot of the pool: zfs snapshot -r pool@snapshot
  3. Create a clone: zfs clone pool/dataset/subdataset@snapshot pool/dataset/cloneofsubdataset
  4. Try to destroy pool/dataset/subdataset: zfs destroy -r pool/dataset/subdataset. This will throw an error and prompting to use -R.
  5. Try to destroy pool/dataset: zfs destroy -r pool/dataset and observe how it happily destroys both pool/dataset and pool/dataset/subdataset

Shouldn't the behaviour be consistent whether it concerns the dataset or any of its parents?

@maanloper maanloper added the Type: Defect Incorrect behavior (e.g. crash, hang) label Feb 12, 2025
@scineram
Copy link

  1. What is problem? Why wouldn't it destroy the whole hierarchy?

@maanloper
Copy link
Author

Because there is a difference in behaviour for the same command depending if it is executed directly on a dataset or on its parent?

@scineram
Copy link

RTM

@maanloper
Copy link
Author

RTM

I'm unfamiliar with that abbreviation, what does it mean?

@pcd1193182
Copy link
Contributor

pcd1193182 commented Feb 14, 2025

-R  Recursively  destroy  all dependents, including cloned file systems outside the
             target hierarchy.
...

-r  Recursively destroy all children.
  1. cloneofsubdataset is not a child of subdataset, it's a clone, which in this case is a dependent outside of the heirarchy of subdataset. Thus, -r fails and directs you to -R.
  2. cloneofsubdataset and subdataset are both children of dataset, so -r destroys them all. None of the dependents are outside of the heirarchy, so it doesn't complain.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Defect Incorrect behavior (e.g. crash, hang)
Projects
None yet
Development

No branches or pull requests

3 participants