Print this page
6093 zfsctl_shares_lookup should only VN_RELE() on zfs_zget() success
Reviewed by: Gordon Ross <gwr@nexenta.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>


   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
  23  * Copyright (c) 2012, 2014 by Delphix. All rights reserved.

  24  */
  25 
  26 /*
  27  * ZFS control directory (a.k.a. ".zfs")
  28  *
  29  * This directory provides a common location for all ZFS meta-objects.
  30  * Currently, this is only the 'snapshot' directory, but this may expand in the
  31  * future.  The elements are built using the GFS primitives, as the hierarchy
  32  * does not actually exist on disk.
  33  *
  34  * For 'snapshot', we don't want to have all snapshots always mounted, because
  35  * this would take up a huge amount of space in /etc/mnttab.  We have three
  36  * types of objects:
  37  *
  38  *      ctldir ------> snapshotdir -------> snapshot
  39  *                                             |
  40  *                                             |
  41  *                                             V
  42  *                                         mounted fs
  43  *


 949 static int
 950 zfsctl_shares_lookup(vnode_t *dvp, char *nm, vnode_t **vpp, pathname_t *pnp,
 951     int flags, vnode_t *rdir, cred_t *cr, caller_context_t *ct,
 952     int *direntflags, pathname_t *realpnp)
 953 {
 954         zfsvfs_t *zfsvfs = dvp->v_vfsp->vfs_data;
 955         znode_t *dzp;
 956         int error;
 957 
 958         ZFS_ENTER(zfsvfs);
 959 
 960         if (gfs_lookup_dot(vpp, dvp, zfsvfs->z_ctldir, nm) == 0) {
 961                 ZFS_EXIT(zfsvfs);
 962                 return (0);
 963         }
 964 
 965         if (zfsvfs->z_shares_dir == 0) {
 966                 ZFS_EXIT(zfsvfs);
 967                 return (SET_ERROR(ENOTSUP));
 968         }
 969         if ((error = zfs_zget(zfsvfs, zfsvfs->z_shares_dir, &dzp)) == 0)
 970                 error = VOP_LOOKUP(ZTOV(dzp), nm, vpp, pnp,
 971                     flags, rdir, cr, ct, direntflags, realpnp);
 972 
 973         VN_RELE(ZTOV(dzp));


 974         ZFS_EXIT(zfsvfs);
 975 
 976         return (error);
 977 }
 978 
 979 /* ARGSUSED */
 980 static int
 981 zfsctl_snapdir_readdir_cb(vnode_t *vp, void *dp, int *eofp,
 982     offset_t *offp, offset_t *nextp, void *data, int flags)
 983 {
 984         zfsvfs_t *zfsvfs = vp->v_vfsp->vfs_data;
 985         char snapname[MAXNAMELEN];
 986         uint64_t id, cookie;
 987         boolean_t case_conflict;
 988         int error;
 989 
 990         ZFS_ENTER(zfsvfs);
 991 
 992         cookie = *offp;
 993         dsl_pool_config_enter(dmu_objset_pool(zfsvfs->z_os), FTAG);




   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
  23  * Copyright (c) 2012, 2014 by Delphix. All rights reserved.
  24  * Copyright 2015, OmniTI Computer Consulting, Inc. All rights reserved.
  25  */
  26 
  27 /*
  28  * ZFS control directory (a.k.a. ".zfs")
  29  *
  30  * This directory provides a common location for all ZFS meta-objects.
  31  * Currently, this is only the 'snapshot' directory, but this may expand in the
  32  * future.  The elements are built using the GFS primitives, as the hierarchy
  33  * does not actually exist on disk.
  34  *
  35  * For 'snapshot', we don't want to have all snapshots always mounted, because
  36  * this would take up a huge amount of space in /etc/mnttab.  We have three
  37  * types of objects:
  38  *
  39  *      ctldir ------> snapshotdir -------> snapshot
  40  *                                             |
  41  *                                             |
  42  *                                             V
  43  *                                         mounted fs
  44  *


 950 static int
 951 zfsctl_shares_lookup(vnode_t *dvp, char *nm, vnode_t **vpp, pathname_t *pnp,
 952     int flags, vnode_t *rdir, cred_t *cr, caller_context_t *ct,
 953     int *direntflags, pathname_t *realpnp)
 954 {
 955         zfsvfs_t *zfsvfs = dvp->v_vfsp->vfs_data;
 956         znode_t *dzp;
 957         int error;
 958 
 959         ZFS_ENTER(zfsvfs);
 960 
 961         if (gfs_lookup_dot(vpp, dvp, zfsvfs->z_ctldir, nm) == 0) {
 962                 ZFS_EXIT(zfsvfs);
 963                 return (0);
 964         }
 965 
 966         if (zfsvfs->z_shares_dir == 0) {
 967                 ZFS_EXIT(zfsvfs);
 968                 return (SET_ERROR(ENOTSUP));
 969         }
 970         if ((error = zfs_zget(zfsvfs, zfsvfs->z_shares_dir, &dzp)) == 0) {
 971                 error = VOP_LOOKUP(ZTOV(dzp), nm, vpp, pnp,
 972                     flags, rdir, cr, ct, direntflags, realpnp);

 973                 VN_RELE(ZTOV(dzp));
 974         }
 975 
 976         ZFS_EXIT(zfsvfs);
 977 
 978         return (error);
 979 }
 980 
 981 /* ARGSUSED */
 982 static int
 983 zfsctl_snapdir_readdir_cb(vnode_t *vp, void *dp, int *eofp,
 984     offset_t *offp, offset_t *nextp, void *data, int flags)
 985 {
 986         zfsvfs_t *zfsvfs = vp->v_vfsp->vfs_data;
 987         char snapname[MAXNAMELEN];
 988         uint64_t id, cookie;
 989         boolean_t case_conflict;
 990         int error;
 991 
 992         ZFS_ENTER(zfsvfs);
 993 
 994         cookie = *offp;
 995         dsl_pool_config_enter(dmu_objset_pool(zfsvfs->z_os), FTAG);