Skip to content

zfs destroy's and zfs rollback's error messages do not list blocking snapshots sorted #12751

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

Open
ChristophSchmidpeter opened this issue Nov 11, 2021 · 4 comments · May be fixed by #17264
Open
Labels
Bot: Not Stale Override for the stale bot good first issue Indicates a good issue for first-time contributors Type: Defect Incorrect behavior (e.g. crash, hang)

Comments

@ChristophSchmidpeter
Copy link

ChristophSchmidpeter commented Nov 11, 2021

System information

Type Version/Name
Distribution Name Arch Linux
Distribution Version NA
Kernel Version 5.14.2 (zen)
Architecture x64
OpenZFS Version 2.1.1

Describe the problem you're observing

When multiple snapshots prevent the destruction/rollback of the respective dataset/snapshot/volume via zfs destroy or zfs rollback, the respective error message does not list the blocking snapshots sorted according to their order of creation.

Describe how to reproduce the problem

The commands

zfs create MyPool/Test
zfs snap MyPool/Test@Snap1
zfs snap MyPool/Test@Snap2
zfs snap MyPool/Test@Snap3
zfs snap MyPool/Test@Snap4
zfs snap MyPool/Test@Snap5
zfs snap MyPool/Test@Snap6
zfs destroy MyPool/Test

result in the following error message:

cannot destroy 'ZfsRoot/Test': filesystem has children
use '-r' to destroy the following datasets:
MyPool/Test@Snap3
MyPool/Test@Snap4
MyPool/Test@Snap6
MyPool/Test@Snap1
MyPool/Test@Snap5
MyPool/Test@Snap2

Equivalent behaviour occurs when trying to roll back to a blocked snapshot, e.g. via zfs rollback MyPool/Test@Snap1

Notice how, as mentioned, the resulting error message does not list the snapshots 1-6 in the order of their creation. This results in the error message being somewhat confusing/less intuitive and less informative and thus less useful. It also results in a less uniform behaviour, as zfs list -t snap MyPool/Test in contrast sorts the blocking snapshots in the order of their creation already:

zfs list -t snap MyPool/Test
NAME                 USED  AVAIL     REFER  MOUNTPOINT
MyPool/Test@Snap1     0B      -      304K  -
MyPool/Test@Snap2     0B      -      304K  -
MyPool/Test@Snap3     0B      -      304K  -
MyPool/Test@Snap4     0B      -      304K  -
MyPool/Test@Snap5     0B      -      304K  -
MyPool/Test@Snap6     0B      -      304K  -

Include any warning/errors/backtraces from the system logs

@ChristophSchmidpeter ChristophSchmidpeter added the Type: Defect Incorrect behavior (e.g. crash, hang) label Nov 11, 2021
@ChristophSchmidpeter ChristophSchmidpeter changed the title zfs destroy's error message does not list blocking snapshots sorted zfs destroy's and zfs rollback's error messages do not list blocking snapshots sorted Nov 11, 2021
@rincebrain rincebrain added the good first issue Indicates a good issue for first-time contributors label Nov 11, 2021
@stale
Copy link

stale bot commented Nov 12, 2022

This issue has been automatically marked as "stale" because it has not had any activity for a while. It will be closed in 90 days if no further activity occurs. Thank you for your contributions.

@stale stale bot added the Status: Stale No recent activity for issue label Nov 12, 2022
@behlendorf behlendorf added Bot: Not Stale Override for the stale bot and removed Status: Stale No recent activity for issue labels Nov 14, 2022
@GenericRikka
Copy link

I was able to confirm the unsorted error message on artix-6.6.34-1-lts by compiling from source on the main branch. If 4 snapshots of a test dataset were created and named by creation time, the output of zfs destroy zroot/test (using the freshly compiled binary) is still

use '-r' to destroy the following datasets:
zroot/test@3
zroot/test@4
zroot/test@2
zroot/test@1 

The unsorted list seems to be pulled and printed at line 1381 in cmd/zfs/zfs_main.c
I will have a look at it and see what i can do to fix this. Will keep you updated.

@GenericRikka
Copy link

GenericRikka commented Nov 27, 2024

Okay, sorry for the long pause, i have some private stuff going on that is slowing me down a lot. Anyways i read through some of the code and the line i mentioned earlier (line 1381 in zfs_main.c) is calling destroy_print_snapshots, which in turn is calling zfs_iter_snapshots_sorted_v2 which utilizes zfs_snapshot_compare from libzfs_iter.c which already sorts snapshots by creation time, so probably somewhere while passing the sorted list of snapshots they get unsorted. I will look further into it. This is indeed a good first issue, since i am slowly starting to become familiar with the Source Tree!

@Artem-OSSRevival
Copy link
Contributor

Hi there. I am Artem from OSS Revival. If no one is mind, I will deal with this issue.

Artem-OSSRevival added a commit to Project-OSS-Revival/zfs that referenced this issue Apr 21, 2025
@Artem-OSSRevival Artem-OSSRevival linked a pull request Apr 23, 2025 that will close this issue
13 tasks
@amotin amotin linked a pull request Apr 23, 2025 that will close this issue
13 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bot: Not Stale Override for the stale bot good first issue Indicates a good issue for first-time contributors Type: Defect Incorrect behavior (e.g. crash, hang)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants