Index: UPDATING =================================================================== --- UPDATING (wersja 197195) +++ UPDATING (kopia robocza) @@ -22,6 +22,10 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 9.x IS SLOW: machines to maximize performance. (To disable malloc debugging, run ln -s aj /etc/malloc.conf.) +20090910: + ZFS snapshots are now mounted with MNT_IGNORE flag. Use -v option for + mount(8) and -a option for df(1) to see them. + 20090825: The old tunable hw.bus.devctl_disable has been superseded by hw.bus.devctl_queue. hw.bus.devctl_disable=1 in loader.conf should be Index: sbin/mount/mount.c =================================================================== --- sbin/mount/mount.c (wersja 197195) +++ sbin/mount/mount.c (kopia robocza) @@ -348,6 +348,9 @@ main(int argc, char *argv[]) if (checkvfsname(mntbuf[i].f_fstypename, vfslist)) continue; + if (!verbose && + (mntbuf[i].f_flags & MNT_IGNORE) != 0) + continue; prmount(&mntbuf[i]); } } Index: sbin/mount/mount.8 =================================================================== --- sbin/mount/mount.8 (wersja 197195) +++ sbin/mount/mount.8 (kopia robocza) @@ -469,6 +469,12 @@ or option. .It Fl v Verbose mode. +If the +.Fl v +is used alone, show all file systems, including those that were mounted with the +.Dv MNT_IGNORE +flag and show additional information about each file system (including fsid +when run by root). .It Fl w The file system object is to be read and write. .El Index: sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c =================================================================== --- sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c (wersja 197195) +++ sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c (kopia robocza) @@ -880,17 +880,9 @@ domount: mountpoint = kmem_alloc(mountpoint_len, KM_SLEEP); (void) snprintf(mountpoint, mountpoint_len, "%s/.zfs/snapshot/%s", dvp->v_vfsp->mnt_stat.f_mntonname, nm); - err = domount(curthread, *vpp, "zfs", mountpoint, snapname, 0); + err = mount_snapshot(curthread, vpp, "zfs", mountpoint, snapname, 0); kmem_free(mountpoint, mountpoint_len); if (err == 0) { - vnode_t *mvp; - - ASSERT((*vpp)->v_mountedhere != NULL); - err = VFS_ROOT((*vpp)->v_mountedhere, LK_EXCLUSIVE, &mvp); - ASSERT(err == 0); - VN_RELE(*vpp); - *vpp = mvp; - /* * Fix up the root vnode mounted on .zfs/snapshot/. * @@ -902,14 +894,6 @@ domount: VTOZ(*vpp)->z_zfsvfs->z_parent = zfsvfs; } mutex_exit(&sdp->sd_lock); - /* - * If we had an error, drop our hold on the vnode and - * zfsctl_snapshot_inactive() will clean up. - */ - if (err) { - VN_RELE(*vpp); - *vpp = NULL; - } ZFS_EXIT(zfsvfs); return (err); } Index: sys/cddl/compat/opensolaris/kern/opensolaris_vfs.c =================================================================== --- sys/cddl/compat/opensolaris/kern/opensolaris_vfs.c (wersja 197196) +++ sys/cddl/compat/opensolaris/kern/opensolaris_vfs.c (kopia robocza) @@ -112,12 +112,13 @@ vfs_optionisset(const vfs_t *vfsp, const char *opt } int -domount(kthread_t *td, vnode_t *vp, const char *fstype, char *fspath, +mount_snapshot(kthread_t *td, vnode_t **vpp, const char *fstype, char *fspath, char *fspec, int fsflags) { struct mount *mp; struct vfsconf *vfsp; struct ucred *cr; + vnode_t *vp; int error; /* @@ -132,11 +133,11 @@ int if (vfsp == NULL) return (ENODEV); + vp = *vpp; if (vp->v_type != VDIR) return (ENOTDIR); VI_LOCK(vp); - if ((vp->v_iflag & VI_MOUNT) != 0 || - vp->v_mountedhere != NULL) { + if ((vp->v_iflag & VI_MOUNT) != 0 || vp->v_mountedhere != NULL) { VI_UNLOCK(vp); return (EBUSY); } @@ -146,9 +147,7 @@ int /* * Allocate and initialize the filesystem. */ - vn_lock(vp, LK_SHARED | LK_RETRY); mp = vfs_mount_alloc(vp, vfsp, fspath, td->td_ucred); - VOP_UNLOCK(vp, 0); mp->mnt_optnew = NULL; vfs_setmntopt(mp, "from", fspec, 0); @@ -158,11 +157,18 @@ int /* * Set the mount level flags. */ - if (fsflags & MNT_RDONLY) - mp->mnt_flag |= MNT_RDONLY; - mp->mnt_flag &=~ MNT_UPDATEMASK; + mp->mnt_flag &= ~MNT_UPDATEMASK; mp->mnt_flag |= fsflags & (MNT_UPDATEMASK | MNT_FORCE | MNT_ROOTFS); /* + * Snapshots are always read-only. + */ + mp->mnt_flag |= MNT_RDONLY; + /* + * We don't want snapshots to be visible in regular + * mount(8) and df(1) output. + */ + mp->mnt_flag |= MNT_IGNORE; + /* * Unprivileged user can trigger mounting a snapshot, but we don't want * him to unmount it, so we switch to privileged of original mount. */ @@ -170,11 +176,6 @@ int mp->mnt_cred = crdup(vp->v_mount->mnt_cred); mp->mnt_stat.f_owner = mp->mnt_cred->cr_uid; /* - * Mount the filesystem. - * XXX The final recipients of VFS_MOUNT just overwrite the ndp they - * get. No freeing of cn_pnbuf. - */ - /* * XXX: This is evil, but we can't mount a snapshot as a regular user. * XXX: Is is safe when snapshot is mounted from within a jail? */ @@ -183,7 +184,7 @@ int error = VFS_MOUNT(mp); td->td_ucred = cr; - if (!error) { + if (error == 0) { if (mp->mnt_opt != NULL) vfs_freeopts(mp->mnt_opt); mp->mnt_opt = mp->mnt_optnew; @@ -195,42 +196,33 @@ int */ mp->mnt_optnew = NULL; vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); - /* - * Put the new filesystem on the mount list after root. - */ #ifdef FREEBSD_NAMECACHE cache_purge(vp); #endif - if (!error) { + VI_LOCK(vp); + vp->v_iflag &= ~VI_MOUNT; + VI_UNLOCK(vp); + if (error == 0) { vnode_t *mvp; - VI_LOCK(vp); - vp->v_iflag &= ~VI_MOUNT; - VI_UNLOCK(vp); vp->v_mountedhere = mp; + /* + * Put the new filesystem on the mount list. + */ mtx_lock(&mountlist_mtx); TAILQ_INSERT_TAIL(&mountlist, mp, mnt_list); mtx_unlock(&mountlist_mtx); vfs_event_signal(NULL, VQ_MOUNT, 0); if (VFS_ROOT(mp, LK_EXCLUSIVE, &mvp)) panic("mount: lost mount"); - mountcheckdirs(vp, mvp); - vput(mvp); - VOP_UNLOCK(vp, 0); - if ((mp->mnt_flag & MNT_RDONLY) == 0) - error = vfs_allocate_syncvnode(mp); + vput(vp); vfs_unbusy(mp); - if (error) - vrele(vp); - else - vfs_mountedfrom(mp, fspec); + *vpp = mvp; } else { - VI_LOCK(vp); - vp->v_iflag &= ~VI_MOUNT; - VI_UNLOCK(vp); - VOP_UNLOCK(vp, 0); + vput(vp); vfs_unbusy(mp); vfs_mount_destroy(mp); + *vpp = NULL; } return (error); } Index: sys/cddl/compat/opensolaris/sys/vfs.h =================================================================== --- sys/cddl/compat/opensolaris/sys/vfs.h (wersja 197195) +++ sys/cddl/compat/opensolaris/sys/vfs.h (kopia robocza) @@ -110,8 +110,8 @@ void vfs_setmntopt(vfs_t *vfsp, const char *name, int flags __unused); void vfs_clearmntopt(vfs_t *vfsp, const char *name); int vfs_optionisset(const vfs_t *vfsp, const char *opt, char **argp); -int domount(kthread_t *td, vnode_t *vp, const char *fstype, char *fspath, - char *fspec, int fsflags); +int mount_snapshot(kthread_t *td, vnode_t **vpp, const char *fstype, + char *fspath, char *fspec, int fsflags); typedef uint64_t vfs_feature_t;