xref: /openbsd/sys/ufs/ffs/ffs_extern.h (revision db3296cf)
1 /*	$OpenBSD: ffs_extern.h,v 1.21 2003/06/02 23:28:23 millert 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_MAXID		17	/* number of valid ffs ids */
52 
53 #define FFS_NAMES { \
54 	{ 0, 0 }, \
55 	{ "doclusterread", CTLTYPE_INT }, \
56 	{ "doclusterwrite", CTLTYPE_INT }, \
57 	{ "doreallocblks", CTLTYPE_INT }, \
58 	{ "doasyncfree", CTLTYPE_INT }, \
59 	{ "max_softdeps", CTLTYPE_INT }, \
60 	{ "sd_tickdelay", CTLTYPE_INT }, \
61 	{ "sd_worklist_push", CTLTYPE_INT }, \
62 	{ "sd_blk_limit_push", CTLTYPE_INT }, \
63 	{ "sd_ino_limit_push", CTLTYPE_INT }, \
64 	{ "sd_blk_limit_hit", CTLTYPE_INT }, \
65 	{ "sd_ino_limit_hit", CTLTYPE_INT }, \
66 	{ "sd_sync_limit_hit", CTLTYPE_INT }, \
67 	{ "sd_indir_blk_ptrs", CTLTYPE_INT }, \
68 	{ "sd_inode_bitmap", CTLTYPE_INT }, \
69 	{ "sd_direct_blk_ptrs", CTLTYPE_INT }, \
70 	{ "sd_dir_entry", CTLTYPE_INT }, \
71 }
72 
73 
74 struct buf;
75 struct fid;
76 struct fs;
77 struct inode;
78 struct mount;
79 struct nameidata;
80 struct proc;
81 struct statfs;
82 struct timeval;
83 struct ucred;
84 struct ufsmount;
85 struct vfsconf;
86 struct uio;
87 struct vnode;
88 struct mbuf;
89 struct cg;
90 struct vop_vfree_args;
91 
92 __BEGIN_DECLS
93 
94 /* ffs_alloc.c */
95 int ffs_alloc(struct inode *, daddr_t, daddr_t , int, struct ucred *,
96 		   daddr_t *);
97 int ffs_realloccg(struct inode *, daddr_t, daddr_t, int, int ,
98 		       struct ucred *, struct buf **, daddr_t *);
99 int ffs_reallocblks(void *);
100 int ffs_inode_alloc(struct inode *, int, struct ucred *, struct vnode **);
101 int ffs_inode_free(struct inode *, ino_t, int);
102 int ffs_freefile(struct inode *, ino_t, int);
103 
104 daddr_t ffs_blkpref(struct inode *, daddr_t, int, daddr_t *);
105 void ffs_blkfree(struct inode *, daddr_t, long);
106 void ffs_clusteracct(struct fs *, struct cg *, daddr_t, int);
107 
108 /* ffs_balloc.c */
109 int ffs_balloc(struct inode *, off_t, int, struct ucred *, int, struct buf **);
110 
111 /* ffs_inode.c */
112 int ffs_init(struct vfsconf *);
113 int ffs_update(struct inode *, struct timespec *, struct timespec *, int);
114 int ffs_truncate(struct inode *, off_t, int, struct ucred *);
115 
116 /* ffs_subr.c */
117 int ffs_bufatoff(struct inode *, off_t, char **, struct buf **);
118 void ffs_fragacct(struct fs *, int, int32_t[], int);
119 #ifdef DIAGNOSTIC
120 void	ffs_checkoverlap(struct buf *, struct inode *);
121 #endif
122 int   ffs_isfreeblock(struct fs *, unsigned char *, daddr_t);
123 int ffs_isblock(struct fs *, unsigned char *, daddr_t);
124 void ffs_clrblock(struct fs *, u_char *, daddr_t);
125 void ffs_setblock(struct fs *, unsigned char *, daddr_t);
126 
127 /* ffs_vfsops.c */
128 int ffs_mountroot(void);
129 int ffs_mount(struct mount *, const char *, void *, struct nameidata *,
130 		   struct proc *);
131 int ffs_reload(struct mount *, struct ucred *, struct proc *);
132 int ffs_mountfs(struct vnode *, struct mount *, struct proc *);
133 int ffs_oldfscompat(struct fs *);
134 int ffs_unmount(struct mount *, int, struct proc *);
135 int ffs_flushfiles(struct mount *, int, struct proc *);
136 int ffs_statfs(struct mount *, struct statfs *, struct proc *);
137 int ffs_sync(struct mount *, int, struct ucred *, struct proc *);
138 int ffs_vget(struct mount *, ino_t, struct vnode **);
139 int ffs_fhtovp(struct mount *, struct fid *, struct vnode **);
140 int ffs_vptofh(struct vnode *, struct fid *);
141 int ffs_sysctl(int *, u_int, void *, size_t *, void *, size_t,
142 		    struct proc *);
143 int ffs_sbupdate(struct ufsmount *, int);
144 int ffs_cgupdate(struct ufsmount *, int);
145 
146 /* ffs_vnops.c */
147 int ffs_read(void *);
148 int ffs_write(void *);
149 int ffs_fsync(void *);
150 int ffs_reclaim(void *);
151 
152 
153 /*
154  * Soft dependency function prototypes.
155  */
156 
157 struct vop_vfree_args;
158 struct vop_fsync_args;
159 
160 void  softdep_initialize(void);
161 int   softdep_process_worklist(struct mount *);
162 int   softdep_mount(struct vnode *, struct mount *, struct fs *,
163           struct ucred *);
164 int   softdep_flushworklist(struct mount *, int *, struct proc *);
165 int   softdep_flushfiles(struct mount *, int, struct proc *);
166 void  softdep_update_inodeblock(struct inode *, struct buf *, int);
167 void  softdep_load_inodeblock(struct inode *);
168 void  softdep_freefile(struct vnode *, ino_t, int);
169 void  softdep_setup_freeblocks(struct inode *, off_t);
170 void  softdep_setup_inomapdep(struct buf *, struct inode *, ino_t);
171 void  softdep_setup_blkmapdep(struct buf *, struct fs *, daddr_t);
172 void  softdep_setup_allocdirect(struct inode *, ufs_lbn_t, daddr_t,
173             daddr_t, long, long, struct buf *);
174 void  softdep_setup_allocindir_meta(struct buf *, struct inode *,
175             struct buf *, int, daddr_t);
176 void  softdep_setup_allocindir_page(struct inode *, ufs_lbn_t,
177             struct buf *, int, daddr_t, daddr_t, struct buf *);
178 void  softdep_fsync_mountdev(struct vnode *);
179 int   softdep_sync_metadata(struct vop_fsync_args *);
180 int   softdep_fsync(struct vnode *vp);
181 __END_DECLS
182 
183 extern int (**ffs_vnodeop_p)(void *);
184 extern int (**ffs_specop_p)(void *);
185 #ifdef FIFO
186 extern int (**ffs_fifoop_p)(void *);
187 #define FFS_FIFOOPS ffs_fifoop_p
188 #else
189 #define FFS_FIFOOPS NULL
190 #endif
191 
192 extern struct pool ffs_ino_pool;
193