* CDDL HEADER END
*/
/*
- * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
*/
/*
* so that it cannot be freed until all snapshots have been unmounted.
*/
+#ifdef HAVE_ZPL
+
#include <fs/fs_subr.h>
#include <sys/zfs_ctldir.h>
#include <sys/zfs_ioctl.h>
zfsctl_ops_shares_dir = NULL;
}
+boolean_t
+zfsctl_is_node(vnode_t *vp)
+{
+ return (vn_matchops(vp, zfsctl_ops_root) ||
+ vn_matchops(vp, zfsctl_ops_snapdir) ||
+ vn_matchops(vp, zfsctl_ops_snapshot) ||
+ vn_matchops(vp, zfsctl_ops_shares) ||
+ vn_matchops(vp, zfsctl_ops_shares_dir));
+
+}
+
/*
* Return the inode number associated with the 'snapshot' or
* 'shares' directory.
{
vnode_t *vp, *rvp;
zfsctl_node_t *zcp;
+ uint64_t crtime[2];
ASSERT(zfsvfs->z_ctldir == NULL);
zcp->zc_id = ZFSCTL_INO_ROOT;
VERIFY(VFS_ROOT(zfsvfs->z_vfs, &rvp) == 0);
- ZFS_TIME_DECODE(&zcp->zc_cmtime, VTOZ(rvp)->z_phys->zp_crtime);
+ VERIFY(0 == sa_lookup(VTOZ(rvp)->z_sa_hdl, SA_ZPL_CRTIME(zfsvfs),
+ &crtime, sizeof (crtime)));
+ ZFS_TIME_DECODE(&zcp->zc_cmtime, crtime);
VN_RELE(rvp);
/*
static void
zfsctl_common_getattr(vnode_t *vp, vattr_t *vap)
{
- zfsctl_node_t *zcp = vp->v_data;
timestruc_t now;
vap->va_uid = 0;
vap->va_gid = 0;
vap->va_rdev = 0;
/*
- * We are a purly virtual object, so we have no
+ * We are a purely virtual object, so we have no
* blocksize or allocated blocks.
*/
vap->va_blksize = 0;
*/
gethrestime(&now);
vap->va_atime = now;
- vap->va_mtime = vap->va_ctime = zcp->zc_cmtime;
}
/*ARGSUSED*/
caller_context_t *ct)
{
zfsvfs_t *zfsvfs = vp->v_vfsp->vfs_data;
+ zfsctl_node_t *zcp = vp->v_data;
ZFS_ENTER(zfsvfs);
vap->va_nodeid = ZFSCTL_INO_ROOT;
vap->va_nlink = vap->va_size = NROOT_ENTRIES;
+ vap->va_mtime = vap->va_ctime = zcp->zc_cmtime;
zfsctl_common_getattr(vp, vap);
ZFS_EXIT(zfsvfs);
ASSERT3U(strlen(newpath) + strlen(nm), <, sizeof (newpath));
(void) strcat(newpath, nm);
refstr_rele(pathref);
- vfs_setmntpoint(vfsp, newpath);
+ vfs_setmntpoint(vfsp, newpath, 0);
pathref = vfs_getresource(vfsp);
(void) strncpy(newpath, refstr_value(pathref), sizeof (newpath));
ASSERT3U(strlen(newpath) + strlen(nm), <, sizeof (newpath));
(void) strcat(newpath, nm);
refstr_rele(pathref);
- vfs_setresource(vfsp, newpath);
+ vfs_setresource(vfsp, newpath, 0);
vfs_unlock(vfsp);
}
if (err)
avl_add(&sdp->sd_snaps, sep);
else
- err = dmu_objset_destroy(snapname);
+ err = dmu_objset_destroy(snapname, B_FALSE);
} else {
err = ENOENT;
}
return (err);
if (err == 0) {
- err = dmu_objset_snapshot(name, dirname, NULL, B_FALSE);
+ err = dmu_objset_snapshot(name, dirname, NULL, NULL,
+ B_FALSE, B_FALSE, -1);
if (err)
return (err);
err = lookupnameat(dirname, seg, follow, NULL, vpp, dvp);
*/
return (err == EILSEQ ? ENOENT : err);
}
- if (dmu_objset_open(snapname, DMU_OST_ZFS,
- DS_MODE_USER | DS_MODE_READONLY, &snap) != 0) {
+ if (dmu_objset_hold(snapname, FTAG, &snap) != 0) {
mutex_exit(&sdp->sd_lock);
ZFS_EXIT(zfsvfs);
return (ENOENT);
*vpp = sep->se_root = zfsctl_snapshot_mknode(dvp, dmu_objset_id(snap));
avl_insert(&sdp->sd_snaps, sep, where);
- dmu_objset_close(snap);
+ dmu_objset_rele(snap, FTAG);
domount:
mountpoint_len = strlen(refstr_value(dvp->v_vfsp->vfs_mntpt)) +
strlen("/.zfs/snapshot/") + strlen(nm) + 1;
zfsctl_common_getattr(vp, vap);
vap->va_nodeid = gfs_file_inode(vp);
vap->va_nlink = vap->va_size = avl_numnodes(&sdp->sd_snaps) + 2;
+ vap->va_ctime = vap->va_mtime = dmu_objset_snap_cmtime(zfsvfs->z_os);
ZFS_EXIT(zfsvfs);
return (0);
return (error);
}
+#endif /* HAVE_ZPL */