Skip to content

Conversation

@ghost
Copy link

@ghost ghost commented Apr 23, 2025

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
@tonyhutter
Copy link
Contributor

Could you add the description text from this PR into your commit message, and add a Closes line, like:

Sort the blocking snapshots list

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.

Closes: #12751
Signed-off-by: Artem-OSSRevival <artem.vlasenko@ossrevival.org>

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.

Closes: openzfs#12751
Signed-off-by: Artem-OSSRevival <artem.vlasenko@ossrevival.org>
@tonyhutter tonyhutter merged commit 27f3d94 into openzfs:master May 2, 2025
17 of 24 checks passed
@amotin amotin added Status: Accepted Ready to integrate (reviewed, tested) and removed Status: Code Review Needed Ready for review and testing labels May 2, 2025
robn pushed a commit to robn/zfs that referenced this pull request May 23, 2025
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.

Closes: openzfs#12751

Signed-off-by: Artem-OSSRevival <artem.vlasenko@ossrevival.org>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
(cherry picked from commit 27f3d94)
@robn robn mentioned this pull request May 23, 2025
14 tasks
robn pushed a commit to robn/zfs that referenced this pull request May 24, 2025
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.

Closes: openzfs#12751

Signed-off-by: Artem-OSSRevival <artem.vlasenko@ossrevival.org>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
(cherry picked from commit 27f3d94)
tonyhutter pushed a commit that referenced this pull request May 28, 2025
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.

Closes: #12751

Signed-off-by: Artem-OSSRevival <artem.vlasenko@ossrevival.org>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
(cherry picked from commit 27f3d94)
spauka pushed a commit to spauka/zfs that referenced this pull request Aug 30, 2025
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.

Closes: openzfs#12751

Signed-off-by: Artem-OSSRevival <artem.vlasenko@ossrevival.org>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
lundman pushed a commit to openzfsonosx/openzfs-fork that referenced this pull request Jan 27, 2026
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.

Closes: openzfs#12751

Signed-off-by: Artem-OSSRevival <artem.vlasenko@ossrevival.org>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Status: Accepted Ready to integrate (reviewed, tested)

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