2002-05-13 03:06:27 +04:00
|
|
|
/* $NetBSD: lfs_syscalls.c,v 1.64 2002/05/12 23:06:29 matt Exp $ */
|
1994-06-29 10:39:25 +04:00
|
|
|
|
1999-03-10 03:20:00 +03:00
|
|
|
/*-
|
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.
|
1999-03-10 03:20:00 +03:00
|
|
|
* 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.
|
|
|
|
*/
|
1994-06-08 15:41:58 +04:00
|
|
|
/*-
|
|
|
|
* 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_syscalls.c 8.10 (Berkeley) 5/14/95
|
1994-06-08 15:41:58 +04:00
|
|
|
*/
|
|
|
|
|
2001-11-08 05:39:06 +03:00
|
|
|
#include <sys/cdefs.h>
|
2002-05-13 03:06:27 +04:00
|
|
|
__KERNEL_RCSID(0, "$NetBSD: lfs_syscalls.c,v 1.64 2002/05/12 23:06:29 matt Exp $");
|
2001-11-08 05:39:06 +03:00
|
|
|
|
2000-11-30 18:57:35 +03:00
|
|
|
#define LFS /* for prototypes in syscallargs.h */
|
1998-02-19 03:54:39 +03:00
|
|
|
|
1994-06-08 15:41:58 +04:00
|
|
|
#include <sys/param.h>
|
1994-10-20 07:20:55 +03:00
|
|
|
#include <sys/systm.h>
|
1994-06-08 15:41:58 +04:00
|
|
|
#include <sys/proc.h>
|
|
|
|
#include <sys/buf.h>
|
|
|
|
#include <sys/mount.h>
|
|
|
|
#include <sys/vnode.h>
|
|
|
|
#include <sys/malloc.h>
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
|
1994-10-20 07:20:55 +03:00
|
|
|
#include <sys/syscallargs.h>
|
|
|
|
|
1994-06-08 15:41:58 +04:00
|
|
|
#include <ufs/ufs/inode.h>
|
|
|
|
#include <ufs/ufs/ufsmount.h>
|
|
|
|
#include <ufs/ufs/ufs_extern.h>
|
|
|
|
|
|
|
|
#include <ufs/lfs/lfs.h>
|
|
|
|
#include <ufs/lfs/lfs_extern.h>
|
1996-02-10 01:28:45 +03:00
|
|
|
|
1999-03-10 03:20:00 +03:00
|
|
|
/* Flags for return from lfs_fastvget */
|
|
|
|
#define FVG_UNLOCK 0x01 /* Needs to be unlocked */
|
|
|
|
#define FVG_PUT 0x02 /* Needs to be vput() */
|
1994-06-08 15:41:58 +04:00
|
|
|
|
2001-08-03 10:02:42 +04:00
|
|
|
/* Max block count for lfs_markv() */
|
|
|
|
#define MARKV_MAXBLKCNT 65536
|
|
|
|
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
struct buf *lfs_fakebuf(struct vnode *, int, size_t, caddr_t);
|
|
|
|
int lfs_fasthashget(dev_t, ino_t, int *, struct vnode **);
|
1994-06-08 15:41:58 +04:00
|
|
|
|
1998-03-01 05:20:01 +03:00
|
|
|
int debug_cleaner = 0;
|
|
|
|
int clean_vnlocked = 0;
|
|
|
|
int clean_inlocked = 0;
|
1999-03-10 03:20:00 +03:00
|
|
|
int verbose_debug = 0;
|
|
|
|
|
|
|
|
pid_t lfs_cleaner_pid = 0;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Definitions for the buffer free lists.
|
|
|
|
*/
|
|
|
|
#define BQUEUES 4 /* number of free buffer queues */
|
|
|
|
|
|
|
|
#define BQ_LOCKED 0 /* super-blocks &c */
|
|
|
|
#define BQ_LRU 1 /* lru, useful buffers */
|
|
|
|
#define BQ_AGE 2 /* rubbish */
|
|
|
|
#define BQ_EMPTY 3 /* buffer headers with no memory */
|
|
|
|
|
|
|
|
extern TAILQ_HEAD(bqueues, buf) bufqueues[BQUEUES];
|
|
|
|
|
|
|
|
#define LFS_FORCE_WRITE UNASSIGNED
|
|
|
|
|
|
|
|
#define LFS_VREF_THRESHOLD 128
|
1998-03-01 05:20:01 +03:00
|
|
|
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
static int lfs_bmapv(struct proc *, fsid_t *, BLOCK_INFO *, int);
|
|
|
|
static int lfs_markv(struct proc *, fsid_t *, BLOCK_INFO *, int);
|
|
|
|
|
1994-06-08 15:41:58 +04:00
|
|
|
/*
|
1999-06-09 08:52:11 +04:00
|
|
|
* sys_lfs_markv:
|
1994-06-08 15:41:58 +04:00
|
|
|
*
|
|
|
|
* This will mark inodes and blocks dirty, so they are written into the log.
|
|
|
|
* It will block until all the blocks have been written. The segment create
|
|
|
|
* time passed in the block_info and inode_info structures is used to decide
|
|
|
|
* if the data is valid for each block (in case some process dirtied a block
|
|
|
|
* or inode that is being cleaned between the determination that a block is
|
|
|
|
* live and the lfs_markv call).
|
|
|
|
*
|
|
|
|
* 0 on success
|
|
|
|
* -1/errno is return on error.
|
|
|
|
*/
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
#ifdef USE_64BIT_SYSCALLS
|
|
|
|
int
|
|
|
|
sys_lfs_markv(struct proc *p, void *v, register_t *retval)
|
|
|
|
{
|
|
|
|
struct sys_lfs_markv_args /* {
|
|
|
|
syscallarg(fsid_t *) fsidp;
|
|
|
|
syscallarg(struct block_info *) blkiov;
|
|
|
|
syscallarg(int) blkcnt;
|
|
|
|
} */ *uap = v;
|
|
|
|
BLOCK_INFO *blkiov;
|
|
|
|
int blkcnt, error;
|
|
|
|
fsid_t fsid;
|
|
|
|
|
|
|
|
if ((error = suser(p->p_ucred, &p->p_acflag)) != 0)
|
|
|
|
return (error);
|
|
|
|
|
|
|
|
if ((error = copyin(SCARG(uap, fsidp), &fsid, sizeof(fsid_t))) != 0)
|
|
|
|
return (error);
|
|
|
|
|
|
|
|
blkcnt = SCARG(uap, blkcnt);
|
2001-08-03 10:02:42 +04:00
|
|
|
if ((u_int) blkcnt > MARKV_MAXBLKCNT)
|
|
|
|
return (EINVAL);
|
|
|
|
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
blkiov = malloc(blkcnt * sizeof(BLOCK_INFO), M_SEGMENT, M_WAITOK);
|
|
|
|
if ((error = copyin(SCARG(uap, blkiov), blkiov,
|
|
|
|
blkcnt * sizeof(BLOCK_INFO))) != 0)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
if ((error = lfs_markv(p, &fsid, blkiov, blkcnt)) == 0)
|
|
|
|
copyout(blkiov, SCARG(uap, blkiov),
|
|
|
|
blkcnt * sizeof(BLOCK_INFO));
|
|
|
|
out:
|
|
|
|
free(blkiov, M_SEGMENT);
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
#else
|
1994-06-08 15:41:58 +04:00
|
|
|
int
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
sys_lfs_markv(struct proc *p, void *v, register_t *retval)
|
1995-09-22 03:39:20 +04:00
|
|
|
{
|
1999-06-09 16:18:19 +04:00
|
|
|
struct sys_lfs_markv_args /* {
|
1994-10-20 07:20:55 +03:00
|
|
|
syscallarg(fsid_t *) fsidp;
|
|
|
|
syscallarg(struct block_info *) blkiov;
|
|
|
|
syscallarg(int) blkcnt;
|
1999-06-09 16:18:19 +04:00
|
|
|
} */ *uap = v;
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
BLOCK_INFO *blkiov;
|
|
|
|
BLOCK_INFO_15 *blkiov15;
|
|
|
|
int i, blkcnt, error;
|
|
|
|
fsid_t fsid;
|
|
|
|
|
|
|
|
if ((error = suser(p->p_ucred, &p->p_acflag)) != 0)
|
|
|
|
return (error);
|
|
|
|
|
|
|
|
if ((error = copyin(SCARG(uap, fsidp), &fsid, sizeof(fsid_t))) != 0)
|
|
|
|
return (error);
|
|
|
|
|
|
|
|
blkcnt = SCARG(uap, blkcnt);
|
2001-08-03 10:02:42 +04:00
|
|
|
if ((u_int) blkcnt > MARKV_MAXBLKCNT)
|
|
|
|
return (EINVAL);
|
|
|
|
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
blkiov = malloc(blkcnt * sizeof(BLOCK_INFO), M_SEGMENT, M_WAITOK);
|
|
|
|
blkiov15 = malloc(blkcnt * sizeof(BLOCK_INFO_15), M_SEGMENT, M_WAITOK);
|
|
|
|
if ((error = copyin(SCARG(uap, blkiov), blkiov15,
|
|
|
|
blkcnt * sizeof(BLOCK_INFO_15))) != 0)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
for (i = 0; i < blkcnt; i++) {
|
|
|
|
blkiov[i].bi_inode = blkiov15[i].bi_inode;
|
|
|
|
blkiov[i].bi_lbn = blkiov15[i].bi_lbn;
|
|
|
|
blkiov[i].bi_daddr = blkiov15[i].bi_daddr;
|
|
|
|
blkiov[i].bi_segcreate = blkiov15[i].bi_segcreate;
|
|
|
|
blkiov[i].bi_version = blkiov15[i].bi_version;
|
|
|
|
blkiov[i].bi_bp = blkiov15[i].bi_bp;
|
|
|
|
blkiov[i].bi_size = blkiov15[i].bi_size;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((error = lfs_markv(p, &fsid, blkiov, blkcnt)) == 0) {
|
|
|
|
for (i = 0; i < blkcnt; i++) {
|
|
|
|
blkiov15[i].bi_inode = blkiov[i].bi_inode;
|
|
|
|
blkiov15[i].bi_lbn = blkiov[i].bi_lbn;
|
|
|
|
blkiov15[i].bi_daddr = blkiov[i].bi_daddr;
|
|
|
|
blkiov15[i].bi_segcreate = blkiov[i].bi_segcreate;
|
|
|
|
blkiov15[i].bi_version = blkiov[i].bi_version;
|
|
|
|
blkiov15[i].bi_bp = blkiov[i].bi_bp;
|
|
|
|
blkiov15[i].bi_size = blkiov[i].bi_size;
|
|
|
|
}
|
|
|
|
copyout(blkiov15, SCARG(uap, blkiov),
|
|
|
|
blkcnt * sizeof(BLOCK_INFO_15));
|
|
|
|
}
|
|
|
|
out:
|
|
|
|
free(blkiov, M_SEGMENT);
|
|
|
|
free(blkiov15, M_SEGMENT);
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static int
|
|
|
|
lfs_markv(struct proc *p, fsid_t *fsidp, BLOCK_INFO *blkiov, int blkcnt)
|
|
|
|
{
|
1994-06-08 15:41:58 +04:00
|
|
|
BLOCK_INFO *blkp;
|
|
|
|
IFILE *ifp;
|
1999-03-10 03:20:00 +03:00
|
|
|
struct buf *bp, *nbp;
|
1996-02-10 01:28:45 +03:00
|
|
|
struct inode *ip = NULL;
|
1994-06-08 15:41:58 +04:00
|
|
|
struct lfs *fs;
|
|
|
|
struct mount *mntp;
|
|
|
|
struct vnode *vp;
|
1999-03-10 03:20:00 +03:00
|
|
|
#ifdef DEBUG_LFS
|
2001-11-24 00:44:25 +03:00
|
|
|
int vputc = 0, iwritten = 0;
|
1999-03-10 03:20:00 +03:00
|
|
|
#endif
|
1994-06-08 15:41:58 +04:00
|
|
|
ino_t lastino;
|
1998-03-01 05:20:01 +03:00
|
|
|
ufs_daddr_t b_daddr, v_daddr;
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
int cnt, error, lfs_fastvget_unlock;
|
2001-11-24 00:44:25 +03:00
|
|
|
int do_again = 0;
|
1999-03-10 03:20:00 +03:00
|
|
|
int s;
|
|
|
|
#ifdef CHECK_COPYIN
|
|
|
|
int i;
|
|
|
|
#endif /* CHECK_COPYIN */
|
|
|
|
#ifdef LFS_TRACK_IOS
|
|
|
|
int j;
|
|
|
|
#endif
|
2001-11-24 00:44:25 +03:00
|
|
|
int numlocked = 0, numrefed = 0;
|
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
|
|
|
ino_t maxino;
|
1994-06-08 15:41:58 +04:00
|
|
|
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
if ((mntp = vfs_getvfs(fsidp)) == NULL)
|
2000-11-23 01:11:34 +03:00
|
|
|
return (ENOENT);
|
1994-06-08 15:41:58 +04:00
|
|
|
|
1999-03-10 03:20:00 +03:00
|
|
|
fs = VFSTOUFS(mntp)->um_lfs;
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
maxino = (fragstoblks(fs, fsbtofrags(fs, VTOI(fs->lfs_ivnode)->i_ffs_blocks)) -
|
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
|
|
|
fs->lfs_cleansz - fs->lfs_segtabsz) * fs->lfs_ifpb;
|
|
|
|
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
cnt = blkcnt;
|
1999-03-10 03:20:00 +03:00
|
|
|
|
2000-11-23 01:11:34 +03:00
|
|
|
if ((error = vfs_busy(mntp, LK_NOWAIT, NULL)) != 0)
|
|
|
|
return (error);
|
|
|
|
|
1999-03-10 03:20:00 +03:00
|
|
|
/*
|
|
|
|
* This seglock is just to prevent the fact that we might have to sleep
|
|
|
|
* from allowing the possibility that our blocks might become
|
|
|
|
* invalid.
|
|
|
|
*
|
|
|
|
* It is also important to note here that unless we specify SEGM_CKP,
|
|
|
|
* any Ifile blocks that we might be asked to clean will never get
|
|
|
|
* to the disk.
|
|
|
|
*/
|
|
|
|
lfs_seglock(fs, SEGM_SYNC|SEGM_CLEAN|SEGM_CKP);
|
|
|
|
|
1994-06-08 15:41:58 +04:00
|
|
|
/* Mark blocks/inodes dirty. */
|
|
|
|
error = 0;
|
|
|
|
|
1999-03-10 03:20:00 +03:00
|
|
|
#ifdef DEBUG_LFS
|
|
|
|
/* Run through and count the inodes */
|
|
|
|
lastino = LFS_UNUSED_INUM;
|
2001-11-24 00:44:25 +03:00
|
|
|
for (blkp = blkiov; cnt--; ++blkp) {
|
|
|
|
if (lastino != blkp->bi_inode) {
|
1999-03-10 03:20:00 +03:00
|
|
|
lastino = blkp->bi_inode;
|
|
|
|
vputc++;
|
|
|
|
}
|
|
|
|
}
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
cnt = blkcnt;
|
1999-03-10 03:20:00 +03:00
|
|
|
printf("[%d/",vputc);
|
2001-11-24 00:44:25 +03:00
|
|
|
iwritten = 0;
|
1999-03-10 03:20:00 +03:00
|
|
|
#endif /* DEBUG_LFS */
|
|
|
|
/* these were inside the initialization for the for loop */
|
|
|
|
v_daddr = LFS_UNUSED_DADDR;
|
|
|
|
lastino = LFS_UNUSED_INUM;
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
for (blkp = blkiov; cnt--; ++blkp)
|
1999-03-10 03:20:00 +03:00
|
|
|
{
|
2001-11-24 00:44:25 +03:00
|
|
|
if (blkp->bi_daddr == LFS_FORCE_WRITE)
|
1999-04-12 04:40:06 +04:00
|
|
|
printf("lfs_markv: warning: force-writing ino %d lbn %d\n",
|
|
|
|
blkp->bi_inode, blkp->bi_lbn);
|
1999-03-10 03:20:00 +03:00
|
|
|
#ifdef LFS_TRACK_IOS
|
|
|
|
/*
|
|
|
|
* If there is I/O on this segment that is not yet complete,
|
|
|
|
* the cleaner probably does not have the right information.
|
|
|
|
* Send it packing.
|
|
|
|
*/
|
2001-11-24 00:44:25 +03:00
|
|
|
for (j = 0; j < LFS_THROTTLE; j++) {
|
|
|
|
if (fs->lfs_pending[j] != LFS_UNUSED_DADDR
|
|
|
|
&& dtosn(fs,fs->lfs_pending[j]) == dtosn(fs,blkp->bi_daddr)
|
1999-03-10 03:20:00 +03:00
|
|
|
&& blkp->bi_daddr != LFS_FORCE_WRITE)
|
|
|
|
{
|
|
|
|
printf("lfs_markv: attempt to clean pending segment? (#%d)\n",
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
dtosn(fs, fs->lfs_pending[j]));
|
1999-03-10 03:20:00 +03:00
|
|
|
/* return (EBUSY); */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif /* LFS_TRACK_IOS */
|
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
|
|
|
/* Bounds-check incoming data, avoid panic for failed VGET */
|
|
|
|
if (blkp->bi_inode <= 0 || blkp->bi_inode >= maxino) {
|
|
|
|
error = EINVAL;
|
|
|
|
goto again;
|
|
|
|
}
|
1994-06-08 15:41:58 +04:00
|
|
|
/*
|
|
|
|
* Get the IFILE entry (only once) and see if the file still
|
|
|
|
* exists.
|
|
|
|
*/
|
|
|
|
if (lastino != blkp->bi_inode) {
|
1999-03-10 03:20:00 +03:00
|
|
|
/*
|
|
|
|
* Finish the old file, if there was one. The presence
|
|
|
|
* of a usable vnode in vp is signaled by a valid v_daddr.
|
|
|
|
*/
|
2001-11-24 00:44:25 +03:00
|
|
|
if (v_daddr != LFS_UNUSED_DADDR) {
|
1999-03-10 03:20:00 +03:00
|
|
|
#ifdef DEBUG_LFS
|
2001-11-24 00:44:25 +03:00
|
|
|
if (ip->i_flag & (IN_MODIFIED|IN_CLEANING))
|
1999-03-10 03:20:00 +03:00
|
|
|
iwritten++;
|
|
|
|
#endif
|
2001-11-24 00:44:25 +03:00
|
|
|
if (lfs_fastvget_unlock) {
|
2000-06-28 00:57:11 +04:00
|
|
|
VOP_UNLOCK(vp, 0);
|
1999-03-10 03:20:00 +03:00
|
|
|
numlocked--;
|
1994-06-08 15:41:58 +04:00
|
|
|
}
|
|
|
|
lfs_vunref(vp);
|
1999-03-10 03:20:00 +03:00
|
|
|
numrefed--;
|
1994-06-08 15:41:58 +04:00
|
|
|
}
|
|
|
|
|
1999-03-10 03:20:00 +03:00
|
|
|
/*
|
|
|
|
* Start a new file
|
|
|
|
*/
|
1994-06-08 15:41:58 +04:00
|
|
|
lastino = blkp->bi_inode;
|
|
|
|
if (blkp->bi_inode == LFS_IFILE_INUM)
|
|
|
|
v_daddr = fs->lfs_idaddr;
|
|
|
|
else {
|
|
|
|
LFS_IENTRY(ifp, fs, blkp->bi_inode, bp);
|
1999-03-10 03:20:00 +03:00
|
|
|
/* XXX fix for force write */
|
1994-06-08 15:41:58 +04:00
|
|
|
v_daddr = ifp->if_daddr;
|
|
|
|
brelse(bp);
|
|
|
|
}
|
1999-03-10 03:20:00 +03:00
|
|
|
/* Don't force-write the ifile */
|
|
|
|
if (blkp->bi_inode == LFS_IFILE_INUM
|
|
|
|
&& blkp->bi_daddr == LFS_FORCE_WRITE)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
1999-11-12 19:56:48 +03:00
|
|
|
if (v_daddr == LFS_UNUSED_DADDR
|
|
|
|
&& blkp->bi_daddr != LFS_FORCE_WRITE)
|
1999-03-10 03:20:00 +03:00
|
|
|
{
|
1994-06-08 15:41:58 +04:00
|
|
|
continue;
|
1999-03-10 03:20:00 +03:00
|
|
|
}
|
1994-06-08 15:41:58 +04:00
|
|
|
|
|
|
|
/* Get the vnode/inode. */
|
2001-11-24 00:44:25 +03:00
|
|
|
error = lfs_fastvget(mntp, blkp->bi_inode, v_daddr,
|
1999-03-10 03:20:00 +03:00
|
|
|
&vp,
|
2001-11-24 00:44:25 +03:00
|
|
|
(blkp->bi_lbn == LFS_UNUSED_LBN
|
1999-03-10 03:20:00 +03:00
|
|
|
? blkp->bi_bp
|
|
|
|
: NULL),
|
|
|
|
&lfs_fastvget_unlock);
|
2001-11-24 00:44:25 +03:00
|
|
|
if (lfs_fastvget_unlock)
|
1999-03-10 03:20:00 +03:00
|
|
|
numlocked++;
|
|
|
|
|
2001-11-24 00:44:25 +03:00
|
|
|
if (!error) {
|
1999-03-10 03:20:00 +03:00
|
|
|
numrefed++;
|
|
|
|
}
|
2001-11-24 00:44:25 +03:00
|
|
|
if (error) {
|
2000-06-28 00:57:11 +04:00
|
|
|
#ifdef DEBUG_LFS
|
1999-04-12 04:40:06 +04:00
|
|
|
printf("lfs_markv: lfs_fastvget failed with %d (ino %d, segment %d)\n",
|
1999-03-10 03:20:00 +03:00
|
|
|
error, blkp->bi_inode,
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
dtosn(fs, blkp->bi_daddr));
|
2000-06-28 00:57:11 +04:00
|
|
|
#endif /* DEBUG_LFS */
|
1999-03-10 03:20:00 +03:00
|
|
|
/*
|
|
|
|
* If we got EAGAIN, that means that the
|
|
|
|
* Inode was locked. This is
|
|
|
|
* recoverable: just clean the rest of
|
|
|
|
* this segment, and let the cleaner try
|
|
|
|
* again with another. (When the
|
|
|
|
* cleaner runs again, this segment will
|
|
|
|
* sort high on the list, since it is
|
|
|
|
* now almost entirely empty.) But, we
|
|
|
|
* still set v_daddr = LFS_UNUSED_ADDR
|
|
|
|
* so as not to test this over and over
|
|
|
|
* again.
|
|
|
|
*/
|
2001-11-24 00:44:25 +03:00
|
|
|
if (error == EAGAIN) {
|
1999-03-10 03:20:00 +03:00
|
|
|
error = 0;
|
|
|
|
do_again++;
|
|
|
|
}
|
1994-06-08 15:41:58 +04:00
|
|
|
#ifdef DIAGNOSTIC
|
2001-11-24 00:44:25 +03:00
|
|
|
else if (error != ENOENT)
|
1999-03-10 03:20:00 +03:00
|
|
|
panic("lfs_markv VFS_VGET FAILED");
|
1994-06-08 15:41:58 +04:00
|
|
|
#endif
|
1999-03-10 03:20:00 +03:00
|
|
|
/* lastino = LFS_UNUSED_INUM; */
|
1994-06-08 15:41:58 +04:00
|
|
|
v_daddr = LFS_UNUSED_DADDR;
|
1999-03-10 03:20:00 +03:00
|
|
|
vp = NULL;
|
|
|
|
ip = NULL;
|
1994-06-08 15:41:58 +04:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
ip = VTOI(vp);
|
1999-03-10 03:20:00 +03:00
|
|
|
} else if (v_daddr == LFS_UNUSED_DADDR) {
|
|
|
|
/*
|
|
|
|
* This can only happen if the vnode is dead (or
|
|
|
|
* in any case we can't get it...e.g., it is
|
|
|
|
* inlocked). Keep going.
|
|
|
|
*/
|
1994-06-08 15:41:58 +04:00
|
|
|
continue;
|
1999-03-10 03:20:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Past this point we are guaranteed that vp, ip are valid. */
|
1994-06-08 15:41:58 +04:00
|
|
|
|
|
|
|
/* If this BLOCK_INFO didn't contain a block, keep going. */
|
1999-03-10 03:20:00 +03:00
|
|
|
if (blkp->bi_lbn == LFS_UNUSED_LBN) {
|
|
|
|
/* XXX need to make sure that the inode gets written in this case */
|
|
|
|
/* XXX but only write the inode if it's the right one */
|
2000-11-23 01:11:34 +03:00
|
|
|
if (blkp->bi_inode != LFS_IFILE_INUM) {
|
|
|
|
LFS_IENTRY(ifp, fs, blkp->bi_inode, bp);
|
2001-11-24 00:44:25 +03:00
|
|
|
if (ifp->if_daddr == blkp->bi_daddr
|
1999-03-10 03:20:00 +03:00
|
|
|
|| blkp->bi_daddr == LFS_FORCE_WRITE)
|
|
|
|
{
|
2000-07-06 02:25:43 +04:00
|
|
|
LFS_SET_UINO(ip, IN_CLEANING);
|
1999-03-10 03:20:00 +03:00
|
|
|
}
|
2000-11-23 01:11:34 +03:00
|
|
|
brelse(bp);
|
|
|
|
}
|
1994-06-08 15:41:58 +04:00
|
|
|
continue;
|
1999-03-10 03:20:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
b_daddr = 0;
|
2001-11-24 00:44:25 +03:00
|
|
|
if (blkp->bi_daddr != LFS_FORCE_WRITE) {
|
1999-03-10 03:20:00 +03:00
|
|
|
if (VOP_BMAP(vp, blkp->bi_lbn, NULL, &b_daddr, NULL) ||
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
dbtofsb(fs, b_daddr) != blkp->bi_daddr)
|
1999-03-10 03:20:00 +03:00
|
|
|
{
|
2001-11-24 00:44:25 +03:00
|
|
|
if (dtosn(fs,dbtofsb(fs, b_daddr))
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
== dtosn(fs,blkp->bi_daddr))
|
1999-03-10 03:20:00 +03:00
|
|
|
{
|
1999-04-12 04:40:06 +04:00
|
|
|
printf("lfs_markv: wrong da same seg: %x vs %x\n",
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
blkp->bi_daddr, dbtofsb(fs, b_daddr));
|
1999-03-10 03:20:00 +03:00
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* If we got to here, then we are keeping the block. If
|
|
|
|
* it is an indirect block, we want to actually put it
|
|
|
|
* in the buffer cache so that it can be updated in the
|
|
|
|
* finish_meta section. If it's not, we need to
|
|
|
|
* allocate a fake buffer so that writeseg can perform
|
|
|
|
* the copyin and write the buffer.
|
|
|
|
*/
|
|
|
|
/*
|
|
|
|
* XXX - if the block we are reading has been *extended* since
|
|
|
|
* it was written to disk, then we risk throwing away
|
|
|
|
* the extension in bread()/getblk(). Check the size
|
|
|
|
* here.
|
|
|
|
*/
|
2001-11-24 00:44:25 +03:00
|
|
|
if (blkp->bi_size < fs->lfs_bsize) {
|
1999-03-10 03:20:00 +03:00
|
|
|
s = splbio();
|
|
|
|
bp = incore(vp, blkp->bi_lbn);
|
2001-11-24 00:44:25 +03:00
|
|
|
if (bp && bp->b_bcount > blkp->bi_size) {
|
1999-03-10 03:20:00 +03:00
|
|
|
printf("lfs_markv: %ld > %d (fixed)\n",
|
|
|
|
bp->b_bcount, blkp->bi_size);
|
|
|
|
blkp->bi_size = bp->b_bcount;
|
|
|
|
}
|
|
|
|
splx(s);
|
|
|
|
}
|
2000-01-15 00:41:11 +03:00
|
|
|
if (ip->i_number != LFS_IFILE_INUM && blkp->bi_lbn >= 0) {
|
|
|
|
/* Data Block */
|
1999-03-26 00:39:18 +03:00
|
|
|
bp = lfs_fakebuf(vp, blkp->bi_lbn,
|
|
|
|
blkp->bi_size, blkp->bi_bp);
|
|
|
|
/* Pretend we used bread() to get it */
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
bp->b_blkno = fsbtodb(fs, blkp->bi_daddr);
|
2000-01-15 00:41:11 +03:00
|
|
|
} else {
|
|
|
|
/* Indirect block */
|
1999-03-10 03:20:00 +03:00
|
|
|
bp = getblk(vp, blkp->bi_lbn, blkp->bi_size, 0, 0);
|
|
|
|
if (!(bp->b_flags & (B_DONE|B_DELWRI))) { /* B_CACHE */
|
|
|
|
/*
|
|
|
|
* The block in question was not found
|
|
|
|
* in the cache; i.e., the block that
|
|
|
|
* getblk() returned is empty. So, we
|
|
|
|
* can (and should) copy in the
|
|
|
|
* contents, because we've already
|
|
|
|
* determined that this was the right
|
|
|
|
* version of this block on disk.
|
|
|
|
*
|
|
|
|
* And, it can't have changed underneath
|
|
|
|
* us, because we have the segment lock.
|
|
|
|
*/
|
|
|
|
error = copyin(blkp->bi_bp, bp->b_data, blkp->bi_size);
|
2001-11-24 00:44:25 +03:00
|
|
|
if (error)
|
1999-03-10 03:20:00 +03:00
|
|
|
goto err2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ((error = lfs_bwrite_ext(bp,BW_CLEAN)) != 0)
|
|
|
|
goto err2;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Finish the old file, if there was one
|
|
|
|
*/
|
2001-11-24 00:44:25 +03:00
|
|
|
if (v_daddr != LFS_UNUSED_DADDR) {
|
1999-03-10 03:20:00 +03:00
|
|
|
#ifdef DEBUG_LFS
|
2001-11-24 00:44:25 +03:00
|
|
|
if (ip->i_flag & (IN_MODIFIED|IN_CLEANING))
|
1999-03-10 03:20:00 +03:00
|
|
|
iwritten++;
|
|
|
|
#endif
|
2001-11-24 00:44:25 +03:00
|
|
|
if (lfs_fastvget_unlock) {
|
2000-06-28 00:57:11 +04:00
|
|
|
VOP_UNLOCK(vp, 0);
|
1999-03-10 03:20:00 +03:00
|
|
|
numlocked--;
|
1994-06-08 15:41:58 +04:00
|
|
|
}
|
1999-03-10 03:20:00 +03:00
|
|
|
lfs_vunref(vp);
|
|
|
|
numrefed--;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The last write has to be SEGM_SYNC, because of calling semantics.
|
|
|
|
* It also has to be SEGM_CKP, because otherwise we could write
|
|
|
|
* over the newly cleaned data contained in a checkpoint, and then
|
|
|
|
* we'd be unhappy at recovery time.
|
|
|
|
*/
|
|
|
|
lfs_segwrite(mntp, SEGM_SYNC|SEGM_CLEAN|SEGM_CKP);
|
|
|
|
|
1994-06-08 15:41:58 +04:00
|
|
|
lfs_segunlock(fs);
|
|
|
|
|
1999-03-10 03:20:00 +03:00
|
|
|
#ifdef DEBUG_LFS
|
|
|
|
printf("%d]",iwritten);
|
2001-11-24 00:44:25 +03:00
|
|
|
if (numlocked != 0 || numrefed != 0) {
|
1999-03-10 03:20:00 +03:00
|
|
|
panic("lfs_markv: numlocked=%d numrefed=%d", numlocked, numrefed);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2000-11-23 01:11:34 +03:00
|
|
|
vfs_unbusy(mntp);
|
2001-11-24 00:44:25 +03:00
|
|
|
if (error)
|
1999-03-10 03:20:00 +03:00
|
|
|
return (error);
|
2001-11-24 00:44:25 +03:00
|
|
|
else if (do_again)
|
1999-03-10 03:20:00 +03:00
|
|
|
return EAGAIN;
|
1994-06-08 15:41:58 +04:00
|
|
|
|
1999-03-10 03:20:00 +03:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
err2:
|
1999-04-12 04:40:06 +04:00
|
|
|
printf("lfs_markv err2\n");
|
2001-11-24 00:44:25 +03:00
|
|
|
if (lfs_fastvget_unlock) {
|
2000-11-23 01:11:34 +03:00
|
|
|
VOP_UNLOCK(vp, 0);
|
|
|
|
--numlocked;
|
|
|
|
}
|
1999-03-10 03:20:00 +03:00
|
|
|
lfs_vunref(vp);
|
2000-11-23 01:11:34 +03:00
|
|
|
--numrefed;
|
|
|
|
|
1999-03-10 03:20:00 +03:00
|
|
|
/* Free up fakebuffers -- have to take these from the LOCKED list */
|
|
|
|
again:
|
1999-11-24 02:52:40 +03:00
|
|
|
s = splbio();
|
2001-11-24 00:44:25 +03:00
|
|
|
for (bp = bufqueues[BQ_LOCKED].tqh_first; bp; bp = nbp) {
|
1999-03-10 03:20:00 +03:00
|
|
|
nbp = bp->b_freelist.tqe_next;
|
2001-11-24 00:44:25 +03:00
|
|
|
if (bp->b_flags & B_CALL) {
|
|
|
|
if (bp->b_flags & B_BUSY) { /* not bloody likely */
|
1999-03-10 03:20:00 +03:00
|
|
|
bp->b_flags |= B_WANTED;
|
|
|
|
tsleep(bp, PRIBIO+1, "markv", 0);
|
|
|
|
splx(s);
|
|
|
|
goto again;
|
|
|
|
}
|
2001-11-24 00:44:25 +03:00
|
|
|
if (bp->b_flags & B_DELWRI)
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
fs->lfs_avail += btofsb(fs, bp->b_bcount);
|
1999-03-10 03:20:00 +03:00
|
|
|
bremfree(bp);
|
|
|
|
splx(s);
|
|
|
|
brelse(bp);
|
1999-11-24 02:52:40 +03:00
|
|
|
s = splbio();
|
1999-03-10 03:20:00 +03:00
|
|
|
}
|
|
|
|
}
|
1999-11-24 02:52:40 +03:00
|
|
|
splx(s);
|
1994-06-08 15:41:58 +04:00
|
|
|
lfs_segunlock(fs);
|
2000-11-23 01:11:34 +03:00
|
|
|
vfs_unbusy(mntp);
|
|
|
|
#ifdef DEBUG_LFS
|
2001-11-24 00:44:25 +03:00
|
|
|
if (numlocked != 0 || numrefed != 0) {
|
2000-11-23 01:11:34 +03:00
|
|
|
panic("lfs_markv: numlocked=%d numrefed=%d", numlocked, numrefed);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
1999-03-10 03:20:00 +03:00
|
|
|
return (error);
|
1994-06-08 15:41:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1999-06-09 08:52:11 +04:00
|
|
|
* sys_lfs_bmapv:
|
1994-06-08 15:41:58 +04:00
|
|
|
*
|
|
|
|
* This will fill in the current disk address for arrays of blocks.
|
|
|
|
*
|
|
|
|
* 0 on success
|
|
|
|
* -1/errno is return on error.
|
|
|
|
*/
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
#ifdef USE_64BIT_SYSCALLS
|
|
|
|
int
|
|
|
|
sys_lfs_bmapv(struct proc *p, void *v, register_t *retval)
|
|
|
|
{
|
|
|
|
struct sys_lfs_bmapv_args /* {
|
|
|
|
syscallarg(fsid_t *) fsidp;
|
|
|
|
syscallarg(struct block_info *) blkiov;
|
|
|
|
syscallarg(int) blkcnt;
|
|
|
|
} */ *uap = v;
|
|
|
|
BLOCK_INFO *blkiov;
|
|
|
|
int blkcnt, error;
|
|
|
|
fsid_t fsid;
|
|
|
|
|
|
|
|
if ((error = suser(p->p_ucred, &p->p_acflag)) != 0)
|
|
|
|
return (error);
|
|
|
|
|
|
|
|
if ((error = copyin(SCARG(uap, fsidp), &fsid, sizeof(fsid_t))) != 0)
|
|
|
|
return (error);
|
|
|
|
|
|
|
|
blkcnt = SCARG(uap, blkcnt);
|
|
|
|
blkiov = malloc(blkcnt * sizeof(BLOCK_INFO), M_SEGMENT, M_WAITOK);
|
|
|
|
if ((error = copyin(SCARG(uap, blkiov), blkiov,
|
|
|
|
blkcnt * sizeof(BLOCK_INFO))) != 0)
|
|
|
|
goto out;
|
1999-03-10 03:20:00 +03:00
|
|
|
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
if ((error = lfs_bmapv(p, &fsid, blkiov, blkcnt)) == 0)
|
|
|
|
copyout(blkiov, SCARG(uap, blkiov),
|
|
|
|
blkcnt * sizeof(BLOCK_INFO));
|
|
|
|
out:
|
|
|
|
free(blkiov, M_SEGMENT);
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
#else
|
1994-06-08 15:41:58 +04:00
|
|
|
int
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
sys_lfs_bmapv(struct proc *p, void *v, register_t *retval)
|
1995-09-22 03:39:20 +04:00
|
|
|
{
|
1999-06-09 16:18:19 +04:00
|
|
|
struct sys_lfs_bmapv_args /* {
|
|
|
|
syscallarg(fsid_t *) fsidp;
|
|
|
|
syscallarg(struct block_info *) blkiov;
|
|
|
|
syscallarg(int) blkcnt;
|
|
|
|
} */ *uap = v;
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
BLOCK_INFO *blkiov;
|
|
|
|
BLOCK_INFO_15 *blkiov15;
|
|
|
|
int i, blkcnt, error;
|
|
|
|
fsid_t fsid;
|
|
|
|
|
|
|
|
if ((error = suser(p->p_ucred, &p->p_acflag)) != 0)
|
|
|
|
return (error);
|
|
|
|
|
|
|
|
if ((error = copyin(SCARG(uap, fsidp), &fsid, sizeof(fsid_t))) != 0)
|
|
|
|
return (error);
|
|
|
|
|
|
|
|
blkcnt = SCARG(uap, blkcnt);
|
|
|
|
blkiov = malloc(blkcnt * sizeof(BLOCK_INFO), M_SEGMENT, M_WAITOK);
|
|
|
|
blkiov15 = malloc(blkcnt * sizeof(BLOCK_INFO_15), M_SEGMENT, M_WAITOK);
|
|
|
|
if ((error = copyin(SCARG(uap, blkiov), blkiov15,
|
|
|
|
blkcnt * sizeof(BLOCK_INFO_15))) != 0)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
for (i = 0; i < blkcnt; i++) {
|
|
|
|
blkiov[i].bi_inode = blkiov15[i].bi_inode;
|
|
|
|
blkiov[i].bi_lbn = blkiov15[i].bi_lbn;
|
|
|
|
blkiov[i].bi_daddr = blkiov15[i].bi_daddr;
|
|
|
|
blkiov[i].bi_segcreate = blkiov15[i].bi_segcreate;
|
|
|
|
blkiov[i].bi_version = blkiov15[i].bi_version;
|
|
|
|
blkiov[i].bi_bp = blkiov15[i].bi_bp;
|
|
|
|
blkiov[i].bi_size = blkiov15[i].bi_size;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((error = lfs_bmapv(p, &fsid, blkiov, blkcnt)) == 0) {
|
|
|
|
for (i = 0; i < blkcnt; i++) {
|
|
|
|
blkiov15[i].bi_inode = blkiov[i].bi_inode;
|
|
|
|
blkiov15[i].bi_lbn = blkiov[i].bi_lbn;
|
|
|
|
blkiov15[i].bi_daddr = blkiov[i].bi_daddr;
|
|
|
|
blkiov15[i].bi_segcreate = blkiov[i].bi_segcreate;
|
|
|
|
blkiov15[i].bi_version = blkiov[i].bi_version;
|
|
|
|
blkiov15[i].bi_bp = blkiov[i].bi_bp;
|
|
|
|
blkiov15[i].bi_size = blkiov[i].bi_size;
|
|
|
|
}
|
|
|
|
copyout(blkiov15, SCARG(uap, blkiov),
|
|
|
|
blkcnt * sizeof(BLOCK_INFO_15));
|
|
|
|
}
|
|
|
|
out:
|
|
|
|
free(blkiov, M_SEGMENT);
|
|
|
|
free(blkiov15, M_SEGMENT);
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static int
|
|
|
|
lfs_bmapv(struct proc *p, fsid_t *fsidp, BLOCK_INFO *blkiov, int blkcnt)
|
|
|
|
{
|
1994-06-08 15:41:58 +04:00
|
|
|
BLOCK_INFO *blkp;
|
1999-03-10 03:20:00 +03:00
|
|
|
IFILE *ifp;
|
|
|
|
struct buf *bp;
|
|
|
|
struct inode *ip = NULL;
|
|
|
|
struct lfs *fs;
|
1994-06-08 15:41:58 +04:00
|
|
|
struct mount *mntp;
|
1998-03-01 05:20:01 +03:00
|
|
|
struct ufsmount *ump;
|
1994-06-08 15:41:58 +04:00
|
|
|
struct vnode *vp;
|
1999-03-10 03:20:00 +03:00
|
|
|
ino_t lastino;
|
|
|
|
ufs_daddr_t v_daddr;
|
2001-11-24 00:44:25 +03:00
|
|
|
int cnt, error, need_unlock = 0;
|
|
|
|
int numlocked = 0, numrefed = 0;
|
1999-03-10 03:20:00 +03:00
|
|
|
#ifdef LFS_TRACK_IOS
|
|
|
|
int j;
|
|
|
|
#endif
|
1994-06-08 15:41:58 +04:00
|
|
|
|
1999-03-10 03:20:00 +03:00
|
|
|
lfs_cleaner_pid = p->p_pid;
|
|
|
|
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
if ((mntp = vfs_getvfs(fsidp)) == NULL)
|
2000-11-23 01:11:34 +03:00
|
|
|
return (ENOENT);
|
1999-03-10 03:20:00 +03:00
|
|
|
|
|
|
|
ump = VFSTOUFS(mntp);
|
2000-11-23 01:11:34 +03:00
|
|
|
if ((error = vfs_busy(mntp, LK_NOWAIT, NULL)) != 0)
|
|
|
|
return (error);
|
1999-03-10 03:20:00 +03:00
|
|
|
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
cnt = blkcnt;
|
1999-03-10 03:20:00 +03:00
|
|
|
|
|
|
|
fs = VFSTOUFS(mntp)->um_lfs;
|
|
|
|
|
|
|
|
error = 0;
|
|
|
|
|
|
|
|
/* these were inside the initialization for the for loop */
|
|
|
|
v_daddr = LFS_UNUSED_DADDR;
|
|
|
|
lastino = LFS_UNUSED_INUM;
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
for (blkp = blkiov; cnt--; ++blkp)
|
1999-03-10 03:20:00 +03:00
|
|
|
{
|
|
|
|
#ifdef DEBUG
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
if (dtosn(fs, fs->lfs_curseg) == dtosn(fs, blkp->bi_daddr)) {
|
1999-04-12 04:40:06 +04:00
|
|
|
printf("lfs_bmapv: attempt to clean current segment? (#%d)\n",
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
dtosn(fs, fs->lfs_curseg));
|
2000-11-23 01:11:34 +03:00
|
|
|
vfs_unbusy(mntp);
|
1999-03-10 03:20:00 +03:00
|
|
|
return (EBUSY);
|
|
|
|
}
|
|
|
|
#endif /* DEBUG */
|
|
|
|
#ifdef LFS_TRACK_IOS
|
|
|
|
/*
|
|
|
|
* If there is I/O on this segment that is not yet complete,
|
|
|
|
* the cleaner probably does not have the right information.
|
|
|
|
* Send it packing.
|
|
|
|
*/
|
2001-11-24 00:44:25 +03:00
|
|
|
for (j = 0; j < LFS_THROTTLE; j++) {
|
|
|
|
if (fs->lfs_pending[j] != LFS_UNUSED_DADDR
|
|
|
|
&& dtosn(fs,fs->lfs_pending[j]) == dtosn(fs,blkp->bi_daddr))
|
1999-03-10 03:20:00 +03:00
|
|
|
{
|
|
|
|
printf("lfs_bmapv: attempt to clean pending segment? (#%d)\n",
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
dtosn(fs, fs->lfs_pending[j]));
|
2000-11-23 01:11:34 +03:00
|
|
|
vfs_unbusy(mntp);
|
1999-03-10 03:20:00 +03:00
|
|
|
return (EBUSY);
|
|
|
|
}
|
|
|
|
}
|
1994-06-08 15:41:58 +04:00
|
|
|
|
1999-03-10 03:20:00 +03:00
|
|
|
#endif /* LFS_TRACK_IOS */
|
1998-03-01 05:20:01 +03:00
|
|
|
/*
|
1999-03-10 03:20:00 +03:00
|
|
|
* Get the IFILE entry (only once) and see if the file still
|
|
|
|
* exists.
|
1998-03-01 05:20:01 +03:00
|
|
|
*/
|
1999-03-10 03:20:00 +03:00
|
|
|
if (lastino != blkp->bi_inode) {
|
|
|
|
/*
|
|
|
|
* Finish the old file, if there was one. The presence
|
|
|
|
* of a usable vnode in vp is signaled by a valid
|
|
|
|
* v_daddr.
|
|
|
|
*/
|
2001-11-24 00:44:25 +03:00
|
|
|
if (v_daddr != LFS_UNUSED_DADDR) {
|
|
|
|
if (need_unlock) {
|
2000-06-28 00:57:11 +04:00
|
|
|
VOP_UNLOCK(vp, 0);
|
1999-03-10 03:20:00 +03:00
|
|
|
numlocked--;
|
|
|
|
}
|
|
|
|
lfs_vunref(vp);
|
|
|
|
numrefed--;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Start a new file
|
|
|
|
*/
|
|
|
|
lastino = blkp->bi_inode;
|
|
|
|
if (blkp->bi_inode == LFS_IFILE_INUM)
|
|
|
|
v_daddr = fs->lfs_idaddr;
|
|
|
|
else {
|
|
|
|
LFS_IENTRY(ifp, fs, blkp->bi_inode, bp);
|
|
|
|
v_daddr = ifp->if_daddr;
|
|
|
|
brelse(bp);
|
|
|
|
}
|
|
|
|
if (v_daddr == LFS_UNUSED_DADDR) {
|
|
|
|
blkp->bi_daddr = LFS_UNUSED_DADDR;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* A regular call to VFS_VGET could deadlock
|
|
|
|
* here. Instead, we try an unlocked access.
|
|
|
|
*/
|
|
|
|
vp = ufs_ihashlookup(ump->um_dev, blkp->bi_inode);
|
1999-03-26 00:54:10 +03:00
|
|
|
if (vp != NULL && !(vp->v_flag & VXLOCK)) {
|
1999-03-10 03:20:00 +03:00
|
|
|
ip = VTOI(vp);
|
2000-06-22 22:11:45 +04:00
|
|
|
if (lfs_vref(vp)) {
|
|
|
|
v_daddr = LFS_UNUSED_DADDR;
|
|
|
|
need_unlock = 0;
|
|
|
|
continue;
|
|
|
|
}
|
2000-06-28 00:57:11 +04:00
|
|
|
numrefed++;
|
2001-11-24 00:44:25 +03:00
|
|
|
if (VOP_ISLOCKED(vp)) {
|
2000-06-28 00:57:11 +04:00
|
|
|
#ifdef DEBUG_LFS
|
|
|
|
printf("lfs_bmapv: inode %d inlocked\n",ip->i_number);
|
|
|
|
#endif
|
|
|
|
v_daddr = LFS_UNUSED_DADDR;
|
1999-03-10 03:20:00 +03:00
|
|
|
need_unlock = 0;
|
2000-06-28 00:57:11 +04:00
|
|
|
lfs_vunref(vp);
|
|
|
|
--numrefed;
|
|
|
|
continue;
|
1999-03-10 03:20:00 +03:00
|
|
|
} else {
|
2000-06-28 00:57:11 +04:00
|
|
|
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
|
1999-03-10 03:20:00 +03:00
|
|
|
need_unlock = FVG_UNLOCK;
|
|
|
|
numlocked++;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
error = VFS_VGET(mntp, blkp->bi_inode, &vp);
|
2001-11-24 00:44:25 +03:00
|
|
|
if (error) {
|
1999-03-26 00:54:10 +03:00
|
|
|
#ifdef DEBUG_LFS
|
1999-03-26 01:26:52 +03:00
|
|
|
printf("lfs_bmapv: vget of ino %d failed with %d",blkp->bi_inode,error);
|
1999-03-26 00:54:10 +03:00
|
|
|
#endif
|
2000-06-28 00:57:11 +04:00
|
|
|
v_daddr = LFS_UNUSED_DADDR;
|
|
|
|
need_unlock = 0;
|
1999-03-10 03:20:00 +03:00
|
|
|
continue;
|
|
|
|
} else {
|
|
|
|
need_unlock = FVG_PUT;
|
|
|
|
numlocked++;
|
|
|
|
numrefed++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ip = VTOI(vp);
|
|
|
|
} else if (v_daddr == LFS_UNUSED_DADDR) {
|
|
|
|
/*
|
|
|
|
* This can only happen if the vnode is dead.
|
|
|
|
* Keep going. Note that we DO NOT set the
|
|
|
|
* bi_addr to anything -- if we failed to get
|
|
|
|
* the vnode, for example, we want to assume
|
|
|
|
* conservatively that all of its blocks *are*
|
|
|
|
* located in the segment in question.
|
|
|
|
* lfs_markv will throw them out if we are
|
|
|
|
* wrong.
|
|
|
|
*/
|
|
|
|
/* blkp->bi_daddr = LFS_UNUSED_DADDR; */
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Past this point we are guaranteed that vp, ip are valid. */
|
|
|
|
|
2001-11-24 00:44:25 +03:00
|
|
|
if (blkp->bi_lbn == LFS_UNUSED_LBN) {
|
1999-03-10 03:20:00 +03:00
|
|
|
/*
|
|
|
|
* We just want the inode address, which is
|
|
|
|
* conveniently in v_daddr.
|
|
|
|
*/
|
|
|
|
blkp->bi_daddr = v_daddr;
|
|
|
|
} else {
|
|
|
|
error = VOP_BMAP(vp, blkp->bi_lbn, NULL,
|
|
|
|
&(blkp->bi_daddr), NULL);
|
2001-11-24 00:44:25 +03:00
|
|
|
if (error)
|
1999-03-10 03:20:00 +03:00
|
|
|
{
|
|
|
|
blkp->bi_daddr = LFS_UNUSED_DADDR;
|
|
|
|
continue;
|
|
|
|
}
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
blkp->bi_daddr = dbtofsb(fs, blkp->bi_daddr);
|
1999-03-10 03:20:00 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Finish the old file, if there was one. The presence
|
|
|
|
* of a usable vnode in vp is signaled by a valid v_daddr.
|
|
|
|
*/
|
2001-11-24 00:44:25 +03:00
|
|
|
if (v_daddr != LFS_UNUSED_DADDR) {
|
|
|
|
if (need_unlock) {
|
2000-06-28 00:57:11 +04:00
|
|
|
VOP_UNLOCK(vp, 0);
|
1999-03-10 03:20:00 +03:00
|
|
|
numlocked--;
|
1994-06-08 15:41:58 +04:00
|
|
|
}
|
1999-03-10 03:20:00 +03:00
|
|
|
lfs_vunref(vp);
|
|
|
|
numrefed--;
|
|
|
|
}
|
|
|
|
|
2001-11-24 00:44:25 +03:00
|
|
|
if (numlocked != 0 || numrefed != 0) {
|
1999-03-10 03:20:00 +03:00
|
|
|
panic("lfs_bmapv: numlocked=%d numrefed=%d", numlocked,
|
|
|
|
numrefed);
|
|
|
|
}
|
|
|
|
|
2000-11-23 01:11:34 +03:00
|
|
|
vfs_unbusy(mntp);
|
1999-03-10 03:20:00 +03:00
|
|
|
|
|
|
|
return 0;
|
1994-06-08 15:41:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1999-06-09 08:52:11 +04:00
|
|
|
* sys_lfs_segclean:
|
1994-06-08 15:41:58 +04:00
|
|
|
*
|
|
|
|
* Mark the segment clean.
|
|
|
|
*
|
|
|
|
* 0 on success
|
|
|
|
* -1/errno is return on error.
|
|
|
|
*/
|
|
|
|
int
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
sys_lfs_segclean(struct proc *p, void *v, register_t *retval)
|
1995-09-22 03:39:20 +04:00
|
|
|
{
|
1999-06-09 16:18:19 +04:00
|
|
|
struct sys_lfs_segclean_args /* {
|
|
|
|
syscallarg(fsid_t *) fsidp;
|
|
|
|
syscallarg(u_long) segment;
|
|
|
|
} */ *uap = v;
|
1994-06-08 15:41:58 +04:00
|
|
|
CLEANERINFO *cip;
|
|
|
|
SEGUSE *sup;
|
|
|
|
struct buf *bp;
|
|
|
|
struct mount *mntp;
|
|
|
|
struct lfs *fs;
|
|
|
|
fsid_t fsid;
|
|
|
|
int error;
|
1999-03-10 03:20:00 +03:00
|
|
|
|
1996-02-10 01:28:45 +03:00
|
|
|
if ((error = suser(p->p_ucred, &p->p_acflag)) != 0)
|
1994-06-08 15:41:58 +04:00
|
|
|
return (error);
|
1999-03-10 03:20:00 +03:00
|
|
|
|
1996-02-10 01:28:45 +03:00
|
|
|
if ((error = copyin(SCARG(uap, fsidp), &fsid, sizeof(fsid_t))) != 0)
|
1994-06-08 15:41:58 +04:00
|
|
|
return (error);
|
1998-03-01 05:20:01 +03:00
|
|
|
if ((mntp = vfs_getvfs(&fsid)) == NULL)
|
2000-11-23 01:11:34 +03:00
|
|
|
return (ENOENT);
|
1999-03-10 03:20:00 +03:00
|
|
|
|
1994-06-08 15:41:58 +04:00
|
|
|
fs = VFSTOUFS(mntp)->um_lfs;
|
1999-03-10 03:20:00 +03:00
|
|
|
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
if (dtosn(fs, fs->lfs_curseg) == SCARG(uap, segment))
|
1994-06-08 15:41:58 +04:00
|
|
|
return (EBUSY);
|
1999-03-10 03:20:00 +03:00
|
|
|
|
2000-11-23 01:11:34 +03:00
|
|
|
if ((error = vfs_busy(mntp, LK_NOWAIT, NULL)) != 0)
|
|
|
|
return (error);
|
1994-10-20 07:20:55 +03:00
|
|
|
LFS_SEGENTRY(sup, fs, SCARG(uap, segment), bp);
|
1994-06-08 15:41:58 +04:00
|
|
|
if (sup->su_flags & SEGUSE_ACTIVE) {
|
|
|
|
brelse(bp);
|
2000-11-23 01:11:34 +03:00
|
|
|
vfs_unbusy(mntp);
|
1994-06-08 15:41:58 +04:00
|
|
|
return (EBUSY);
|
|
|
|
}
|
2000-10-20 21:48:05 +04:00
|
|
|
if (!(sup->su_flags & SEGUSE_DIRTY)) {
|
|
|
|
brelse(bp);
|
2000-11-23 01:11:34 +03:00
|
|
|
vfs_unbusy(mntp);
|
2000-10-20 21:48:05 +04:00
|
|
|
return (EALREADY);
|
|
|
|
}
|
1999-03-10 03:20:00 +03:00
|
|
|
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
fs->lfs_avail += segtod(fs, 1);
|
2000-07-05 02:30:37 +04:00
|
|
|
if (sup->su_flags & SEGUSE_SUPERBLOCK)
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
fs->lfs_avail -= btofsb(fs, LFS_SBPAD);
|
|
|
|
if (fs->lfs_version > 1 && SCARG(uap, segment) == 0 &&
|
|
|
|
fs->lfs_start < btofsb(fs, LFS_LABELPAD))
|
|
|
|
fs->lfs_avail -= btofsb(fs, LFS_LABELPAD) - fs->lfs_start;
|
|
|
|
fs->lfs_bfree += sup->su_nsums * btofsb(fs, fs->lfs_sumsize) +
|
|
|
|
btofsb(fs, sup->su_ninos * fs->lfs_ibsize);
|
|
|
|
fs->lfs_dmeta -= sup->su_nsums * btofsb(fs, fs->lfs_sumsize) +
|
|
|
|
btofsb(fs, sup->su_ninos * fs->lfs_ibsize);
|
2000-06-28 00:57:11 +04:00
|
|
|
if (fs->lfs_dmeta < 0)
|
|
|
|
fs->lfs_dmeta = 0;
|
1994-06-08 15:41:58 +04:00
|
|
|
sup->su_flags &= ~SEGUSE_DIRTY;
|
1999-03-10 03:20:00 +03:00
|
|
|
(void) VOP_BWRITE(bp);
|
|
|
|
|
1994-06-08 15:41:58 +04:00
|
|
|
LFS_CLEANERINFO(cip, fs, bp);
|
|
|
|
++cip->clean;
|
|
|
|
--cip->dirty;
|
1999-03-10 03:20:00 +03:00
|
|
|
fs->lfs_nclean = cip->clean;
|
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
|
|
|
cip->bfree = fs->lfs_bfree;
|
|
|
|
cip->avail = fs->lfs_avail - fs->lfs_ravail;
|
1994-06-08 15:41:58 +04:00
|
|
|
(void) VOP_BWRITE(bp);
|
|
|
|
wakeup(&fs->lfs_avail);
|
2000-11-23 01:11:34 +03:00
|
|
|
vfs_unbusy(mntp);
|
1999-03-10 03:20:00 +03:00
|
|
|
|
1994-06-08 15:41:58 +04:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1999-06-09 08:52:11 +04:00
|
|
|
* sys_lfs_segwait:
|
1994-06-08 15:41:58 +04:00
|
|
|
*
|
|
|
|
* This will block until a segment in file system fsid is written. A timeout
|
|
|
|
* in milliseconds may be specified which will awake the cleaner automatically.
|
|
|
|
* An fsid of -1 means any file system, and a timeout of 0 means forever.
|
|
|
|
*
|
|
|
|
* 0 on success
|
|
|
|
* 1 on timeout
|
|
|
|
* -1/errno is return on error.
|
|
|
|
*/
|
|
|
|
int
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
sys_lfs_segwait(struct proc *p, void *v, register_t *retval)
|
1995-09-22 03:39:20 +04:00
|
|
|
{
|
1999-06-09 16:18:19 +04:00
|
|
|
struct sys_lfs_segwait_args /* {
|
|
|
|
syscallarg(fsid_t *) fsidp;
|
|
|
|
syscallarg(struct timeval *) tv;
|
|
|
|
} */ *uap = v;
|
1994-06-08 15:41:58 +04:00
|
|
|
struct mount *mntp;
|
|
|
|
struct timeval atv;
|
|
|
|
fsid_t fsid;
|
|
|
|
void *addr;
|
|
|
|
u_long timeout;
|
|
|
|
int error, s;
|
1999-03-10 03:20:00 +03:00
|
|
|
|
1996-02-10 01:28:45 +03:00
|
|
|
if ((error = suser(p->p_ucred, &p->p_acflag)) != 0) {
|
1994-06-08 15:41:58 +04:00
|
|
|
return (error);
|
|
|
|
}
|
1996-02-10 01:28:45 +03:00
|
|
|
if ((error = copyin(SCARG(uap, fsidp), &fsid, sizeof(fsid_t))) != 0)
|
1994-06-08 15:41:58 +04:00
|
|
|
return (error);
|
1998-03-01 05:20:01 +03:00
|
|
|
if ((mntp = vfs_getvfs(&fsid)) == NULL)
|
1994-06-08 15:41:58 +04:00
|
|
|
addr = &lfs_allclean_wakeup;
|
|
|
|
else
|
|
|
|
addr = &VFSTOUFS(mntp)->um_lfs->lfs_nextseg;
|
1999-03-10 03:20:00 +03:00
|
|
|
|
1994-10-20 07:20:55 +03:00
|
|
|
if (SCARG(uap, tv)) {
|
1996-02-10 01:28:45 +03:00
|
|
|
error = copyin(SCARG(uap, tv), &atv, sizeof(struct timeval));
|
|
|
|
if (error)
|
1994-06-08 15:41:58 +04:00
|
|
|
return (error);
|
|
|
|
if (itimerfix(&atv))
|
|
|
|
return (EINVAL);
|
2000-07-13 21:35:03 +04:00
|
|
|
/*
|
|
|
|
* XXX THIS COULD SLEEP FOREVER IF TIMEOUT IS {0,0}!
|
|
|
|
* XXX IS THAT WHAT IS INTENDED?
|
|
|
|
*/
|
1994-06-08 15:41:58 +04:00
|
|
|
s = splclock();
|
1995-03-21 16:33:34 +03:00
|
|
|
timeradd(&atv, &time, &atv);
|
1994-06-08 15:41:58 +04:00
|
|
|
timeout = hzto(&atv);
|
|
|
|
splx(s);
|
|
|
|
} else
|
|
|
|
timeout = 0;
|
1999-03-10 03:20:00 +03:00
|
|
|
|
1994-06-08 15:41:58 +04:00
|
|
|
error = tsleep(addr, PCATCH | PUSER, "segment", timeout);
|
|
|
|
return (error == ERESTART ? EINTR : 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* VFS_VGET call specialized for the cleaner. The cleaner already knows the
|
|
|
|
* daddr from the ifile, so don't look it up again. If the cleaner is
|
|
|
|
* processing IINFO structures, it may have the ondisk inode already, so
|
|
|
|
* don't go retrieving it again.
|
1999-03-10 03:20:00 +03:00
|
|
|
*
|
|
|
|
* If we find the vnode on the hash chain, then it may be locked by another
|
|
|
|
* process; so we set (*need_unlock) to zero.
|
|
|
|
*
|
|
|
|
* If we don't, we call ufs_ihashins, which locks the inode, and we set
|
|
|
|
* (*need_unlock) to non-zero.
|
|
|
|
*
|
|
|
|
* In either case we lfs_vref, and it is the caller's responsibility to
|
|
|
|
* lfs_vunref and VOP_UNLOCK (if necessary) when finished.
|
1994-06-08 15:41:58 +04:00
|
|
|
*/
|
1999-03-10 03:20:00 +03:00
|
|
|
extern struct lock ufs_hashlock;
|
|
|
|
|
2000-07-01 00:45:38 +04:00
|
|
|
int
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
lfs_fasthashget(dev_t dev, ino_t ino, int *need_unlock, struct vnode **vpp)
|
2000-07-01 00:45:38 +04:00
|
|
|
{
|
|
|
|
struct inode *ip;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This is playing fast and loose. Someone may have the inode
|
|
|
|
* locked, in which case they are going to be distinctly unhappy
|
|
|
|
* if we trash something.
|
|
|
|
*/
|
|
|
|
if ((*vpp = ufs_ihashlookup(dev, ino)) != NULL) {
|
|
|
|
if ((*vpp)->v_flag & VXLOCK) {
|
2000-07-05 02:30:37 +04:00
|
|
|
printf("lfs_fastvget: vnode VXLOCKed for ino %d\n",
|
|
|
|
ino);
|
2000-07-01 00:45:38 +04:00
|
|
|
clean_vnlocked++;
|
|
|
|
#ifdef LFS_EAGAIN_FAIL
|
|
|
|
return EAGAIN;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
ip = VTOI(*vpp);
|
|
|
|
if (lfs_vref(*vpp)) {
|
|
|
|
clean_inlocked++;
|
|
|
|
return EAGAIN;
|
|
|
|
}
|
|
|
|
if (VOP_ISLOCKED(*vpp)) {
|
|
|
|
#ifdef DEBUG_LFS
|
|
|
|
printf("lfs_fastvget: ino %d inlocked by pid %d\n",
|
2000-07-05 02:30:37 +04:00
|
|
|
ip->i_number, (*vpp)->v_lock.lk_lockholder);
|
2000-07-01 00:45:38 +04:00
|
|
|
#endif
|
|
|
|
clean_inlocked++;
|
|
|
|
#ifdef LFS_EAGAIN_FAIL
|
|
|
|
lfs_vunref(*vpp);
|
|
|
|
return EAGAIN;
|
|
|
|
#endif /* LFS_EAGAIN_FAIL */
|
|
|
|
} else {
|
|
|
|
vn_lock(*vpp, LK_EXCLUSIVE | LK_RETRY);
|
|
|
|
*need_unlock |= FVG_UNLOCK;
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
*vpp = NULL;
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
1994-06-08 15:41:58 +04:00
|
|
|
int
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
lfs_fastvget(struct mount *mp, ino_t ino, ufs_daddr_t daddr, struct vnode **vpp, struct dinode *dinp, int *need_unlock)
|
1994-06-08 15:41:58 +04:00
|
|
|
{
|
2000-03-30 16:41:09 +04:00
|
|
|
struct inode *ip;
|
1994-06-08 15:41:58 +04:00
|
|
|
struct vnode *vp;
|
|
|
|
struct ufsmount *ump;
|
|
|
|
dev_t dev;
|
|
|
|
int error;
|
1999-03-10 03:20:00 +03:00
|
|
|
struct buf *bp;
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
struct lfs *fs;
|
1999-03-10 03:20:00 +03:00
|
|
|
|
1994-06-08 15:41:58 +04:00
|
|
|
ump = VFSTOUFS(mp);
|
|
|
|
dev = ump->um_dev;
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
fs = ump->um_lfs;
|
1999-03-10 03:20:00 +03:00
|
|
|
*need_unlock = 0;
|
2000-07-01 00:45:38 +04:00
|
|
|
|
2000-11-27 06:33:57 +03:00
|
|
|
/*
|
|
|
|
* Wait until the filesystem is fully mounted before allowing vget
|
|
|
|
* to complete. This prevents possible problems with roll-forward.
|
|
|
|
*/
|
2001-11-24 00:44:25 +03:00
|
|
|
while (fs->lfs_flags & LFS_NOTYET) {
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
tsleep(&fs->lfs_flags, PRIBIO+1, "lfs_fnotyet", 0);
|
2000-11-27 06:33:57 +03:00
|
|
|
}
|
|
|
|
/*
|
|
|
|
* This is playing fast and loose. Someone may have the inode
|
|
|
|
* locked, in which case they are going to be distinctly unhappy
|
|
|
|
* if we trash something.
|
|
|
|
*/
|
|
|
|
|
2000-07-01 00:45:38 +04:00
|
|
|
error = lfs_fasthashget(dev, ino, need_unlock, vpp);
|
|
|
|
if (error != 0 || *vpp != NULL)
|
|
|
|
return (error);
|
|
|
|
|
2000-07-03 22:22:10 +04:00
|
|
|
if ((error = getnewvnode(VT_LFS, mp, lfs_vnodeop_p, &vp)) != 0) {
|
2000-07-01 00:45:38 +04:00
|
|
|
*vpp = NULL;
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
1999-03-10 03:20:00 +03:00
|
|
|
do {
|
2000-07-01 00:45:38 +04:00
|
|
|
error = lfs_fasthashget(dev, ino, need_unlock, vpp);
|
|
|
|
if (error != 0 || *vpp != NULL) {
|
|
|
|
ungetnewvnode(vp);
|
|
|
|
return (error);
|
1999-03-10 03:20:00 +03:00
|
|
|
}
|
|
|
|
} while (lockmgr(&ufs_hashlock, LK_EXCLUSIVE|LK_SLEEPFAIL, 0));
|
1994-06-08 15:41:58 +04:00
|
|
|
|
|
|
|
/* Allocate new vnode/inode. */
|
2000-07-01 00:45:38 +04:00
|
|
|
lfs_vcreate(mp, ino, vp);
|
|
|
|
|
1994-06-08 15:41:58 +04:00
|
|
|
/*
|
|
|
|
* Put it onto its hash chain and lock it so that other requests for
|
|
|
|
* this inode will block if they arrive while we are sleeping waiting
|
|
|
|
* for old data structures to be purged or for the contents of the
|
|
|
|
* disk portion of this inode to be read.
|
|
|
|
*/
|
|
|
|
ip = VTOI(vp);
|
|
|
|
ufs_ihashins(ip);
|
1999-03-10 03:20:00 +03:00
|
|
|
lockmgr(&ufs_hashlock, LK_RELEASE, 0);
|
|
|
|
|
1994-06-08 15:41:58 +04:00
|
|
|
/*
|
|
|
|
* XXX
|
|
|
|
* This may not need to be here, logically it should go down with
|
|
|
|
* the i_devvp initialization.
|
|
|
|
* Ask Kirk.
|
|
|
|
*/
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
ip->i_lfs = fs;
|
1994-06-08 15:41:58 +04:00
|
|
|
|
|
|
|
/* Read in the disk contents for the inode, copy into the inode. */
|
1996-02-10 01:28:45 +03:00
|
|
|
if (dinp) {
|
1998-10-23 04:32:35 +04:00
|
|
|
error = copyin(dinp, &ip->i_din.ffs_din, DINODE_SIZE);
|
1999-03-10 03:20:00 +03:00
|
|
|
if (error) {
|
1999-03-26 00:54:10 +03:00
|
|
|
printf("lfs_fastvget: dinode copyin failed for ino %d\n", ino);
|
1999-03-10 03:20:00 +03:00
|
|
|
ufs_ihashrem(ip);
|
|
|
|
|
|
|
|
/* Unlock and discard unneeded inode. */
|
1999-07-08 05:05:58 +04:00
|
|
|
lockmgr(&vp->v_lock, LK_RELEASE, &vp->v_interlock);
|
1999-03-10 03:20:00 +03:00
|
|
|
lfs_vunref(vp);
|
|
|
|
*vpp = NULL;
|
1994-06-08 15:41:58 +04:00
|
|
|
return (error);
|
1999-03-10 03:20:00 +03:00
|
|
|
}
|
2001-11-24 00:44:25 +03:00
|
|
|
if (ip->i_number != ino)
|
1999-03-10 03:20:00 +03:00
|
|
|
panic("lfs_fastvget: I was fed the wrong inode!");
|
|
|
|
} else {
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
error = bread(ump->um_devvp, fsbtodb(fs, daddr), fs->lfs_ibsize,
|
|
|
|
NOCRED, &bp);
|
1996-02-10 01:28:45 +03:00
|
|
|
if (error) {
|
1999-04-12 04:40:06 +04:00
|
|
|
printf("lfs_fastvget: bread failed with %d\n",error);
|
1994-06-08 15:41:58 +04:00
|
|
|
/*
|
|
|
|
* The inode does not contain anything useful, so it
|
|
|
|
* would be misleading to leave it on its hash chain.
|
|
|
|
* Iput() will return it to the free list.
|
|
|
|
*/
|
|
|
|
ufs_ihashrem(ip);
|
1999-03-10 03:20:00 +03:00
|
|
|
|
1994-06-08 15:41:58 +04:00
|
|
|
/* Unlock and discard unneeded inode. */
|
1999-07-08 05:05:58 +04:00
|
|
|
lockmgr(&vp->v_lock, LK_RELEASE, &vp->v_interlock);
|
1994-06-08 15:41:58 +04:00
|
|
|
lfs_vunref(vp);
|
|
|
|
brelse(bp);
|
|
|
|
*vpp = NULL;
|
|
|
|
return (error);
|
|
|
|
}
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
ip->i_din.ffs_din = *lfs_ifind(fs, ino, bp);
|
1994-06-08 15:41:58 +04:00
|
|
|
brelse(bp);
|
|
|
|
}
|
1999-11-21 22:25:31 +03:00
|
|
|
ip->i_ffs_effnlink = ip->i_ffs_nlink;
|
2000-10-21 17:53:25 +04:00
|
|
|
ip->i_lfs_effnblks = ip->i_ffs_blocks;
|
1994-06-08 15:41:58 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Initialize the vnode from the inode, check for aliases. In all
|
|
|
|
* cases re-init ip, the underlying vnode/inode may have changed.
|
|
|
|
*/
|
a whole bunch of changes to improve performance and robustness under load:
- remove special treatment of pager_map mappings in pmaps. this is
required now, since I've removed the globals that expose the address range.
pager_map now uses pmap_kenter_pa() instead of pmap_enter(), so there's
no longer any need to special-case it.
- eliminate struct uvm_vnode by moving its fields into struct vnode.
- rewrite the pageout path. the pager is now responsible for handling the
high-level requests instead of only getting control after a bunch of work
has already been done on its behalf. this will allow us to UBCify LFS,
which needs tighter control over its pages than other filesystems do.
writing a page to disk no longer requires making it read-only, which
allows us to write wired pages without causing all kinds of havoc.
- use a new PG_PAGEOUT flag to indicate that a page should be freed
on behalf of the pagedaemon when it's unlocked. this flag is very similar
to PG_RELEASED, but unlike PG_RELEASED, PG_PAGEOUT can be cleared if the
pageout fails due to eg. an indirect-block buffer being locked.
this allows us to remove the "version" field from struct vm_page,
and together with shrinking "loan_count" from 32 bits to 16,
struct vm_page is now 4 bytes smaller.
- no longer use PG_RELEASED for swap-backed pages. if the page is busy
because it's being paged out, we can't release the swap slot to be
reallocated until that write is complete, but unlike with vnodes we
don't keep a count of in-progress writes so there's no good way to
know when the write is done. instead, when we need to free a busy
swap-backed page, just sleep until we can get it busy ourselves.
- implement a fast-path for extending writes which allows us to avoid
zeroing new pages. this substantially reduces cpu usage.
- encapsulate the data used by the genfs code in a struct genfs_node,
which must be the first element of the filesystem-specific vnode data
for filesystems which use genfs_{get,put}pages().
- eliminate many of the UVM pagerops, since they aren't needed anymore
now that the pager "put" operation is a higher-level operation.
- enhance the genfs code to allow NFS to use the genfs_{get,put}pages
instead of a modified copy.
- clean up struct vnode by removing all the fields that used to be used by
the vfs_cluster.c code (which we don't use anymore with UBC).
- remove kmem_object and mb_object since they were useless.
instead of allocating pages to these objects, we now just allocate
pages with no object. such pages are mapped in the kernel until they
are freed, so we can use the mapping to find the page to free it.
this allows us to remove splvm() protection in several places.
The sum of all these changes improves write throughput on my
decstation 5000/200 to within 1% of the rate of NetBSD 1.5
and reduces the elapsed time for "make release" of a NetBSD 1.5
source tree on my 128MB pc to 10% less than a 1.5 kernel took.
2001-09-16 00:36:31 +04:00
|
|
|
ufs_vinit(mp, lfs_specop_p, lfs_fifoop_p, &vp);
|
1999-03-10 03:20:00 +03:00
|
|
|
#ifdef DEBUG_LFS
|
2001-11-24 00:44:25 +03:00
|
|
|
if (vp->v_type == VNON) {
|
1999-03-10 03:20:00 +03:00
|
|
|
printf("lfs_fastvget: ino %d is type VNON! (ifmt=%o, dinp=%p)\n",
|
2001-11-24 00:44:25 +03:00
|
|
|
ip->i_number, (ip->i_ffs_mode & IFMT) >> 12, dinp);
|
1999-03-10 03:20:00 +03:00
|
|
|
lfs_dump_dinode(&ip->i_din.ffs_din);
|
|
|
|
#ifdef DDB
|
|
|
|
Debugger();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
#endif /* DEBUG_LFS */
|
1994-06-08 15:41:58 +04:00
|
|
|
/*
|
|
|
|
* Finish inode initialization now that aliasing has been resolved.
|
|
|
|
*/
|
2001-12-18 10:51:16 +03:00
|
|
|
|
|
|
|
genfs_node_init(vp, &lfs_genfsops);
|
1994-06-08 15:41:58 +04:00
|
|
|
ip->i_devvp = ump->um_devvp;
|
|
|
|
VREF(ip->i_devvp);
|
|
|
|
*vpp = vp;
|
1999-03-10 03:20:00 +03:00
|
|
|
*need_unlock |= FVG_PUT;
|
|
|
|
|
2000-12-03 10:34:49 +03:00
|
|
|
uvm_vnp_setsize(vp, ip->i_ffs_size);
|
|
|
|
|
1994-06-08 15:41:58 +04:00
|
|
|
return (0);
|
|
|
|
}
|
1999-03-10 03:20:00 +03:00
|
|
|
|
1994-06-08 15:41:58 +04:00
|
|
|
struct buf *
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
lfs_fakebuf(struct vnode *vp, int lbn, size_t size, caddr_t uaddr)
|
1994-06-08 15:41:58 +04:00
|
|
|
{
|
|
|
|
struct buf *bp;
|
1999-03-26 01:26:52 +03:00
|
|
|
int error;
|
1999-03-10 03:20:00 +03:00
|
|
|
|
1999-03-26 01:26:52 +03:00
|
|
|
#ifndef ALLOW_VFLUSH_CORRUPTION
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
bp = lfs_newbuf(VTOI(vp)->i_lfs, vp, lbn, size);
|
1999-03-26 01:26:52 +03:00
|
|
|
error = copyin(uaddr, bp->b_data, size);
|
2001-11-24 00:44:25 +03:00
|
|
|
if (error) {
|
1999-03-26 01:26:52 +03:00
|
|
|
lfs_freebuf(bp);
|
|
|
|
return NULL;
|
1999-03-10 03:20:00 +03:00
|
|
|
}
|
1999-03-26 01:26:52 +03:00
|
|
|
#else
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
bp = lfs_newbuf(VTOI(vp)->i_lfs, vp, lbn, 0);
|
1999-03-26 01:26:52 +03:00
|
|
|
bp->b_flags |= B_INVAL;
|
1994-06-08 15:41:58 +04:00
|
|
|
bp->b_saveaddr = uaddr;
|
1999-03-26 01:26:52 +03:00
|
|
|
#endif
|
|
|
|
|
1994-06-08 15:41:58 +04:00
|
|
|
bp->b_bufsize = size;
|
|
|
|
bp->b_bcount = size;
|
|
|
|
return (bp);
|
|
|
|
}
|