lfs_extern.h revision 1.122 1 /* $NetBSD: lfs_extern.h,v 1.122 2025/09/17 04:01:53 perseant Exp $ */
2
3 /*-
4 * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Konrad E. Schroder <perseant (at) hhhh.org>.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 */
31 /*-
32 * Copyright (c) 1991, 1993, 1994
33 * The Regents of the University of California. All rights reserved.
34 *
35 * Redistribution and use in source and binary forms, with or without
36 * modification, are permitted provided that the following conditions
37 * are met:
38 * 1. Redistributions of source code must retain the above copyright
39 * notice, this list of conditions and the following disclaimer.
40 * 2. Redistributions in binary form must reproduce the above copyright
41 * notice, this list of conditions and the following disclaimer in the
42 * documentation and/or other materials provided with the distribution.
43 * 3. Neither the name of the University nor the names of its contributors
44 * may be used to endorse or promote products derived from this software
45 * without specific prior written permission.
46 *
47 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
48 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
49 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
50 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
51 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
52 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
53 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
54 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
55 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
56 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
57 * SUCH DAMAGE.
58 *
59 * @(#)lfs_extern.h 8.6 (Berkeley) 5/8/95
60 */
61
62 #ifndef _UFS_LFS_LFS_EXTERN_H_
63 #define _UFS_LFS_LFS_EXTERN_H_
64
65 #ifdef _KERNEL
66 #include <sys/mallocvar.h>
67
68 MALLOC_DECLARE(M_SEGMENT);
69 #endif
70
71 /* Copied from ext2fs for ITIMES. XXX This is a bogus use of v_tag. */
72 #define IS_LFS_VNODE(vp) (vp->v_tag == VT_LFS)
73
74 /*
75 * Sysctl values for LFS.
76 */
77 #define LFS_WRITEINDIR 1 /* flush indirect blocks on non-checkpoint writes */
78 #define LFS_CLEAN_VNHEAD 2 /* put prev unrefed cleaned vnodes on head of free list */
79 #define LFS_DOSTATS 3
80 #define LFS_MAXPAGES 4
81 #define LFS_FS_PAGETRIP 5
82 #define LFS_STATS 6
83 #define LFS_DO_RFW 7
84 #define LFS_DEBUG 8
85 #define LFS_DEBUG_FREELIST 1
86 #define LFS_DEBUG_LOG 2
87 #define LFS_IGNORE_LAZY_SYNC 9
88 #define LFS_RFW_LIMIT 10
89
90 /* not ours */
91 struct fid;
92 struct mount;
93 struct nameidata;
94 struct proc;
95 struct statvfs;
96 struct timeval;
97 struct uio;
98 struct mbuf;
99 struct buf;
100 struct vnode;
101 struct work;
102
103 /* ours */
104 struct inode;
105 union lfs_dinode;
106 struct dlfs;
107 struct lfs;
108 struct segment;
109 struct block_info;
110
111 __BEGIN_DECLS
112
113 #if defined(_KERNEL)
114
115 extern kcondvar_t lfs_allclean_wakeup;
116 extern struct pool lfs_inode_pool; /* memory pool for inodes */
117 extern struct pool lfs_dinode_pool; /* memory pool for dinodes */
118 extern struct pool lfs_inoext_pool; /* memory pool for inode extension */
119 extern struct pool lfs_lbnentry_pool; /* memory pool for balloc accounting */
120
121 extern int locked_queue_count;
122 extern long locked_queue_bytes;
123 extern int lfs_do_check_freelist;
124 extern int lfs_subsys_pages;
125 extern int lfs_dirvcount;
126 extern kmutex_t lfs_lock;
127 extern int lfs_debug_log_subsys[];
128 extern kcondvar_t lfs_writing_cv;
129 extern kcondvar_t locked_queue_cv;
130 extern int lfs_rfw_max_psegs;
131
132 /* lfs_alloc.c */
133 int lfs_valloc(struct vnode *, int, kauth_cred_t, ino_t *, int *);
134 int lfs_valloc_fixed(struct lfs *, ino_t, int);
135 int lfs_vfree(struct vnode *, ino_t, int);
136 void lfs_order_freelist(struct lfs *, ino_t **, size_t *);
137 int lfs_extend_ifile(struct lfs *, kauth_cred_t);
138 void lfs_orphan(struct lfs *, ino_t);
139 void lfs_free_orphans(struct lfs *, ino_t *, size_t);
140 #ifdef DEBUG
141 void lfs_check_freelist(struct lfs *, const char *, int);
142 # define DEBUG_CHECK_FREELIST(fs) \
143 do { \
144 if (lfs_do_check_freelist) \
145 lfs_check_freelist((fs), __func__, __LINE__); \
146 } while (0)
147 #else /* ! DEBUG */
148 # define DEBUG_CHECK_FREELIST(fs)
149 #endif /* DEBUG */
150
151 /* lfs_balloc.c */
152 int lfs_balloc(struct vnode *, off_t, int, kauth_cred_t, int, struct buf **);
153 void lfs_register_block(struct vnode *, daddr_t);
154 void lfs_deregister_block(struct vnode *, daddr_t);
155 void lfs_deregister_all(struct vnode *);
156
157 /* lfs_bio.c */
158 int lfs_availwait(struct lfs *, int);
159 int lfs_bwrite_ext(struct buf *, int);
160 int lfs_fits(struct lfs *, int);
161 void lfs_flush_fs(struct lfs *, int);
162 void lfs_flush(struct lfs *, int, int);
163 int lfs_check(struct vnode *, daddr_t, int);
164 void lfs_freebuf(struct lfs *, struct buf *);
165 struct buf *lfs_newbuf(struct lfs *, struct vnode *, daddr_t, size_t, int);
166 void lfs_countlocked(int *, long *, const char *);
167 int lfs_reserve(struct lfs *, struct vnode *, struct vnode *, int);
168 int lfs_max_bufs(void);
169 int lfs_wait_bufs(void);
170
171 /* lfs_debug.c */
172 #ifdef DEBUG
173 int lfs_bwrite_log(struct buf *, const char *, int);
174 void lfs_dumplog(void);
175 void lfs_dump_super(struct lfs *);
176 void lfs_dump_dinode(struct lfs *, union lfs_dinode *);
177 void lfs_check_bpp(struct lfs *, struct segment *, char *, int);
178 void lfs_check_segsum(struct lfs *, struct segment *, char *, int);
179 void lfs_debug_log(int, const char *, ...);
180 #endif /* DEBUG */
181
182 /* lfs_inode.c */
183 int lfs_update(struct vnode *, const struct timespec *, const struct timespec *,
184 int);
185 int lfs_truncate(struct vnode *, off_t, int, kauth_cred_t);
186 union lfs_dinode *lfs_ifind(struct lfs *, ino_t, struct buf *);
187 void lfs_finalize_ino_seguse(struct lfs *, struct inode *);
188 void lfs_finalize_fs_seguse(struct lfs *);
189
190 /* lfs_rename.c */
191 int lfs_rename(void *);
192
193 /* lfs_rfw.c */
194 int lfs_rf_valloc(struct lfs *, ino_t, int, struct lwp *, struct vnode **, union lfs_dinode *);
195 void lfs_roll_forward(struct lfs *, struct mount *, struct lwp *);
196
197 /* lfs_segment.c */
198 void lfs_imtime(struct lfs *);
199 int lfs_vflush(struct vnode *);
200 int lfs_segwrite(struct mount *, int);
201 int lfs_writefile(struct lfs *, struct segment *, struct vnode *);
202 int lfs_writeinode(struct lfs *, struct segment *, struct inode *);
203 int lfs_gatherblock(struct segment *, struct buf *, kmutex_t *);
204 int lfs_gather(struct lfs *, struct segment *, struct vnode *, int (*match )(struct lfs *, struct buf *));
205 void lfs_update_single(struct lfs *, struct segment *, struct vnode *,
206 daddr_t, daddr_t, int);
207 void lfs_updatemeta(struct segment *);
208 int lfs_rewind(struct lfs *, int);
209 void lfs_unset_inval_all(struct lfs *);
210 int lfs_initseg(struct lfs *, uint16_t);
211 int lfs_writeseg(struct lfs *, struct segment *);
212 void lfs_writesuper(struct lfs *, daddr_t);
213 int lfs_match_data(struct lfs *, struct buf *);
214 int lfs_match_indir(struct lfs *, struct buf *);
215 int lfs_match_dindir(struct lfs *, struct buf *);
216 int lfs_match_tindir(struct lfs *, struct buf *);
217 void lfs_acquire_finfo(struct lfs *fs, ino_t, int);
218 void lfs_release_finfo(struct lfs *fs);
219 void lfs_cluster_work(struct work *wk, void *arg);
220 void lfs_super_work(struct work *wk, void *arg);
221 void lfs_free_work(struct work *wk, void *arg);
222 void lfs_free_aiodone(struct buf *);
223
224 /* lfs_subr.c */
225 void lfs_setup_resblks(struct lfs *);
226 void lfs_pad_check(unsigned char *, int, char *, int);
227 void lfs_free_resblks(struct lfs *);
228 void *lfs_malloc(struct lfs *, size_t, int);
229 void lfs_free(struct lfs *, void *, int);
230 int lfs_seglock(struct lfs *, unsigned long);
231 void lfs_segunlock(struct lfs *);
232 void lfs_segunlock_relock(struct lfs *);
233 void lfs_writer_enter(struct lfs *, const char *);
234 int lfs_writer_tryenter(struct lfs *);
235 void lfs_writer_leave(struct lfs *);
236 void lfs_wakeup_cleaner(struct lfs *);
237
238 /* lfs_syscalls.c */
239 int lfs_do_segclean(struct lfs *, unsigned long);
240 int lfs_segwait(fsid_t *, struct timeval *);
241 int lfs_bmapv(struct lwp *, fsid_t *, struct block_info *, int);
242 int lfs_markv(struct lwp *, fsid_t *, struct block_info *, int);
243
244 /* lfs_vfsops.c */
245 VFS_PROTOS(lfs);
246 void lfs_vinit(struct mount *, struct vnode **);
247 int lfs_resize_fs(struct lfs *, int);
248 void lfs_reset_avail(struct lfs *);
249
250 /* lfs_vnops.c */
251 void lfs_mark_vnode(struct vnode *);
252 void lfs_unmark_vnode(struct vnode *);
253 int lfs_gop_alloc(struct vnode *, off_t, off_t, int, kauth_cred_t);
254 void lfs_gop_size(struct vnode *, off_t, off_t *, int);
255 int lfs_putpages_ext(void *, int);
256 int lfs_gatherpages(struct vnode *);
257 int lfs_flush_dirops(struct lfs *);
258 int lfs_flush_pchain(struct lfs *);
259
260 int lfs_bwrite (void *);
261 int lfs_fsync (void *);
262 int lfs_symlink (void *);
263 int lfs_mknod (void *);
264 int lfs_create (void *);
265 int lfs_mkdir (void *);
266 int lfs_read (void *);
267 int lfs_remove (void *);
268 int lfs_rmdir (void *);
269 int lfs_link (void *);
270 int lfs_mmap (void *);
271 int lfs_rename (void *);
272 int lfs_getattr (void *);
273 int lfs_setattr (void *);
274 int lfs_close (void *);
275 int lfsspec_close(void *);
276 int lfsfifo_close(void *);
277 int lfs_fcntl (void *);
278 int lfs_inactive (void *);
279 int lfs_reclaim (void *);
280 int lfs_strategy (void *);
281 int lfs_write (void *);
282 int lfs_getpages (void *);
283 int lfs_putpages (void *);
284
285 int lfs_bufrd(struct vnode *, struct uio *, int, kauth_cred_t);
286 int lfs_bufwr(struct vnode *, struct uio *, int, kauth_cred_t);
287
288 extern int lfs_mount_type;
289 extern int (**lfs_vnodeop_p)(void *);
290 extern int (**lfs_specop_p)(void *);
291 extern int (**lfs_fifoop_p)(void *);
292 extern const struct genfs_ops lfs_genfsops;
293
294 #endif /* defined(_KERNEL) */
295
296 /* lfs_cksum.c */
297 uint32_t cksum(void *, size_t);
298 uint32_t lfs_cksum_part(void *, size_t, uint32_t);
299 #define lfs_cksum_fold(sum) (sum)
300 uint32_t lfs_sb_cksum(struct lfs *);
301
302 __END_DECLS
303
304 #endif /* !_UFS_LFS_LFS_EXTERN_H_ */
305