1/* $NetBSD: vnode.h,v 1.3 2007/10/10 20:42:20 ad Exp $ */ 2/*- 3 * Copyright (c) 2003 The NetBSD Foundation, Inc. 4 * All rights reserved. 5 * 6 * This code is derived from software contributed to The NetBSD Foundation 7 * by Konrad E. Schroder <perseant@hhhh.org>. 8 * 9 * Redistribution and use in source and binary forms, with or without 10 * modification, are permitted provided that the following conditions 11 * are met: 12 * 1. Redistributions of source code must retain the above copyright 13 * notice, this list of conditions and the following disclaimer. 14 * 2. Redistributions in binary form must reproduce the above copyright 15 * notice, this list of conditions and the following disclaimer in the 16 * documentation and/or other materials provided with the distribution. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 19 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 20 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 22 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 * POSSIBILITY OF SUCH DAMAGE. 29 */ 30 31#define VNODE_HASH_MAX 1024 /* Must be a PO2 */ 32#define VNODE_CACHE_SIZE 1024 /* Need not be a PO2 */ 33 34LIST_HEAD(ubuflists, ubuf); 35LIST_HEAD(uvnodelst, uvnode); 36LIST_HEAD(vgrlst, vget_reg); 37 38struct uvnode { 39 int v_fd; 40 int (*v_strategy_op) (struct ubuf *); 41 int (*v_bwrite_op) (struct ubuf *); 42 int (*v_bmap_op) (struct uvnode *, daddr_t, daddr_t *); 43 u_int32_t v_uflag; 44 void *v_fs; 45 void *v_data; 46#undef v_usecount 47 int v_usecount; 48 struct ubuflists v_cleanblkhd; /* clean blocklist head */ 49 struct ubuflists v_dirtyblkhd; /* dirty blocklist head */ 50 LIST_ENTRY(uvnode) v_mntvnodes; 51 LIST_ENTRY(uvnode) v_getvnodes; 52}; 53 54struct vget_reg { 55 void *vgr_fs; 56 struct uvnode *(*vgr_func) (void *, ino_t); 57 LIST_ENTRY(vget_reg) vgr_list; 58}; 59 60#define VOP_STRATEGY(bp) ((bp)->b_vp->v_strategy_op(bp)) 61#define VOP_BWRITE(bp) ((bp)->b_vp->v_bwrite_op(bp)) 62#define VOP_BMAP(vp, lbn, daddrp) ((vp)->v_bmap_op((vp), (lbn), (daddrp))) 63 64extern int fsdirty; 65extern struct uvnodelst vnodelist; 66 67int raw_vop_strategy(struct ubuf *); 68int raw_vop_bwrite(struct ubuf *); 69int raw_vop_bmap(struct uvnode *, daddr_t, daddr_t *); 70 71void vnode_destroy(struct uvnode *); 72struct uvnode *vget(void *, ino_t); 73void register_vget(void *, struct uvnode *(void *, ino_t)); 74void vfs_init(void); 75