1 1.122 perseant /* $NetBSD: lfs_extern.h,v 1.122 2025/09/17 04:01:53 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.121 perseant #define LFS_DEBUG 8 85 1.121 perseant #define LFS_DEBUG_FREELIST 1 86 1.121 perseant #define LFS_DEBUG_LOG 2 87 1.121 perseant #define LFS_IGNORE_LAZY_SYNC 9 88 1.121 perseant #define LFS_RFW_LIMIT 10 89 1.13 perseant 90 1.110 dholland /* not ours */ 91 1.1 mycroft struct fid; 92 1.1 mycroft struct mount; 93 1.1 mycroft struct nameidata; 94 1.1 mycroft struct proc; 95 1.60 christos struct statvfs; 96 1.1 mycroft struct timeval; 97 1.1 mycroft struct uio; 98 1.1 mycroft struct mbuf; 99 1.4 christos struct buf; 100 1.4 christos struct vnode; 101 1.122 perseant struct work; 102 1.110 dholland 103 1.110 dholland /* ours */ 104 1.110 dholland struct inode; 105 1.110 dholland union lfs_dinode; 106 1.18 perseant struct dlfs; 107 1.4 christos struct lfs; 108 1.4 christos struct segment; 109 1.43 perseant struct block_info; 110 1.10 thorpej 111 1.98 joerg __BEGIN_DECLS 112 1.98 joerg 113 1.82 elad #if defined(_KERNEL) 114 1.82 elad 115 1.113 maya extern kcondvar_t lfs_allclean_wakeup; 116 1.47 fvdl extern struct pool lfs_inode_pool; /* memory pool for inodes */ 117 1.47 fvdl extern struct pool lfs_dinode_pool; /* memory pool for dinodes */ 118 1.39 perseant extern struct pool lfs_inoext_pool; /* memory pool for inode extension */ 119 1.62 perseant extern struct pool lfs_lbnentry_pool; /* memory pool for balloc accounting */ 120 1.52 yamt 121 1.52 yamt extern int locked_queue_count; 122 1.52 yamt extern long locked_queue_bytes; 123 1.121 perseant extern int lfs_do_check_freelist; 124 1.63 perry extern int lfs_subsys_pages; 125 1.52 yamt extern int lfs_dirvcount; 126 1.94 ad extern kmutex_t lfs_lock; 127 1.64 perseant extern int lfs_debug_log_subsys[]; 128 1.94 ad extern kcondvar_t lfs_writing_cv; 129 1.94 ad extern kcondvar_t locked_queue_cv; 130 1.121 perseant extern int lfs_rfw_max_psegs; 131 1.1 mycroft 132 1.4 christos /* lfs_alloc.c */ 133 1.105 hannken int lfs_valloc(struct vnode *, int, kauth_cred_t, ino_t *, int *); 134 1.105 hannken int lfs_valloc_fixed(struct lfs *, ino_t, int); 135 1.72 yamt int lfs_vfree(struct vnode *, ino_t, int); 136 1.118 riastrad void lfs_order_freelist(struct lfs *, ino_t **, size_t *); 137 1.86 perseant int lfs_extend_ifile(struct lfs *, kauth_cred_t); 138 1.87 perseant void lfs_orphan(struct lfs *, ino_t); 139 1.118 riastrad void lfs_free_orphans(struct lfs *, ino_t *, size_t); 140 1.121 perseant #ifdef DEBUG 141 1.121 perseant void lfs_check_freelist(struct lfs *, const char *, int); 142 1.121 perseant # define DEBUG_CHECK_FREELIST(fs) \ 143 1.121 perseant do { \ 144 1.121 perseant if (lfs_do_check_freelist) \ 145 1.121 perseant lfs_check_freelist((fs), __func__, __LINE__); \ 146 1.121 perseant } while (0) 147 1.121 perseant #else /* ! DEBUG */ 148 1.121 perseant # define DEBUG_CHECK_FREELIST(fs) 149 1.121 perseant #endif /* DEBUG */ 150 1.62 perseant 151 1.62 perseant /* lfs_balloc.c */ 152 1.82 elad int lfs_balloc(struct vnode *, off_t, int, kauth_cred_t, int, struct buf **); 153 1.62 perseant void lfs_register_block(struct vnode *, daddr_t); 154 1.62 perseant void lfs_deregister_block(struct vnode *, daddr_t); 155 1.66 perseant void lfs_deregister_all(struct vnode *); 156 1.62 perseant 157 1.4 christos /* lfs_bio.c */ 158 1.25 perseant int lfs_availwait(struct lfs *, int); 159 1.25 perseant int lfs_bwrite_ext(struct buf *, int); 160 1.25 perseant int lfs_fits(struct lfs *, int); 161 1.25 perseant void lfs_flush_fs(struct lfs *, int); 162 1.62 perseant void lfs_flush(struct lfs *, int, int); 163 1.35 fvdl int lfs_check(struct vnode *, daddr_t, int); 164 1.39 perseant void lfs_freebuf(struct lfs *, struct buf *); 165 1.39 perseant struct buf *lfs_newbuf(struct lfs *, struct vnode *, daddr_t, size_t, int); 166 1.68 christos void lfs_countlocked(int *, long *, const char *); 167 1.34 yamt int lfs_reserve(struct lfs *, struct vnode *, struct vnode *, int); 168 1.112 chs int lfs_max_bufs(void); 169 1.112 chs int lfs_wait_bufs(void); 170 1.4 christos 171 1.4 christos /* lfs_debug.c */ 172 1.1 mycroft #ifdef DEBUG 173 1.68 christos int lfs_bwrite_log(struct buf *, const char *, int); 174 1.30 perseant void lfs_dumplog(void); 175 1.25 perseant void lfs_dump_super(struct lfs *); 176 1.110 dholland void lfs_dump_dinode(struct lfs *, union lfs_dinode *); 177 1.25 perseant void lfs_check_bpp(struct lfs *, struct segment *, char *, int); 178 1.25 perseant void lfs_check_segsum(struct lfs *, struct segment *, char *, int); 179 1.64 perseant void lfs_debug_log(int, const char *, ...); 180 1.13 perseant #endif /* DEBUG */ 181 1.4 christos 182 1.4 christos /* lfs_inode.c */ 183 1.72 yamt int lfs_update(struct vnode *, const struct timespec *, const struct timespec *, 184 1.72 yamt int); 185 1.93 pooka int lfs_truncate(struct vnode *, off_t, int, kauth_cred_t); 186 1.110 dholland union lfs_dinode *lfs_ifind(struct lfs *, ino_t, struct buf *); 187 1.80 perseant void lfs_finalize_ino_seguse(struct lfs *, struct inode *); 188 1.80 perseant void lfs_finalize_fs_seguse(struct lfs *); 189 1.4 christos 190 1.100 dholland /* lfs_rename.c */ 191 1.100 dholland int lfs_rename(void *); 192 1.100 dholland 193 1.86 perseant /* lfs_rfw.c */ 194 1.121 perseant int lfs_rf_valloc(struct lfs *, ino_t, int, struct lwp *, struct vnode **, union lfs_dinode *); 195 1.86 perseant void lfs_roll_forward(struct lfs *, struct mount *, struct lwp *); 196 1.86 perseant 197 1.4 christos /* lfs_segment.c */ 198 1.25 perseant void lfs_imtime(struct lfs *); 199 1.25 perseant int lfs_vflush(struct vnode *); 200 1.25 perseant int lfs_segwrite(struct mount *, int); 201 1.76 perseant int lfs_writefile(struct lfs *, struct segment *, struct vnode *); 202 1.25 perseant int lfs_writeinode(struct lfs *, struct segment *, struct inode *); 203 1.94 ad int lfs_gatherblock(struct segment *, struct buf *, kmutex_t *); 204 1.25 perseant int lfs_gather(struct lfs *, struct segment *, struct vnode *, int (*match )(struct lfs *, struct buf *)); 205 1.57 yamt void lfs_update_single(struct lfs *, struct segment *, struct vnode *, 206 1.106 dholland daddr_t, daddr_t, int); 207 1.25 perseant void lfs_updatemeta(struct segment *); 208 1.67 perseant int lfs_rewind(struct lfs *, int); 209 1.67 perseant void lfs_unset_inval_all(struct lfs *); 210 1.120 perseant int lfs_initseg(struct lfs *, uint16_t); 211 1.25 perseant int lfs_writeseg(struct lfs *, struct segment *); 212 1.25 perseant void lfs_writesuper(struct lfs *, daddr_t); 213 1.25 perseant int lfs_match_data(struct lfs *, struct buf *); 214 1.25 perseant int lfs_match_indir(struct lfs *, struct buf *); 215 1.25 perseant int lfs_match_dindir(struct lfs *, struct buf *); 216 1.25 perseant int lfs_match_tindir(struct lfs *, struct buf *); 217 1.83 perseant void lfs_acquire_finfo(struct lfs *fs, ino_t, int); 218 1.83 perseant void lfs_release_finfo(struct lfs *fs); 219 1.122 perseant void lfs_cluster_work(struct work *wk, void *arg); 220 1.122 perseant void lfs_super_work(struct work *wk, void *arg); 221 1.122 perseant void lfs_free_work(struct work *wk, void *arg); 222 1.122 perseant void lfs_free_aiodone(struct buf *); 223 1.4 christos 224 1.4 christos /* lfs_subr.c */ 225 1.39 perseant void lfs_setup_resblks(struct lfs *); 226 1.43 perseant void lfs_pad_check(unsigned char *, int, char *, int); 227 1.39 perseant void lfs_free_resblks(struct lfs *); 228 1.39 perseant void *lfs_malloc(struct lfs *, size_t, int); 229 1.39 perseant void lfs_free(struct lfs *, void *, int); 230 1.39 perseant int lfs_seglock(struct lfs *, unsigned long); 231 1.25 perseant void lfs_segunlock(struct lfs *); 232 1.76 perseant void lfs_segunlock_relock(struct lfs *); 233 1.117 riastrad void lfs_writer_enter(struct lfs *, const char *); 234 1.116 riastrad int lfs_writer_tryenter(struct lfs *); 235 1.51 yamt void lfs_writer_leave(struct lfs *); 236 1.84 perseant void lfs_wakeup_cleaner(struct lfs *); 237 1.4 christos 238 1.4 christos /* lfs_syscalls.c */ 239 1.39 perseant int lfs_do_segclean(struct lfs *, unsigned long); 240 1.43 perseant int lfs_segwait(fsid_t *, struct timeval *); 241 1.109 dholland int lfs_bmapv(struct lwp *, fsid_t *, struct block_info *, int); 242 1.109 dholland int lfs_markv(struct lwp *, fsid_t *, struct block_info *, int); 243 1.4 christos 244 1.4 christos /* lfs_vfsops.c */ 245 1.103 hannken VFS_PROTOS(lfs); 246 1.67 perseant void lfs_vinit(struct mount *, struct vnode **); 247 1.67 perseant int lfs_resize_fs(struct lfs *, int); 248 1.121 perseant void lfs_reset_avail(struct lfs *); 249 1.4 christos 250 1.18 perseant /* lfs_vnops.c */ 251 1.54 yamt void lfs_mark_vnode(struct vnode *); 252 1.25 perseant void lfs_unmark_vnode(struct vnode *); 253 1.82 elad int lfs_gop_alloc(struct vnode *, off_t, off_t, int, kauth_cred_t); 254 1.39 perseant void lfs_gop_size(struct vnode *, off_t, off_t *, int); 255 1.39 perseant int lfs_putpages_ext(void *, int); 256 1.39 perseant int lfs_gatherpages(struct vnode *); 257 1.97 perseant int lfs_flush_dirops(struct lfs *); 258 1.97 perseant int lfs_flush_pchain(struct lfs *); 259 1.25 perseant 260 1.31 perseant int lfs_bwrite (void *); 261 1.31 perseant int lfs_fsync (void *); 262 1.31 perseant int lfs_symlink (void *); 263 1.31 perseant int lfs_mknod (void *); 264 1.31 perseant int lfs_create (void *); 265 1.31 perseant int lfs_mkdir (void *); 266 1.31 perseant int lfs_read (void *); 267 1.31 perseant int lfs_remove (void *); 268 1.31 perseant int lfs_rmdir (void *); 269 1.31 perseant int lfs_link (void *); 270 1.39 perseant int lfs_mmap (void *); 271 1.31 perseant int lfs_rename (void *); 272 1.31 perseant int lfs_getattr (void *); 273 1.31 perseant int lfs_setattr (void *); 274 1.31 perseant int lfs_close (void *); 275 1.31 perseant int lfsspec_close(void *); 276 1.31 perseant int lfsfifo_close(void *); 277 1.44 perseant int lfs_fcntl (void *); 278 1.31 perseant int lfs_inactive (void *); 279 1.31 perseant int lfs_reclaim (void *); 280 1.45 perseant int lfs_strategy (void *); 281 1.31 perseant int lfs_write (void *); 282 1.31 perseant int lfs_getpages (void *); 283 1.31 perseant int lfs_putpages (void *); 284 1.4 christos 285 1.102 riastrad int lfs_bufrd(struct vnode *, struct uio *, int, kauth_cred_t); 286 1.102 riastrad int lfs_bufwr(struct vnode *, struct uio *, int, kauth_cred_t); 287 1.102 riastrad 288 1.7 fvdl extern int lfs_mount_type; 289 1.25 perseant extern int (**lfs_vnodeop_p)(void *); 290 1.25 perseant extern int (**lfs_specop_p)(void *); 291 1.25 perseant extern int (**lfs_fifoop_p)(void *); 292 1.69 yamt extern const struct genfs_ops lfs_genfsops; 293 1.32 matt 294 1.82 elad #endif /* defined(_KERNEL) */ 295 1.82 elad 296 1.82 elad /* lfs_cksum.c */ 297 1.111 dholland uint32_t cksum(void *, size_t); 298 1.111 dholland uint32_t lfs_cksum_part(void *, size_t, uint32_t); 299 1.82 elad #define lfs_cksum_fold(sum) (sum) 300 1.111 dholland uint32_t lfs_sb_cksum(struct lfs *); 301 1.82 elad 302 1.82 elad __END_DECLS 303 1.82 elad 304 1.32 matt #endif /* !_UFS_LFS_LFS_EXTERN_H_ */ 305