NetBSD/sys/ufs/lfs/lfs_extern.h

222 lines
8.9 KiB
C
Raw Normal View History

Various bug-fixes to LFS, to wit: Kernel: * Add runtime quantity lfs_ravail, the number of disk-blocks reserved for writing. Writes to the filesystem first reserve a maximum amount of blocks before their write is allowed to proceed; after the blocks are allocated the reserved total is reduced by a corresponding amount. If the lfs_reserve function cannot immediately reserve the requested number of blocks, the inode is unlocked, and the thread sleeps until the cleaner has made enough space available for the blocks to be reserved. In this way large files can be written to the filesystem (or, smaller files can be written to a nearly-full but thoroughly clean filesystem) and the cleaner can still function properly. * Remove explicit switching on dlfs_minfreeseg from the kernel code; it is now merely a fs-creation parameter used to compute dlfs_avail and dlfs_bfree (and used by fsck_lfs(8) to check their accuracy). Its former role is better assumed by a properly computed dlfs_avail. * Bounds-check inode numbers submitted through lfs_bmapv and lfs_markv. This prevents a panic, but, if the cleaner is feeding the filesystem the wrong data, you are still in a world of hurt. * Cleanup: remove explicit references of DEV_BSIZE in favor of btodb()/dbtob(). lfs_cleanerd: * Make -n mean "send N segments' blocks through a single call to lfs_markv". Previously it had meant "clean N segments though N calls to lfs_markv, before looking again to see if more need to be cleaned". The new behavior gives better packing of direct data on disk with as little metadata as possible, largely alleviating the problem that the cleaner can consume more disk through inefficient use of metadata than it frees by moving dirty data away from clean "holes" to produce entirely clean segments. * Make -b mean "read as many segments as necessary to write N segments of dirty data back to disk", rather than its former meaning of "read as many segments as necessary to free N segments worth of space". The new meaning, combined with the new -n behavior described above, further aids in cleaning storage efficiency as entire segments can be written at once, using as few blocks as possible for segment summaries and inode blocks. * Make the cleaner take note of segments which could not be cleaned due to error, and not attempt to clean them until they are entirely free of dirty blocks. This prevents the case in which a cleanerd running with -n 1 and without -b (formerly the default) would spin trying repeatedly to clean a corrupt segment, while the remaining space filled and deadlocked the filesystem. * Update the lfs_cleanerd manual page to describe all the options, including the changes mentioned here (in particular, the -b and -n flags were previously undocumented). fsck_lfs: * Check, and optionally fix, lfs_avail (to an exact figure) and lfs_bfree (within a margin of error) in pass 5. newfs_lfs: * Reduce the default dlfs_minfreeseg to 1/20 of the total segments. * Add a warning if the sgs disklabel field is 16 (the default for FFS' cpg, but not usually desirable for LFS' sgs: 5--8 is a better range). * Change the calculation of lfs_avail and lfs_bfree, corresponding to the kernel changes mentioned above. mount_lfs: * Add -N and -b options to pass corresponding -n and -b options to lfs_cleanerd. * Default to calling lfs_cleanerd with "-b -n 4". [All of these changes were largely tested in the 1.5 branch, with the idea that they (along with previous un-pulled-up work) could be applied to the branch while it was still in ALPHA2; however my test system has experienced corruption on another filesystem (/dev/console has gone missing :^), and, while I believe this unrelated to the LFS changes, I cannot with good conscience request that the changes be pulled up.]
2000-09-09 08:49:54 +04:00
/* $NetBSD: lfs_extern.h,v 1.21 2000/09/09 04:49:55 perseant Exp $ */
/*-
Various bug-fixes to LFS, to wit: Kernel: * Add runtime quantity lfs_ravail, the number of disk-blocks reserved for writing. Writes to the filesystem first reserve a maximum amount of blocks before their write is allowed to proceed; after the blocks are allocated the reserved total is reduced by a corresponding amount. If the lfs_reserve function cannot immediately reserve the requested number of blocks, the inode is unlocked, and the thread sleeps until the cleaner has made enough space available for the blocks to be reserved. In this way large files can be written to the filesystem (or, smaller files can be written to a nearly-full but thoroughly clean filesystem) and the cleaner can still function properly. * Remove explicit switching on dlfs_minfreeseg from the kernel code; it is now merely a fs-creation parameter used to compute dlfs_avail and dlfs_bfree (and used by fsck_lfs(8) to check their accuracy). Its former role is better assumed by a properly computed dlfs_avail. * Bounds-check inode numbers submitted through lfs_bmapv and lfs_markv. This prevents a panic, but, if the cleaner is feeding the filesystem the wrong data, you are still in a world of hurt. * Cleanup: remove explicit references of DEV_BSIZE in favor of btodb()/dbtob(). lfs_cleanerd: * Make -n mean "send N segments' blocks through a single call to lfs_markv". Previously it had meant "clean N segments though N calls to lfs_markv, before looking again to see if more need to be cleaned". The new behavior gives better packing of direct data on disk with as little metadata as possible, largely alleviating the problem that the cleaner can consume more disk through inefficient use of metadata than it frees by moving dirty data away from clean "holes" to produce entirely clean segments. * Make -b mean "read as many segments as necessary to write N segments of dirty data back to disk", rather than its former meaning of "read as many segments as necessary to free N segments worth of space". The new meaning, combined with the new -n behavior described above, further aids in cleaning storage efficiency as entire segments can be written at once, using as few blocks as possible for segment summaries and inode blocks. * Make the cleaner take note of segments which could not be cleaned due to error, and not attempt to clean them until they are entirely free of dirty blocks. This prevents the case in which a cleanerd running with -n 1 and without -b (formerly the default) would spin trying repeatedly to clean a corrupt segment, while the remaining space filled and deadlocked the filesystem. * Update the lfs_cleanerd manual page to describe all the options, including the changes mentioned here (in particular, the -b and -n flags were previously undocumented). fsck_lfs: * Check, and optionally fix, lfs_avail (to an exact figure) and lfs_bfree (within a margin of error) in pass 5. newfs_lfs: * Reduce the default dlfs_minfreeseg to 1/20 of the total segments. * Add a warning if the sgs disklabel field is 16 (the default for FFS' cpg, but not usually desirable for LFS' sgs: 5--8 is a better range). * Change the calculation of lfs_avail and lfs_bfree, corresponding to the kernel changes mentioned above. mount_lfs: * Add -N and -b options to pass corresponding -n and -b options to lfs_cleanerd. * Default to calling lfs_cleanerd with "-b -n 4". [All of these changes were largely tested in the 1.5 branch, with the idea that they (along with previous un-pulled-up work) could be applied to the branch while it was still in ALPHA2; however my test system has experienced corruption on another filesystem (/dev/console has gone missing :^), and, while I believe this unrelated to the LFS changes, I cannot with good conscience request that the changes be pulled up.]
2000-09-09 08:49:54 +04:00
* Copyright (c) 1999, 2000 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Konrad E. Schroder <perseant@hhhh.org>.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/*-
* Copyright (c) 1991, 1993, 1994
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
1998-03-01 05:20:01 +03:00
* @(#)lfs_extern.h 8.6 (Berkeley) 5/8/95
*/
/* Copied from ext2fs for ITIMES. XXX This is a bogus use of v_tag. */
#define IS_LFS_VNODE(vp) (vp->v_tag == VT_LFS)
/*
* Sysctl values for LFS.
*/
#define LFS_WRITEINDIR 1 /* flush indirect blocks on non-checkpoint writes */
#define LFS_CLEAN_VNHEAD 2 /* put prev unrefed cleaned vnodes on head of free list */
#define LFS_DOSTATS 3
#define LFS_STATS 4
#define LFS_MAXID 5
#define LFS_NAMES { \
{ 0, 0 }, \
{ "flushindir", CTLTYPE_INT }, \
{ "clean_vnhead", CTLTYPE_INT }, \
{ "dostats", CTLTYPE_INT }, \
{ "stats", CTLTYPE_STRUCT }, \
}
struct fid;
struct mount;
struct nameidata;
struct proc;
struct statfs;
struct timeval;
struct inode;
struct uio;
struct mbuf;
1996-02-10 01:28:45 +03:00
struct dinode;
struct buf;
struct vnode;
struct dlfs;
1996-02-10 01:28:45 +03:00
struct lfs;
struct segment;
1996-02-12 18:20:12 +03:00
struct ucred;
extern struct pool lfs_inode_pool; /* memory pool for inodes */
__BEGIN_DECLS
1996-02-10 01:28:45 +03:00
/* lfs_alloc.c */
void lfs_vcreate __P((struct mount *, ino_t, struct vnode *));
1996-02-10 01:28:45 +03:00
/* lfs_bio.c */
int lfs_bwrite_ext __P((struct buf *, int));
void lfs_flush_fs __P((struct lfs *, int));
void lfs_flush __P((struct lfs *, int));
int lfs_check __P((struct vnode *, ufs_daddr_t, int));
void lfs_freebuf __P((struct buf *));
void lfs_countlocked __P((int *, long *));
Various bug-fixes to LFS, to wit: Kernel: * Add runtime quantity lfs_ravail, the number of disk-blocks reserved for writing. Writes to the filesystem first reserve a maximum amount of blocks before their write is allowed to proceed; after the blocks are allocated the reserved total is reduced by a corresponding amount. If the lfs_reserve function cannot immediately reserve the requested number of blocks, the inode is unlocked, and the thread sleeps until the cleaner has made enough space available for the blocks to be reserved. In this way large files can be written to the filesystem (or, smaller files can be written to a nearly-full but thoroughly clean filesystem) and the cleaner can still function properly. * Remove explicit switching on dlfs_minfreeseg from the kernel code; it is now merely a fs-creation parameter used to compute dlfs_avail and dlfs_bfree (and used by fsck_lfs(8) to check their accuracy). Its former role is better assumed by a properly computed dlfs_avail. * Bounds-check inode numbers submitted through lfs_bmapv and lfs_markv. This prevents a panic, but, if the cleaner is feeding the filesystem the wrong data, you are still in a world of hurt. * Cleanup: remove explicit references of DEV_BSIZE in favor of btodb()/dbtob(). lfs_cleanerd: * Make -n mean "send N segments' blocks through a single call to lfs_markv". Previously it had meant "clean N segments though N calls to lfs_markv, before looking again to see if more need to be cleaned". The new behavior gives better packing of direct data on disk with as little metadata as possible, largely alleviating the problem that the cleaner can consume more disk through inefficient use of metadata than it frees by moving dirty data away from clean "holes" to produce entirely clean segments. * Make -b mean "read as many segments as necessary to write N segments of dirty data back to disk", rather than its former meaning of "read as many segments as necessary to free N segments worth of space". The new meaning, combined with the new -n behavior described above, further aids in cleaning storage efficiency as entire segments can be written at once, using as few blocks as possible for segment summaries and inode blocks. * Make the cleaner take note of segments which could not be cleaned due to error, and not attempt to clean them until they are entirely free of dirty blocks. This prevents the case in which a cleanerd running with -n 1 and without -b (formerly the default) would spin trying repeatedly to clean a corrupt segment, while the remaining space filled and deadlocked the filesystem. * Update the lfs_cleanerd manual page to describe all the options, including the changes mentioned here (in particular, the -b and -n flags were previously undocumented). fsck_lfs: * Check, and optionally fix, lfs_avail (to an exact figure) and lfs_bfree (within a margin of error) in pass 5. newfs_lfs: * Reduce the default dlfs_minfreeseg to 1/20 of the total segments. * Add a warning if the sgs disklabel field is 16 (the default for FFS' cpg, but not usually desirable for LFS' sgs: 5--8 is a better range). * Change the calculation of lfs_avail and lfs_bfree, corresponding to the kernel changes mentioned above. mount_lfs: * Add -N and -b options to pass corresponding -n and -b options to lfs_cleanerd. * Default to calling lfs_cleanerd with "-b -n 4". [All of these changes were largely tested in the 1.5 branch, with the idea that they (along with previous un-pulled-up work) could be applied to the branch while it was still in ALPHA2; however my test system has experienced corruption on another filesystem (/dev/console has gone missing :^), and, while I believe this unrelated to the LFS changes, I cannot with good conscience request that the changes be pulled up.]
2000-09-09 08:49:54 +04:00
int lfs_reserve __P((struct lfs *, struct vnode *, int));
1996-02-10 01:28:45 +03:00
/* lfs_cksum.c */
u_long cksum __P((void *, size_t));
u_long lfs_sb_cksum __P((struct dlfs *));
1996-02-10 01:28:45 +03:00
/* lfs_debug.c */
#ifdef DEBUG
1996-02-10 01:28:45 +03:00
void lfs_dump_super __P((struct lfs *));
void lfs_dump_dinode __P((struct dinode *));
void lfs_check_bpp __P((struct lfs *, struct segment *, char *, int));
void lfs_check_segsum __P((struct lfs *, struct segment *, char *, int));
#endif /* DEBUG */
1996-02-10 01:28:45 +03:00
/* lfs_inode.c */
struct dinode *lfs_ifind __P((struct lfs *, ino_t, struct buf *));
1996-02-10 01:28:45 +03:00
/* lfs_segment.c */
void lfs_imtime __P((struct lfs *));
1996-02-10 01:28:45 +03:00
int lfs_vflush __P((struct vnode *));
int lfs_writevnodes __P((struct lfs *, struct mount *, struct segment *, int));
1996-02-10 01:28:45 +03:00
int lfs_segwrite __P((struct mount *, int));
void lfs_writefile __P((struct lfs *, struct segment *, struct vnode *));
int lfs_writeinode __P((struct lfs *, struct segment *, struct inode *));
int lfs_gatherblock __P((struct segment *, struct buf *, int *));
int lfs_gather __P((struct lfs *, struct segment *, struct vnode *, int (*match )__P ((struct lfs *, struct buf *))));
1996-02-10 01:28:45 +03:00
void lfs_updatemeta __P((struct segment *));
int lfs_initseg __P((struct lfs *));
void lfs_newseg __P((struct lfs *));
int lfs_writeseg __P((struct lfs *, struct segment *));
void lfs_writesuper __P((struct lfs *, daddr_t));
1996-02-10 01:28:45 +03:00
int lfs_match_data __P((struct lfs *, struct buf *));
int lfs_match_indir __P((struct lfs *, struct buf *));
int lfs_match_dindir __P((struct lfs *, struct buf *));
int lfs_match_tindir __P((struct lfs *, struct buf *));
1998-03-01 05:20:01 +03:00
struct buf *lfs_newbuf __P((struct vnode *, ufs_daddr_t, size_t));
1996-02-10 01:28:45 +03:00
void lfs_callback __P((struct buf *));
void lfs_supercallback __P((struct buf *));
1998-03-01 05:20:01 +03:00
void lfs_shellsort __P((struct buf **, ufs_daddr_t *, int));
1996-02-10 01:28:45 +03:00
int lfs_vref __P((struct vnode *));
void lfs_vunref __P((struct vnode *));
void lfs_vunref_head __P((struct vnode *));
1996-02-10 01:28:45 +03:00
/* lfs_subr.c */
void lfs_seglock __P((struct lfs *, unsigned long));
void lfs_segunlock __P((struct lfs *));
/* lfs_syscalls.c */
int lfs_fastvget __P((struct mount *, ino_t, ufs_daddr_t, struct vnode **, struct dinode *, int *));
1996-02-10 01:28:45 +03:00
struct buf *lfs_fakebuf __P((struct vnode *, int, size_t, caddr_t));
/* lfs_vfsops.c */
void lfs_init __P((void));
void lfs_done __P((void));
1996-02-10 01:28:45 +03:00
int lfs_mountroot __P((void));
int lfs_mount __P((struct mount *, const char *, void *, struct nameidata *, struct proc *));
1996-02-10 01:28:45 +03:00
int lfs_mountfs __P((struct vnode *, struct mount *, struct proc *));
int lfs_unmount __P((struct mount *, int, struct proc *));
int lfs_statfs __P((struct mount *, struct statfs *, struct proc *));
int lfs_sync __P((struct mount *, int, struct ucred *, struct proc *));
int lfs_vget __P((struct mount *, ino_t, struct vnode **));
int lfs_fhtovp __P((struct mount *, struct fid *, struct vnode **));
1996-02-10 01:28:45 +03:00
int lfs_vptofh __P((struct vnode *, struct fid *));
1998-03-01 05:20:01 +03:00
int lfs_sysctl __P((int *, u_int, void *, size_t *, void *, size_t,
struct proc *));
1996-02-10 01:28:45 +03:00
/* lfs_vnops.c */
void lfs_unmark_vnode __P((struct vnode *));
void lfs_itimes __P((struct inode *, struct timespec *, struct timespec *,
struct timespec *));
1996-02-10 01:28:45 +03:00
int lfs_balloc __P((void *));
1996-02-10 01:28:45 +03:00
int lfs_valloc __P((void *));
int lfs_vfree __P((void *));
int lfs_bwrite __P((void *));
int lfs_update __P((void *));
int lfs_truncate __P((void *));
int lfs_blkatoff __P((void *));
int lfs_fsync __P((void *));
int lfs_symlink __P((void *));
int lfs_mknod __P((void *));
int lfs_create __P((void *));
int lfs_mkdir __P((void *));
int lfs_read __P((void *));
int lfs_remove __P((void *));
int lfs_rmdir __P((void *));
int lfs_link __P((void *));
int lfs_rename __P((void *));
int lfs_getattr __P((void *));
int lfs_close __P((void *));
int lfs_inactive __P((void *));
int lfs_reclaim __P((void *));
int lfs_write __P((void *));
int lfs_whiteout __P((void *));
1996-02-10 01:28:45 +03:00
__END_DECLS
1998-03-01 05:20:01 +03:00
extern int lfs_mount_type;
1996-02-10 01:28:45 +03:00
extern int (**lfs_vnodeop_p) __P((void *));
extern int (**lfs_specop_p) __P((void *));
extern int (**lfs_fifoop_p) __P((void *));