Home | History | Annotate | Line # | Download | only in coda
coda_vfsops.c revision 1.84.2.2
      1 /*	$NetBSD: coda_vfsops.c,v 1.84.2.2 2017/03/20 06:57:23 pgoyette Exp $	*/
      2 
      3 /*
      4  *
      5  *             Coda: an Experimental Distributed File System
      6  *                              Release 3.1
      7  *
      8  *           Copyright (c) 1987-1998 Carnegie Mellon University
      9  *                          All Rights Reserved
     10  *
     11  * Permission  to  use, copy, modify and distribute this software and its
     12  * documentation is hereby granted,  provided  that  both  the  copyright
     13  * notice  and  this  permission  notice  appear  in  all  copies  of the
     14  * software, derivative works or  modified  versions,  and  any  portions
     15  * thereof, and that both notices appear in supporting documentation, and
     16  * that credit is given to Carnegie Mellon University  in  all  documents
     17  * and publicity pertaining to direct or indirect use of this code or its
     18  * derivatives.
     19  *
     20  * CODA IS AN EXPERIMENTAL SOFTWARE SYSTEM AND IS  KNOWN  TO  HAVE  BUGS,
     21  * SOME  OF  WHICH MAY HAVE SERIOUS CONSEQUENCES.  CARNEGIE MELLON ALLOWS
     22  * FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION.   CARNEGIE  MELLON
     23  * DISCLAIMS  ANY  LIABILITY  OF  ANY  KIND  FOR  ANY  DAMAGES WHATSOEVER
     24  * RESULTING DIRECTLY OR INDIRECTLY FROM THE USE OF THIS SOFTWARE  OR  OF
     25  * ANY DERIVATIVE WORK.
     26  *
     27  * Carnegie  Mellon  encourages  users  of  this  software  to return any
     28  * improvements or extensions that  they  make,  and  to  grant  Carnegie
     29  * Mellon the rights to redistribute these changes without encumbrance.
     30  *
     31  * 	@(#) cfs/coda_vfsops.c,v 1.1.1.1 1998/08/29 21:26:45 rvb Exp $
     32  */
     33 
     34 /*
     35  * Mach Operating System
     36  * Copyright (c) 1989 Carnegie-Mellon University
     37  * All rights reserved.  The CMU software License Agreement specifies
     38  * the terms and conditions for use and redistribution.
     39  */
     40 
     41 /*
     42  * This code was written for the Coda file system at Carnegie Mellon
     43  * University.  Contributers include David Steere, James Kistler, and
     44  * M. Satyanarayanan.
     45  */
     46 
     47 #include <sys/cdefs.h>
     48 __KERNEL_RCSID(0, "$NetBSD: coda_vfsops.c,v 1.84.2.2 2017/03/20 06:57:23 pgoyette Exp $");
     49 
     50 #include <sys/param.h>
     51 #include <sys/systm.h>
     52 #include <sys/sysctl.h>
     53 #include <sys/malloc.h>
     54 #include <sys/conf.h>
     55 #include <sys/namei.h>
     56 #include <sys/dirent.h>
     57 #include <sys/mount.h>
     58 #include <sys/proc.h>
     59 #include <sys/select.h>
     60 #include <sys/kauth.h>
     61 #include <sys/module.h>
     62 
     63 #include <coda/coda.h>
     64 #include <coda/cnode.h>
     65 #include <coda/coda_vfsops.h>
     66 #include <coda/coda_venus.h>
     67 #include <coda/coda_subr.h>
     68 #include <coda/coda_opstats.h>
     69 /* for VN_RDEV */
     70 #include <miscfs/specfs/specdev.h>
     71 #include <miscfs/genfs/genfs.h>
     72 
     73 MODULE(MODULE_CLASS_VFS, coda, "vcoda");
     74 
     75 #define ENTRY if(coda_vfsop_print_entry) myprintf(("Entered %s\n",__func__))
     76 
     77 extern struct vnode *coda_ctlvp;
     78 extern struct coda_mntinfo coda_mnttbl[NVCODA]; /* indexed by minor device number */
     79 
     80 /* structure to keep statistics of internally generated/satisfied calls */
     81 
     82 struct coda_op_stats coda_vfsopstats[CODA_VFSOPS_SIZE];
     83 
     84 #define MARK_ENTRY(op) (coda_vfsopstats[op].entries++)
     85 #define MARK_INT_SAT(op) (coda_vfsopstats[op].sat_intrn++)
     86 #define MARK_INT_FAIL(op) (coda_vfsopstats[op].unsat_intrn++)
     87 #define MRAK_INT_GEN(op) (coda_vfsopstats[op].gen_intrn++)
     88 
     89 extern const struct cdevsw vcoda_cdevsw;
     90 extern const struct vnodeopv_desc coda_vnodeop_opv_desc;
     91 
     92 const struct vnodeopv_desc * const coda_vnodeopv_descs[] = {
     93 	&coda_vnodeop_opv_desc,
     94 	NULL,
     95 };
     96 
     97 struct vfsops coda_vfsops = {
     98 	.vfs_name = MOUNT_CODA,
     99 	.vfs_min_mount_data = 256,
    100 			/* This is the pathname, unlike every other fs */
    101 	.vfs_mount = coda_mount,
    102 	.vfs_start = coda_start,
    103 	.vfs_unmount = coda_unmount,
    104 	.vfs_root = coda_root,
    105 	.vfs_quotactl = (void *)eopnotsupp,
    106 	.vfs_statvfs = coda_nb_statvfs,
    107 	.vfs_sync = coda_sync,
    108 	.vfs_vget = coda_vget,
    109 	.vfs_loadvnode = coda_loadvnode,
    110 	.vfs_fhtovp = (void *)eopnotsupp,
    111 	.vfs_vptofh = (void *)eopnotsupp,
    112 	.vfs_init = coda_init,
    113 	.vfs_done = coda_done,
    114 	.vfs_mountroot = (void *)eopnotsupp,
    115 	.vfs_snapshot = (void *)eopnotsupp,
    116 	.vfs_extattrctl = vfs_stdextattrctl,
    117 	.vfs_suspendctl = genfs_suspendctl,
    118 	.vfs_renamelock_enter = genfs_renamelock_enter,
    119 	.vfs_renamelock_exit = genfs_renamelock_exit,
    120 	.vfs_fsync = (void *)eopnotsupp,
    121 	.vfs_opv_descs = coda_vnodeopv_descs
    122 };
    123 
    124 static int
    125 coda_modcmd(modcmd_t cmd, void *arg)
    126 {
    127 
    128 	switch (cmd) {
    129 	case MODULE_CMD_INIT:
    130 		return vfs_attach(&coda_vfsops);
    131 	case MODULE_CMD_FINI:
    132 		return vfs_detach(&coda_vfsops);
    133 	default:
    134 		return ENOTTY;
    135 	}
    136 }
    137 
    138 int
    139 coda_vfsopstats_init(void)
    140 {
    141 	int i;
    142 
    143 	for (i=0;i<CODA_VFSOPS_SIZE;i++) {
    144 		coda_vfsopstats[i].opcode = i;
    145 		coda_vfsopstats[i].entries = 0;
    146 		coda_vfsopstats[i].sat_intrn = 0;
    147 		coda_vfsopstats[i].unsat_intrn = 0;
    148 		coda_vfsopstats[i].gen_intrn = 0;
    149 	}
    150 
    151 	return 0;
    152 }
    153 
    154 /*
    155  * cfs mount vfsop
    156  * Set up mount info record and attach it to vfs struct.
    157  */
    158 /*ARGSUSED*/
    159 int
    160 coda_mount(struct mount *vfsp,	/* Allocated and initialized by mount(2) */
    161     const char *path,	/* path covered: ignored by the fs-layer */
    162     void *data,		/* Need to define a data type for this in netbsd? */
    163     size_t *data_len)
    164 {
    165     struct lwp *l = curlwp;
    166     struct vnode *dvp;
    167     struct cnode *cp;
    168     dev_t dev;
    169     struct coda_mntinfo *mi;
    170     struct vnode *rtvp;
    171     const struct cdevsw *cdev;
    172     CodaFid rootfid = INVAL_FID;
    173     CodaFid ctlfid = CTL_FID;
    174     int error;
    175 
    176     if (data == NULL)
    177 	return EINVAL;
    178     if (vfsp->mnt_flag & MNT_GETARGS)
    179 	return EINVAL;
    180     ENTRY;
    181 
    182     coda_vfsopstats_init();
    183     coda_vnodeopstats_init();
    184 
    185     MARK_ENTRY(CODA_MOUNT_STATS);
    186     if (CODA_MOUNTED(vfsp)) {
    187 	MARK_INT_FAIL(CODA_MOUNT_STATS);
    188 	return(EBUSY);
    189     }
    190 
    191     /* Validate mount device.  Similar to getmdev(). */
    192 
    193     /*
    194      * XXX: coda passes the mount device as the entire mount args,
    195      * All other fs pass a structure contining a pointer.
    196      * In order to get sys_mount() to do the copyin() we've set a
    197      * fixed default size for the filename buffer.
    198      */
    199     /* Ensure that namei() doesn't run off the filename buffer */
    200     ((char *)data)[*data_len - 1] = 0;
    201     error = namei_simple_kernel((char *)data, NSM_FOLLOW_NOEMULROOT,
    202 		&dvp);
    203 
    204     if (error) {
    205 	MARK_INT_FAIL(CODA_MOUNT_STATS);
    206 	return (error);
    207     }
    208     if (dvp->v_type != VCHR) {
    209 	MARK_INT_FAIL(CODA_MOUNT_STATS);
    210 	vrele(dvp);
    211 	return(ENXIO);
    212     }
    213     dev = dvp->v_rdev;
    214     vrele(dvp);
    215     cdev = cdevsw_lookup_acquire(dev);
    216     if (cdev == NULL) {
    217 	MARK_INT_FAIL(CODA_MOUNT_STATS);
    218 	return(ENXIO);
    219     }
    220 
    221     /*
    222      * See if the device table matches our expectations.
    223      */
    224     if (cdev != &vcoda_cdevsw)
    225     {
    226 	MARK_INT_FAIL(CODA_MOUNT_STATS);
    227 	cdevsw_release(cdev);
    228 	return(ENXIO);
    229     }
    230 
    231     if (minor(dev) >= NVCODA) {
    232 	MARK_INT_FAIL(CODA_MOUNT_STATS);
    233 	cdevsw_release(cdev);
    234 	return(ENXIO);
    235     }
    236 
    237     /*
    238      * Initialize the mount record and link it to the vfs struct
    239      */
    240     mi = &coda_mnttbl[minor(dev)];
    241 
    242     if (!VC_OPEN(&mi->mi_vcomm)) {
    243 	MARK_INT_FAIL(CODA_MOUNT_STATS);
    244 	cdevsw_release(cdev);
    245 	return(ENODEV);
    246     }
    247 
    248     /* No initialization (here) of mi_vcomm! */
    249     vfsp->mnt_data = mi;
    250     vfsp->mnt_stat.f_fsidx.__fsid_val[0] = 0;
    251     vfsp->mnt_stat.f_fsidx.__fsid_val[1] = makefstype(MOUNT_CODA);
    252     vfsp->mnt_stat.f_fsid = vfsp->mnt_stat.f_fsidx.__fsid_val[0];
    253     vfsp->mnt_stat.f_namemax = CODA_MAXNAMLEN;
    254     mi->mi_vfsp = vfsp;
    255 
    256     /*
    257      * Make a root vnode to placate the Vnode interface, but don't
    258      * actually make the CODA_ROOT call to venus until the first call
    259      * to coda_root in case a server is down while venus is starting.
    260      */
    261     cp = make_coda_node(&rootfid, vfsp, VDIR);
    262     rtvp = CTOV(cp);
    263     rtvp->v_vflag |= VV_ROOT;
    264 
    265     cp = make_coda_node(&ctlfid, vfsp, VCHR);
    266 
    267     coda_ctlvp = CTOV(cp);
    268 
    269     /* Add vfs and rootvp to chain of vfs hanging off mntinfo */
    270     mi->mi_vfsp = vfsp;
    271     mi->mi_rootvp = rtvp;
    272 
    273     /* set filesystem block size */
    274     vfsp->mnt_stat.f_bsize = 8192;	    /* XXX -JJK */
    275     vfsp->mnt_stat.f_frsize = 8192;	    /* XXX -JJK */
    276 
    277     /* error is currently guaranteed to be zero, but in case some
    278        code changes... */
    279     CODADEBUG(1,
    280 	     myprintf(("coda_mount returned %d\n",error)););
    281     if (error)
    282 	MARK_INT_FAIL(CODA_MOUNT_STATS);
    283     else
    284 	MARK_INT_SAT(CODA_MOUNT_STATS);
    285 
    286     error = set_statvfs_info("/coda", UIO_SYSSPACE, "CODA", UIO_SYSSPACE,
    287 	vfsp->mnt_op->vfs_name, vfsp, l);
    288     cdevsw_release(cdev);
    289     return error;
    290 }
    291 
    292 int
    293 coda_start(struct mount *vfsp, int flags)
    294 {
    295     ENTRY;
    296     vftomi(vfsp)->mi_started = 1;
    297     return (0);
    298 }
    299 
    300 int
    301 coda_unmount(struct mount *vfsp, int mntflags)
    302 {
    303     struct coda_mntinfo *mi = vftomi(vfsp);
    304     int active, error = 0;
    305 
    306     ENTRY;
    307     MARK_ENTRY(CODA_UMOUNT_STATS);
    308     if (!CODA_MOUNTED(vfsp)) {
    309 	MARK_INT_FAIL(CODA_UMOUNT_STATS);
    310 	return(EINVAL);
    311     }
    312 
    313     if (mi->mi_vfsp == vfsp) {	/* We found the victim */
    314 	if (!IS_UNMOUNTING(VTOC(mi->mi_rootvp)))
    315 	    return (EBUSY); 	/* Venus is still running */
    316 
    317 #ifdef	DEBUG
    318 	printf("coda_unmount: ROOT: vp %p, cp %p\n", mi->mi_rootvp, VTOC(mi->mi_rootvp));
    319 #endif
    320 	mi->mi_started = 0;
    321 
    322 	vrele(mi->mi_rootvp);
    323 	vrele(coda_ctlvp);
    324 
    325 	active = coda_kill(vfsp, NOT_DOWNCALL);
    326 	mi->mi_rootvp->v_vflag &= ~VV_ROOT;
    327 	error = vflush(mi->mi_vfsp, NULLVP, FORCECLOSE);
    328 	printf("coda_unmount: active = %d, vflush active %d\n", active, error);
    329 	error = 0;
    330 
    331 	/* I'm going to take this out to allow lookups to go through. I'm
    332 	 * not sure it's important anyway. -- DCS 2/2/94
    333 	 */
    334 	/* vfsp->VFS_DATA = NULL; */
    335 
    336 	/* No more vfsp's to hold onto */
    337 	mi->mi_vfsp = NULL;
    338 	mi->mi_rootvp = NULL;
    339 
    340 	if (error)
    341 	    MARK_INT_FAIL(CODA_UMOUNT_STATS);
    342 	else
    343 	    MARK_INT_SAT(CODA_UMOUNT_STATS);
    344 
    345 	return(error);
    346     }
    347     return (EINVAL);
    348 }
    349 
    350 /*
    351  * find root of cfs
    352  */
    353 int
    354 coda_root(struct mount *vfsp, struct vnode **vpp)
    355 {
    356     struct coda_mntinfo *mi = vftomi(vfsp);
    357     int error;
    358     struct lwp *l = curlwp;    /* XXX - bnoble */
    359     CodaFid VFid;
    360     static const CodaFid invalfid = INVAL_FID;
    361 
    362     ENTRY;
    363     MARK_ENTRY(CODA_ROOT_STATS);
    364 
    365     if (vfsp == mi->mi_vfsp) {
    366     	if (memcmp(&VTOC(mi->mi_rootvp)->c_fid, &invalfid, sizeof(CodaFid)))
    367 	    { /* Found valid root. */
    368 		*vpp = mi->mi_rootvp;
    369 		/* On Mach, this is vref.  On NetBSD, VOP_LOCK */
    370 		vref(*vpp);
    371 		vn_lock(*vpp, LK_EXCLUSIVE);
    372 		MARK_INT_SAT(CODA_ROOT_STATS);
    373 		return(0);
    374 	    }
    375     }
    376 
    377     error = venus_root(vftomi(vfsp), l->l_cred, l->l_proc, &VFid);
    378 
    379     if (!error) {
    380 	struct cnode *cp = VTOC(mi->mi_rootvp);
    381 
    382 	/*
    383 	 * Save the new rootfid in the cnode, and rekey the cnode
    384 	 * with the new fid key.
    385 	 */
    386 	error = vcache_rekey_enter(vfsp, mi->mi_rootvp,
    387 	    &invalfid, sizeof(CodaFid), &VFid, sizeof(CodaFid));
    388 	if (error)
    389 	        goto exit;
    390 	cp->c_fid = VFid;
    391 	vcache_rekey_exit(vfsp, mi->mi_rootvp,
    392 	    &invalfid, sizeof(CodaFid), &cp->c_fid, sizeof(CodaFid));
    393 
    394 	*vpp = mi->mi_rootvp;
    395 	vref(*vpp);
    396 	vn_lock(*vpp, LK_EXCLUSIVE);
    397 	MARK_INT_SAT(CODA_ROOT_STATS);
    398 	goto exit;
    399     } else if (error == ENODEV || error == EINTR) {
    400 	/* Gross hack here! */
    401 	/*
    402 	 * If Venus fails to respond to the CODA_ROOT call, coda_call returns
    403 	 * ENODEV. Return the uninitialized root vnode to allow vfs
    404 	 * operations such as unmount to continue. Without this hack,
    405 	 * there is no way to do an unmount if Venus dies before a
    406 	 * successful CODA_ROOT call is done. All vnode operations
    407 	 * will fail.
    408 	 */
    409 	*vpp = mi->mi_rootvp;
    410 	vref(*vpp);
    411 	vn_lock(*vpp, LK_EXCLUSIVE);
    412 	MARK_INT_FAIL(CODA_ROOT_STATS);
    413 	error = 0;
    414 	goto exit;
    415     } else {
    416 	CODADEBUG( CODA_ROOT, myprintf(("error %d in CODA_ROOT\n", error)); );
    417 	MARK_INT_FAIL(CODA_ROOT_STATS);
    418 
    419 	goto exit;
    420     }
    421  exit:
    422     return(error);
    423 }
    424 
    425 /*
    426  * Get file system statistics.
    427  */
    428 int
    429 coda_nb_statvfs(struct mount *vfsp, struct statvfs *sbp)
    430 {
    431     struct lwp *l = curlwp;
    432     struct coda_statfs fsstat;
    433     int error;
    434 
    435     ENTRY;
    436     MARK_ENTRY(CODA_STATFS_STATS);
    437     if (!CODA_MOUNTED(vfsp)) {
    438 /*	MARK_INT_FAIL(CODA_STATFS_STATS); */
    439 	return(EINVAL);
    440     }
    441 
    442     /* XXX - what to do about f_flags, others? --bnoble */
    443     /* Below This is what AFS does
    444     	#define NB_SFS_SIZ 0x895440
    445      */
    446     /* Note: Normal fs's have a bsize of 0x400 == 1024 */
    447 
    448     error = venus_statfs(vftomi(vfsp), l->l_cred, l, &fsstat);
    449 
    450     if (!error) {
    451 	sbp->f_bsize = 8192; /* XXX */
    452 	sbp->f_frsize = 8192; /* XXX */
    453 	sbp->f_iosize = 8192; /* XXX */
    454 	sbp->f_blocks = fsstat.f_blocks;
    455 	sbp->f_bfree  = fsstat.f_bfree;
    456 	sbp->f_bavail = fsstat.f_bavail;
    457 	sbp->f_bresvd = 0;
    458 	sbp->f_files  = fsstat.f_files;
    459 	sbp->f_ffree  = fsstat.f_ffree;
    460 	sbp->f_favail = fsstat.f_ffree;
    461 	sbp->f_fresvd = 0;
    462 	copy_statvfs_info(sbp, vfsp);
    463     }
    464 
    465     MARK_INT_SAT(CODA_STATFS_STATS);
    466     return(error);
    467 }
    468 
    469 /*
    470  * Flush any pending I/O.
    471  */
    472 int
    473 coda_sync(struct mount *vfsp, int waitfor,
    474     kauth_cred_t cred)
    475 {
    476     ENTRY;
    477     MARK_ENTRY(CODA_SYNC_STATS);
    478     MARK_INT_SAT(CODA_SYNC_STATS);
    479     return(0);
    480 }
    481 
    482 int
    483 coda_vget(struct mount *vfsp, ino_t ino,
    484     struct vnode **vpp)
    485 {
    486     ENTRY;
    487     return (EOPNOTSUPP);
    488 }
    489 
    490 int
    491 coda_loadvnode(struct mount *mp, struct vnode *vp,
    492     const void *key, size_t key_len, const void **new_key)
    493 {
    494 	CodaFid fid;
    495 	struct cnode *cp;
    496 	extern int (**coda_vnodeop_p)(void *);
    497 
    498 	KASSERT(key_len == sizeof(CodaFid));
    499 	memcpy(&fid, key, key_len);
    500 
    501 	cp = kmem_zalloc(sizeof(*cp), KM_SLEEP);
    502 	mutex_init(&cp->c_lock, MUTEX_DEFAULT, IPL_NONE);
    503 	cp->c_fid = fid;
    504 	cp->c_vnode = vp;
    505 	vp->v_op = coda_vnodeop_p;
    506 	vp->v_tag = VT_CODA;
    507 	vp->v_type = VNON;
    508 	vp->v_data = cp;
    509 
    510 	*new_key = &cp->c_fid;
    511 
    512 	return 0;
    513 }
    514 
    515 /*
    516  * fhtovp is now what vget used to be in 4.3-derived systems.  For
    517  * some silly reason, vget is now keyed by a 32 bit ino_t, rather than
    518  * a type-specific fid.
    519  */
    520 int
    521 coda_fhtovp(struct mount *vfsp, struct fid *fhp, struct mbuf *nam,
    522     struct vnode **vpp, int *exflagsp,
    523     kauth_cred_t *creadanonp)
    524 {
    525     struct cfid *cfid = (struct cfid *)fhp;
    526     struct cnode *cp = 0;
    527     int error;
    528     struct lwp *l = curlwp; /* XXX -mach */
    529     CodaFid VFid;
    530     int vtype;
    531 
    532     ENTRY;
    533 
    534     MARK_ENTRY(CODA_VGET_STATS);
    535     /* Check for vget of control object. */
    536     if (IS_CTL_FID(&cfid->cfid_fid)) {
    537 	*vpp = coda_ctlvp;
    538 	vref(coda_ctlvp);
    539 	MARK_INT_SAT(CODA_VGET_STATS);
    540 	return(0);
    541     }
    542 
    543     error = venus_fhtovp(vftomi(vfsp), &cfid->cfid_fid, l->l_cred, l->l_proc, &VFid, &vtype);
    544 
    545     if (error) {
    546 	CODADEBUG(CODA_VGET, myprintf(("vget error %d\n",error));)
    547 	    *vpp = (struct vnode *)0;
    548     } else {
    549 	CODADEBUG(CODA_VGET,
    550 		 myprintf(("vget: %s type %d result %d\n",
    551 			coda_f2s(&VFid), vtype, error)); )
    552 
    553 	cp = make_coda_node(&VFid, vfsp, vtype);
    554 	*vpp = CTOV(cp);
    555     }
    556     return(error);
    557 }
    558 
    559 int
    560 coda_vptofh(struct vnode *vnp, struct fid *fidp)
    561 {
    562     ENTRY;
    563     return (EOPNOTSUPP);
    564 }
    565 
    566 void
    567 coda_init(void)
    568 {
    569     ENTRY;
    570 }
    571 
    572 void
    573 coda_done(void)
    574 {
    575     ENTRY;
    576 }
    577 
    578 SYSCTL_SETUP(sysctl_vfs_coda_setup, "sysctl vfs.coda subtree setup")
    579 {
    580 
    581 	sysctl_createv(clog, 0, NULL, NULL,
    582 		       CTLFLAG_PERMANENT,
    583 		       CTLTYPE_NODE, "coda",
    584 		       SYSCTL_DESCR("code vfs options"),
    585 		       NULL, 0, NULL, 0,
    586 		       CTL_VFS, 18, CTL_EOL);
    587 	/*
    588 	 * XXX the "18" above could be dynamic, thereby eliminating
    589 	 * one more instance of the "number to vfs" mapping problem,
    590 	 * but "18" is the order as taken from sys/mount.h
    591 	 */
    592 
    593 /*
    594 	sysctl_createv(clog, 0, NULL, NULL,
    595 		       CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
    596 		       CTLTYPE_INT, "clusterread",
    597 		       SYSCTL_DESCR( anyone? ),
    598 		       NULL, 0, &doclusterread, 0,
    599 		       CTL_VFS, 18, FFS_CLUSTERREAD, CTL_EOL);
    600 */
    601 }
    602 
    603 /*
    604  * To allow for greater ease of use, some vnodes may be orphaned when
    605  * Venus dies.  Certain operations should still be allowed to go
    606  * through, but without propagating orphan-ness.  So this function will
    607  * get a new vnode for the file from the current run of Venus.
    608  */
    609 
    610 int
    611 getNewVnode(struct vnode **vpp)
    612 {
    613     struct cfid cfid;
    614     struct coda_mntinfo *mi = vftomi((*vpp)->v_mount);
    615 
    616     ENTRY;
    617 
    618     cfid.cfid_len = (short)sizeof(CodaFid);
    619     cfid.cfid_fid = VTOC(*vpp)->c_fid;	/* Structure assignment. */
    620     /* XXX ? */
    621 
    622     /* We're guessing that if set, the 1st element on the list is a
    623      * valid vnode to use. If not, return ENODEV as venus is dead.
    624      */
    625     if (mi->mi_vfsp == NULL)
    626 	return ENODEV;
    627 
    628     return coda_fhtovp(mi->mi_vfsp, (struct fid*)&cfid, NULL, vpp,
    629 		      NULL, NULL);
    630 }
    631 
    632 #include <ufs/ufs/quota.h>
    633 #include <ufs/ufs/ufsmount.h>
    634 /* get the mount structure corresponding to a given device.  Assume
    635  * device corresponds to a UFS. Return NULL if no device is found.
    636  */
    637 struct mount *devtomp(dev_t dev)
    638 {
    639     struct mount *mp;
    640 
    641     mutex_enter(&mountlist_lock);
    642     TAILQ_FOREACH(mp, &mountlist, mnt_list) {
    643 	if ((!strcmp(mp->mnt_op->vfs_name, MOUNT_UFS)) &&
    644 	    ((VFSTOUFS(mp))->um_dev == (dev_t) dev)) {
    645 	    /* mount corresponds to UFS and the device matches one we want */
    646 	    break;
    647 	}
    648     }
    649     mutex_exit(&mountlist_lock);
    650     return mp;
    651 }
    652