Home | History | Annotate | Line # | Download | only in lfs
lfs_extern.h revision 1.52
      1 /*	$NetBSD: lfs_extern.h,v 1.52 2003/07/12 16:17:07 yamt 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. All advertising materials mentioning features or use of this software
     51  *    must display the following acknowledgement:
     52  *	This product includes software developed by the University of
     53  *	California, Berkeley and its contributors.
     54  * 4. Neither the name of the University nor the names of its contributors
     55  *    may be used to endorse or promote products derived from this software
     56  *    without specific prior written permission.
     57  *
     58  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     59  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     60  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     61  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     62  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     63  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     64  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     65  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     66  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     67  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     68  * SUCH DAMAGE.
     69  *
     70  *	@(#)lfs_extern.h	8.6 (Berkeley) 5/8/95
     71  */
     72 
     73 #ifndef _UFS_LFS_LFS_EXTERN_H_
     74 #define _UFS_LFS_LFS_EXTERN_H_
     75 
     76 #ifdef _KERNEL
     77 #include <sys/mallocvar.h>
     78 
     79 MALLOC_DECLARE(M_SEGMENT);
     80 #endif
     81 
     82 /* Copied from ext2fs for ITIMES.  XXX This is a bogus use of v_tag. */
     83 #define IS_LFS_VNODE(vp)   (vp->v_tag == VT_LFS)
     84 
     85 /*
     86  * Sysctl values for LFS.
     87  */
     88 #define LFS_WRITEINDIR	 1 /* flush indirect blocks on non-checkpoint writes */
     89 #define LFS_CLEAN_VNHEAD 2 /* put prev unrefed cleaned vnodes on head of free list */
     90 #define LFS_DOSTATS	 3
     91 #define LFS_MAXPAGES	 4
     92 #define LFS_MAXID	 5
     93 
     94 #define LFS_NAMES { \
     95 	{ 0, 0 }, \
     96 	{ "flushindir", CTLTYPE_INT }, \
     97 	{ "clean_vnhead", CTLTYPE_INT }, \
     98 	{ "dostats", CTLTYPE_INT }, \
     99 	{ "maxpages", CTLTYPE_INT }, \
    100 }
    101 
    102 struct fid;
    103 struct mount;
    104 struct nameidata;
    105 struct proc;
    106 struct statfs;
    107 struct timeval;
    108 struct inode;
    109 struct uio;
    110 struct mbuf;
    111 struct ufs1_dinode;
    112 struct buf;
    113 struct vnode;
    114 struct dlfs;
    115 struct lfs;
    116 struct segment;
    117 struct ucred;
    118 struct block_info;
    119 
    120 extern int lfs_allclean_wakeup;
    121 extern struct pool lfs_inode_pool;		/* memory pool for inodes */
    122 extern struct pool lfs_dinode_pool;		/* memory pool for dinodes */
    123 extern struct pool lfs_inoext_pool;	/* memory pool for inode extension */
    124 
    125 extern int locked_queue_count;
    126 extern long locked_queue_bytes;
    127 extern int lfs_subsys_pages;
    128 extern int lfs_dirvcount;
    129 extern struct simplelock lfs_subsys_lock;
    130 
    131 __BEGIN_DECLS
    132 /* lfs_alloc.c */
    133 int lfs_rf_valloc(struct lfs *, ino_t, int, struct proc *, struct vnode **);
    134 void lfs_vcreate(struct mount *, ino_t, struct vnode *);
    135 /* lfs_bio.c */
    136 int lfs_availwait(struct lfs *, int);
    137 int lfs_bwrite_ext(struct buf *, int);
    138 int lfs_fits(struct lfs *, int);
    139 void lfs_flush_fs(struct lfs *, int);
    140 void lfs_flush(struct lfs *, int);
    141 int lfs_check(struct vnode *, daddr_t, int);
    142 void lfs_freebuf(struct lfs *, struct buf *);
    143 struct buf *lfs_newbuf(struct lfs *, struct vnode *, daddr_t, size_t, int);
    144 void lfs_countlocked(int *, long *, char *);
    145 int lfs_reserve(struct lfs *, struct vnode *, struct vnode *, int);
    146 
    147 /* lfs_cksum.c */
    148 u_int32_t cksum(void *, size_t);
    149 u_int32_t lfs_sb_cksum(struct dlfs *);
    150 
    151 /* lfs_debug.c */
    152 #ifdef DEBUG
    153 int lfs_bwrite_log(struct buf *, char *, int);
    154 void lfs_dumplog(void);
    155 void lfs_dump_super(struct lfs *);
    156 void lfs_dump_dinode(struct ufs1_dinode *);
    157 void lfs_check_bpp(struct lfs *, struct segment *, char *, int);
    158 void lfs_check_segsum(struct lfs *, struct segment *, char *, int);
    159 #endif /* DEBUG */
    160 
    161 /* lfs_inode.c */
    162 struct ufs1_dinode *lfs_ifind(struct lfs *, ino_t, struct buf *);
    163 
    164 /* lfs_segment.c */
    165 void lfs_imtime(struct lfs *);
    166 int lfs_vflush(struct vnode *);
    167 int lfs_writevnodes(struct lfs *, struct mount *, struct segment *, int);
    168 int lfs_segwrite(struct mount *, int);
    169 void lfs_writefile(struct lfs *, struct segment *, struct vnode *);
    170 int lfs_writeinode(struct lfs *, struct segment *, struct inode *);
    171 int lfs_gatherblock(struct segment *, struct buf *, int *);
    172 int lfs_gather(struct lfs *, struct segment *, struct vnode *, int (*match )(struct lfs *, struct buf *));
    173 void lfs_update_single(struct lfs *, struct segment *, daddr_t, int32_t, int);
    174 void lfs_updatemeta(struct segment *);
    175 int lfs_initseg(struct lfs *);
    176 void lfs_newseg(struct lfs *);
    177 int lfs_writeseg(struct lfs *, struct segment *);
    178 void lfs_writesuper(struct lfs *, daddr_t);
    179 int lfs_match_data(struct lfs *, struct buf *);
    180 int lfs_match_indir(struct lfs *, struct buf *);
    181 int lfs_match_dindir(struct lfs *, struct buf *);
    182 int lfs_match_tindir(struct lfs *, struct buf *);
    183 void lfs_callback(struct buf *);
    184 void lfs_supercallback(struct buf *);
    185 /* XXX ondisk32 */
    186 void lfs_shellsort(struct buf **, int32_t *, int, int);
    187 int lfs_vref(struct vnode *);
    188 void lfs_vunref(struct vnode *);
    189 void lfs_vunref_head(struct vnode *);
    190 
    191 /* lfs_subr.c */
    192 void lfs_setup_resblks(struct lfs *);
    193 void lfs_pad_check(unsigned char *, int, char *, int);
    194 void lfs_free_resblks(struct lfs *);
    195 void *lfs_malloc(struct lfs *, size_t, int);
    196 void lfs_free(struct lfs *, void *, int);
    197 int lfs_seglock(struct lfs *, unsigned long);
    198 void lfs_segunlock(struct lfs *);
    199 int lfs_writer_enter(struct lfs *, const char *);
    200 void lfs_writer_leave(struct lfs *);
    201 
    202 /* lfs_syscalls.c */
    203 int lfs_fastvget(struct mount *, ino_t, daddr_t, struct vnode **, struct ufs1_dinode *);
    204 struct buf *lfs_fakebuf(struct lfs *, struct vnode *, int, size_t, caddr_t);
    205 int lfs_do_segclean(struct lfs *, unsigned long);
    206 void lfs_fakebuf_iodone(struct buf *);
    207 int lfs_segwait(fsid_t *, struct timeval *);
    208 int lfs_bmapv(struct proc *, fsid_t *, struct block_info *, int);
    209 int lfs_markv(struct proc *, fsid_t *, struct block_info *, int);
    210 
    211 /* lfs_vfsops.c */
    212 void lfs_init(void);
    213 void lfs_reinit(void);
    214 void lfs_done(void);
    215 int lfs_mountroot(void);
    216 int lfs_mount(struct mount *, const char *, void *, struct nameidata *, struct proc *);
    217 int lfs_unmount(struct mount *, int, struct proc *);
    218 int lfs_statfs(struct mount *, struct statfs *, struct proc *);
    219 int lfs_sync(struct mount *, int, struct ucred *, struct proc *);
    220 int lfs_vget(struct mount *, ino_t, struct vnode **);
    221 int lfs_fhtovp(struct mount *, struct fid *, struct vnode **);
    222 int lfs_vptofh(struct vnode *, struct fid *);
    223 int lfs_sysctl(int *, u_int, void *, size_t *, void *, size_t, struct proc *);
    224 void lfs_vinit(struct mount *mp, struct vnode *);
    225 
    226 /* lfs_vnops.c */
    227 void lfs_unmark_vnode(struct vnode *);
    228 void lfs_itimes(struct inode *, struct timespec *, struct timespec *,
    229 		struct timespec *);
    230 int lfs_gop_alloc(struct vnode *, off_t, off_t, int, struct ucred *);
    231 void lfs_gop_size(struct vnode *, off_t, off_t *, int);
    232 int lfs_putpages_ext(void *, int);
    233 int lfs_gatherpages(struct vnode *);
    234 
    235 int lfs_balloc	 (void *);
    236 int lfs_valloc	 (void *);
    237 int lfs_vfree	 (void *);
    238 int lfs_bwrite	 (void *);
    239 int lfs_update	 (void *);
    240 int lfs_truncate (void *);
    241 int lfs_blkatoff (void *);
    242 int lfs_fsync	 (void *);
    243 int lfs_symlink	 (void *);
    244 int lfs_mknod	 (void *);
    245 int lfs_create	 (void *);
    246 int lfs_mkdir	 (void *);
    247 int lfs_read	 (void *);
    248 int lfs_remove	 (void *);
    249 int lfs_rmdir	 (void *);
    250 int lfs_link	 (void *);
    251 int lfs_mmap	 (void *);
    252 int lfs_rename	 (void *);
    253 int lfs_getattr	 (void *);
    254 int lfs_setattr	 (void *);
    255 int lfs_close	 (void *);
    256 int lfsspec_close(void *);
    257 int lfsfifo_close(void *);
    258 int lfs_fcntl	 (void *);
    259 int lfs_inactive (void *);
    260 int lfs_reclaim	 (void *);
    261 int lfs_strategy (void *);
    262 int lfs_write	 (void *);
    263 int lfs_getpages (void *);
    264 int lfs_putpages (void *);
    265 
    266 __END_DECLS
    267 extern int lfs_mount_type;
    268 extern int (**lfs_vnodeop_p)(void *);
    269 extern int (**lfs_specop_p)(void *);
    270 extern int (**lfs_fifoop_p)(void *);
    271 extern struct genfs_ops lfs_genfsops;
    272 
    273 #endif /* !_UFS_LFS_LFS_EXTERN_H_ */
    274