xref: /netbsd-src/sys/ufs/ffs/ffs_extern.h (revision f298a94b738ab130659689d3f04c17f6991b6de5)
1 /*	$NetBSD: ffs_extern.h,v 1.88 2023/01/07 19:41:30 chs Exp $	*/
2 
3 /*-
4  * Copyright (c) 1991, 1993, 1994
5  *	The Regents of the University of California.  All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  * 3. Neither the name of the University nor the names of its contributors
16  *    may be used to endorse or promote products derived from this software
17  *    without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29  * SUCH DAMAGE.
30  *
31  *	@(#)ffs_extern.h	8.6 (Berkeley) 3/30/95
32  */
33 
34 #ifndef _UFS_FFS_FFS_EXTERN_H_
35 #define _UFS_FFS_FFS_EXTERN_H_
36 
37 /*
38  * Sysctl values for the fast filesystem.
39  */
40 #define FFS_CLUSTERREAD		1	/* cluster reading enabled */
41 #define FFS_CLUSTERWRITE	2	/* cluster writing enabled */
42 #define FFS_REALLOCBLKS		3	/* block reallocation enabled */
43 #define FFS_ASYNCFREE		4	/* asynchronous block freeing enabled */
44 #define FFS_LOG_CHANGEOPT	5	/* log optimalization strategy change */
45 #define FFS_EXTATTR_AUTOCREATE	6	/* size for backing file autocreation */
46 
47 struct buf;
48 struct fid;
49 struct fs;
50 struct inode;
51 struct ufs1_dinode;
52 struct ufs2_dinode;
53 struct mount;
54 struct nameidata;
55 struct lwp;
56 struct statvfs;
57 struct timeval;
58 struct timespec;
59 struct ufsmount;
60 struct uio;
61 struct vnode;
62 struct mbuf;
63 struct cg;
64 
65 #if defined(_KERNEL)
66 
67 #include <sys/pool.h>
68 
69 #define FFS_NOBLK		((daddr_t)-1)
70 
71 #define	FFS_ITIMES(ip, acc, mod, cre) \
72 	while ((ip)->i_flag & (IN_ACCESS | IN_CHANGE | IN_UPDATE | IN_MODIFY)) \
73 		ffs_itimes(ip, acc, mod, cre)
74 
75 extern pool_cache_t ffs_inode_cache;	/* memory pool for inodes */
76 extern pool_cache_t ffs_dinode1_cache;	/* memory pool for UFS1 dinodes */
77 extern pool_cache_t ffs_dinode2_cache;	/* memory pool for UFS2 dinodes */
78 
79 #endif /* defined(_KERNEL) */
80 
81 __BEGIN_DECLS
82 
83 #if defined(_KERNEL)
84 
85 #include <sys/param.h>
86 #include <sys/mount.h>
87 #include <sys/wapbl.h>
88 
89 /* ffs_alloc.c */
90 int	ffs_alloc(struct inode *, daddr_t, daddr_t , int, int, kauth_cred_t,
91 		  daddr_t *);
92 int	ffs_realloccg(struct inode *, daddr_t, daddr_t, daddr_t, int, int,
93 		      int, kauth_cred_t, struct buf **, daddr_t *);
94 int	ffs_valloc(struct vnode *, int, kauth_cred_t, ino_t *);
95 daddr_t	ffs_blkpref_ufs1(struct inode *, daddr_t, int, int, int32_t *);
96 daddr_t	ffs_blkpref_ufs2(struct inode *, daddr_t, int, int, int64_t *);
97 int	ffs_blkalloc(struct inode *, daddr_t, long);
98 int	ffs_blkalloc_ump(struct ufsmount *, daddr_t, long);
99 void	ffs_blkfree(struct fs *, struct vnode *, daddr_t, long, ino_t);
100 void	*ffs_discard_init(struct vnode *, struct fs *);
101 void	ffs_discard_finish(void *, int);
102 void	ffs_blkfree_snap(struct fs *, struct vnode *, daddr_t, long, ino_t);
103 int	ffs_vfree(struct vnode *, ino_t, int);
104 int	ffs_checkfreefile(struct fs *, struct vnode *, ino_t);
105 int	ffs_freefile(struct mount *, ino_t, int);
106 int	ffs_freefile_snap(struct fs *, struct vnode *, ino_t, int);
107 
108 /* ffs_balloc.c */
109 int	ffs_balloc(struct vnode *, off_t, int, kauth_cred_t, int,
110     struct buf **);
111 
112 /* ffs_inode.c */
113 int	ffs_update(struct vnode *, const struct timespec *,
114     const struct timespec *, int);
115 int	ffs_truncate(struct vnode *, off_t, int, kauth_cred_t);
116 
117 /* ffs_vfsops.c */
118 VFS_PROTOS(ffs);
119 
120 int     ffs_reload(struct mount *, kauth_cred_t, struct lwp *);
121 int     ffs_mountfs(struct vnode *, struct mount *, struct lwp *);
122 int	ffs_flushfiles(struct mount *, int, struct lwp *);
123 int	ffs_sbupdate(struct ufsmount *, int);
124 int	ffs_cgupdate(struct ufsmount *, int);
125 
126 /* ffs_vnops.c */
127 int	ffs_read(void *);
128 int	ffs_write(void *);
129 int	ffs_bufio(enum uio_rw, struct vnode *, void *, size_t, off_t, int,
130 	    kauth_cred_t, size_t *, struct lwp *);
131 int	ffs_bufrd(struct vnode *, struct uio *, int, kauth_cred_t);
132 int	ffs_bufwr(struct vnode *, struct uio *, int, kauth_cred_t);
133 int	ffs_fsync(void *);
134 int	ffs_spec_fsync(void *);
135 int	ffs_reclaim(void *);
136 int	ffs_getpages(void *);
137 void	ffs_gop_size(struct vnode *, off_t, off_t *, int);
138 int	ffs_lock(void *);
139 int	ffs_unlock(void *);
140 int	ffs_islocked(void *);
141 int	ffs_full_fsync(struct vnode *, int);
142 
143 /* ffs_extattr.c */
144 int	ffs_openextattr(void *);
145 int	ffs_closeextattr(void *);
146 int	ffs_getextattr(void *);
147 int	ffs_setextattr(void *);
148 int	ffs_listextattr(void *);
149 int	ffs_deleteextattr(void *);
150 int	ffsext_strategy(void *);
151 
152 /*
153  * Snapshot function prototypes.
154  */
155 int	ffs_snapshot_init(struct ufsmount *);
156 void	ffs_snapshot_fini(struct ufsmount *);
157 int	ffs_snapblkfree(struct fs *, struct vnode *, daddr_t, long, ino_t);
158 void	ffs_snapremove(struct vnode *);
159 int	ffs_snapshot(struct mount *, struct vnode *, struct timespec *);
160 void	ffs_snapshot_mount(struct mount *);
161 void	ffs_snapshot_unmount(struct mount *);
162 void	ffs_snapgone(struct vnode *);
163 int	ffs_snapshot_read(struct vnode *, struct uio *, int);
164 
165 /* Write Ahead Physical Block Logging */
166 void	ffs_wapbl_verify_inodes(struct mount *, const char *);
167 void	ffs_wapbl_replay_finish(struct mount *);
168 int	ffs_wapbl_start(struct mount *);
169 int	ffs_wapbl_stop(struct mount *, int);
170 int	ffs_wapbl_replay_start(struct mount *, struct fs *, struct vnode *);
171 void	ffs_wapbl_blkalloc(struct fs *, struct vnode *, daddr_t, int);
172 
173 void	ffs_wapbl_sync_metadata(struct mount *, struct wapbl_dealloc *);
174 void	ffs_wapbl_abort_sync_metadata(struct mount *, struct wapbl_dealloc *);
175 
176 extern int (**ffs_vnodeop_p)(void *);
177 extern int (**ffs_specop_p)(void *);
178 extern int (**ffs_fifoop_p)(void *);
179 
180 #endif /* defined(_KERNEL) */
181 
182 /* ffs_appleufs.c */
183 struct appleufslabel;
184 u_int16_t ffs_appleufs_cksum(const struct appleufslabel *);
185 int	ffs_appleufs_validate(const char*, const struct appleufslabel *,
186 			      struct appleufslabel *);
187 void	ffs_appleufs_set(struct appleufslabel *, const char *, time_t,
188 			 uint64_t);
189 
190 /* ffs_bswap.c */
191 void	ffs_sb_swap(const struct fs *, struct fs *);
192 void	ffs_dinode1_swap(struct ufs1_dinode *, struct ufs1_dinode *);
193 void	ffs_dinode2_swap(struct ufs2_dinode *, struct ufs2_dinode *);
194 struct csum;
195 void	ffs_csum_swap(struct csum *, struct csum *, int);
196 struct csum_total;
197 void	ffs_csumtotal_swap(const struct csum_total *, struct csum_total *);
198 void	ffs_cg_swap(struct cg *, struct cg *, struct fs *);
199 
200 /* ffs_subr.c */
201 #if defined(_KERNEL)
202 void	ffs_load_inode(struct buf *, struct inode *, struct fs *, ino_t);
203 int	ffs_getblk(struct vnode *, daddr_t, daddr_t, int, bool, buf_t **);
204 #endif /* defined(_KERNEL) */
205 void	ffs_fragacct(struct fs *, int, uint32_t[], int, int);
206 int	ffs_isblock(struct fs *, u_char *, int32_t);
207 int	ffs_isfreeblock(struct fs *, u_char *, int32_t);
208 void	ffs_clrblock(struct fs *, u_char *, int32_t);
209 void	ffs_setblock(struct fs *, u_char *, int32_t);
210 void	ffs_itimes(struct inode *, const struct timespec *,
211     const struct timespec *, const struct timespec *);
212 void	ffs_clusteracct(struct fs *, struct cg *, int32_t, int);
213 
214 /* ffs_quota2.c */
215 int	ffs_quota2_mount(struct mount *);
216 
217 __END_DECLS
218 
219 #endif /* !_UFS_FFS_FFS_EXTERN_H_ */
220