Sort the blocking snapshots list #12751 (#17264)

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 <[email protected]>
Reviewed-by: Alexander Motin <[email protected]>
Reviewed-by: Tony Hutter <[email protected]>
This commit is contained in:
Artem authored and GitHub committed 2025-05-01 17:40:23 -07:00
1 parent aa46cc9812
commit 27f3d94940
2 files changed
+2 -2

No files matched your search

+1 -1
View File
@@ -4443,7 +4443,7 @@ zfs_do_rollback(int argc, char **argv)
if (cb.cb_create > 0)
min_txg = cb.cb_create;
if ((ret = zfs_iter_snapshots_v2(zhp, 0, rollback_check, &cb,
if ((ret = zfs_iter_snapshots_sorted_v2(zhp, 0, rollback_check, &cb,
min_txg, 0)) != 0)
goto out;
if ((ret = zfs_iter_bookmarks_v2(zhp, 0, rollback_check, &cb)) != 0)
+1 -1
View File
@@ -570,7 +570,7 @@ iter_dependents_cb(zfs_handle_t *zhp, void *arg)
err = zfs_iter_filesystems_v2(zhp, ida->flags,
iter_dependents_cb, ida);
if (err == 0)
err = zfs_iter_snapshots_v2(zhp, ida->flags,
err = zfs_iter_snapshots_sorted_v2(zhp, ida->flags,
iter_dependents_cb, ida, 0, 0);
ida->stack = isf.next;
}