xref: /openbsd/sys/ufs/ffs/ffs_extern.h (revision 307cfebb)
1 /*	$OpenBSD: ffs_extern.h,v 1.51 2024/10/08 02:58:26 jsg Exp $	*/
2 /*	$NetBSD: ffs_extern.h,v 1.4 1996/02/09 22:22:22 christos Exp $	*/
3 
4 /*
5  * Copyright (c) 1991, 1993, 1994
6  *	The Regents of the University of California.  All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in the
15  *    documentation and/or other materials provided with the distribution.
16  * 3. Neither the name of the University nor the names of its contributors
17  *    may be used to endorse or promote products derived from this software
18  *    without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30  * SUCH DAMAGE.
31  *
32  *	@(#)ffs_extern.h	8.3 (Berkeley) 4/16/94
33  */
34 
35 #define FFS_CLUSTERREAD		1	/* cluster reading enabled */
36 #define FFS_CLUSTERWRITE	2	/* cluster writing enabled */
37 #define FFS_REALLOCBLKS		3	/* block reallocation enabled */
38 #define FFS_ASYNCFREE		4	/* asynchronous block freeing enabled */
39 #define	FFS_MAX_SOFTDEPS	5	/* maximum structs before slowdown */
40 #define	FFS_SD_TICKDELAY	6	/* ticks to pause during slowdown */
41 #define	FFS_SD_WORKLIST_PUSH	7	/* # of worklist cleanups */
42 #define	FFS_SD_BLK_LIMIT_PUSH	8	/* # of times block limit neared */
43 #define	FFS_SD_INO_LIMIT_PUSH	9	/* # of times inode limit neared */
44 #define	FFS_SD_BLK_LIMIT_HIT	10	/* # of times block slowdown imposed */
45 #define	FFS_SD_INO_LIMIT_HIT	11	/* # of times inode slowdown imposed */
46 #define	FFS_SD_SYNC_LIMIT_HIT	12	/* # of synchronous slowdowns imposed */
47 #define	FFS_SD_INDIR_BLK_PTRS	13	/* bufs redirtied as indir ptrs not written */
48 #define	FFS_SD_INODE_BITMAP	14	/* bufs redirtied as inode bitmap not written */
49 #define	FFS_SD_DIRECT_BLK_PTRS	15	/* bufs redirtied as direct ptrs not written */
50 #define	FFS_SD_DIR_ENTRY	16	/* bufs redirtied as dir entry cannot write */
51 #define	FFS_DIRHASH_DIRSIZE	17	/* min directory size, in bytes */
52 #define	FFS_DIRHASH_MAXMEM	18	/* max kvm to use, in bytes */
53 #define	FFS_DIRHASH_MEM		19	/* current mem usage, in bytes */
54 #define	FFS_MAXID		20	/* number of valid ffs ids */
55 
56 #define FFS_NAMES { \
57 	{ 0, 0 }, \
58 	{ 0, 0 }, \
59 	{ 0, 0 }, \
60 	{ 0, 0 }, \
61 	{ 0, 0 }, \
62 	{ 0, 0 }, \
63 	{ 0, 0 }, \
64 	{ 0, 0 }, \
65 	{ 0, 0 }, \
66 	{ 0, 0 }, \
67 	{ 0, 0 }, \
68 	{ 0, 0 }, \
69 	{ 0, 0 }, \
70 	{ 0, 0 }, \
71 	{ 0, 0 }, \
72 	{ 0, 0 }, \
73 	{ 0, 0 }, \
74 	{ "dirhash_dirsize", CTLTYPE_INT }, \
75 	{ "dirhash_maxmem", CTLTYPE_INT }, \
76 	{ "dirhash_mem", CTLTYPE_INT }, \
77 }
78 
79 struct buf;
80 struct fid;
81 struct fs;
82 struct inode;
83 struct mount;
84 struct nameidata;
85 struct proc;
86 struct statfs;
87 struct timeval;
88 struct ucred;
89 struct ufsmount;
90 struct vfsconf;
91 struct uio;
92 struct vnode;
93 struct mbuf;
94 struct cg;
95 struct vop_vfree_args;
96 
97 extern const struct vops	ffs_vops;
98 extern const struct vops	ffs_specvops;
99 extern const struct vops	ffs_fifovops;
100 
101 /* ffs_alloc.c */
102 int ffs_alloc(struct inode *, daddr_t, daddr_t , int, struct ucred *,
103 		   daddr_t *);
104 int ffs_realloccg(struct inode *, daddr_t, daddr_t, int, int ,
105 		       struct ucred *, struct buf **, daddr_t *);
106 int ffs_inode_alloc(struct inode *, mode_t, struct ucred *, struct vnode **);
107 int ffs_inode_free(struct inode *, ufsino_t, mode_t);
108 int ffs_freefile(struct inode *, ufsino_t, mode_t);
109 
110 int32_t ffs1_blkpref(struct inode *, daddr_t, int, int32_t *);
111 #ifdef FFS2
112 int64_t ffs2_blkpref(struct inode *, daddr_t, int, int64_t *);
113 #endif
114 void ffs_blkfree(struct inode *, daddr_t, long);
115 void ffs_clusteracct(struct fs *, struct cg *, daddr_t, int);
116 
117 /* ffs_balloc.c */
118 int ffs_balloc(struct inode *, off_t, int, struct ucred *, int, struct buf **);
119 
120 /* ffs_inode.c */
121 int ffs_init(struct vfsconf *);
122 int ffs_update(struct inode *, int);
123 int ffs_truncate(struct inode *, off_t, int, struct ucred *);
124 
125 /* ffs_subr.c */
126 int  ffs_bufatoff(struct inode *, off_t, char **, struct buf **);
127 void ffs_fragacct(struct fs *, int, int32_t[], int);
128 int  ffs_isfreeblock(struct fs *, u_char *, daddr_t);
129 int  ffs_isblock(struct fs *, u_char *, daddr_t);
130 void ffs_clrblock(struct fs *, u_char *, daddr_t);
131 void ffs_setblock(struct fs *, u_char *, daddr_t);
132 int  ffs_vinit(struct mount *, struct vnode **);
133 
134 /* ffs_vfsops.c */
135 int ffs_mountroot(void);
136 int ffs_mount(struct mount *, const char *, void *, struct nameidata *,
137 		   struct proc *);
138 int ffs_reload(struct mount *, struct ucred *, struct proc *);
139 int ffs_mountfs(struct vnode *, struct mount *, struct proc *);
140 int ffs_oldfscompat(struct fs *);
141 int ffs_unmount(struct mount *, int, struct proc *);
142 int ffs_flushfiles(struct mount *, int, struct proc *);
143 int ffs_statfs(struct mount *, struct statfs *, struct proc *);
144 int ffs_sync(struct mount *, int, int, struct ucred *, struct proc *);
145 int ffs_vget(struct mount *, ino_t, struct vnode **);
146 int ffs_fhtovp(struct mount *, struct fid *, struct vnode **);
147 int ffs_vptofh(struct vnode *, struct fid *);
148 int ffs_sysctl(int *, u_int, void *, size_t *, void *, size_t,
149 		    struct proc *);
150 int ffs_sbupdate(struct ufsmount *, int);
151 
152 /* ffs_vnops.c */
153 int ffs_read(void *);
154 int ffs_write(void *);
155 int ffs_fsync(void *);
156 int ffs_reclaim(void *);
157 int ffsfifo_reclaim(void *);
158 
159 /*
160  * Soft dependency function prototypes.
161  */
162 
163 struct vop_vfree_args;
164 struct vop_fsync_args;
165 
166 extern struct pool ffs_ino_pool;	/* memory pool for inodes */
167 extern struct pool ffs_dinode1_pool;	/* memory pool for UFS1 dinodes */
168 #ifdef FFS2
169 extern struct pool ffs_dinode2_pool;	/* memory pool for UFS2 dinodes */
170 #endif
171