vnode.h revision 1.6.4.2 1 /* $NetBSD: vnode.h,v 1.6.4.2 2025/09/06 21:51:10 perseant 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 (at) 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 #include <sys/queue.h>
32
33 #define VNODE_HASH_MAX 1024 /* Must be a PO2 */
34 #define VNODE_CACHE_SIZE 1024 /* Need not be a PO2 */
35
36 LIST_HEAD(ubuflists, ubuf);
37 LIST_HEAD(uvnodelst, uvnode);
38 LIST_HEAD(vgrlst, vget_reg);
39
40 struct uvnode {
41 int v_fd;
42 int (*v_strategy_op) (struct ubuf *);
43 int (*v_bwrite_op) (struct ubuf *);
44 int (*v_bmap_op) (struct uvnode *, daddr_t, daddr_t *);
45 u_int32_t v_uflag;
46 void *v_fs;
47 void *v_data;
48 #undef v_usecount
49 int v_usecount;
50 struct ubuflists v_cleanblkhd; /* clean blocklist head */
51 struct ubuflists v_dirtyblkhd; /* dirty blocklist head */
52 LIST_ENTRY(uvnode) v_mntvnodes;
53 LIST_ENTRY(uvnode) v_getvnodes;
54 };
55
56 struct vget_reg {
57 void *vgr_fs;
58 struct uvnode *(*vgr_func) (void *, ino_t);
59 LIST_ENTRY(vget_reg) vgr_list;
60 };
61
62 #define VOP_STRATEGY(bp) ((bp)->b_vp->v_strategy_op(bp))
63 #define VOP_BWRITE(bp) ((bp)->b_vp->v_bwrite_op(bp))
64 #define VOP_BMAP(vp, lbn, daddrp) ((vp)->v_bmap_op((vp), (lbn), (daddrp)))
65
66 extern int fsdirty;
67 extern struct uvnodelst vnodelist;
68
69 int raw_vop_strategy(struct ubuf *);
70 int raw_vop_bwrite(struct ubuf *);
71 int raw_vop_bmap(struct uvnode *, daddr_t, daddr_t *);
72
73 void vnode_destroy(struct uvnode *);
74 struct uvnode *vget(void *, ino_t);
75 void register_vget(void *, struct uvnode *(*)(void *, ino_t));
76 void vfs_init(void);
77