Print this page
2882 implement libzfs_core
2883 changing "canmount" property to "on" should not always remount dataset
2900 "zfs snapshot" should be able to create multiple, arbitrary snapshots at once
Reviewed by: George Wilson <george.wilson@delphix.com>
Reviewed by: Chris Siden <christopher.siden@delphix.com>
Reviewed by: Garrett D'Amore <garrett@damore.org>
Reviewed by: Bill Pijewski <wdp@joyent.com>
Reviewed by: Dan Kruchinin <dan.kruchinin@gmail.com>


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


 732     cred_t *cr, caller_context_t *cc, int flags, vsecattr_t *vsecp)
 733 {
 734         zfsvfs_t *zfsvfs = dvp->v_vfsp->vfs_data;
 735         char name[MAXNAMELEN];
 736         int err;
 737         static enum symfollow follow = NO_FOLLOW;
 738         static enum uio_seg seg = UIO_SYSSPACE;
 739 
 740         if (snapshot_namecheck(dirname, NULL, NULL) != 0)
 741                 return (EILSEQ);
 742 
 743         dmu_objset_name(zfsvfs->z_os, name);
 744 
 745         *vpp = NULL;
 746 
 747         err = zfs_secpolicy_snapshot_perms(name, cr);
 748         if (err)
 749                 return (err);
 750 
 751         if (err == 0) {
 752                 err = dmu_objset_snapshot(name, dirname, NULL, NULL,
 753                     B_FALSE, B_FALSE, -1);
 754                 if (err)
 755                         return (err);
 756                 err = lookupnameat(dirname, seg, follow, NULL, vpp, dvp);
 757         }
 758 
 759         return (err);
 760 }
 761 
 762 /*
 763  * Lookup entry point for the 'snapshot' directory.  Try to open the
 764  * snapshot if it exist, creating the pseudo filesystem vnode as necessary.
 765  * Perform a mount of the associated dataset on top of the vnode.
 766  */
 767 /* ARGSUSED */
 768 static int
 769 zfsctl_snapdir_lookup(vnode_t *dvp, char *nm, vnode_t **vpp, pathname_t *pnp,
 770     int flags, vnode_t *rdir, cred_t *cr, caller_context_t *ct,
 771     int *direntflags, pathname_t *realpnp)
 772 {
 773         zfsctl_snapdir_t *sdp = dvp->v_data;




   3  *
   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 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  *


 733     cred_t *cr, caller_context_t *cc, int flags, vsecattr_t *vsecp)
 734 {
 735         zfsvfs_t *zfsvfs = dvp->v_vfsp->vfs_data;
 736         char name[MAXNAMELEN];
 737         int err;
 738         static enum symfollow follow = NO_FOLLOW;
 739         static enum uio_seg seg = UIO_SYSSPACE;
 740 
 741         if (snapshot_namecheck(dirname, NULL, NULL) != 0)
 742                 return (EILSEQ);
 743 
 744         dmu_objset_name(zfsvfs->z_os, name);
 745 
 746         *vpp = NULL;
 747 
 748         err = zfs_secpolicy_snapshot_perms(name, cr);
 749         if (err)
 750                 return (err);
 751 
 752         if (err == 0) {
 753                 err = dmu_objset_snapshot_one(name, dirname);

 754                 if (err)
 755                         return (err);
 756                 err = lookupnameat(dirname, seg, follow, NULL, vpp, dvp);
 757         }
 758 
 759         return (err);
 760 }
 761 
 762 /*
 763  * Lookup entry point for the 'snapshot' directory.  Try to open the
 764  * snapshot if it exist, creating the pseudo filesystem vnode as necessary.
 765  * Perform a mount of the associated dataset on top of the vnode.
 766  */
 767 /* ARGSUSED */
 768 static int
 769 zfsctl_snapdir_lookup(vnode_t *dvp, char *nm, vnode_t **vpp, pathname_t *pnp,
 770     int flags, vnode_t *rdir, cred_t *cr, caller_context_t *ct,
 771     int *direntflags, pathname_t *realpnp)
 772 {
 773         zfsctl_snapdir_t *sdp = dvp->v_data;