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