int VMBlockInit(int fstype, // IN: file system type char *name) // IN: Name of the file system { int ret; static const fs_operation_def_t vfsOpsArr[] = { VMBLOCK_VOP(VFSNAME_MOUNT, vfs_mount, VMBlockMount), VMBLOCK_VOP(VFSNAME_UNMOUNT, vfs_unmount, VMBlockUnmount), VMBLOCK_VOP(VFSNAME_ROOT, vfs_root, VMBlockRoot), VMBLOCK_VOP(VFSNAME_STATVFS, vfs_statvfs, VMBlockStatvfs), { NULL } }; if (!name) { Warning("VMBlockInit: received NULL input from kernel.\n"); return EINVAL; } Debug(VMBLOCK_ENTRY_LOGLEVEL, "VMBlockInit: fstype=%d, name=\"%s\"\n", fstype, name); /* * Set our file system type and the vfs operations in the kernel's VFS * switch table. */ vmblockType = fstype; ret = vfs_setfsops(vmblockType, vfsOpsArr, &vmblockVfsOps); if (ret) { Warning("VMBlockInit: could not set vfs operations.\n"); return ret; } ret = vn_make_ops(name, vnodeOpsArr, &vmblockVnodeOps); if (ret) { Warning("VMBlockInit: could not create vnode operations.\n"); /* * It's important not to call vfs_freevfsops() here; that's only for * freeing ops created with vfs_makefsops(). */ vfs_freevfsops_by_type(vmblockType); return ret; } /* * We need to find a unique device number for this instance of the module; * it will be used at each mount to secure a unique device number and file * system identifier. If one cannot be located, we'll just use zero like * other Solaris file systems. */ if ((vmblockMajor = getudev()) == (major_t)-1) { Warning("VMBlockInit: could not obtain unique device.\n"); vmblockMajor = 0; } vmblockMinor = 0; mutex_init(&vmblockMutex, NULL, MUTEX_DEFAULT, NULL); return 0; }
int zfs_create_op_tables() { int error; /* * zfs_dvnodeops can be set if mod_remove() calls mod_installfs() * due to a failure to remove the the 2nd modlinkage (zfs_modldrv). * In this case we just return as the ops vectors are already set up. */ if (zfs_dvnodeops) return (0); error = vn_make_ops(MNTTYPE_ZFS, zfs_dvnodeops_template, &zfs_dvnodeops); if (error) return (error); error = vn_make_ops(MNTTYPE_ZFS, zfs_fvnodeops_template, &zfs_fvnodeops); if (error) return (error); error = vn_make_ops(MNTTYPE_ZFS, zfs_symvnodeops_template, &zfs_symvnodeops); if (error) return (error); error = vn_make_ops(MNTTYPE_ZFS, zfs_xdvnodeops_template, &zfs_xdvnodeops); if (error) return (error); error = vn_make_ops(MNTTYPE_ZFS, zfs_evnodeops_template, &zfs_evnodeops); return (error); }
/* * Initialize the page retire mechanism: * * - Establish the correctable error retire limit. * - Initialize locks. * - Build the retired_pages vnode. * - Set up the kstats. * - Fire off the background thread. * - Tell page_tryretire() it's OK to start retiring pages. */ void page_retire_init(void) { const fs_operation_def_t retired_vnodeops_template[] = {NULL, NULL}; struct vnodeops *vops; const uint_t page_retire_ndata = sizeof (page_retire_kstat) / sizeof (kstat_named_t); ASSERT(page_retire_ksp == NULL); if (max_pages_retired_bps <= 0) { max_pages_retired_bps = MCE_BPT; } mutex_init(&pr_q_mutex, NULL, MUTEX_DEFAULT, NULL); retired_pages = vn_alloc(KM_SLEEP); if (vn_make_ops("retired_pages", retired_vnodeops_template, &vops)) { cmn_err(CE_PANIC, "page_retired_init: can't make retired vnodeops"); } vn_setops(retired_pages, vops); if ((page_retire_ksp = kstat_create("unix", 0, "page_retire", "misc", KSTAT_TYPE_NAMED, page_retire_ndata, KSTAT_FLAG_VIRTUAL)) == NULL) { cmn_err(CE_WARN, "kstat_create for page_retire failed"); } else { page_retire_ksp->ks_data = (void *)&page_retire_kstat; page_retire_ksp->ks_update = page_retire_kstat_update; kstat_install(page_retire_ksp); } pr_thread_shortwait = 23 * hz; pr_thread_longwait = 1201 * hz; mutex_init(&pr_thread_mutex, NULL, MUTEX_DEFAULT, NULL); cv_init(&pr_cv, NULL, CV_DEFAULT, NULL); pr_thread_id = thread_create(NULL, 0, page_retire_thread, NULL, 0, &p0, TS_RUN, minclsyspri); pr_enable = 1; }
/* * gfs_make_opsvec: take an array of vnode type definitions and create * their vnodeops_t structures * * This routine takes an array of gfs_opsvec_t's. It could * alternatively take an array of gfs_opsvec_t*'s, which would allow * vnode types to be completely defined in files external to the caller * of gfs_make_opsvec(). As it stands, much more sharing takes place -- * both the caller and the vnode type provider need to access gfsv_ops * and gfsv_template, and the caller also needs to know gfsv_name. */ int gfs_make_opsvec(gfs_opsvec_t *vec) { int error, i; for (i = 0; ; i++) { if (vec[i].gfsv_name == NULL) return (0); error = vn_make_ops(vec[i].gfsv_name, vec[i].gfsv_template, vec[i].gfsv_ops); if (error) break; } cmn_err(CE_WARN, "gfs_make_opsvec: bad vnode ops template for '%s'", vec[i].gfsv_name); for (i--; i >= 0; i--) { vn_freevnodeops(*vec[i].gfsv_ops); *vec[i].gfsv_ops = NULL; } return (error); }
iumfs_init(struct vfssw *iumfs_vfssw, int fstype) #endif { int err; DEBUG_PRINT((CE_CONT, "iumfs_init called\n")); DEBUG_PRINT((CE_CONT, "iumfs_init: fstype = %d(0x%x)\n", fstype, fstype)); iumfs_fstype = fstype; #ifdef SOL10 do { err = vfs_setfsops(fstype, iumfs_vfs_ops_def_array, &iumfs_vfsops); if (err) break; err = vn_make_ops(fsname, iumfs_vnode_ops_def_array, &iumfs_vnodeops); if (err) break; } while (FALSE); if (err) { if (iumfs_vfsops != NULL) { vfs_freevfsops_by_type(fstype); } if (iumfs_vnodeops != NULL) { vn_freevnodeops(iumfs_vnodeops); } } #endif /* * filesystem id に使うデバイス番号を決める。 */ iumfs_major = getudev(); DEBUG_PRINT((CE_CONT, "iumfs_init: major = %d(0x%x)\n", iumfs_major, iumfs_major)); DEBUG_PRINT((CE_CONT, "iumfs_init: return(%d)\n", err)); return (err); }
int smbfsinit(int fstyp, char *name) { int error; error = vfs_setfsops(fstyp, smbfs_vfsops_template, &smbfs_vfsops); if (error != 0) { zcmn_err(GLOBAL_ZONEID, CE_WARN, "smbfsinit: bad vfs ops template"); return (error); } error = vn_make_ops(name, smbfs_vnodeops_template, &smbfs_vnodeops); if (error != 0) { (void) vfs_freevfsops_by_type(fstyp); zcmn_err(GLOBAL_ZONEID, CE_WARN, "smbfsinit: bad vnode ops template"); return (error); } smbfsfstyp = fstyp; return (0); }
/* * Save file system type/index, initialize vfs operations vector, get * unique device number for FIFOFS and initialize the FIFOFS hash. * Create and initialize a "generic" vfs pointer that will be placed * in the v_vfsp field of each pipe's vnode. */ int fifoinit(int fstype, char *name) { static const fs_operation_def_t fifo_vfsops_template[] = { NULL, NULL }; int error; major_t dev; fifofstype = fstype; error = vfs_setfsops(fstype, fifo_vfsops_template, &fifo_vfsops); if (error != 0) { cmn_err(CE_WARN, "fifoinit: bad vfs ops template"); return (error); } error = vn_make_ops(name, fifo_vnodeops_template, &fifo_vnodeops); if (error != 0) { (void) vfs_freevfsops_by_type(fstype); cmn_err(CE_WARN, "fifoinit: bad vnode ops template"); return (error); } if ((dev = getudev()) == (major_t)-1) { cmn_err(CE_WARN, "fifoinit: can't get unique device number"); dev = 0; } fifodev = makedevice(dev, 0); fifovfsp = kmem_zalloc(sizeof (struct vfs), KM_SLEEP); fifovfsp->vfs_next = NULL; vfs_setops(fifovfsp, fifo_vfsops); fifovfsp->vfs_vnodecovered = NULL; fifovfsp->vfs_flag = 0; fifovfsp->vfs_bsize = 1024; fifovfsp->vfs_fstype = fifofstype; vfs_make_fsid(&fifovfsp->vfs_fsid, fifodev, fifofstype); fifovfsp->vfs_data = NULL; fifovfsp->vfs_dev = fifodev; fifovfsp->vfs_bcount = 0; /* * It is necessary to initialize vfs_count here to 1. * This prevents the fifovfsp from getting freed when * a thread does a VFS_HOLD followed by a VFS_RELE * on the fifovfsp * * The fifovfsp should never be freed. */ fifovfsp->vfs_count = 1; mutex_init(&ftable_lock, NULL, MUTEX_DEFAULT, NULL); mutex_init(&fino_lock, NULL, MUTEX_DEFAULT, NULL); /* * vnodes are cached aligned */ fnode_cache = kmem_cache_create("fnode_cache", sizeof (fifodata_t) - sizeof (fifonode_t), 32, fnode_constructor, fnode_destructor, NULL, (void *)(sizeof (fifodata_t) - sizeof (fifonode_t)), NULL, 0); pipe_cache = kmem_cache_create("pipe_cache", sizeof (fifodata_t), 32, pipe_constructor, pipe_destructor, NULL, (void *)(sizeof (fifodata_t)), NULL, 0); #if FIFODEBUG if (Fifohiwat < FIFOHIWAT) Fifohiwat = FIFOHIWAT; #endif /* FIFODEBUG */ fifo_strdata.qi_minfo->mi_hiwat = Fifohiwat; return (0); }