From 04f06e0c2cc56c239581cbb5db75462019704cb8 Mon Sep 17 00:00:00 2001 From: Andrew Barnes Date: Mon, 6 Feb 2012 20:56:17 +1100 Subject: [PATCH 1/2] snapshot name mangled in zfs_umount_snap() Fixed comment at top of zfs_umount_snap() Corrected construction of fullname. --- module/zfs/zfs_ioctl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/module/zfs/zfs_ioctl.c b/module/zfs/zfs_ioctl.c index cb2f04c7050e..0cd54a2dfb4f 100644 --- a/module/zfs/zfs_ioctl.c +++ b/module/zfs/zfs_ioctl.c @@ -3079,7 +3079,7 @@ zfs_ioc_snapshot(zfs_cmd_t *zc) /* * inputs: - * name full snapshot name, or when 'arg == NULL' the dataset name + * name dataset name, or when 'arg == NULL' the full snapshot name * arg short snapshot name (i.e. part after the '@') */ int @@ -3106,7 +3106,7 @@ zfs_unmount_snap(const char *name, void *arg) } } - fullname = kmem_asprintf("%s@%s", name, snapname); + fullname = kmem_asprintf("%s@%s", dsname, snapname); error = zfs_sb_hold(dsname, FTAG, &zsb, B_FALSE); if (error == 0) { From 2d69db27f9f459d4205050899589893dee4564bc Mon Sep 17 00:00:00 2001 From: Andrew Barnes Date: Tue, 7 Feb 2012 01:23:20 +1100 Subject: [PATCH 2/2] Fix destroy snapshots and race on zfs diff Fixes "dataset not found" error on zfs destory see #173. Fixes race in dsl_dataset_user_release_tmp() when the temp snapshot from zfs diff dataset@snap command is used see #481. --- module/zfs/zfs_ctldir.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/module/zfs/zfs_ctldir.c b/module/zfs/zfs_ctldir.c index 6abbedf5cc6a..ed43e615f149 100644 --- a/module/zfs/zfs_ctldir.c +++ b/module/zfs/zfs_ctldir.c @@ -677,7 +677,14 @@ zfsctl_unmount_snapshot(zfs_sb_t *zsb, char *name, int flags) else zfsctl_sep_free(sep); } else { - error = ENOENT; + /* + * This was not recorded in z_ctldir_snaps but may have been + * mounted manually so may need to add check and unmount if + * this being called prior to a destroy. + * Returning ENOENT here causes race in dsl_dataset_user_release_tmp() and + * prevents destroy of snapshots so return 0. + */ + error = 0; } mutex_exit(&zsb->z_ctldir_lock);