aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorAndriy Gapon <avg@FreeBSD.org>2018-02-21 15:10:33 +0000
committerAndriy Gapon <avg@FreeBSD.org>2018-02-21 15:10:33 +0000
commit86b66fca8b87d5666cea41e33950bf1768d13ff3 (patch)
treea3a7dd86875f9c4c485178669dfbcfce2dbe71dc /lib
parent02a28ad84246a5fcc588ba409fc3c9e7335e52fe (diff)
downloadsrc-86b66fca8b87d5666cea41e33950bf1768d13ff3.tar.gz
src-86b66fca8b87d5666cea41e33950bf1768d13ff3.zip
8520 7198 lzc_rollback_to should support rolling back to origin
illumos/illumos-gate@95643f75d23914a3e332adc9661ed51749e9858d https://github.com/illumos/illumos-gate/commit/95643f75d23914a3e332adc9661ed51749e9858d https://www.illumos.org/issues/8520 lzc_rollback_to() should support rolling back to a clone's origin. The current checks in zfs_ioc_rollback() would not allow that because the origin snapshot belongs to a different filesystem. The overly restrictive check was introduced in 7600, but it was not a regression as none of the existing tools provided a way to rollback to the origin. https://www.illumos.org/issues/7198 EINVAL is returned when a dataset does not have any snapshots, so there is nothing to roll back to. Although the code in zfs_do_rollback checks for that condition in advance, it's still possible that the snapshot(s) gets removed after the check and before the rollback sync task is executed. At the moment zfs command would crash when that happens. Reviewed by: Matthew Ahrens <mahrens@delphix.com> Approved by: Dan McDonald <danmcd@joyent.com> Author: Andriy Gapon <avg@FreeBSD.org>
Notes
Notes: svn path=/vendor-sys/illumos/dist/; revision=329718
Diffstat (limited to 'lib')
-rw-r--r--lib/libzfs/common/libzfs_dataset.c32
1 files changed, 23 insertions, 9 deletions
diff --git a/lib/libzfs/common/libzfs_dataset.c b/lib/libzfs/common/libzfs_dataset.c
index 0182afcbc44a..31c8b60f4131 100644
--- a/lib/libzfs/common/libzfs_dataset.c
+++ b/lib/libzfs/common/libzfs_dataset.c
@@ -4023,17 +4023,31 @@ zfs_rollback(zfs_handle_t *zhp, zfs_handle_t *snap, boolean_t force)
* a new snapshot is created before this request is processed.
*/
err = lzc_rollback_to(zhp->zfs_name, snap->zfs_name);
- if (err == EXDEV) {
- zfs_error_aux(zhp->zfs_hdl, dgettext(TEXT_DOMAIN,
- "'%s' is not the latest snapshot"), snap->zfs_name);
- (void) zfs_error_fmt(zhp->zfs_hdl, EZFS_BUSY,
- dgettext(TEXT_DOMAIN, "cannot rollback '%s'"),
- zhp->zfs_name);
- return (err);
- } else if (err != 0) {
- (void) zfs_standard_error_fmt(zhp->zfs_hdl, errno,
+ if (err != 0) {
+ char errbuf[1024];
+
+ (void) snprintf(errbuf, sizeof (errbuf),
dgettext(TEXT_DOMAIN, "cannot rollback '%s'"),
zhp->zfs_name);
+ switch (err) {
+ case EEXIST:
+ zfs_error_aux(zhp->zfs_hdl, dgettext(TEXT_DOMAIN,
+ "there is a snapshot or bookmark more recent "
+ "than '%s'"), snap->zfs_name);
+ (void) zfs_error(zhp->zfs_hdl, EZFS_EXISTS, errbuf);
+ break;
+ case ESRCH:
+ zfs_error_aux(zhp->zfs_hdl, dgettext(TEXT_DOMAIN,
+ "'%s' is not found among snapshots of '%s'"),
+ snap->zfs_name, zhp->zfs_name);
+ (void) zfs_error(zhp->zfs_hdl, EZFS_NOENT, errbuf);
+ break;
+ case EINVAL:
+ (void) zfs_error(zhp->zfs_hdl, EZFS_BADTYPE, errbuf);
+ break;
+ default:
+ (void) zfs_standard_error(zhp->zfs_hdl, err, errbuf);
+ }
return (err);
}