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