xref: /openbsd-src/sys/ufs/ffs/ffs_extern.h (revision 307cfebb4763f3c4ca6ad5215fb00804000935ec)
1*307cfebbSjsg /*	$OpenBSD: ffs_extern.h,v 1.51 2024/10/08 02:58:26 jsg Exp $	*/
2d28910b8Sniklas /*	$NetBSD: ffs_extern.h,v 1.4 1996/02/09 22:22:22 christos Exp $	*/
3df930be7Sderaadt 
47fd3a002Spedro /*
5df930be7Sderaadt  * Copyright (c) 1991, 1993, 1994
6df930be7Sderaadt  *	The Regents of the University of California.  All rights reserved.
7df930be7Sderaadt  *
8df930be7Sderaadt  * Redistribution and use in source and binary forms, with or without
9df930be7Sderaadt  * modification, are permitted provided that the following conditions
10df930be7Sderaadt  * are met:
11df930be7Sderaadt  * 1. Redistributions of source code must retain the above copyright
12df930be7Sderaadt  *    notice, this list of conditions and the following disclaimer.
13df930be7Sderaadt  * 2. Redistributions in binary form must reproduce the above copyright
14df930be7Sderaadt  *    notice, this list of conditions and the following disclaimer in the
15df930be7Sderaadt  *    documentation and/or other materials provided with the distribution.
1629295d1cSmillert  * 3. Neither the name of the University nor the names of its contributors
17df930be7Sderaadt  *    may be used to endorse or promote products derived from this software
18df930be7Sderaadt  *    without specific prior written permission.
19df930be7Sderaadt  *
20df930be7Sderaadt  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21df930be7Sderaadt  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22df930be7Sderaadt  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23df930be7Sderaadt  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24df930be7Sderaadt  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25df930be7Sderaadt  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26df930be7Sderaadt  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27df930be7Sderaadt  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28df930be7Sderaadt  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29df930be7Sderaadt  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30df930be7Sderaadt  * SUCH DAMAGE.
31df930be7Sderaadt  *
32df930be7Sderaadt  *	@(#)ffs_extern.h	8.3 (Berkeley) 4/16/94
33df930be7Sderaadt  */
34df930be7Sderaadt 
3507feb63cScsapuntz #define FFS_CLUSTERREAD		1	/* cluster reading enabled */
3607feb63cScsapuntz #define FFS_CLUSTERWRITE	2	/* cluster writing enabled */
3707feb63cScsapuntz #define FFS_REALLOCBLKS		3	/* block reallocation enabled */
3807feb63cScsapuntz #define FFS_ASYNCFREE		4	/* asynchronous block freeing enabled */
39cb1c4641Sjca #define	FFS_MAX_SOFTDEPS	5	/* maximum structs before slowdown */
40eac15e2aSmillert #define	FFS_SD_TICKDELAY	6	/* ticks to pause during slowdown */
41eac15e2aSmillert #define	FFS_SD_WORKLIST_PUSH	7	/* # of worklist cleanups */
42eac15e2aSmillert #define	FFS_SD_BLK_LIMIT_PUSH	8	/* # of times block limit neared */
43eac15e2aSmillert #define	FFS_SD_INO_LIMIT_PUSH	9	/* # of times inode limit neared */
44eac15e2aSmillert #define	FFS_SD_BLK_LIMIT_HIT	10	/* # of times block slowdown imposed */
45eac15e2aSmillert #define	FFS_SD_INO_LIMIT_HIT	11	/* # of times inode slowdown imposed */
46eac15e2aSmillert #define	FFS_SD_SYNC_LIMIT_HIT	12	/* # of synchronous slowdowns imposed */
47eac15e2aSmillert #define	FFS_SD_INDIR_BLK_PTRS	13	/* bufs redirtied as indir ptrs not written */
48eac15e2aSmillert #define	FFS_SD_INODE_BITMAP	14	/* bufs redirtied as inode bitmap not written */
49eac15e2aSmillert #define	FFS_SD_DIRECT_BLK_PTRS	15	/* bufs redirtied as direct ptrs not written */
50eac15e2aSmillert #define	FFS_SD_DIR_ENTRY	16	/* bufs redirtied as dir entry cannot write */
513c0cca26Stedu #define	FFS_DIRHASH_DIRSIZE	17	/* min directory size, in bytes */
523c0cca26Stedu #define	FFS_DIRHASH_MAXMEM	18	/* max kvm to use, in bytes */
533c0cca26Stedu #define	FFS_DIRHASH_MEM		19	/* current mem usage, in bytes */
543c0cca26Stedu #define	FFS_MAXID		20	/* number of valid ffs ids */
5507feb63cScsapuntz 
5607feb63cScsapuntz #define FFS_NAMES { \
5707feb63cScsapuntz 	{ 0, 0 }, \
58b75d15caSmpi 	{ 0, 0 }, \
59b75d15caSmpi 	{ 0, 0 }, \
602e90784bSnatano 	{ 0, 0 }, \
612e90784bSnatano 	{ 0, 0 }, \
6255d645bcSotto 	{ 0, 0 }, \
634ea0b15aSjca 	{ 0, 0 }, \
644ea0b15aSjca 	{ 0, 0 }, \
654ea0b15aSjca 	{ 0, 0 }, \
664ea0b15aSjca 	{ 0, 0 }, \
674ea0b15aSjca 	{ 0, 0 }, \
684ea0b15aSjca 	{ 0, 0 }, \
694ea0b15aSjca 	{ 0, 0 }, \
704ea0b15aSjca 	{ 0, 0 }, \
714ea0b15aSjca 	{ 0, 0 }, \
724ea0b15aSjca 	{ 0, 0 }, \
734ea0b15aSjca 	{ 0, 0 }, \
743c0cca26Stedu 	{ "dirhash_dirsize", CTLTYPE_INT }, \
753c0cca26Stedu 	{ "dirhash_maxmem", CTLTYPE_INT }, \
763c0cca26Stedu 	{ "dirhash_mem", CTLTYPE_INT }, \
7707feb63cScsapuntz }
7807feb63cScsapuntz 
79df930be7Sderaadt struct buf;
80df930be7Sderaadt struct fid;
81df930be7Sderaadt struct fs;
82df930be7Sderaadt struct inode;
83df930be7Sderaadt struct mount;
84df930be7Sderaadt struct nameidata;
85df930be7Sderaadt struct proc;
86df930be7Sderaadt struct statfs;
87df930be7Sderaadt struct timeval;
88df930be7Sderaadt struct ucred;
89d28910b8Sniklas struct ufsmount;
9007feb63cScsapuntz struct vfsconf;
91df930be7Sderaadt struct uio;
92df930be7Sderaadt struct vnode;
93df930be7Sderaadt struct mbuf;
94d28910b8Sniklas struct cg;
95bf701d15Smillert struct vop_vfree_args;
96df930be7Sderaadt 
972d6b9e38Sclaudio extern const struct vops	ffs_vops;
982d6b9e38Sclaudio extern const struct vops	ffs_specvops;
992d6b9e38Sclaudio extern const struct vops	ffs_fifovops;
100d28910b8Sniklas 
101d28910b8Sniklas /* ffs_alloc.c */
1021abdbfdeSderaadt int ffs_alloc(struct inode *, daddr_t, daddr_t , int, struct ucred *,
1031abdbfdeSderaadt 		   daddr_t *);
1041abdbfdeSderaadt int ffs_realloccg(struct inode *, daddr_t, daddr_t, int, int ,
1051abdbfdeSderaadt 		       struct ucred *, struct buf **, daddr_t *);
106cc2fc615Smillert int ffs_inode_alloc(struct inode *, mode_t, struct ucred *, struct vnode **);
107e012d6d3Sguenther int ffs_inode_free(struct inode *, ufsino_t, mode_t);
108e012d6d3Sguenther int ffs_freefile(struct inode *, ufsino_t, mode_t);
109b080ad39Scsapuntz 
1101abdbfdeSderaadt int32_t ffs1_blkpref(struct inode *, daddr_t, int, int32_t *);
111f4342418Spedro #ifdef FFS2
1121abdbfdeSderaadt int64_t ffs2_blkpref(struct inode *, daddr_t, int, int64_t *);
113f4342418Spedro #endif
1141abdbfdeSderaadt void ffs_blkfree(struct inode *, daddr_t, long);
1151abdbfdeSderaadt void ffs_clusteracct(struct fs *, struct cg *, daddr_t, int);
116d28910b8Sniklas 
117d28910b8Sniklas /* ffs_balloc.c */
118b080ad39Scsapuntz int ffs_balloc(struct inode *, off_t, int, struct ucred *, int, struct buf **);
119d28910b8Sniklas 
120d28910b8Sniklas /* ffs_inode.c */
121c4071fd1Smillert int ffs_init(struct vfsconf *);
122d4fc1c49Sguenther int ffs_update(struct inode *, int);
123b080ad39Scsapuntz int ffs_truncate(struct inode *, off_t, int, struct ucred *);
124d28910b8Sniklas 
125d28910b8Sniklas /* ffs_subr.c */
126b080ad39Scsapuntz int  ffs_bufatoff(struct inode *, off_t, char **, struct buf **);
127c4071fd1Smillert void ffs_fragacct(struct fs *, int, int32_t[], int);
1281abdbfdeSderaadt int  ffs_isfreeblock(struct fs *, u_char *, daddr_t);
1291abdbfdeSderaadt int  ffs_isblock(struct fs *, u_char *, daddr_t);
1301abdbfdeSderaadt void ffs_clrblock(struct fs *, u_char *, daddr_t);
1311abdbfdeSderaadt void ffs_setblock(struct fs *, u_char *, daddr_t);
132b2403cbaSnatano int  ffs_vinit(struct mount *, struct vnode **);
133d28910b8Sniklas 
134d28910b8Sniklas /* ffs_vfsops.c */
135c4071fd1Smillert int ffs_mountroot(void);
136c4071fd1Smillert int ffs_mount(struct mount *, const char *, void *, struct nameidata *,
137c4071fd1Smillert 		   struct proc *);
138c4071fd1Smillert int ffs_reload(struct mount *, struct ucred *, struct proc *);
139c4071fd1Smillert int ffs_mountfs(struct vnode *, struct mount *, struct proc *);
140c4071fd1Smillert int ffs_oldfscompat(struct fs *);
141c4071fd1Smillert int ffs_unmount(struct mount *, int, struct proc *);
142c4071fd1Smillert int ffs_flushfiles(struct mount *, int, struct proc *);
143c4071fd1Smillert int ffs_statfs(struct mount *, struct statfs *, struct proc *);
144976e9839Sderaadt int ffs_sync(struct mount *, int, int, struct ucred *, struct proc *);
145c4071fd1Smillert int ffs_vget(struct mount *, ino_t, struct vnode **);
146c4071fd1Smillert int ffs_fhtovp(struct mount *, struct fid *, struct vnode **);
147c4071fd1Smillert int ffs_vptofh(struct vnode *, struct fid *);
148c4071fd1Smillert int ffs_sysctl(int *, u_int, void *, size_t *, void *, size_t,
149c4071fd1Smillert 		    struct proc *);
150c4071fd1Smillert int ffs_sbupdate(struct ufsmount *, int);
151d28910b8Sniklas 
152d28910b8Sniklas /* ffs_vnops.c */
153c4071fd1Smillert int ffs_read(void *);
154c4071fd1Smillert int ffs_write(void *);
155c4071fd1Smillert int ffs_fsync(void *);
156c4071fd1Smillert int ffs_reclaim(void *);
157c0c67a4cStedu int ffsfifo_reclaim(void *);
1581414b0faSart 
15907feb63cScsapuntz /*
16007feb63cScsapuntz  * Soft dependency function prototypes.
16107feb63cScsapuntz  */
16207feb63cScsapuntz 
16307feb63cScsapuntz struct vop_vfree_args;
16407feb63cScsapuntz struct vop_fsync_args;
16507feb63cScsapuntz 
1661e22f4bdSpedro extern struct pool ffs_ino_pool;	/* memory pool for inodes */
1671e22f4bdSpedro extern struct pool ffs_dinode1_pool;	/* memory pool for UFS1 dinodes */
1681204efbaSpedro #ifdef FFS2
1691204efbaSpedro extern struct pool ffs_dinode2_pool;	/* memory pool for UFS2 dinodes */
1701204efbaSpedro #endif
171