1 /* $NetBSD: lfs_extern.h,v 1.100 2013/07/20 19:59:31 dholland 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@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_DEBUGLOG 8 85 #define LFS_IGNORE_LAZY_SYNC 9 86 #define LFS_MAXID 10 87 88 struct fid; 89 struct mount; 90 struct nameidata; 91 struct proc; 92 struct statvfs; 93 struct timeval; 94 struct inode; 95 struct uio; 96 struct mbuf; 97 struct ulfs1_dinode; 98 struct buf; 99 struct vnode; 100 struct dlfs; 101 struct lfs; 102 struct segment; 103 struct block_info; 104 105 __BEGIN_DECLS 106 107 #if defined(_KERNEL) 108 109 extern int lfs_allclean_wakeup; 110 extern struct pool lfs_inode_pool; /* memory pool for inodes */ 111 extern struct pool lfs_dinode_pool; /* memory pool for dinodes */ 112 extern struct pool lfs_inoext_pool; /* memory pool for inode extension */ 113 extern struct pool lfs_lbnentry_pool; /* memory pool for balloc accounting */ 114 115 extern int locked_queue_count; 116 extern long locked_queue_bytes; 117 extern int lfs_subsys_pages; 118 extern int lfs_dirvcount; 119 extern kmutex_t lfs_lock; 120 extern int lfs_debug_log_subsys[]; 121 extern kcondvar_t lfs_writing_cv; 122 extern kcondvar_t locked_queue_cv; 123 124 /* lfs_alloc.c */ 125 void lfs_vcreate(struct mount *, ino_t, struct vnode *); 126 int lfs_valloc(struct vnode *, int, kauth_cred_t, struct vnode **); 127 int lfs_vfree(struct vnode *, ino_t, int); 128 void lfs_order_freelist(struct lfs *); 129 int lfs_extend_ifile(struct lfs *, kauth_cred_t); 130 int lfs_ialloc(struct lfs *, struct vnode *, ino_t, int, struct vnode **); 131 void lfs_orphan(struct lfs *, ino_t); 132 133 /* lfs_balloc.c */ 134 int lfs_balloc(struct vnode *, off_t, int, kauth_cred_t, int, struct buf **); 135 void lfs_register_block(struct vnode *, daddr_t); 136 void lfs_deregister_block(struct vnode *, daddr_t); 137 void lfs_deregister_all(struct vnode *); 138 139 /* lfs_bio.c */ 140 int lfs_availwait(struct lfs *, int); 141 int lfs_bwrite_ext(struct buf *, int); 142 int lfs_fits(struct lfs *, int); 143 void lfs_flush_fs(struct lfs *, int); 144 void lfs_flush(struct lfs *, int, int); 145 int lfs_check(struct vnode *, daddr_t, int); 146 void lfs_freebuf(struct lfs *, struct buf *); 147 struct buf *lfs_newbuf(struct lfs *, struct vnode *, daddr_t, size_t, int); 148 void lfs_countlocked(int *, long *, const char *); 149 int lfs_reserve(struct lfs *, struct vnode *, struct vnode *, int); 150 151 /* lfs_debug.c */ 152 #ifdef DEBUG 153 int lfs_bwrite_log(struct buf *, const char *, int); 154 void lfs_dumplog(void); 155 void lfs_dump_super(struct lfs *); 156 void lfs_dump_dinode(struct ulfs1_dinode *); 157 void lfs_check_bpp(struct lfs *, struct segment *, char *, int); 158 void lfs_check_segsum(struct lfs *, struct segment *, char *, int); 159 void lfs_debug_log(int, const char *, ...); 160 #endif /* DEBUG */ 161 162 /* lfs_inode.c */ 163 int lfs_update(struct vnode *, const struct timespec *, const struct timespec *, 164 int); 165 int lfs_truncate(struct vnode *, off_t, int, kauth_cred_t); 166 struct ulfs1_dinode *lfs_ifind(struct lfs *, ino_t, struct buf *); 167 void lfs_finalize_ino_seguse(struct lfs *, struct inode *); 168 void lfs_finalize_fs_seguse(struct lfs *); 169 170 /* lfs_rename.c */ 171 int lfs_rename(void *); 172 173 /* lfs_rfw.c */ 174 int lfs_rf_valloc(struct lfs *, ino_t, int, struct lwp *, struct vnode **); 175 void lfs_roll_forward(struct lfs *, struct mount *, struct lwp *); 176 177 /* lfs_segment.c */ 178 void lfs_imtime(struct lfs *); 179 int lfs_vflush(struct vnode *); 180 int lfs_segwrite(struct mount *, int); 181 int lfs_writefile(struct lfs *, struct segment *, struct vnode *); 182 int lfs_writeinode(struct lfs *, struct segment *, struct inode *); 183 int lfs_gatherblock(struct segment *, struct buf *, kmutex_t *); 184 int lfs_gather(struct lfs *, struct segment *, struct vnode *, int (*match )(struct lfs *, struct buf *)); 185 void lfs_update_single(struct lfs *, struct segment *, struct vnode *, 186 daddr_t, int32_t, int); 187 void lfs_updatemeta(struct segment *); 188 int lfs_rewind(struct lfs *, int); 189 void lfs_unset_inval_all(struct lfs *); 190 int lfs_initseg(struct lfs *); 191 int lfs_writeseg(struct lfs *, struct segment *); 192 void lfs_writesuper(struct lfs *, daddr_t); 193 int lfs_match_data(struct lfs *, struct buf *); 194 int lfs_match_indir(struct lfs *, struct buf *); 195 int lfs_match_dindir(struct lfs *, struct buf *); 196 int lfs_match_tindir(struct lfs *, struct buf *); 197 void lfs_callback(struct buf *); 198 int lfs_vref(struct vnode *); 199 void lfs_vunref(struct vnode *); 200 void lfs_vunref_head(struct vnode *); 201 void lfs_acquire_finfo(struct lfs *fs, ino_t, int); 202 void lfs_release_finfo(struct lfs *fs); 203 204 /* lfs_subr.c */ 205 void lfs_setup_resblks(struct lfs *); 206 void lfs_pad_check(unsigned char *, int, char *, int); 207 void lfs_free_resblks(struct lfs *); 208 void *lfs_malloc(struct lfs *, size_t, int); 209 void lfs_free(struct lfs *, void *, int); 210 int lfs_seglock(struct lfs *, unsigned long); 211 void lfs_segunlock(struct lfs *); 212 void lfs_segunlock_relock(struct lfs *); 213 int lfs_writer_enter(struct lfs *, const char *); 214 void lfs_writer_leave(struct lfs *); 215 void lfs_wakeup_cleaner(struct lfs *); 216 217 /* lfs_syscalls.c */ 218 int lfs_fastvget(struct mount *, ino_t, daddr_t, struct vnode **, struct ulfs1_dinode *); 219 struct buf *lfs_fakebuf(struct lfs *, struct vnode *, int, size_t, void *); 220 int lfs_do_segclean(struct lfs *, unsigned long); 221 int lfs_segwait(fsid_t *, struct timeval *); 222 int lfs_bmapv(struct proc *, fsid_t *, struct block_info *, int); 223 int lfs_markv(struct proc *, fsid_t *, struct block_info *, int); 224 225 /* lfs_vfsops.c */ 226 void lfs_init(void); 227 void lfs_reinit(void); 228 void lfs_done(void); 229 int lfs_mountroot(void); 230 int lfs_mount(struct mount *, const char *, void *, size_t *); 231 int lfs_unmount(struct mount *, int); 232 int lfs_statvfs(struct mount *, struct statvfs *); 233 int lfs_sync(struct mount *, int, kauth_cred_t); 234 int lfs_vget(struct mount *, ino_t, struct vnode **); 235 int lfs_fhtovp(struct mount *, struct fid *, struct vnode **); 236 int lfs_vptofh(struct vnode *, struct fid *, size_t *); 237 void lfs_vinit(struct mount *, struct vnode **); 238 int lfs_resize_fs(struct lfs *, int); 239 240 /* lfs_vnops.c */ 241 void lfs_mark_vnode(struct vnode *); 242 void lfs_unmark_vnode(struct vnode *); 243 int lfs_gop_alloc(struct vnode *, off_t, off_t, int, kauth_cred_t); 244 void lfs_gop_size(struct vnode *, off_t, off_t *, int); 245 int lfs_putpages_ext(void *, int); 246 int lfs_gatherpages(struct vnode *); 247 int lfs_flush_dirops(struct lfs *); 248 int lfs_flush_pchain(struct lfs *); 249 250 int lfs_bwrite (void *); 251 int lfs_fsync (void *); 252 int lfs_symlink (void *); 253 int lfs_mknod (void *); 254 int lfs_create (void *); 255 int lfs_mkdir (void *); 256 int lfs_read (void *); 257 int lfs_remove (void *); 258 int lfs_rmdir (void *); 259 int lfs_link (void *); 260 int lfs_mmap (void *); 261 int lfs_rename (void *); 262 int lfs_getattr (void *); 263 int lfs_setattr (void *); 264 int lfs_close (void *); 265 int lfsspec_close(void *); 266 int lfsfifo_close(void *); 267 int lfs_fcntl (void *); 268 int lfs_inactive (void *); 269 int lfs_reclaim (void *); 270 int lfs_strategy (void *); 271 int lfs_write (void *); 272 int lfs_getpages (void *); 273 int lfs_putpages (void *); 274 275 extern int lfs_mount_type; 276 extern int (**lfs_vnodeop_p)(void *); 277 extern int (**lfs_specop_p)(void *); 278 extern int (**lfs_fifoop_p)(void *); 279 extern const struct genfs_ops lfs_genfsops; 280 281 #endif /* defined(_KERNEL) */ 282 283 /* lfs_cksum.c */ 284 u_int32_t cksum(void *, size_t); 285 u_int32_t lfs_cksum_part(void *, size_t, u_int32_t); 286 #define lfs_cksum_fold(sum) (sum) 287 u_int32_t lfs_sb_cksum(struct dlfs *); 288 289 __END_DECLS 290 291 #endif /* !_UFS_LFS_LFS_EXTERN_H_ */ 292