Skip to content

Sorted displaying of the blocking snapshots list #17264

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
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Artem-OSSRevival
Copy link
Contributor

Motivation and Context

When multiple snapshots prevent the destruction/rollback of the respective dataset/snapshot/volume via zfs destroy or zfs rollback, the error message does not list the blocking snapshots sorted according to their order of creation.
This causes inconvenience and can lead to confusion, and also creates a contrast with a returned message from zfs list -t snap function.
#12751

Description

The zfs_iter_snapshots_v2 functions used in these cases are replaced by zfs_iter_snapshots_sorted_v2

Prepare:

sudo zpool create MyPool /tmp/vdev1.img
sudo zfs create MyPool/Test
sudo zfs snap MyPool/Test@Snap1
sudo zfs snap MyPool/Test@Snap2
sudo zfs snap MyPool/Test@Snap3
sudo zfs snap MyPool/Test@Snap4
sudo zfs snap MyPool/Test@Snap5
sudo zfs snap MyPool/Test@Snap6

Before:

sudo zfs destroy MyPool/Test
cannot destroy 'MyPool/Test': filesystem has children
use '-r' to destroy the following datasets:
MyPool/Test@Snap4
MyPool/Test@Snap3
MyPool/Test@Snap2
MyPool/Test@Snap5
MyPool/Test@Snap1
MyPool/Test@Snap6
sudo zfs rollback MyPool/Test@Snap1
cannot rollback to 'MyPool/Test@Snap1': more recent snapshots or bookmarks exist
use '-r' to force deletion of the following snapshots and bookmarks:
MyPool/Test@Snap4
MyPool/Test@Snap3
MyPool/Test@Snap2
MyPool/Test@Snap5
MyPool/Test@Snap6

After:

sudo zfs destroy MyPool/Test
cannot destroy 'MyPool/Test': filesystem has children
use '-r' to destroy the following datasets:
MyPool/Test@Snap1
MyPool/Test@Snap2
MyPool/Test@Snap3
MyPool/Test@Snap4
MyPool/Test@Snap5
MyPool/Test@Snap6
sudo zfs rollback MyPool/Test@Snap1
cannot rollback to 'MyPool/Test@Snap1': more recent snapshots or bookmarks exist
use '-r' to force deletion of the following snapshots and bookmarks:
MyPool/Test@Snap2
MyPool/Test@Snap3
MyPool/Test@Snap4
MyPool/Test@Snap5
MyPool/Test@Snap6

How Has This Been Tested?

Run the commands in the different combinations.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Performance enhancement (non-breaking change which improves efficiency)
  • Code cleanup (non-breaking change which makes code smaller or more readable)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Library ABI change (libzfs, libzfs_core, libnvpair, libuutil and libzfsbootenv)
  • Documentation (a change to man pages or other documentation)

Checklist:

Copy link
Member

@amotin amotin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It definitely looks right for the mentioned cases. I just wonder whether you looked in what other cases the code may be used, where sorting could theoretically be a waste.

@amotin amotin added the Status: Code Review Needed Ready for review and testing label Apr 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Code Review Needed Ready for review and testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

zfs destroy's and zfs rollback's error messages do not list blocking snapshots sorted
2 participants