Home | History | Annotate | Line # | Download | only in fsck_lfs
vnode.h revision 1.6.4.1
      1 /* $NetBSD: vnode.h,v 1.6.4.1 2024/06/29 19:43:25 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 #ifndef FSCK_LFS_VNODE_H_
     31 #define FSCK_LFS_VNODE_H_
     32 
     33 #include <sys/queue.h>
     34 
     35 #define VNODE_HASH_MAX   1024 /* Must be a PO2 */
     36 #define VNODE_CACHE_SIZE 10 /* Need not be a PO2 */
     37 
     38 LIST_HEAD(ubuflists, ubuf);
     39 LIST_HEAD(uvnodelst, uvnode);
     40 LIST_HEAD(vgrlst,    vget_reg);
     41 
     42 TAILQ_HEAD(uvnodetq, uvnode);
     43 
     44 struct uvnode {
     45 	int v_fd;
     46 	int (*v_strategy_op) (struct ubuf *);
     47 	int (*v_bwrite_op) (struct ubuf *);
     48 	int (*v_bmap_op) (struct uvnode *, daddr_t, daddr_t *);
     49 	u_int32_t v_uflag;
     50 	void *v_fs;
     51 	void *v_data;
     52 #undef v_usecount
     53 	int v_usecount;
     54 	struct ubuflists v_cleanblkhd;	/* clean blocklist head */
     55 	struct ubuflists v_dirtyblkhd;	/* dirty blocklist head */
     56 	TAILQ_ENTRY(uvnode) v_mntvnodes;
     57 	LIST_ENTRY(uvnode) v_getvnodes;
     58 	/* Unused, for source compatibility only */
     59 	int v_vflag;
     60 	int v_type;
     61 	int v_tag;
     62 };
     63 
     64 struct vget_reg {
     65 	void *vgr_fs;
     66 	struct uvnode *(*vgr_getfunc) (void *, ino_t, void *);
     67 	int (*vgr_freefunc) (struct uvnode *);
     68 	LIST_ENTRY(vget_reg) vgr_list;
     69 };
     70 
     71 #define VOP_STRATEGY(bp)          ((bp)->b_vp->v_strategy_op(bp))
     72 #define VOP_BWRITE(bp)            ((bp)->b_vp->v_bwrite_op(bp))
     73 #define VOP_BMAP(vp, lbn, daddrp) ((vp)->v_bmap_op((vp), (lbn), (daddrp)))
     74 
     75 extern int fsdirty;
     76 extern struct uvnodetq vnodetq;
     77 
     78 int raw_vop_strategy(struct ubuf *);
     79 int raw_vop_bwrite(struct ubuf *);
     80 int raw_vop_bmap(struct uvnode *, daddr_t, daddr_t *);
     81 
     82 void vnode_destroy(struct uvnode *);
     83 struct uvnode *vget(void *, ino_t);
     84 struct uvnode *vget3(void *, ino_t, void *);
     85 void register_vget(void *, struct uvnode *(*)(void *, ino_t, void *),
     86 		   int (*)(struct uvnode *));
     87 void vfs_init(void);
     88 void vref(struct uvnode *);
     89 void vrele(struct uvnode *);
     90 
     91 #endif /* FSCK_LFS_VNODE_H_ */
     92