zfs hold or release of a non-existent snapshot does not output error
If placing a hold or releasing a hold of a non-existent snapshot of a existent dataset, there is no error output and a zero return code.
Steps to reproduce:
zfs create tank/test zfs hold tank/test@s1 zfs release tank/test@s1
Prior to changeset 13973:4972ab336f54 (3464 zfs synctask code needs restructuring) the following error was returned:
cannot hold 'tank/test@s1': dataset does not exist
This case should be treated as an error. As to my investigation non-existing snapshots of existing datasets are skipped already in libzfs (there is no ioctl call).
Updated by Martin Matuška over 8 years ago
Attaching a patch that is a possible solution to fix this issue.
In libzfs_dataset.c the functions zfs_hold() and zfs_release() do not check after calling zfs_hold_one() or zfs_release_one() if the ha.nvl nvlist was populated. If it is empty, the ioctl call should be omitted and a error message printed as no matching snapshots have been found.