diff options
author | mm <mm@FreeBSD.org> | 2013-03-19 12:51:18 +0000 |
---|---|---|
committer | mm <mm@FreeBSD.org> | 2013-03-19 12:51:18 +0000 |
commit | 7c87858955593be19a80e57b7353b09f5587ae9b (patch) | |
tree | 68fb8eac18f4259926de9bd4d4ecba5b46b638c3 /sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c | |
parent | c94cc27299ba2ab2acf00ca31ec90c92a37b16f7 (diff) | |
parent | 09a831de87c71a9f94f38dbd36b73746467e3182 (diff) | |
download | FreeBSD-src-7c87858955593be19a80e57b7353b09f5587ae9b.zip FreeBSD-src-7c87858955593be19a80e57b7353b09f5587ae9b.tar.gz |
MFV r247580:
Merge synctask code restructuring from vendor.
Modify forward and backward compatibility to support new change.
Illumos ZFS issues:
3464 zfs synctask code needs restructuring
Sponsored by: Hybrid Logic Ltd.
Diffstat (limited to 'sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c')
-rw-r--r-- | sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c | 52 |
1 files changed, 32 insertions, 20 deletions
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c index 93ae2f3..6601736 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c @@ -20,8 +20,6 @@ */ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2011 Pawel Jakub Dawidek <pawel@dawidek.net>. - * All rights reserved. * Copyright (c) 2012 by Delphix. All rights reserved. */ @@ -74,6 +72,7 @@ #include <sys/gfs.h> #include <sys/stat.h> #include <sys/dmu.h> +#include <sys/dsl_destroy.h> #include <sys/dsl_deleg.h> #include <sys/mount.h> #include <sys/sunddi.h> @@ -744,7 +743,7 @@ zfsctl_snapdir_rename(vnode_t *sdvp, char *snm, vnode_t *tdvp, char *tnm, zfsvfs_t *zfsvfs; avl_index_t where; char from[MAXNAMELEN], to[MAXNAMELEN]; - char real[MAXNAMELEN]; + char real[MAXNAMELEN], fsname[MAXNAMELEN]; int err; zfsvfs = sdvp->v_vfsp->vfs_data; @@ -763,12 +762,14 @@ zfsctl_snapdir_rename(vnode_t *sdvp, char *snm, vnode_t *tdvp, char *tnm, ZFS_EXIT(zfsvfs); + dmu_objset_name(zfsvfs->z_os, fsname); + err = zfsctl_snapshot_zname(sdvp, snm, MAXNAMELEN, from); - if (!err) + if (err == 0) err = zfsctl_snapshot_zname(tdvp, tnm, MAXNAMELEN, to); - if (!err) + if (err == 0) err = zfs_secpolicy_rename_perms(from, to, cr); - if (err) + if (err != 0) return (err); /* @@ -788,7 +789,7 @@ zfsctl_snapdir_rename(vnode_t *sdvp, char *snm, vnode_t *tdvp, char *tnm, return (ENOENT); } - err = dmu_objset_rename(from, to, 0); + err = dsl_dataset_rename_snapshot(fsname, snm, tnm, 0); if (err == 0) zfsctl_rename_snap(sdp, sep, tnm); @@ -830,9 +831,9 @@ zfsctl_snapdir_remove(vnode_t *dvp, char *name, vnode_t *cwd, cred_t *cr, ZFS_EXIT(zfsvfs); err = zfsctl_snapshot_zname(dvp, name, MAXNAMELEN, snapname); - if (!err) + if (err == 0) err = zfs_secpolicy_destroy_perms(snapname, cr); - if (err) + if (err != 0) return (err); mutex_enter(&sdp->sd_lock); @@ -842,13 +843,10 @@ zfsctl_snapdir_remove(vnode_t *dvp, char *name, vnode_t *cwd, cred_t *cr, if (sep) { avl_remove(&sdp->sd_snaps, sep); err = zfsctl_unmount_snap(sep, MS_FORCE, cr); - if (err) { - avl_index_t where; - - if (avl_find(&sdp->sd_snaps, sep, &where) == NULL) - avl_insert(&sdp->sd_snaps, sep, where); - } else - err = dmu_objset_destroy(snapname, B_FALSE); + if (err != 0) + avl_add(&sdp->sd_snaps, sep); + else + err = dsl_destroy_snapshot(snapname, B_FALSE); } else { err = ENOENT; } @@ -881,12 +879,12 @@ zfsctl_snapdir_mkdir(vnode_t *dvp, char *dirname, vattr_t *vap, vnode_t **vpp, *vpp = NULL; err = zfs_secpolicy_snapshot_perms(name, cr); - if (err) + if (err != 0) return (err); if (err == 0) { err = dmu_objset_snapshot_one(name, dirname); - if (err) + if (err != 0) return (err); err = lookupnameat(dirname, seg, follow, NULL, vpp, dvp); } @@ -994,7 +992,7 @@ zfsctl_snapdir_lookup(ap) *vpp = sep->se_root; VN_HOLD(*vpp); err = traverse(vpp, LK_EXCLUSIVE | LK_RETRY); - if (err) { + if (err != 0) { VN_RELE(*vpp); *vpp = NULL; } else if (*vpp == sep->se_root) { @@ -1021,7 +1019,7 @@ zfsctl_snapdir_lookup(ap) * The requested snapshot is not currently mounted, look it up. */ err = zfsctl_snapshot_zname(dvp, nm, MAXNAMELEN, snapname); - if (err) { + if (err != 0) { mutex_exit(&sdp->sd_lock); ZFS_EXIT(zfsvfs); /* @@ -1074,8 +1072,20 @@ domount: } mutex_exit(&sdp->sd_lock); ZFS_EXIT(zfsvfs); + +#ifdef illumos + /* + * If we had an error, drop our hold on the vnode and + * zfsctl_snapshot_inactive() will clean up. + */ + if (err != 0) { + VN_RELE(*vpp); + *vpp = NULL; + } +#else if (err != 0) *vpp = NULL; +#endif return (err); } @@ -1133,8 +1143,10 @@ zfsctl_snapdir_readdir_cb(vnode_t *vp, void *dp, int *eofp, ZFS_ENTER(zfsvfs); cookie = *offp; + dsl_pool_config_enter(dmu_objset_pool(zfsvfs->z_os), FTAG); error = dmu_snapshot_list_next(zfsvfs->z_os, MAXNAMELEN, snapname, &id, &cookie, &case_conflict); + dsl_pool_config_exit(dmu_objset_pool(zfsvfs->z_os), FTAG); if (error) { ZFS_EXIT(zfsvfs); if (error == ENOENT) { |