Home | History | Annotate | Line # | Download | only in chfs
chfs_vfsops.c revision 1.7.2.1
      1  1.7.2.1     rmind /*	$NetBSD: chfs_vfsops.c,v 1.7.2.1 2014/05/18 17:46:21 rmind Exp $	*/
      2      1.1     ahoka 
      3      1.1     ahoka /*-
      4      1.1     ahoka  * Copyright (c) 2010 Department of Software Engineering,
      5      1.1     ahoka  *		      University of Szeged, Hungary
      6      1.1     ahoka  * Copyright (C) 2010 Tamas Toth <ttoth (at) inf.u-szeged.hu>
      7      1.1     ahoka  * Copyright (C) 2010 Adam Hoka <ahoka (at) NetBSD.org>
      8      1.1     ahoka  * All rights reserved.
      9      1.1     ahoka  *
     10      1.1     ahoka  * This code is derived from software contributed to The NetBSD Foundation
     11      1.1     ahoka  * by the Department of Software Engineering, University of Szeged, Hungary
     12      1.1     ahoka  *
     13      1.1     ahoka  * Redistribution and use in source and binary forms, with or without
     14      1.1     ahoka  * modification, are permitted provided that the following conditions
     15      1.1     ahoka  * are met:
     16      1.1     ahoka  * 1. Redistributions of source code must retain the above copyright
     17      1.1     ahoka  *    notice, this list of conditions and the following disclaimer.
     18      1.1     ahoka  * 2. Redistributions in binary form must reproduce the above copyright
     19      1.1     ahoka  *    notice, this list of conditions and the following disclaimer in the
     20      1.1     ahoka  *    documentation and/or other materials provided with the distribution.
     21      1.1     ahoka  *
     22      1.1     ahoka  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     23      1.1     ahoka  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     24      1.1     ahoka  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     25      1.1     ahoka  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     26      1.1     ahoka  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
     27      1.1     ahoka  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
     28      1.1     ahoka  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
     29      1.1     ahoka  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
     30      1.1     ahoka  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     31      1.1     ahoka  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     32      1.1     ahoka  * SUCH DAMAGE.
     33      1.1     ahoka  */
     34      1.1     ahoka 
     35      1.1     ahoka #include <sys/cdefs.h>
     36      1.1     ahoka 
     37      1.1     ahoka #include <sys/param.h>
     38      1.1     ahoka #include <sys/types.h>
     39      1.1     ahoka #include <sys/kmem.h>
     40      1.1     ahoka #include <sys/mount.h>
     41      1.1     ahoka #include <sys/stat.h>
     42      1.1     ahoka #include <sys/systm.h>
     43      1.1     ahoka #include <sys/proc.h>
     44      1.1     ahoka #include <sys/module.h>
     45      1.1     ahoka #include <sys/namei.h>
     46      1.1     ahoka #include <sys/malloc.h>
     47      1.1     ahoka #include <sys/fcntl.h>
     48      1.1     ahoka #include <sys/conf.h>
     49      1.1     ahoka #include <sys/buf.h>
     50      1.1     ahoka //XXX needed just for debugging
     51      1.1     ahoka #include <sys/fstrans.h>
     52      1.1     ahoka #include <sys/sleepq.h>
     53      1.1     ahoka #include <sys/lockdebug.h>
     54      1.1     ahoka #include <sys/ktrace.h>
     55      1.1     ahoka 
     56      1.1     ahoka #include <uvm/uvm.h>
     57      1.1     ahoka #include <uvm/uvm_pager.h>
     58      1.1     ahoka #include <ufs/ufs/dir.h>
     59      1.1     ahoka #include <ufs/ufs/ufs_extern.h>
     60      1.1     ahoka #include <miscfs/genfs/genfs.h>
     61      1.1     ahoka #include <miscfs/genfs/genfs_node.h>
     62      1.1     ahoka #include <miscfs/specfs/specdev.h>
     63      1.1     ahoka #include "chfs.h"
     64      1.1     ahoka #include "chfs_args.h"
     65      1.1     ahoka 
     66      1.1     ahoka MODULE(MODULE_CLASS_VFS, chfs, "flash");
     67      1.1     ahoka 
     68      1.1     ahoka /* --------------------------------------------------------------------- */
     69      1.1     ahoka /* functions */
     70      1.1     ahoka 
     71      1.1     ahoka static int chfs_mount(struct mount *, const char *, void *, size_t *);
     72      1.1     ahoka static int chfs_unmount(struct mount *, int);
     73      1.1     ahoka static int chfs_root(struct mount *, struct vnode **);
     74      1.1     ahoka static int chfs_vget(struct mount *, ino_t, struct vnode **);
     75      1.1     ahoka static int chfs_fhtovp(struct mount *, struct fid *, struct vnode **);
     76      1.1     ahoka static int chfs_vptofh(struct vnode *, struct fid *, size_t *);
     77      1.1     ahoka static int chfs_start(struct mount *, int);
     78      1.1     ahoka static int chfs_statvfs(struct mount *, struct statvfs *);
     79      1.1     ahoka static int chfs_sync(struct mount *, int, kauth_cred_t);
     80      1.1     ahoka static void chfs_init(void);
     81      1.1     ahoka static void chfs_reinit(void);
     82      1.1     ahoka static void chfs_done(void);
     83      1.1     ahoka static int chfs_snapshot(struct mount *, struct vnode *,
     84      1.1     ahoka     struct timespec *);
     85      1.1     ahoka 
     86      1.1     ahoka /* --------------------------------------------------------------------- */
     87      1.1     ahoka /* structures */
     88      1.1     ahoka 
     89      1.1     ahoka int
     90      1.1     ahoka chfs_gop_alloc(struct vnode *vp, off_t off, off_t len,  int flags,
     91      1.1     ahoka     kauth_cred_t cred)
     92      1.1     ahoka {
     93      1.1     ahoka 	return (0);
     94      1.1     ahoka }
     95      1.1     ahoka 
     96      1.1     ahoka const struct genfs_ops chfs_genfsops = {
     97      1.1     ahoka 	.gop_size = genfs_size,
     98      1.1     ahoka 	.gop_alloc = chfs_gop_alloc,
     99      1.1     ahoka 	.gop_write = genfs_gop_write,
    100      1.1     ahoka 	.gop_markupdate = ufs_gop_markupdate,
    101      1.1     ahoka };
    102      1.1     ahoka 
    103      1.1     ahoka struct pool chfs_inode_pool;
    104      1.1     ahoka 
    105      1.1     ahoka /* for looking up the major for flash */
    106      1.1     ahoka extern const struct cdevsw flash_cdevsw;
    107      1.1     ahoka 
    108      1.1     ahoka /* --------------------------------------------------------------------- */
    109      1.1     ahoka 
    110      1.1     ahoka static int
    111      1.1     ahoka chfs_mount(struct mount *mp,
    112      1.1     ahoka     const char *path, void *data, size_t *data_len)
    113      1.1     ahoka {
    114      1.1     ahoka 	struct lwp *l = curlwp;
    115      1.1     ahoka 	struct nameidata nd;
    116      1.1     ahoka 	struct pathbuf *pb;
    117      1.1     ahoka 	struct vnode *devvp = NULL;
    118      1.1     ahoka 	struct ufs_args *args = data;
    119      1.1     ahoka 	struct ufsmount *ump = NULL;
    120      1.1     ahoka 	struct chfs_mount *chmp;
    121      1.1     ahoka 	int err = 0;
    122      1.1     ahoka 	int xflags;
    123      1.1     ahoka 
    124      1.1     ahoka 	dbg("mount()\n");
    125      1.1     ahoka 
    126  1.7.2.1     rmind 	if (args == NULL)
    127  1.7.2.1     rmind 		return EINVAL;
    128      1.1     ahoka 	if (*data_len < sizeof *args)
    129      1.1     ahoka 		return EINVAL;
    130      1.1     ahoka 
    131      1.1     ahoka 	if (mp->mnt_flag & MNT_GETARGS) {
    132      1.1     ahoka 		ump = VFSTOUFS(mp);
    133      1.1     ahoka 		if (ump == NULL)
    134      1.1     ahoka 			return EIO;
    135      1.1     ahoka 		memset(args, 0, sizeof *args);
    136      1.1     ahoka 		args->fspec = NULL;
    137      1.1     ahoka 		*data_len = sizeof *args;
    138      1.1     ahoka 		return 0;
    139      1.1     ahoka 	}
    140      1.1     ahoka 
    141      1.1     ahoka 	if (mp->mnt_flag & MNT_UPDATE) {
    142      1.1     ahoka 		/* XXX: There is no support yet to update file system
    143      1.1     ahoka 		 * settings.  Should be added. */
    144      1.1     ahoka 
    145      1.1     ahoka 		return ENODEV;
    146      1.1     ahoka 	}
    147      1.1     ahoka 
    148      1.1     ahoka 	if (args->fspec != NULL) {
    149      1.1     ahoka 		err = pathbuf_copyin(args->fspec, &pb);
    150      1.1     ahoka 		if (err) {
    151      1.1     ahoka 			return err;
    152      1.1     ahoka 		}
    153      1.6     ttoth 		/* Look up the name and verify that it's sane. */
    154      1.1     ahoka 		NDINIT(&nd, LOOKUP, FOLLOW, pb);
    155      1.1     ahoka 		if ((err = namei(&nd)) != 0 )
    156      1.1     ahoka 			return (err);
    157      1.1     ahoka 		devvp = nd.ni_vp;
    158      1.1     ahoka 
    159      1.6     ttoth 		/* Be sure this is a valid block device */
    160      1.1     ahoka 		if (devvp->v_type != VBLK)
    161      1.1     ahoka 			err = ENOTBLK;
    162      1.1     ahoka 		else if (bdevsw_lookup(devvp->v_rdev) == NULL)
    163      1.1     ahoka 			err = ENXIO;
    164      1.1     ahoka 	}
    165      1.1     ahoka 
    166      1.1     ahoka 	if (err) {
    167      1.1     ahoka 		vrele(devvp);
    168      1.1     ahoka 		return (err);
    169      1.1     ahoka 	}
    170      1.1     ahoka 
    171      1.1     ahoka 	if (mp->mnt_flag & MNT_RDONLY)
    172      1.1     ahoka 		xflags = FREAD;
    173      1.1     ahoka 	else
    174      1.1     ahoka 		xflags = FREAD|FWRITE;
    175      1.1     ahoka 
    176      1.1     ahoka 	err = VOP_OPEN(devvp, xflags, FSCRED);
    177      1.1     ahoka 	if (err)
    178      1.1     ahoka 		goto fail;
    179      1.1     ahoka 
    180      1.6     ttoth 	/* call CHFS mount function */
    181      1.1     ahoka 	err = chfs_mountfs(devvp, mp);
    182      1.1     ahoka 	if (err) {
    183      1.1     ahoka 		vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY);
    184      1.1     ahoka 		(void)VOP_CLOSE(devvp, xflags, NOCRED);
    185      1.1     ahoka 		VOP_UNLOCK(devvp);
    186      1.1     ahoka 		goto fail;
    187      1.1     ahoka 	}
    188      1.6     ttoth 
    189      1.1     ahoka 	ump = VFSTOUFS(mp);
    190      1.1     ahoka 	chmp = ump->um_chfs;
    191      1.1     ahoka 
    192      1.1     ahoka 	vfs_getnewfsid(mp);
    193      1.1     ahoka 	chmp->chm_fsmp = mp;
    194      1.1     ahoka 
    195      1.1     ahoka 	return set_statvfs_info(path,
    196      1.1     ahoka 	    UIO_USERSPACE, args->fspec,
    197      1.1     ahoka 	    UIO_USERSPACE, mp->mnt_op->vfs_name, mp, l);
    198      1.1     ahoka 
    199      1.1     ahoka fail:
    200      1.1     ahoka 	vrele(devvp);
    201      1.1     ahoka 	return (err);
    202      1.1     ahoka }
    203      1.1     ahoka 
    204      1.6     ttoth /* chfs_mountfs - init CHFS */
    205      1.1     ahoka int
    206      1.1     ahoka chfs_mountfs(struct vnode *devvp, struct mount *mp)
    207      1.1     ahoka {
    208      1.1     ahoka 	struct lwp *l = curlwp;
    209      1.1     ahoka 	kauth_cred_t cred;
    210      1.1     ahoka 	devmajor_t flash_major;
    211      1.1     ahoka 	dev_t dev;
    212      1.1     ahoka 	struct ufsmount* ump = NULL;
    213      1.1     ahoka 	struct chfs_mount* chmp;
    214      1.1     ahoka 	struct vnode *vp;
    215      1.1     ahoka 	int err = 0;
    216      1.1     ahoka 
    217      1.1     ahoka 	dbg("mountfs()\n");
    218      1.1     ahoka 
    219      1.1     ahoka 	dev = devvp->v_rdev;
    220      1.1     ahoka 	cred = l ? l->l_cred : NOCRED;
    221      1.1     ahoka 
    222      1.1     ahoka 	/* Flush out any old buffers remaining from a previous use. */
    223      1.1     ahoka 	vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY);
    224      1.1     ahoka 	err = vinvalbuf(devvp, V_SAVE, cred, l, 0, 0);
    225      1.1     ahoka 	VOP_UNLOCK(devvp);
    226      1.1     ahoka 	if (err)
    227      1.1     ahoka 		return (err);
    228      1.1     ahoka 
    229      1.6     ttoth 	/* Setup device. */
    230      1.1     ahoka 	flash_major = cdevsw_lookup_major(&flash_cdevsw);
    231      1.1     ahoka 
    232      1.1     ahoka 	if (devvp->v_type != VBLK)
    233      1.1     ahoka 		err = ENOTBLK;
    234      1.1     ahoka 	else if (bdevsw_lookup(dev) == NULL)
    235      1.1     ahoka 		err = ENXIO;
    236      1.1     ahoka 	else if (major(dev) != flash_major) {
    237      1.1     ahoka 		dbg("major(dev): %d, flash_major: %d\n",
    238      1.1     ahoka 		    major(dev), flash_major);
    239      1.1     ahoka 		err = ENODEV;
    240      1.1     ahoka 	}
    241      1.1     ahoka 	if (err) {
    242      1.1     ahoka 		vrele(devvp);
    243      1.1     ahoka 		return (err);
    244      1.1     ahoka 	}
    245      1.1     ahoka 
    246      1.6     ttoth 	/* Connect CHFS to UFS. */
    247      1.4     rmind 	ump = kmem_zalloc(sizeof(struct ufsmount), KM_SLEEP);
    248      1.4     rmind 
    249      1.1     ahoka 	ump->um_fstype = UFS1;
    250      1.4     rmind 	ump->um_chfs = kmem_zalloc(sizeof(struct chfs_mount), KM_SLEEP);
    251      1.1     ahoka 	mutex_init(&ump->um_lock, MUTEX_DEFAULT, IPL_NONE);
    252      1.1     ahoka 
    253      1.1     ahoka 	chmp = ump->um_chfs;
    254      1.1     ahoka 
    255      1.6     ttoth 	/* Initialize erase block handler. */
    256      1.1     ahoka 	chmp->chm_ebh = kmem_alloc(sizeof(struct chfs_ebh), KM_SLEEP);
    257      1.1     ahoka 
    258      1.1     ahoka 	dbg("[]opening flash: %u\n", (unsigned int)devvp->v_rdev);
    259      1.1     ahoka 	err = ebh_open(chmp->chm_ebh, devvp->v_rdev);
    260      1.1     ahoka 	if (err) {
    261      1.1     ahoka 		dbg("error while opening flash\n");
    262      1.4     rmind 		goto fail;
    263      1.1     ahoka 	}
    264      1.1     ahoka 
    265      1.1     ahoka 	//TODO check flash sizes
    266      1.1     ahoka 
    267      1.6     ttoth 	/* Initialize vnode cache's hashtable and eraseblock array. */
    268      1.1     ahoka 	chmp->chm_gbl_version = 0;
    269      1.1     ahoka 	chmp->chm_vnocache_hash = chfs_vnocache_hash_init();
    270      1.1     ahoka 
    271      1.1     ahoka 	chmp->chm_blocks = kmem_zalloc(chmp->chm_ebh->peb_nr *
    272      1.1     ahoka 	    sizeof(struct chfs_eraseblock), KM_SLEEP);
    273      1.1     ahoka 
    274      1.6     ttoth 	/* Initialize mutexes. */
    275      1.1     ahoka 	mutex_init(&chmp->chm_lock_mountfields, MUTEX_DEFAULT, IPL_NONE);
    276      1.1     ahoka 	mutex_init(&chmp->chm_lock_sizes, MUTEX_DEFAULT, IPL_NONE);
    277      1.1     ahoka 	mutex_init(&chmp->chm_lock_vnocache, MUTEX_DEFAULT, IPL_NONE);
    278      1.1     ahoka 
    279      1.6     ttoth 	/* Initialize read/write contants. (from UFS) */
    280      1.1     ahoka 	chmp->chm_fs_bmask = -4096;
    281      1.1     ahoka 	chmp->chm_fs_bsize = 4096;
    282      1.1     ahoka 	chmp->chm_fs_qbmask = 4095;
    283      1.1     ahoka 	chmp->chm_fs_bshift = 12;
    284      1.1     ahoka 	chmp->chm_fs_fmask = -2048;
    285      1.1     ahoka 	chmp->chm_fs_qfmask = 2047;
    286      1.1     ahoka 
    287      1.6     ttoth 	/* Initialize writebuffer. */
    288      1.1     ahoka 	chmp->chm_wbuf_pagesize = chmp->chm_ebh->flash_if->page_size;
    289      1.1     ahoka 	dbg("wbuf size: %zu\n", chmp->chm_wbuf_pagesize);
    290      1.1     ahoka 	chmp->chm_wbuf = kmem_alloc(chmp->chm_wbuf_pagesize, KM_SLEEP);
    291      1.1     ahoka 	rw_init(&chmp->chm_lock_wbuf);
    292      1.1     ahoka 
    293      1.6     ttoth 	/* Initialize queues. */
    294      1.1     ahoka 	TAILQ_INIT(&chmp->chm_free_queue);
    295      1.1     ahoka 	TAILQ_INIT(&chmp->chm_clean_queue);
    296      1.1     ahoka 	TAILQ_INIT(&chmp->chm_dirty_queue);
    297      1.1     ahoka 	TAILQ_INIT(&chmp->chm_very_dirty_queue);
    298      1.1     ahoka 	TAILQ_INIT(&chmp->chm_erasable_pending_wbuf_queue);
    299      1.1     ahoka 	TAILQ_INIT(&chmp->chm_erase_pending_queue);
    300      1.1     ahoka 
    301      1.6     ttoth 	/* Initialize flash-specific constants. */
    302      1.1     ahoka 	chfs_calc_trigger_levels(chmp);
    303      1.1     ahoka 
    304      1.6     ttoth 	/* Initialize sizes. */
    305      1.1     ahoka 	chmp->chm_nr_free_blocks = 0;
    306      1.1     ahoka 	chmp->chm_nr_erasable_blocks = 0;
    307      1.1     ahoka 	chmp->chm_max_vno = 2;
    308      1.1     ahoka 	chmp->chm_checked_vno = 2;
    309      1.1     ahoka 	chmp->chm_unchecked_size = 0;
    310      1.1     ahoka 	chmp->chm_used_size = 0;
    311      1.1     ahoka 	chmp->chm_dirty_size = 0;
    312      1.1     ahoka 	chmp->chm_wasted_size = 0;
    313      1.1     ahoka 	chmp->chm_free_size = chmp->chm_ebh->eb_size * chmp->chm_ebh->peb_nr;
    314      1.6     ttoth 
    315      1.6     ttoth 	/* Build filesystem. */
    316      1.1     ahoka 	err = chfs_build_filesystem(chmp);
    317      1.1     ahoka 
    318      1.1     ahoka 	if (err) {
    319      1.6     ttoth 		/* Armageddon and return. */
    320      1.1     ahoka 		chfs_vnocache_hash_destroy(chmp->chm_vnocache_hash);
    321      1.1     ahoka 		ebh_close(chmp->chm_ebh);
    322      1.4     rmind 		err = EIO;
    323      1.4     rmind 		goto fail;
    324      1.1     ahoka 	}
    325      1.1     ahoka 
    326      1.6     ttoth 	/* Initialize UFS. */
    327      1.1     ahoka 	mp->mnt_data = ump;
    328      1.1     ahoka 	mp->mnt_stat.f_fsidx.__fsid_val[0] = (long)dev;
    329      1.1     ahoka 	mp->mnt_stat.f_fsidx.__fsid_val[1] = makefstype(MOUNT_CHFS);
    330      1.1     ahoka 	mp->mnt_stat.f_fsid = mp->mnt_stat.f_fsidx.__fsid_val[0];
    331      1.1     ahoka 	mp->mnt_stat.f_namemax = MAXNAMLEN;
    332      1.1     ahoka 	mp->mnt_flag |= MNT_LOCAL;
    333      1.1     ahoka 	mp->mnt_fs_bshift = PAGE_SHIFT;
    334      1.1     ahoka 	mp->mnt_dev_bshift = DEV_BSHIFT;
    335      1.1     ahoka 	mp->mnt_iflag |= IMNT_MPSAFE;
    336      1.1     ahoka 	ump->um_flags = 0;
    337      1.1     ahoka 	ump->um_mountp = mp;
    338      1.1     ahoka 	ump->um_dev = dev;
    339      1.1     ahoka 	ump->um_devvp = devvp;
    340      1.1     ahoka 	ump->um_maxfilesize = 1048512 * 1024;
    341      1.6     ttoth 
    342      1.6     ttoth 	/* Allocate the root vnode. */
    343      1.1     ahoka 	err = VFS_VGET(mp, CHFS_ROOTINO, &vp);
    344      1.1     ahoka 	if (err) {
    345      1.1     ahoka 		dbg("error: %d while allocating root node\n", err);
    346      1.1     ahoka 		return err;
    347      1.1     ahoka 	}
    348      1.1     ahoka 	vput(vp);
    349      1.1     ahoka 
    350      1.6     ttoth 	/* Start GC. */
    351      1.1     ahoka 	chfs_gc_thread_start(chmp);
    352      1.1     ahoka 	mutex_enter(&chmp->chm_lock_mountfields);
    353      1.1     ahoka 	chfs_gc_trigger(chmp);
    354      1.1     ahoka 	mutex_exit(&chmp->chm_lock_mountfields);
    355      1.1     ahoka 
    356  1.7.2.1     rmind 	spec_node_setmountedfs(devvp, mp);
    357      1.1     ahoka 	return 0;
    358      1.6     ttoth 
    359      1.4     rmind fail:
    360      1.4     rmind 	kmem_free(chmp->chm_ebh, sizeof(struct chfs_ebh));
    361      1.4     rmind 	kmem_free(chmp, sizeof(struct chfs_mount));
    362      1.4     rmind 	kmem_free(ump, sizeof(struct ufsmount));
    363      1.4     rmind 	return err;
    364      1.1     ahoka }
    365      1.1     ahoka 
    366      1.1     ahoka /* --------------------------------------------------------------------- */
    367      1.1     ahoka 
    368      1.1     ahoka static int
    369      1.1     ahoka chfs_unmount(struct mount *mp, int mntflags)
    370      1.1     ahoka {
    371      1.1     ahoka 	int flags = 0, i = 0;
    372      1.1     ahoka 	struct ufsmount *ump;
    373      1.1     ahoka 	struct chfs_mount *chmp;
    374      1.1     ahoka 
    375      1.1     ahoka 	if (mntflags & MNT_FORCE)
    376      1.1     ahoka 		flags |= FORCECLOSE;
    377      1.1     ahoka 
    378      1.1     ahoka 	dbg("[START]\n");
    379      1.1     ahoka 
    380      1.1     ahoka 	ump = VFSTOUFS(mp);
    381      1.1     ahoka 	chmp = ump->um_chfs;
    382      1.1     ahoka 
    383      1.6     ttoth 	/* Stop GC. */
    384      1.1     ahoka 	chfs_gc_thread_stop(chmp);
    385      1.1     ahoka 
    386      1.6     ttoth 	/* Flush everyt buffer. */
    387      1.1     ahoka 	(void)vflush(mp, NULLVP, flags);
    388      1.1     ahoka 
    389      1.1     ahoka 	if (chmp->chm_wbuf_len) {
    390      1.1     ahoka 		mutex_enter(&chmp->chm_lock_mountfields);
    391      1.1     ahoka 		chfs_flush_pending_wbuf(chmp);
    392      1.1     ahoka 		mutex_exit(&chmp->chm_lock_mountfields);
    393      1.1     ahoka 	}
    394      1.1     ahoka 
    395      1.6     ttoth 	/* Free node references. */
    396      1.1     ahoka 	for (i = 0; i < chmp->chm_ebh->peb_nr; i++) {
    397      1.1     ahoka 		chfs_free_node_refs(&chmp->chm_blocks[i]);
    398      1.1     ahoka 	}
    399      1.1     ahoka 
    400      1.6     ttoth 	/* Destroy vnode cache hashtable. */
    401      1.1     ahoka 	chfs_vnocache_hash_destroy(chmp->chm_vnocache_hash);
    402      1.1     ahoka 
    403      1.6     ttoth 	/* Close eraseblock handler. */
    404      1.1     ahoka 	ebh_close(chmp->chm_ebh);
    405      1.1     ahoka 
    406      1.6     ttoth 	/* Destroy mutexes. */
    407      1.1     ahoka 	rw_destroy(&chmp->chm_lock_wbuf);
    408      1.1     ahoka 	mutex_destroy(&chmp->chm_lock_vnocache);
    409      1.1     ahoka 	mutex_destroy(&chmp->chm_lock_sizes);
    410      1.1     ahoka 	mutex_destroy(&chmp->chm_lock_mountfields);
    411      1.1     ahoka 
    412      1.6     ttoth 	/* Unmount UFS. */
    413      1.1     ahoka 	if (ump->um_devvp->v_type != VBAD) {
    414  1.7.2.1     rmind 		spec_node_setmountedfs(ump->um_devvp, NULL);
    415      1.1     ahoka 	}
    416      1.1     ahoka 	vn_lock(ump->um_devvp, LK_EXCLUSIVE | LK_RETRY);
    417      1.1     ahoka 	(void)VOP_CLOSE(ump->um_devvp, FREAD|FWRITE, NOCRED);
    418      1.1     ahoka 	vput(ump->um_devvp);
    419      1.1     ahoka 
    420      1.1     ahoka 	mutex_destroy(&ump->um_lock);
    421      1.1     ahoka 
    422      1.6     ttoth 	/* Everything done. */
    423      1.4     rmind 	kmem_free(ump, sizeof(struct ufsmount));
    424      1.1     ahoka 	mp->mnt_data = NULL;
    425      1.1     ahoka 	mp->mnt_flag &= ~MNT_LOCAL;
    426      1.1     ahoka 	dbg("[END]\n");
    427      1.1     ahoka 	return (0);
    428      1.1     ahoka }
    429      1.1     ahoka 
    430      1.1     ahoka /* --------------------------------------------------------------------- */
    431      1.1     ahoka 
    432      1.1     ahoka static int
    433      1.1     ahoka chfs_root(struct mount *mp, struct vnode **vpp)
    434      1.1     ahoka {
    435      1.1     ahoka 	struct vnode *vp;
    436      1.1     ahoka 	int error;
    437      1.1     ahoka 
    438      1.7  dholland 	if ((error = VFS_VGET(mp, (ino_t)UFS_ROOTINO, &vp)) != 0)
    439      1.1     ahoka 		return error;
    440      1.1     ahoka 	*vpp = vp;
    441      1.1     ahoka 	return 0;
    442      1.1     ahoka }
    443      1.1     ahoka 
    444      1.1     ahoka /* --------------------------------------------------------------------- */
    445      1.1     ahoka 
    446      1.1     ahoka extern rb_tree_ops_t frag_rbtree_ops;
    447      1.1     ahoka 
    448      1.1     ahoka static int
    449      1.1     ahoka chfs_vget(struct mount *mp, ino_t ino, struct vnode **vpp)
    450      1.1     ahoka {
    451      1.1     ahoka 	struct chfs_mount *chmp;
    452      1.1     ahoka 	struct chfs_inode *ip;
    453      1.1     ahoka 	struct ufsmount *ump;
    454      1.1     ahoka 	struct vnode *vp;
    455      1.1     ahoka 	dev_t dev;
    456      1.1     ahoka 	int error;
    457      1.1     ahoka 	struct chfs_vnode_cache* chvc = NULL;
    458      1.1     ahoka 	struct chfs_node_ref* nref = NULL;
    459      1.1     ahoka 	struct buf *bp;
    460      1.1     ahoka 
    461      1.2       agc 	dbg("vget() | ino: %llu\n", (unsigned long long)ino);
    462      1.1     ahoka 
    463      1.1     ahoka 	ump = VFSTOUFS(mp);
    464      1.1     ahoka 	dev = ump->um_dev;
    465      1.1     ahoka retry:
    466      1.1     ahoka 	if (!vpp) {
    467      1.1     ahoka 		vpp = kmem_alloc(sizeof(struct vnode*), KM_SLEEP);
    468      1.1     ahoka 	}
    469      1.1     ahoka 
    470      1.6     ttoth 	/* Get node from inode hash. */
    471      1.1     ahoka 	if ((*vpp = chfs_ihashget(dev, ino, LK_EXCLUSIVE)) != NULL) {
    472      1.1     ahoka 		return 0;
    473      1.1     ahoka 	}
    474      1.1     ahoka 
    475      1.1     ahoka 	/* Allocate a new vnode/inode. */
    476      1.1     ahoka 	if ((error = getnewvnode(VT_CHFS,
    477      1.1     ahoka 		    mp, chfs_vnodeop_p, NULL, &vp)) != 0) {
    478      1.1     ahoka 		*vpp = NULL;
    479      1.1     ahoka 		return (error);
    480      1.1     ahoka 	}
    481      1.1     ahoka 	ip = pool_get(&chfs_inode_pool, PR_WAITOK);
    482      1.1     ahoka 
    483      1.1     ahoka 	mutex_enter(&chfs_hashlock);
    484      1.1     ahoka 	if ((*vpp = chfs_ihashget(dev, ino, LK_EXCLUSIVE)) != NULL) {
    485      1.1     ahoka 		mutex_exit(&chfs_hashlock);
    486      1.1     ahoka 		ungetnewvnode(vp);
    487      1.1     ahoka 		pool_put(&chfs_inode_pool, ip);
    488      1.1     ahoka 		goto retry;
    489      1.1     ahoka 	}
    490      1.1     ahoka 
    491      1.1     ahoka 	vp->v_vflag |= VV_LOCKSWORK;
    492      1.1     ahoka 
    493      1.6     ttoth 	/* Initialize vnode/inode. */
    494      1.1     ahoka 	memset(ip, 0, sizeof(*ip));
    495      1.1     ahoka 	vp->v_data = ip;
    496      1.1     ahoka 	ip->vp = vp;
    497      1.3     ttoth 	ip->ch_type = VTTOCHT(vp->v_type);
    498      1.1     ahoka 	ip->ump = ump;
    499      1.1     ahoka 	ip->chmp = chmp = ump->um_chfs;
    500      1.1     ahoka 	ip->dev = dev;
    501      1.1     ahoka 	ip->ino = ino;
    502      1.1     ahoka 	vp->v_mount = mp;
    503      1.1     ahoka 	genfs_node_init(vp, &chfs_genfsops);
    504      1.1     ahoka 
    505      1.1     ahoka 	rb_tree_init(&ip->fragtree, &frag_rbtree_ops);
    506      1.1     ahoka 
    507      1.1     ahoka 	chfs_ihashins(ip);
    508      1.1     ahoka 	mutex_exit(&chfs_hashlock);
    509      1.1     ahoka 
    510      1.6     ttoth 	/* Set root inode. */
    511      1.1     ahoka 	if (ino == CHFS_ROOTINO) {
    512      1.1     ahoka 		dbg("SETROOT\n");
    513      1.1     ahoka 		vp->v_vflag |= VV_ROOT;
    514      1.1     ahoka 		vp->v_type = VDIR;
    515      1.3     ttoth 		ip->ch_type = CHT_DIR;
    516      1.1     ahoka 		ip->mode = IFMT | IEXEC | IWRITE | IREAD;
    517      1.1     ahoka 		ip->iflag |= (IN_ACCESS | IN_CHANGE | IN_UPDATE);
    518      1.1     ahoka 		chfs_update(vp, NULL, NULL, UPDATE_WAIT);
    519      1.1     ahoka 		TAILQ_INIT(&ip->dents);
    520      1.1     ahoka 		chfs_set_vnode_size(vp, 512);
    521      1.1     ahoka 	}
    522      1.1     ahoka 
    523      1.1     ahoka 	mutex_enter(&chmp->chm_lock_vnocache);
    524      1.1     ahoka 	chvc = chfs_vnode_cache_get(chmp, ino);
    525      1.1     ahoka 	mutex_exit(&chmp->chm_lock_vnocache);
    526      1.1     ahoka 	if (!chvc) {
    527      1.1     ahoka 		dbg("!chvc\n");
    528      1.6     ttoth 		/* Initialize the corresponding vnode cache. */
    529      1.1     ahoka 		/* XXX, we cant alloc under a lock, refactor this! */
    530      1.1     ahoka 		chvc = chfs_vnode_cache_alloc(ino);
    531      1.1     ahoka 		mutex_enter(&chmp->chm_lock_vnocache);
    532      1.1     ahoka 		if (ino == CHFS_ROOTINO) {
    533      1.1     ahoka 			chvc->nlink = 2;
    534      1.1     ahoka 			chvc->pvno = CHFS_ROOTINO;
    535      1.5     ttoth 			chvc->state = VNO_STATE_CHECKEDABSENT;
    536      1.1     ahoka 		}
    537      1.1     ahoka 		chfs_vnode_cache_add(chmp, chvc);
    538      1.1     ahoka 		mutex_exit(&chmp->chm_lock_vnocache);
    539      1.1     ahoka 
    540      1.1     ahoka 		ip->chvc = chvc;
    541      1.1     ahoka 		TAILQ_INIT(&ip->dents);
    542      1.1     ahoka 	} else {
    543      1.1     ahoka 		dbg("chvc\n");
    544      1.1     ahoka 		ip->chvc = chvc;
    545      1.6     ttoth 		/* We had a vnode cache, the node is already on flash, so read it */
    546      1.1     ahoka 		if (ino == CHFS_ROOTINO) {
    547      1.1     ahoka 			chvc->pvno = CHFS_ROOTINO;
    548      1.1     ahoka 			TAILQ_INIT(&chvc->scan_dirents);
    549      1.1     ahoka 		} else {
    550      1.1     ahoka 			chfs_readvnode(mp, ino, &vp);
    551      1.1     ahoka 		}
    552      1.1     ahoka 
    553      1.1     ahoka 		mutex_enter(&chmp->chm_lock_mountfields);
    554      1.6     ttoth 		/* Initialize type specific things. */
    555      1.3     ttoth 		switch (ip->ch_type) {
    556      1.3     ttoth 		case CHT_DIR:
    557      1.6     ttoth 			/* Read every dirent. */
    558      1.1     ahoka 			nref = chvc->dirents;
    559      1.1     ahoka 			while (nref &&
    560      1.1     ahoka 			    (struct chfs_vnode_cache *)nref != chvc) {
    561      1.1     ahoka 				chfs_readdirent(mp, nref, ip);
    562      1.1     ahoka 				nref = nref->nref_next;
    563      1.1     ahoka 			}
    564      1.1     ahoka 			chfs_set_vnode_size(vp, 512);
    565      1.1     ahoka 			break;
    566      1.3     ttoth 		case CHT_REG:
    567      1.6     ttoth 			/* FALLTHROUGH */
    568      1.3     ttoth 		case CHT_SOCK:
    569      1.6     ttoth 			/* Collect data. */
    570      1.2       agc 			dbg("read_inode_internal | ino: %llu\n",
    571      1.2       agc 				(unsigned long long)ip->ino);
    572      1.1     ahoka 			error = chfs_read_inode(chmp, ip);
    573      1.1     ahoka 			if (error) {
    574      1.1     ahoka 				vput(vp);
    575      1.1     ahoka 				*vpp = NULL;
    576      1.1     ahoka 				mutex_exit(&chmp->chm_lock_mountfields);
    577      1.1     ahoka 				return (error);
    578      1.1     ahoka 			}
    579      1.1     ahoka 			break;
    580      1.3     ttoth 		case CHT_LNK:
    581      1.6     ttoth 			/* Collect data. */
    582      1.2       agc 			dbg("read_inode_internal | ino: %llu\n",
    583      1.2       agc 				(unsigned long long)ip->ino);
    584      1.1     ahoka 			error = chfs_read_inode_internal(chmp, ip);
    585      1.1     ahoka 			if (error) {
    586      1.1     ahoka 				vput(vp);
    587      1.1     ahoka 				*vpp = NULL;
    588      1.1     ahoka 				mutex_exit(&chmp->chm_lock_mountfields);
    589      1.1     ahoka 				return (error);
    590      1.1     ahoka 			}
    591      1.1     ahoka 
    592      1.6     ttoth 			/* Set link. */
    593      1.2       agc 			dbg("size: %llu\n", (unsigned long long)ip->size);
    594      1.1     ahoka 			bp = getiobuf(vp, true);
    595      1.1     ahoka 			bp->b_blkno = 0;
    596      1.1     ahoka 			bp->b_bufsize = bp->b_resid =
    597      1.1     ahoka 			    bp->b_bcount = ip->size;
    598      1.1     ahoka 			bp->b_data = kmem_alloc(ip->size, KM_SLEEP);
    599      1.1     ahoka 			chfs_read_data(chmp, vp, bp);
    600      1.1     ahoka 			if (!ip->target)
    601      1.1     ahoka 				ip->target = kmem_alloc(ip->size,
    602      1.1     ahoka 				    KM_SLEEP);
    603      1.1     ahoka 			memcpy(ip->target, bp->b_data, ip->size);
    604      1.1     ahoka 			kmem_free(bp->b_data, ip->size);
    605      1.1     ahoka 			putiobuf(bp);
    606      1.1     ahoka 
    607      1.1     ahoka 			break;
    608      1.3     ttoth 		case CHT_CHR:
    609      1.6     ttoth 			/* FALLTHROUGH */
    610      1.3     ttoth 		case CHT_BLK:
    611      1.6     ttoth 			/* FALLTHROUGH */
    612      1.3     ttoth 		case CHT_FIFO:
    613      1.6     ttoth 			/* Collect data. */
    614      1.2       agc 			dbg("read_inode_internal | ino: %llu\n",
    615      1.2       agc 				(unsigned long long)ip->ino);
    616      1.1     ahoka 			error = chfs_read_inode_internal(chmp, ip);
    617      1.1     ahoka 			if (error) {
    618      1.1     ahoka 				vput(vp);
    619      1.1     ahoka 				*vpp = NULL;
    620      1.1     ahoka 				mutex_exit(&chmp->chm_lock_mountfields);
    621      1.1     ahoka 				return (error);
    622      1.1     ahoka 			}
    623      1.1     ahoka 
    624      1.6     ttoth 			/* Set device. */
    625      1.1     ahoka 			bp = getiobuf(vp, true);
    626      1.1     ahoka 			bp->b_blkno = 0;
    627      1.1     ahoka 			bp->b_bufsize = bp->b_resid =
    628      1.1     ahoka 			    bp->b_bcount = sizeof(dev_t);
    629      1.1     ahoka 			bp->b_data = kmem_alloc(sizeof(dev_t), KM_SLEEP);
    630      1.1     ahoka 			chfs_read_data(chmp, vp, bp);
    631      1.1     ahoka 			memcpy(&ip->rdev,
    632      1.1     ahoka 			    bp->b_data, sizeof(dev_t));
    633      1.1     ahoka 			kmem_free(bp->b_data, sizeof(dev_t));
    634      1.1     ahoka 			putiobuf(bp);
    635      1.6     ttoth 			/* Set specific operations. */
    636      1.3     ttoth 			if (ip->ch_type == CHT_FIFO) {
    637      1.1     ahoka 				vp->v_op = chfs_fifoop_p;
    638      1.3     ttoth 			} else {
    639      1.1     ahoka 				vp->v_op = chfs_specop_p;
    640      1.1     ahoka 				spec_node_init(vp, ip->rdev);
    641      1.1     ahoka 			}
    642      1.1     ahoka 
    643      1.1     ahoka 		    break;
    644      1.3     ttoth 		case CHT_BLANK:
    645      1.6     ttoth 			/* FALLTHROUGH */
    646      1.3     ttoth 		case CHT_BAD:
    647      1.1     ahoka 			break;
    648      1.1     ahoka 		}
    649      1.1     ahoka 		mutex_exit(&chmp->chm_lock_mountfields);
    650      1.1     ahoka 
    651      1.1     ahoka 	}
    652      1.1     ahoka 
    653      1.6     ttoth 	/* Finish inode initalization. */
    654      1.1     ahoka 	ip->devvp = ump->um_devvp;
    655      1.1     ahoka 	vref(ip->devvp);
    656      1.1     ahoka 
    657      1.1     ahoka 	uvm_vnp_setsize(vp, ip->size);
    658      1.1     ahoka 	*vpp = vp;
    659      1.1     ahoka 
    660      1.1     ahoka 	return 0;
    661      1.1     ahoka }
    662      1.1     ahoka 
    663      1.1     ahoka /* --------------------------------------------------------------------- */
    664      1.1     ahoka 
    665      1.1     ahoka static int
    666      1.1     ahoka chfs_fhtovp(struct mount *mp, struct fid *fhp, struct vnode **vpp)
    667      1.1     ahoka {
    668      1.1     ahoka 	return ENODEV;
    669      1.1     ahoka }
    670      1.1     ahoka 
    671      1.1     ahoka /* --------------------------------------------------------------------- */
    672      1.1     ahoka 
    673      1.1     ahoka static int
    674      1.1     ahoka chfs_vptofh(struct vnode *vp, struct fid *fhp, size_t *fh_size)
    675      1.1     ahoka {
    676      1.1     ahoka 	return ENODEV;
    677      1.1     ahoka }
    678      1.1     ahoka 
    679      1.1     ahoka /* --------------------------------------------------------------------- */
    680      1.1     ahoka 
    681      1.1     ahoka static int
    682      1.1     ahoka chfs_start(struct mount *mp, int flags)
    683      1.1     ahoka {
    684      1.1     ahoka 	return 0;
    685      1.1     ahoka }
    686      1.1     ahoka 
    687      1.1     ahoka /* --------------------------------------------------------------------- */
    688      1.1     ahoka 
    689      1.1     ahoka static int
    690      1.1     ahoka chfs_statvfs(struct mount *mp, struct statvfs *sbp)
    691      1.1     ahoka {
    692      1.1     ahoka  	struct chfs_mount *chmp;
    693      1.1     ahoka 	struct ufsmount *ump;
    694      1.1     ahoka 	dbg("statvfs\n");
    695      1.1     ahoka 
    696      1.1     ahoka 	ump = VFSTOUFS(mp);
    697      1.1     ahoka 	chmp = ump->um_chfs;
    698      1.1     ahoka 
    699      1.1     ahoka 	sbp->f_flag   = mp->mnt_flag;
    700      1.1     ahoka 	sbp->f_bsize  = chmp->chm_ebh->eb_size;
    701      1.1     ahoka 	sbp->f_frsize = chmp->chm_ebh->eb_size;
    702      1.1     ahoka 	sbp->f_iosize = chmp->chm_ebh->eb_size;
    703      1.1     ahoka 
    704      1.1     ahoka 	sbp->f_blocks = chmp->chm_ebh->peb_nr;
    705      1.1     ahoka 	sbp->f_files  = 0;
    706      1.1     ahoka 	sbp->f_bavail = chmp->chm_nr_free_blocks - chmp->chm_resv_blocks_write;
    707      1.1     ahoka 
    708      1.1     ahoka 	sbp->f_bfree = chmp->chm_nr_free_blocks;
    709      1.1     ahoka 	sbp->f_bresvd = chmp->chm_resv_blocks_write;
    710      1.1     ahoka 
    711      1.1     ahoka 	/* FFS specific */
    712      1.1     ahoka 	sbp->f_ffree  = 0;
    713      1.1     ahoka 	sbp->f_favail = 0;
    714      1.1     ahoka 	sbp->f_fresvd = 0;
    715      1.1     ahoka 
    716      1.1     ahoka 	copy_statvfs_info(sbp, mp);
    717      1.1     ahoka 
    718      1.1     ahoka 	return 0;
    719      1.1     ahoka }
    720      1.1     ahoka 
    721      1.1     ahoka /* --------------------------------------------------------------------- */
    722      1.1     ahoka 
    723      1.1     ahoka static int
    724      1.1     ahoka chfs_sync(struct mount *mp, int waitfor,
    725      1.1     ahoka     kauth_cred_t uc)
    726      1.1     ahoka {
    727      1.1     ahoka 	return 0;
    728      1.1     ahoka }
    729      1.1     ahoka 
    730      1.1     ahoka /* --------------------------------------------------------------------- */
    731      1.1     ahoka 
    732      1.1     ahoka static void
    733      1.1     ahoka chfs_init(void)
    734      1.1     ahoka {
    735      1.6     ttoth 	/* Initialize pools and inode hash. */
    736      1.1     ahoka 	chfs_alloc_pool_caches();
    737      1.1     ahoka 	chfs_ihashinit();
    738      1.1     ahoka 	pool_init(&chfs_inode_pool, sizeof(struct chfs_inode), 0, 0, 0,
    739      1.1     ahoka 	    "chfsinopl", &pool_allocator_nointr, IPL_NONE);
    740      1.1     ahoka 	ufs_init();
    741      1.1     ahoka }
    742      1.1     ahoka 
    743      1.1     ahoka /* --------------------------------------------------------------------- */
    744      1.1     ahoka 
    745      1.1     ahoka static void
    746      1.1     ahoka chfs_reinit(void)
    747      1.1     ahoka {
    748      1.1     ahoka 	chfs_ihashreinit();
    749      1.1     ahoka 	ufs_reinit();
    750      1.1     ahoka }
    751      1.1     ahoka 
    752      1.1     ahoka /* --------------------------------------------------------------------- */
    753      1.1     ahoka 
    754      1.1     ahoka static void
    755      1.1     ahoka chfs_done(void)
    756      1.1     ahoka {
    757      1.1     ahoka 	ufs_done();
    758      1.1     ahoka 	chfs_ihashdone();
    759      1.1     ahoka 	pool_destroy(&chfs_inode_pool);
    760      1.1     ahoka 	chfs_destroy_pool_caches();
    761      1.1     ahoka }
    762      1.1     ahoka 
    763      1.1     ahoka /* --------------------------------------------------------------------- */
    764      1.1     ahoka 
    765      1.1     ahoka static int
    766      1.1     ahoka chfs_snapshot(struct mount *mp, struct vnode *vp,
    767      1.1     ahoka     struct timespec *ctime)
    768      1.1     ahoka {
    769      1.1     ahoka 	return ENODEV;
    770      1.1     ahoka }
    771      1.1     ahoka 
    772      1.1     ahoka /* --------------------------------------------------------------------- */
    773      1.1     ahoka 
    774      1.1     ahoka /*
    775      1.1     ahoka  * chfs vfs operations.
    776      1.1     ahoka  */
    777      1.1     ahoka 
    778      1.1     ahoka extern const struct vnodeopv_desc chfs_fifoop_opv_desc;
    779      1.1     ahoka extern const struct vnodeopv_desc chfs_specop_opv_desc;
    780      1.1     ahoka extern const struct vnodeopv_desc chfs_vnodeop_opv_desc;
    781      1.1     ahoka 
    782      1.1     ahoka const struct vnodeopv_desc * const chfs_vnodeopv_descs[] = {
    783      1.1     ahoka 	&chfs_fifoop_opv_desc,
    784      1.1     ahoka 	&chfs_specop_opv_desc,
    785      1.1     ahoka 	&chfs_vnodeop_opv_desc,
    786      1.1     ahoka 	NULL,
    787      1.1     ahoka };
    788      1.1     ahoka 
    789      1.1     ahoka struct vfsops chfs_vfsops = {
    790  1.7.2.1     rmind 	.vfs_name = MOUNT_CHFS,
    791  1.7.2.1     rmind 	.vfs_min_mount_data = sizeof (struct chfs_args),
    792  1.7.2.1     rmind 	.vfs_mount = chfs_mount,
    793  1.7.2.1     rmind 	.vfs_start = chfs_start,
    794  1.7.2.1     rmind 	.vfs_unmount = chfs_unmount,
    795  1.7.2.1     rmind 	.vfs_root = chfs_root,
    796  1.7.2.1     rmind 	.vfs_quotactl = ufs_quotactl,
    797  1.7.2.1     rmind 	.vfs_statvfs = chfs_statvfs,
    798  1.7.2.1     rmind 	.vfs_sync = chfs_sync,
    799  1.7.2.1     rmind 	.vfs_vget = chfs_vget,
    800  1.7.2.1     rmind 	.vfs_fhtovp = chfs_fhtovp,
    801  1.7.2.1     rmind 	.vfs_vptofh = chfs_vptofh,
    802  1.7.2.1     rmind 	.vfs_init = chfs_init,
    803  1.7.2.1     rmind 	.vfs_reinit = chfs_reinit,
    804  1.7.2.1     rmind 	.vfs_done = chfs_done,
    805  1.7.2.1     rmind 	.vfs_snapshot = chfs_snapshot,
    806  1.7.2.1     rmind 	.vfs_extattrctl = vfs_stdextattrctl,
    807  1.7.2.1     rmind 	.vfs_suspendctl = (void *)eopnotsupp,
    808  1.7.2.1     rmind 	.vfs_renamelock_enter = genfs_renamelock_enter,
    809  1.7.2.1     rmind 	.vfs_renamelock_exit = genfs_renamelock_exit,
    810  1.7.2.1     rmind 	.vfs_fsync = (void *)eopnotsupp,
    811  1.7.2.1     rmind 	.vfs_opv_descs = chfs_vnodeopv_descs
    812      1.1     ahoka };
    813      1.1     ahoka 
    814      1.6     ttoth /* For using CHFS as a module. */
    815      1.1     ahoka static int
    816      1.1     ahoka chfs_modcmd(modcmd_t cmd, void *arg)
    817      1.1     ahoka {
    818      1.1     ahoka 	switch (cmd) {
    819      1.1     ahoka 	case MODULE_CMD_INIT:
    820      1.1     ahoka 		return vfs_attach(&chfs_vfsops);
    821      1.1     ahoka 	case MODULE_CMD_FINI:
    822      1.1     ahoka 		return vfs_detach(&chfs_vfsops);
    823      1.1     ahoka 	default:
    824      1.1     ahoka 		return ENOTTY;
    825      1.1     ahoka 	}
    826      1.1     ahoka }
    827