Install a new sysctl, vfs.lfs.ignore_lazy_sync, which causes LFS to ignore
the "smooth" syncer, as if vfs.sync.*delay = 0, but only for LFS. The
default is "on", i.e., ignore lazy sync.
Reduce the amount of polling/busy-waiting done by lfs_putpages(). To
accomplish this, copied genfs_putpages() and modified it to indicate which
page it was that caused it to return with EDEADLK. fsync()/fdatasync()
should no longer ever fail with EAGAIN, and should not consume huge
quantities of cpu.
Also, try to make dirops less likely to be written as the result of a
VOP_PUTPAGES(), while ensuring that they are written regularly.
2007-04-17 05:16:46 +04:00
|
|
|
/* $NetBSD: lfs_segment.c,v 1.199 2007/04/17 01:16:46 perseant Exp $ */
|
1994-06-29 10:39:25 +04:00
|
|
|
|
1999-03-10 03:20:00 +03:00
|
|
|
/*-
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
* Copyright (c) 1999, 2000, 2001, 2002, 2003 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:
|
2003-02-20 07:27:23 +03:00
|
|
|
* This product includes software developed by the NetBSD
|
|
|
|
* Foundation, Inc. and its contributors.
|
1999-03-10 03:20:00 +03:00
|
|
|
* 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
|
|
|
|
* 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.
|
2003-08-07 20:26:28 +04:00
|
|
|
* 3. Neither the name of the University nor the names of its contributors
|
1994-06-08 15:41:58 +04:00
|
|
|
* 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_segment.c 8.10 (Berkeley) 6/10/95
|
1994-06-08 15:41:58 +04:00
|
|
|
*/
|
|
|
|
|
2001-11-08 05:39:06 +03:00
|
|
|
#include <sys/cdefs.h>
|
Install a new sysctl, vfs.lfs.ignore_lazy_sync, which causes LFS to ignore
the "smooth" syncer, as if vfs.sync.*delay = 0, but only for LFS. The
default is "on", i.e., ignore lazy sync.
Reduce the amount of polling/busy-waiting done by lfs_putpages(). To
accomplish this, copied genfs_putpages() and modified it to indicate which
page it was that caused it to return with EDEADLK. fsync()/fdatasync()
should no longer ever fail with EAGAIN, and should not consume huge
quantities of cpu.
Also, try to make dirops less likely to be written as the result of a
VOP_PUTPAGES(), while ensuring that they are written regularly.
2007-04-17 05:16:46 +04:00
|
|
|
__KERNEL_RCSID(0, "$NetBSD: lfs_segment.c,v 1.199 2007/04/17 01:16:46 perseant Exp $");
|
2001-11-08 05:39:06 +03:00
|
|
|
|
2005-03-08 03:18:19 +03:00
|
|
|
#ifdef DEBUG
|
|
|
|
# define vndebug(vp, str) do { \
|
|
|
|
if (VTOI(vp)->i_flag & IN_CLEANING) \
|
|
|
|
DLOG((DLOG_WVNODE, "not writing ino %d because %s (op %d)\n", \
|
|
|
|
VTOI(vp)->i_number, (str), op)); \
|
|
|
|
} while(0)
|
|
|
|
#else
|
|
|
|
# define vndebug(vp, str)
|
|
|
|
#endif
|
|
|
|
#define ivndebug(vp, str) \
|
|
|
|
DLOG((DLOG_WVNODE, "ino %d: %s\n", VTOI(vp)->i_number, (str)))
|
1999-03-26 00:39:18 +03:00
|
|
|
|
2001-05-30 15:57:16 +04:00
|
|
|
#if defined(_KERNEL_OPT)
|
1999-09-04 02:48:51 +04:00
|
|
|
#include "opt_ddb.h"
|
2000-11-30 18:59:47 +03:00
|
|
|
#endif
|
|
|
|
|
1994-06-08 15:41:58 +04:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/namei.h>
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/resourcevar.h>
|
|
|
|
#include <sys/file.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <sys/buf.h>
|
|
|
|
#include <sys/proc.h>
|
|
|
|
#include <sys/vnode.h>
|
|
|
|
#include <sys/mount.h>
|
2006-05-15 01:31:52 +04:00
|
|
|
#include <sys/kauth.h>
|
2006-06-24 09:28:54 +04:00
|
|
|
#include <sys/syslog.h>
|
1994-06-08 15:41:58 +04:00
|
|
|
|
|
|
|
#include <miscfs/specfs/specdev.h>
|
|
|
|
#include <miscfs/fifofs/fifo.h>
|
|
|
|
|
|
|
|
#include <ufs/ufs/inode.h>
|
|
|
|
#include <ufs/ufs/dir.h>
|
|
|
|
#include <ufs/ufs/ufsmount.h>
|
|
|
|
#include <ufs/ufs/ufs_extern.h>
|
|
|
|
|
|
|
|
#include <ufs/lfs/lfs.h>
|
|
|
|
#include <ufs/lfs/lfs_extern.h>
|
|
|
|
|
For synchronous writes, keep separate i/o counters for each write, so
processes don't have to wait for one another to finish (e.g., nfsd seems
to be a little happier now, though I haven't measured the difference).
Synchronous checkpoints, however, must always wait for all i/o to finish.
Take the contents of the callback functions and have them run in thread
context instead (aiodoned thread). lfs_iocount no longer has to be
protected in splbio(), and quite a bit less of the segment construction
loop needs to be in splbio() as well.
If lfs_markv is handed a block that is not the correct size according to
the inode, refuse to process it. (Formerly it was extended to the "correct"
size.) This is possibly more prone to deadlock, but less prone to corruption.
lfs_segclean now outright refuses to clean segments that appear to have live
bytes in them. Again this may be more prone to deadlock but avoids
corruption.
Replace ufsspec_close and ufsfifo_close with LFS equivalents; this means
that no UFS functions need to know about LFS_ITIMES any more. Remove
the reference from ufs/inode.h.
Tested on i386, test-compiled on alpha.
2002-06-16 04:13:15 +04:00
|
|
|
#include <uvm/uvm.h>
|
2002-05-15 00:03:53 +04:00
|
|
|
#include <uvm/uvm_extern.h>
|
|
|
|
|
2003-02-01 09:23:35 +03:00
|
|
|
MALLOC_DEFINE(M_SEGMENT, "LFS segment", "Segment for 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
|
|
|
extern int count_lock_queue(void);
|
1998-03-01 05:20:01 +03:00
|
|
|
extern struct simplelock vnode_free_list_slock; /* XXX */
|
2003-09-07 15:47:07 +04:00
|
|
|
extern struct simplelock bqueue_slock; /* XXX */
|
1994-06-08 15:41:58 +04:00
|
|
|
|
For synchronous writes, keep separate i/o counters for each write, so
processes don't have to wait for one another to finish (e.g., nfsd seems
to be a little happier now, though I haven't measured the difference).
Synchronous checkpoints, however, must always wait for all i/o to finish.
Take the contents of the callback functions and have them run in thread
context instead (aiodoned thread). lfs_iocount no longer has to be
protected in splbio(), and quite a bit less of the segment construction
loop needs to be in splbio() as well.
If lfs_markv is handed a block that is not the correct size according to
the inode, refuse to process it. (Formerly it was extended to the "correct"
size.) This is possibly more prone to deadlock, but less prone to corruption.
lfs_segclean now outright refuses to clean segments that appear to have live
bytes in them. Again this may be more prone to deadlock but avoids
corruption.
Replace ufsspec_close and ufsfifo_close with LFS equivalents; this means
that no UFS functions need to know about LFS_ITIMES any more. Remove
the reference from ufs/inode.h.
Tested on i386, test-compiled on alpha.
2002-06-16 04:13:15 +04:00
|
|
|
static void lfs_generic_callback(struct buf *, void (*)(struct buf *));
|
Changes to help the roll-forward agent, to wit:
* Mark being-deleted files in the Ifile so we can finish deleting them
at fs mount time.
* Flag the Ifile with "cleaner must clean" when writers are waiting for
the cleaner, rather than relying solely on the cleaner's estimation of
whether it should clean or not.
* Note partial segments written by a user agent (in particular,
fsck_lfs) so that repeated rolls forward don't interfere with one
another.
* Add a new fcntl, LFCNPASS, that allows the log to wrap exactly once,
for better testing of the validity of checkpoints.
* Keep track of the on-disk nlink count when cleaning, so that we don't
partially complete directory operations while cleaning.
* Ensure that every single Ifile inode write represents a consistent
view of the filesystem. In particular, the accounting for the segment
we are writing the inode into must be correct, and the accounting for
the segment that inode used to reside in must be correct. Rather than
just rewriting the inode if we wrote it wrong, rewrite the necessary
ifile blocks before writing the inode so we never write it wrong.
* Don't unmark any VDIROP vnodes if we haven't written them to disk,
avoiding yet another problem with the "wait for the cleaner" error
return from lfs_putpages().
Also, move the last callback to an aiodone call, so we no longer do any
memory management from interrupt context.
2006-09-01 23:41:28 +04:00
|
|
|
static void lfs_free_aiodone(struct buf *);
|
For synchronous writes, keep separate i/o counters for each write, so
processes don't have to wait for one another to finish (e.g., nfsd seems
to be a little happier now, though I haven't measured the difference).
Synchronous checkpoints, however, must always wait for all i/o to finish.
Take the contents of the callback functions and have them run in thread
context instead (aiodoned thread). lfs_iocount no longer has to be
protected in splbio(), and quite a bit less of the segment construction
loop needs to be in splbio() as well.
If lfs_markv is handed a block that is not the correct size according to
the inode, refuse to process it. (Formerly it was extended to the "correct"
size.) This is possibly more prone to deadlock, but less prone to corruption.
lfs_segclean now outright refuses to clean segments that appear to have live
bytes in them. Again this may be more prone to deadlock but avoids
corruption.
Replace ufsspec_close and ufsfifo_close with LFS equivalents; this means
that no UFS functions need to know about LFS_ITIMES any more. Remove
the reference from ufs/inode.h.
Tested on i386, test-compiled on alpha.
2002-06-16 04:13:15 +04:00
|
|
|
static void lfs_super_aiodone(struct buf *);
|
|
|
|
static void lfs_cluster_aiodone(struct buf *);
|
2002-05-15 00:03:53 +04:00
|
|
|
static void lfs_cluster_callback(struct buf *);
|
|
|
|
|
1994-06-08 15:41:58 +04:00
|
|
|
/*
|
|
|
|
* Determine if it's OK to start a partial in this segment, or if we need
|
|
|
|
* to go on to a new segment.
|
|
|
|
*/
|
|
|
|
#define LFS_PARTIAL_FITS(fs) \
|
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_fsbpseg - ((fs)->lfs_offset - (fs)->lfs_curseg) > \
|
|
|
|
fragstofsb((fs), (fs)->lfs_frag))
|
|
|
|
|
2006-03-24 23:05:32 +03:00
|
|
|
/*
|
|
|
|
* Figure out whether we should do a checkpoint write or go ahead with
|
|
|
|
* an ordinary write.
|
|
|
|
*/
|
|
|
|
#define LFS_SHOULD_CHECKPOINT(fs, flags) \
|
2006-07-21 03:12:26 +04:00
|
|
|
((flags & SEGM_CLEAN) == 0 && \
|
|
|
|
((fs->lfs_nactive > LFS_MAX_ACTIVE || \
|
|
|
|
(flags & SEGM_CKP) || \
|
|
|
|
fs->lfs_nclean < LFS_MAX_ACTIVE)))
|
2006-03-24 23:05:32 +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
|
|
|
int lfs_match_fake(struct lfs *, struct buf *);
|
|
|
|
void lfs_newseg(struct lfs *);
|
2003-01-25 00:55:02 +03:00
|
|
|
/* XXX ondisk32 */
|
2003-02-23 03:22:33 +03:00
|
|
|
void lfs_shellsort(struct buf **, int32_t *, int, 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
|
|
|
void lfs_supercallback(struct buf *);
|
|
|
|
void lfs_updatemeta(struct segment *);
|
|
|
|
void lfs_writesuper(struct lfs *, daddr_t);
|
|
|
|
int lfs_writevnodes(struct lfs *fs, struct mount *mp,
|
|
|
|
struct segment *sp, int dirops);
|
1994-06-08 15:41:58 +04:00
|
|
|
|
|
|
|
int lfs_allclean_wakeup; /* Cleaner wakeup address. */
|
2003-02-20 07:27:23 +03:00
|
|
|
int lfs_writeindir = 1; /* whether to flush indir on non-ckp */
|
1999-04-12 04:11:01 +04:00
|
|
|
int lfs_clean_vnhead = 0; /* Allow freeing to head of vn list */
|
1999-11-06 23:33:05 +03:00
|
|
|
int lfs_dirvcount = 0; /* # active dirops */
|
1994-06-08 15:41:58 +04:00
|
|
|
|
|
|
|
/* Statistics Counters */
|
1999-03-10 03:20:00 +03:00
|
|
|
int lfs_dostats = 1;
|
1994-06-08 15:41:58 +04:00
|
|
|
struct lfs_stats lfs_stats;
|
|
|
|
|
|
|
|
/* op values to lfs_writevnodes */
|
2003-02-20 07:27:23 +03:00
|
|
|
#define VN_REG 0
|
1994-06-08 15:41:58 +04:00
|
|
|
#define VN_DIROP 1
|
|
|
|
#define VN_EMPTY 2
|
2003-02-20 07:27:23 +03:00
|
|
|
#define VN_CLEAN 3
|
1999-03-10 03:20:00 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* XXX KS - Set modification time on the Ifile, so the cleaner can
|
|
|
|
* read the fs mod time off of it. We don't set IN_UPDATE here,
|
|
|
|
* since we don't really need this to be flushed to disk (and in any
|
|
|
|
* case that wouldn't happen to the Ifile until we checkpoint).
|
|
|
|
*/
|
|
|
|
void
|
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_imtime(struct lfs *fs)
|
1999-03-10 03:20:00 +03:00
|
|
|
{
|
|
|
|
struct timespec ts;
|
|
|
|
struct inode *ip;
|
2005-02-27 01:31:44 +03:00
|
|
|
|
2005-04-02 01:59:46 +04:00
|
|
|
ASSERT_MAYBE_SEGLOCK(fs);
|
2006-06-23 18:13:02 +04:00
|
|
|
vfs_timestamp(&ts);
|
1999-03-10 03:20:00 +03:00
|
|
|
ip = VTOI(fs->lfs_ivnode);
|
2003-04-02 14:39:19 +04:00
|
|
|
ip->i_ffs1_mtime = ts.tv_sec;
|
|
|
|
ip->i_ffs1_mtimensec = ts.tv_nsec;
|
1999-03-10 03:20:00 +03:00
|
|
|
}
|
1994-06-08 15:41:58 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Ifile and meta data blocks are not marked busy, so segment writes MUST be
|
|
|
|
* single threaded. Currently, there are two paths into lfs_segwrite, sync()
|
|
|
|
* and getnewbuf(). They both mark the file system busy. Lfs_vflush()
|
|
|
|
* explicitly marks the file system busy. So lfs_segwrite is safe. I think.
|
|
|
|
*/
|
|
|
|
|
1999-03-10 03:20:00 +03:00
|
|
|
#define IS_FLUSHING(fs,vp) ((fs)->lfs_flushvp == (vp))
|
|
|
|
|
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_vflush(struct vnode *vp)
|
1994-06-08 15:41:58 +04:00
|
|
|
{
|
|
|
|
struct inode *ip;
|
|
|
|
struct lfs *fs;
|
|
|
|
struct segment *sp;
|
2000-01-15 00:38:46 +03:00
|
|
|
struct buf *bp, *nbp, *tbp, *tnbp;
|
1999-09-04 02:48:51 +04:00
|
|
|
int error, s;
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
int flushed;
|
2006-03-24 23:05:32 +03:00
|
|
|
int relock;
|
Changes to help the roll-forward agent, to wit:
* Mark being-deleted files in the Ifile so we can finish deleting them
at fs mount time.
* Flag the Ifile with "cleaner must clean" when writers are waiting for
the cleaner, rather than relying solely on the cleaner's estimation of
whether it should clean or not.
* Note partial segments written by a user agent (in particular,
fsck_lfs) so that repeated rolls forward don't interfere with one
another.
* Add a new fcntl, LFCNPASS, that allows the log to wrap exactly once,
for better testing of the validity of checkpoints.
* Keep track of the on-disk nlink count when cleaning, so that we don't
partially complete directory operations while cleaning.
* Ensure that every single Ifile inode write represents a consistent
view of the filesystem. In particular, the accounting for the segment
we are writing the inode into must be correct, and the accounting for
the segment that inode used to reside in must be correct. Rather than
just rewriting the inode if we wrote it wrong, rewrite the necessary
ifile blocks before writing the inode so we never write it wrong.
* Don't unmark any VDIROP vnodes if we haven't written them to disk,
avoiding yet another problem with the "wait for the cleaner" error
return from lfs_putpages().
Also, move the last callback to an aiodone call, so we no longer do any
memory management from interrupt context.
2006-09-01 23:41:28 +04:00
|
|
|
int loopcount;
|
1999-03-26 01:26:52 +03:00
|
|
|
|
1999-03-30 20:03:16 +04:00
|
|
|
ip = VTOI(vp);
|
|
|
|
fs = VFSTOUFS(vp->v_mount)->um_lfs;
|
2006-03-24 23:05:32 +03:00
|
|
|
relock = 0;
|
1999-03-30 20:03:16 +04:00
|
|
|
|
2006-03-24 23:05:32 +03:00
|
|
|
top:
|
2005-04-02 01:59:46 +04:00
|
|
|
ASSERT_NO_SEGLOCK(fs);
|
2001-11-24 00:44:25 +03:00
|
|
|
if (ip->i_flag & IN_CLEANING) {
|
1999-03-26 01:26:52 +03:00
|
|
|
ivndebug(vp,"vflush/in_cleaning");
|
2000-07-06 02:25:43 +04:00
|
|
|
LFS_CLR_UINO(ip, IN_CLEANING);
|
|
|
|
LFS_SET_UINO(ip, IN_MODIFIED);
|
|
|
|
|
2000-01-15 00:38:46 +03:00
|
|
|
/*
|
|
|
|
* Toss any cleaning buffers that have real counterparts
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
* to avoid losing new data.
|
2000-01-15 00:38:46 +03:00
|
|
|
*/
|
|
|
|
s = splbio();
|
2002-05-18 01:42:38 +04:00
|
|
|
for (bp = LIST_FIRST(&vp->v_dirtyblkhd); bp; bp = nbp) {
|
|
|
|
nbp = LIST_NEXT(bp, b_vnbufs);
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
if (!LFS_IS_MALLOC_BUF(bp))
|
|
|
|
continue;
|
|
|
|
/*
|
2003-03-04 22:19:43 +03:00
|
|
|
* Look for pages matching the range covered
|
|
|
|
* by cleaning blocks. It's okay if more dirty
|
|
|
|
* pages appear, so long as none disappear out
|
|
|
|
* from under us.
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
*/
|
|
|
|
if (bp->b_lblkno > 0 && vp->v_type == VREG &&
|
|
|
|
vp != fs->lfs_ivnode) {
|
|
|
|
struct vm_page *pg;
|
|
|
|
voff_t off;
|
|
|
|
|
2003-03-04 22:19:43 +03:00
|
|
|
simple_lock(&vp->v_interlock);
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
for (off = lblktosize(fs, bp->b_lblkno);
|
|
|
|
off < lblktosize(fs, bp->b_lblkno + 1);
|
|
|
|
off += PAGE_SIZE) {
|
|
|
|
pg = uvm_pagelookup(&vp->v_uobj, off);
|
2003-03-04 22:19:43 +03:00
|
|
|
if (pg == NULL)
|
|
|
|
continue;
|
|
|
|
if ((pg->flags & PG_CLEAN) == 0 ||
|
|
|
|
pmap_is_modified(pg)) {
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
fs->lfs_avail += btofsb(fs,
|
|
|
|
bp->b_bcount);
|
2000-11-17 22:14:41 +03:00
|
|
|
wakeup(&fs->lfs_avail);
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
lfs_freebuf(fs, 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
|
|
|
bp = NULL;
|
2006-04-14 03:46:28 +04:00
|
|
|
simple_unlock(&vp->v_interlock);
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
goto nextbp;
|
2000-01-15 00:38:46 +03:00
|
|
|
}
|
|
|
|
}
|
2003-03-04 22:19:43 +03:00
|
|
|
simple_unlock(&vp->v_interlock);
|
2000-01-15 00:38:46 +03:00
|
|
|
}
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
for (tbp = LIST_FIRST(&vp->v_dirtyblkhd); tbp;
|
|
|
|
tbp = tnbp)
|
|
|
|
{
|
|
|
|
tnbp = LIST_NEXT(tbp, b_vnbufs);
|
|
|
|
if (tbp->b_vp == bp->b_vp
|
|
|
|
&& tbp->b_lblkno == bp->b_lblkno
|
|
|
|
&& tbp != bp)
|
|
|
|
{
|
|
|
|
fs->lfs_avail += btofsb(fs,
|
|
|
|
bp->b_bcount);
|
|
|
|
wakeup(&fs->lfs_avail);
|
|
|
|
lfs_freebuf(fs, bp);
|
|
|
|
bp = NULL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
nextbp:
|
2003-03-15 05:27:18 +03:00
|
|
|
;
|
2000-01-15 00:38:46 +03:00
|
|
|
}
|
|
|
|
splx(s);
|
1999-03-26 01:26:52 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* If the node is being written, wait until that is done */
|
2005-04-02 01:59:46 +04:00
|
|
|
simple_lock(&vp->v_interlock);
|
2002-05-15 00:03:53 +04:00
|
|
|
s = splbio();
|
2001-11-24 00:44:25 +03:00
|
|
|
if (WRITEINPROG(vp)) {
|
1999-03-26 01:26:52 +03:00
|
|
|
ivndebug(vp,"vflush/writeinprog");
|
2005-04-02 01:59:46 +04:00
|
|
|
ltsleep(vp, (PRIBIO+1), "lfs_vw", 0, &vp->v_interlock);
|
1999-03-26 01:26:52 +03:00
|
|
|
}
|
2002-05-15 00:03:53 +04:00
|
|
|
splx(s);
|
2005-04-02 01:59:46 +04:00
|
|
|
simple_unlock(&vp->v_interlock);
|
1994-06-08 15:41:58 +04:00
|
|
|
|
1999-03-10 03:20:00 +03:00
|
|
|
/* Protect against VXLOCK deadlock in vinvalbuf() */
|
1994-06-08 15:41:58 +04:00
|
|
|
lfs_seglock(fs, SEGM_SYNC);
|
1999-09-04 02:48:51 +04:00
|
|
|
|
|
|
|
/* If we're supposed to flush a freed inode, just toss it */
|
2006-05-13 03:36:11 +04:00
|
|
|
if (ip->i_lfs_iflags & LFSI_DELETED) {
|
2005-03-08 03:18:19 +03:00
|
|
|
DLOG((DLOG_VNODE, "lfs_vflush: ino %d freed, not flushing\n",
|
|
|
|
ip->i_number));
|
1999-09-04 02:48:51 +04:00
|
|
|
s = splbio();
|
2006-05-13 03:36:11 +04:00
|
|
|
/* Drain v_numoutput */
|
|
|
|
simple_lock(&global_v_numoutput_slock);
|
|
|
|
while (vp->v_numoutput > 0) {
|
|
|
|
vp->v_flag |= VBWAIT;
|
|
|
|
ltsleep(&vp->v_numoutput, PRIBIO + 1, "lfs_vf4", 0,
|
|
|
|
&global_v_numoutput_slock);
|
|
|
|
}
|
|
|
|
simple_unlock(&global_v_numoutput_slock);
|
|
|
|
KASSERT(vp->v_numoutput == 0);
|
|
|
|
|
2002-05-18 01:42:38 +04:00
|
|
|
for (bp = LIST_FIRST(&vp->v_dirtyblkhd); bp; bp = nbp) {
|
|
|
|
nbp = LIST_NEXT(bp, b_vnbufs);
|
2006-05-13 03:36:11 +04:00
|
|
|
|
|
|
|
KASSERT((bp->b_flags & B_GATHERED) == 0);
|
2000-11-17 22:14:41 +03:00
|
|
|
if (bp->b_flags & B_DELWRI) { /* XXX always true? */
|
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);
|
2000-11-17 22:14:41 +03:00
|
|
|
wakeup(&fs->lfs_avail);
|
|
|
|
}
|
1999-09-04 02:48:51 +04:00
|
|
|
/* Copied from lfs_writeseg */
|
|
|
|
if (bp->b_flags & B_CALL) {
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
biodone(bp);
|
1999-09-04 02:48:51 +04:00
|
|
|
} else {
|
|
|
|
bremfree(bp);
|
2000-11-17 22:14:41 +03:00
|
|
|
LFS_UNLOCK_BUF(bp);
|
1999-09-04 02:48:51 +04:00
|
|
|
bp->b_flags &= ~(B_ERROR | B_READ | B_DELWRI |
|
2003-02-20 07:27:23 +03:00
|
|
|
B_GATHERED);
|
1999-09-04 02:48:51 +04:00
|
|
|
bp->b_flags |= B_DONE;
|
|
|
|
reassignbuf(bp, vp);
|
2005-02-27 01:31:44 +03:00
|
|
|
brelse(bp);
|
1999-09-04 02:48:51 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
splx(s);
|
2000-07-06 02:25:43 +04:00
|
|
|
LFS_CLR_UINO(ip, IN_CLEANING);
|
|
|
|
LFS_CLR_UINO(ip, IN_MODIFIED | IN_ACCESSED);
|
2000-05-31 05:40:01 +04:00
|
|
|
ip->i_flag &= ~IN_ALLMOD;
|
2005-03-08 03:18:19 +03:00
|
|
|
DLOG((DLOG_VNODE, "lfs_vflush: done not flushing ino %d\n",
|
|
|
|
ip->i_number));
|
1999-09-04 02:48:51 +04:00
|
|
|
lfs_segunlock(fs);
|
2006-05-13 03:36:11 +04:00
|
|
|
|
|
|
|
KASSERT(LIST_FIRST(&vp->v_dirtyblkhd) == NULL);
|
|
|
|
|
1999-09-04 02:48:51 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-04-14 03:46:28 +04:00
|
|
|
fs->lfs_flushvp = vp;
|
2006-03-24 23:05:32 +03:00
|
|
|
if (LFS_SHOULD_CHECKPOINT(fs, fs->lfs_sp->seg_flags)) {
|
For synchronous writes, keep separate i/o counters for each write, so
processes don't have to wait for one another to finish (e.g., nfsd seems
to be a little happier now, though I haven't measured the difference).
Synchronous checkpoints, however, must always wait for all i/o to finish.
Take the contents of the callback functions and have them run in thread
context instead (aiodoned thread). lfs_iocount no longer has to be
protected in splbio(), and quite a bit less of the segment construction
loop needs to be in splbio() as well.
If lfs_markv is handed a block that is not the correct size according to
the inode, refuse to process it. (Formerly it was extended to the "correct"
size.) This is possibly more prone to deadlock, but less prone to corruption.
lfs_segclean now outright refuses to clean segments that appear to have live
bytes in them. Again this may be more prone to deadlock but avoids
corruption.
Replace ufsspec_close and ufsfifo_close with LFS equivalents; this means
that no UFS functions need to know about LFS_ITIMES any more. Remove
the reference from ufs/inode.h.
Tested on i386, test-compiled on alpha.
2002-06-16 04:13:15 +04:00
|
|
|
error = lfs_segwrite(vp->v_mount, SEGM_CKP | SEGM_SYNC);
|
2006-04-14 03:46:28 +04:00
|
|
|
fs->lfs_flushvp = NULL;
|
|
|
|
KASSERT(fs->lfs_flushvp_fakevref == 0);
|
1999-03-10 03:20:00 +03:00
|
|
|
lfs_segunlock(fs);
|
2006-05-13 03:36:11 +04:00
|
|
|
|
|
|
|
/* Make sure that any pending buffers get written */
|
|
|
|
s = splbio();
|
|
|
|
simple_lock(&global_v_numoutput_slock);
|
|
|
|
while (vp->v_numoutput > 0) {
|
|
|
|
vp->v_flag |= VBWAIT;
|
|
|
|
ltsleep(&vp->v_numoutput, PRIBIO + 1, "lfs_vf3", 0,
|
|
|
|
&global_v_numoutput_slock);
|
|
|
|
}
|
|
|
|
simple_unlock(&global_v_numoutput_slock);
|
|
|
|
splx(s);
|
|
|
|
|
|
|
|
KASSERT(LIST_FIRST(&vp->v_dirtyblkhd) == NULL);
|
|
|
|
KASSERT(vp->v_numoutput == 0);
|
|
|
|
|
1999-03-10 03:20:00 +03:00
|
|
|
return error;
|
|
|
|
}
|
1994-06-08 15:41:58 +04:00
|
|
|
sp = fs->lfs_sp;
|
|
|
|
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
flushed = 0;
|
|
|
|
if (VPISEMPTY(vp)) {
|
1994-06-08 15:41:58 +04:00
|
|
|
lfs_writevnodes(fs, vp->v_mount, sp, VN_EMPTY);
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
++flushed;
|
2001-11-24 00:44:25 +03:00
|
|
|
} else if ((ip->i_flag & IN_CLEANING) &&
|
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_sp->seg_flags & SEGM_CLEAN)) {
|
1999-03-26 01:26:52 +03:00
|
|
|
ivndebug(vp,"vflush/clean");
|
|
|
|
lfs_writevnodes(fs, vp->v_mount, sp, VN_CLEAN);
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
++flushed;
|
2002-05-15 00:03:53 +04:00
|
|
|
} else if (lfs_dostats) {
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
if (!VPISEMPTY(vp) || (VTOI(vp)->i_flag & IN_ALLMOD))
|
1999-03-10 03:20:00 +03:00
|
|
|
++lfs_stats.vflush_invoked;
|
1999-03-26 01:26:52 +03:00
|
|
|
ivndebug(vp,"vflush");
|
1999-03-10 03:20:00 +03:00
|
|
|
}
|
|
|
|
|
1999-03-26 01:26:52 +03:00
|
|
|
#ifdef DIAGNOSTIC
|
2001-11-24 00:44:25 +03:00
|
|
|
if (vp->v_flag & VDIROP) {
|
2005-03-08 03:18:19 +03:00
|
|
|
DLOG((DLOG_VNODE, "lfs_vflush: flushing VDIROP\n"));
|
|
|
|
/* panic("lfs_vflush: VDIROP being flushed...this can\'t happen"); */
|
1999-03-10 03:20:00 +03:00
|
|
|
}
|
2001-11-24 00:44:25 +03:00
|
|
|
if (vp->v_usecount < 0) {
|
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
|
|
|
printf("usecount=%ld\n", (long)vp->v_usecount);
|
1999-03-26 01:26:52 +03:00
|
|
|
panic("lfs_vflush: usecount<0");
|
|
|
|
}
|
|
|
|
#endif
|
1994-06-08 15:41:58 +04:00
|
|
|
|
|
|
|
do {
|
Changes to help the roll-forward agent, to wit:
* Mark being-deleted files in the Ifile so we can finish deleting them
at fs mount time.
* Flag the Ifile with "cleaner must clean" when writers are waiting for
the cleaner, rather than relying solely on the cleaner's estimation of
whether it should clean or not.
* Note partial segments written by a user agent (in particular,
fsck_lfs) so that repeated rolls forward don't interfere with one
another.
* Add a new fcntl, LFCNPASS, that allows the log to wrap exactly once,
for better testing of the validity of checkpoints.
* Keep track of the on-disk nlink count when cleaning, so that we don't
partially complete directory operations while cleaning.
* Ensure that every single Ifile inode write represents a consistent
view of the filesystem. In particular, the accounting for the segment
we are writing the inode into must be correct, and the accounting for
the segment that inode used to reside in must be correct. Rather than
just rewriting the inode if we wrote it wrong, rewrite the necessary
ifile blocks before writing the inode so we never write it wrong.
* Don't unmark any VDIROP vnodes if we haven't written them to disk,
avoiding yet another problem with the "wait for the cleaner" error
return from lfs_putpages().
Also, move the last callback to an aiodone call, so we no longer do any
memory management from interrupt context.
2006-09-01 23:41:28 +04:00
|
|
|
loopcount = 0;
|
1994-06-08 15:41:58 +04:00
|
|
|
do {
|
2006-03-24 23:05:32 +03:00
|
|
|
if (LIST_FIRST(&vp->v_dirtyblkhd) != NULL) {
|
|
|
|
relock = lfs_writefile(fs, sp, vp);
|
|
|
|
if (relock) {
|
|
|
|
/*
|
|
|
|
* Might have to wait for the
|
|
|
|
* cleaner to run; but we're
|
|
|
|
* still not done with this vnode.
|
|
|
|
*/
|
Changes to help the roll-forward agent, to wit:
* Mark being-deleted files in the Ifile so we can finish deleting them
at fs mount time.
* Flag the Ifile with "cleaner must clean" when writers are waiting for
the cleaner, rather than relying solely on the cleaner's estimation of
whether it should clean or not.
* Note partial segments written by a user agent (in particular,
fsck_lfs) so that repeated rolls forward don't interfere with one
another.
* Add a new fcntl, LFCNPASS, that allows the log to wrap exactly once,
for better testing of the validity of checkpoints.
* Keep track of the on-disk nlink count when cleaning, so that we don't
partially complete directory operations while cleaning.
* Ensure that every single Ifile inode write represents a consistent
view of the filesystem. In particular, the accounting for the segment
we are writing the inode into must be correct, and the accounting for
the segment that inode used to reside in must be correct. Rather than
just rewriting the inode if we wrote it wrong, rewrite the necessary
ifile blocks before writing the inode so we never write it wrong.
* Don't unmark any VDIROP vnodes if we haven't written them to disk,
avoiding yet another problem with the "wait for the cleaner" error
return from lfs_putpages().
Also, move the last callback to an aiodone call, so we no longer do any
memory management from interrupt context.
2006-09-01 23:41:28 +04:00
|
|
|
KDASSERT(ip->i_number != LFS_IFILE_INUM);
|
2006-05-01 01:19:42 +04:00
|
|
|
lfs_writeinode(fs, sp, ip);
|
|
|
|
LFS_SET_UINO(ip, IN_MODIFIED);
|
2006-03-24 23:05:32 +03:00
|
|
|
lfs_writeseg(fs, sp);
|
|
|
|
lfs_segunlock(fs);
|
|
|
|
lfs_segunlock_relock(fs);
|
|
|
|
goto top;
|
|
|
|
}
|
|
|
|
}
|
2006-04-18 00:02:34 +04:00
|
|
|
/*
|
|
|
|
* If we begin a new segment in the middle of writing
|
|
|
|
* the Ifile, it creates an inconsistent checkpoint,
|
|
|
|
* since the Ifile information for the new segment
|
|
|
|
* is not up-to-date. Take care of this here by
|
|
|
|
* sending the Ifile through again in case there
|
|
|
|
* are newly dirtied blocks. But wait, there's more!
|
|
|
|
* This second Ifile write could *also* cross a segment
|
|
|
|
* boundary, if the first one was large. The second
|
|
|
|
* one is guaranteed to be no more than 8 blocks,
|
|
|
|
* though (two segment blocks and supporting indirects)
|
|
|
|
* so the third write *will not* cross the boundary.
|
|
|
|
*/
|
|
|
|
if (vp == fs->lfs_ivnode) {
|
|
|
|
lfs_writefile(fs, sp, vp);
|
|
|
|
lfs_writefile(fs, sp, vp);
|
|
|
|
}
|
Changes to help the roll-forward agent, to wit:
* Mark being-deleted files in the Ifile so we can finish deleting them
at fs mount time.
* Flag the Ifile with "cleaner must clean" when writers are waiting for
the cleaner, rather than relying solely on the cleaner's estimation of
whether it should clean or not.
* Note partial segments written by a user agent (in particular,
fsck_lfs) so that repeated rolls forward don't interfere with one
another.
* Add a new fcntl, LFCNPASS, that allows the log to wrap exactly once,
for better testing of the validity of checkpoints.
* Keep track of the on-disk nlink count when cleaning, so that we don't
partially complete directory operations while cleaning.
* Ensure that every single Ifile inode write represents a consistent
view of the filesystem. In particular, the accounting for the segment
we are writing the inode into must be correct, and the accounting for
the segment that inode used to reside in must be correct. Rather than
just rewriting the inode if we wrote it wrong, rewrite the necessary
ifile blocks before writing the inode so we never write it wrong.
* Don't unmark any VDIROP vnodes if we haven't written them to disk,
avoiding yet another problem with the "wait for the cleaner" error
return from lfs_putpages().
Also, move the last callback to an aiodone call, so we no longer do any
memory management from interrupt context.
2006-09-01 23:41:28 +04:00
|
|
|
#ifdef DEBUG
|
2006-09-29 03:08:23 +04:00
|
|
|
if (++loopcount > 2)
|
|
|
|
log(LOG_NOTICE, "lfs_vflush: looping count=%d\n", loopcount);
|
Changes to help the roll-forward agent, to wit:
* Mark being-deleted files in the Ifile so we can finish deleting them
at fs mount time.
* Flag the Ifile with "cleaner must clean" when writers are waiting for
the cleaner, rather than relying solely on the cleaner's estimation of
whether it should clean or not.
* Note partial segments written by a user agent (in particular,
fsck_lfs) so that repeated rolls forward don't interfere with one
another.
* Add a new fcntl, LFCNPASS, that allows the log to wrap exactly once,
for better testing of the validity of checkpoints.
* Keep track of the on-disk nlink count when cleaning, so that we don't
partially complete directory operations while cleaning.
* Ensure that every single Ifile inode write represents a consistent
view of the filesystem. In particular, the accounting for the segment
we are writing the inode into must be correct, and the accounting for
the segment that inode used to reside in must be correct. Rather than
just rewriting the inode if we wrote it wrong, rewrite the necessary
ifile blocks before writing the inode so we never write it wrong.
* Don't unmark any VDIROP vnodes if we haven't written them to disk,
avoiding yet another problem with the "wait for the cleaner" error
return from lfs_putpages().
Also, move the last callback to an aiodone call, so we no longer do any
memory management from interrupt context.
2006-09-01 23:41:28 +04:00
|
|
|
#endif
|
1994-06-08 15:41:58 +04:00
|
|
|
} while (lfs_writeinode(fs, sp, ip));
|
|
|
|
} while (lfs_writeseg(fs, sp) && ip->i_number == LFS_IFILE_INUM);
|
2006-03-24 23:05:32 +03:00
|
|
|
|
2001-11-24 00:44:25 +03:00
|
|
|
if (lfs_dostats) {
|
1999-03-10 03:20:00 +03:00
|
|
|
++lfs_stats.nwrites;
|
|
|
|
if (sp->seg_flags & SEGM_SYNC)
|
|
|
|
++lfs_stats.nsync_writes;
|
|
|
|
if (sp->seg_flags & SEGM_CKP)
|
|
|
|
++lfs_stats.ncheckpoints;
|
|
|
|
}
|
2002-05-15 00:03:53 +04:00
|
|
|
/*
|
|
|
|
* If we were called from somewhere that has already held the seglock
|
|
|
|
* (e.g., lfs_markv()), the lfs_segunlock will not wait for
|
|
|
|
* the write to complete because we are still locked.
|
|
|
|
* Since lfs_vflush() must return the vnode with no dirty buffers,
|
|
|
|
* we must explicitly wait, if that is the case.
|
|
|
|
*
|
|
|
|
* We compare the iocount against 1, not 0, because it is
|
|
|
|
* artificially incremented by lfs_seglock().
|
|
|
|
*/
|
2003-03-15 09:58:49 +03:00
|
|
|
simple_lock(&fs->lfs_interlock);
|
2002-05-15 00:03:53 +04:00
|
|
|
if (fs->lfs_seglock > 1) {
|
|
|
|
while (fs->lfs_iocount > 1)
|
2005-04-02 01:59:46 +04:00
|
|
|
(void)ltsleep(&fs->lfs_iocount, PRIBIO + 1,
|
|
|
|
"lfs_vflush", 0, &fs->lfs_interlock);
|
|
|
|
}
|
|
|
|
simple_unlock(&fs->lfs_interlock);
|
2003-03-15 09:58:49 +03:00
|
|
|
|
1994-06-08 15:41:58 +04:00
|
|
|
lfs_segunlock(fs);
|
1999-03-10 03:20:00 +03:00
|
|
|
|
2003-04-23 11:20:37 +04:00
|
|
|
/* Wait for these buffers to be recovered by aiodoned */
|
|
|
|
s = splbio();
|
|
|
|
simple_lock(&global_v_numoutput_slock);
|
|
|
|
while (vp->v_numoutput > 0) {
|
2003-12-17 13:38:39 +03:00
|
|
|
vp->v_flag |= VBWAIT;
|
2003-04-23 11:20:37 +04:00
|
|
|
ltsleep(&vp->v_numoutput, PRIBIO + 1, "lfs_vf2", 0,
|
|
|
|
&global_v_numoutput_slock);
|
|
|
|
}
|
|
|
|
simple_unlock(&global_v_numoutput_slock);
|
|
|
|
splx(s);
|
|
|
|
|
2006-05-13 03:36:11 +04:00
|
|
|
KASSERT(LIST_FIRST(&vp->v_dirtyblkhd) == NULL);
|
|
|
|
KASSERT(vp->v_numoutput == 0);
|
|
|
|
|
2006-04-14 03:46:28 +04:00
|
|
|
fs->lfs_flushvp = NULL;
|
|
|
|
KASSERT(fs->lfs_flushvp_fakevref == 0);
|
|
|
|
|
1994-06-08 15:41:58 +04:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
1999-03-10 03:20:00 +03: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_writevnodes(struct lfs *fs, struct mount *mp, struct segment *sp, int op)
|
1994-06-08 15:41:58 +04:00
|
|
|
{
|
|
|
|
struct inode *ip;
|
2006-10-20 22:58:12 +04:00
|
|
|
struct vnode *vp;
|
2001-11-24 00:44:25 +03:00
|
|
|
int inodes_written = 0, only_cleaning;
|
2006-03-24 23:05:32 +03:00
|
|
|
int error = 0;
|
1994-06-08 15:41:58 +04:00
|
|
|
|
2005-04-02 01:59:46 +04:00
|
|
|
ASSERT_SEGLOCK(fs);
|
2006-10-20 22:58:12 +04:00
|
|
|
loop:
|
2007-02-24 02:16:03 +03:00
|
|
|
/* start at last (newest) vnode. */
|
2006-10-20 22:58:12 +04:00
|
|
|
TAILQ_FOREACH_REVERSE(vp, &mp->mnt_vnodelist, vnodelst, v_mntvnodes) {
|
1994-06-08 15:41:58 +04:00
|
|
|
/*
|
|
|
|
* If the vnode that we are about to sync is no longer
|
|
|
|
* associated with this mount point, start over.
|
|
|
|
*/
|
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
|
|
|
if (vp->v_mount != mp) {
|
2005-03-08 03:18:19 +03:00
|
|
|
DLOG((DLOG_VNODE, "lfs_writevnodes: starting over\n"));
|
2003-03-20 17:17:21 +03:00
|
|
|
/*
|
|
|
|
* After this, pages might be busy
|
|
|
|
* due to our own previous putpages.
|
|
|
|
* Start actual segment write here to avoid deadlock.
|
|
|
|
*/
|
|
|
|
(void)lfs_writeseg(fs, sp);
|
1994-06-08 15:41:58 +04:00
|
|
|
goto loop;
|
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
|
|
|
}
|
2005-02-27 01:31:44 +03:00
|
|
|
|
2002-12-14 14:54:47 +03:00
|
|
|
if (vp->v_type == VNON) {
|
|
|
|
continue;
|
|
|
|
}
|
1994-06-08 15:41:58 +04:00
|
|
|
|
1999-03-10 03:20:00 +03:00
|
|
|
ip = VTOI(vp);
|
|
|
|
if ((op == VN_DIROP && !(vp->v_flag & VDIROP)) ||
|
2003-07-12 20:17:52 +04:00
|
|
|
(op != VN_DIROP && op != VN_CLEAN &&
|
|
|
|
(vp->v_flag & VDIROP))) {
|
1999-03-10 03:20:00 +03:00
|
|
|
vndebug(vp,"dirop");
|
1994-06-08 15:41:58 +04:00
|
|
|
continue;
|
1999-03-10 03:20:00 +03:00
|
|
|
}
|
2005-02-27 01:31:44 +03:00
|
|
|
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
if (op == VN_EMPTY && !VPISEMPTY(vp)) {
|
1999-03-10 03:20:00 +03:00
|
|
|
vndebug(vp,"empty");
|
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
|
|
|
|
2001-11-24 00:44:25 +03:00
|
|
|
if (op == VN_CLEAN && ip->i_number != LFS_IFILE_INUM
|
2000-01-15 00:38:46 +03:00
|
|
|
&& vp != fs->lfs_flushvp
|
1999-03-10 03:20:00 +03:00
|
|
|
&& !(ip->i_flag & IN_CLEANING)) {
|
|
|
|
vndebug(vp,"cleaning");
|
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
|
|
|
|
1999-03-10 03:20:00 +03:00
|
|
|
if (lfs_vref(vp)) {
|
|
|
|
vndebug(vp,"vref");
|
1994-06-08 15:41:58 +04:00
|
|
|
continue;
|
1999-03-10 03:20:00 +03:00
|
|
|
}
|
|
|
|
|
1999-03-30 20:11:43 +04:00
|
|
|
only_cleaning = 0;
|
1994-06-08 15:41:58 +04:00
|
|
|
/*
|
2000-07-05 02:30:37 +04:00
|
|
|
* Write the inode/file if dirty and it's not the IFILE.
|
1994-06-08 15:41:58 +04:00
|
|
|
*/
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
if ((ip->i_flag & IN_ALLMOD) || !VPISEMPTY(vp)) {
|
2003-07-12 20:17:52 +04:00
|
|
|
only_cleaning =
|
|
|
|
((ip->i_flag & IN_ALLMOD) == IN_CLEANING);
|
1999-03-26 01:38:28 +03:00
|
|
|
|
2005-04-02 01:59:46 +04:00
|
|
|
if (ip->i_number != LFS_IFILE_INUM) {
|
2006-03-24 23:05:32 +03:00
|
|
|
error = lfs_writefile(fs, sp, vp);
|
|
|
|
if (error) {
|
|
|
|
lfs_vunref(vp);
|
|
|
|
if (error == EAGAIN) {
|
|
|
|
/*
|
|
|
|
* This error from lfs_putpages
|
|
|
|
* indicates we need to drop
|
|
|
|
* the segment lock and start
|
|
|
|
* over after the cleaner has
|
|
|
|
* had a chance to run.
|
|
|
|
*/
|
2006-05-01 01:19:42 +04:00
|
|
|
lfs_writeinode(fs, sp, ip);
|
2006-03-24 23:05:32 +03:00
|
|
|
lfs_writeseg(fs, sp);
|
2006-04-08 03:59:28 +04:00
|
|
|
if (!VPISEMPTY(vp) &&
|
|
|
|
!WRITEINPROG(vp) &&
|
|
|
|
!(ip->i_flag & IN_ALLMOD))
|
|
|
|
LFS_SET_UINO(ip, IN_MODIFIED);
|
2006-03-24 23:05:32 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
error = 0; /* XXX not quite right */
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2005-04-02 01:59:46 +04:00
|
|
|
if (!VPISEMPTY(vp)) {
|
|
|
|
if (WRITEINPROG(vp)) {
|
|
|
|
ivndebug(vp,"writevnodes/write2");
|
|
|
|
} else if (!(ip->i_flag & IN_ALLMOD)) {
|
|
|
|
LFS_SET_UINO(ip, IN_MODIFIED);
|
|
|
|
}
|
1999-03-10 03:20:00 +03:00
|
|
|
}
|
2005-04-02 01:59:46 +04:00
|
|
|
(void) lfs_writeinode(fs, sp, ip);
|
|
|
|
inodes_written++;
|
1999-03-10 03:20:00 +03:00
|
|
|
}
|
1994-06-08 15:41:58 +04:00
|
|
|
}
|
1999-03-10 03:20:00 +03:00
|
|
|
|
2000-06-28 00:57:11 +04:00
|
|
|
if (lfs_clean_vnhead && only_cleaning)
|
1999-03-26 01:38:28 +03:00
|
|
|
lfs_vunref_head(vp);
|
|
|
|
else
|
|
|
|
lfs_vunref(vp);
|
1994-06-08 15:41:58 +04:00
|
|
|
}
|
2006-03-24 23:05:32 +03:00
|
|
|
return error;
|
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
|
|
|
/*
|
|
|
|
* Do a checkpoint.
|
|
|
|
*/
|
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_segwrite(struct mount *mp, int flags)
|
1994-06-08 15:41:58 +04:00
|
|
|
{
|
|
|
|
struct buf *bp;
|
|
|
|
struct inode *ip;
|
|
|
|
struct lfs *fs;
|
|
|
|
struct segment *sp;
|
|
|
|
struct vnode *vp;
|
|
|
|
SEGUSE *segusep;
|
2003-03-29 01:39:42 +03:00
|
|
|
int do_ckp, did_ckp, error, s;
|
|
|
|
unsigned n, segleft, maxseg, sn, i, curseg;
|
1999-03-10 03:20:00 +03:00
|
|
|
int writer_set = 0;
|
2000-11-12 10:58:36 +03:00
|
|
|
int dirty;
|
2002-05-15 00:03:53 +04:00
|
|
|
int redo;
|
2006-03-24 23:05:32 +03:00
|
|
|
int um_error;
|
Changes to help the roll-forward agent, to wit:
* Mark being-deleted files in the Ifile so we can finish deleting them
at fs mount time.
* Flag the Ifile with "cleaner must clean" when writers are waiting for
the cleaner, rather than relying solely on the cleaner's estimation of
whether it should clean or not.
* Note partial segments written by a user agent (in particular,
fsck_lfs) so that repeated rolls forward don't interfere with one
another.
* Add a new fcntl, LFCNPASS, that allows the log to wrap exactly once,
for better testing of the validity of checkpoints.
* Keep track of the on-disk nlink count when cleaning, so that we don't
partially complete directory operations while cleaning.
* Ensure that every single Ifile inode write represents a consistent
view of the filesystem. In particular, the accounting for the segment
we are writing the inode into must be correct, and the accounting for
the segment that inode used to reside in must be correct. Rather than
just rewriting the inode if we wrote it wrong, rewrite the necessary
ifile blocks before writing the inode so we never write it wrong.
* Don't unmark any VDIROP vnodes if we haven't written them to disk,
avoiding yet another problem with the "wait for the cleaner" error
return from lfs_putpages().
Also, move the last callback to an aiodone call, so we no longer do any
memory management from interrupt context.
2006-09-01 23:41:28 +04:00
|
|
|
int loopcount;
|
2005-02-27 01:31:44 +03:00
|
|
|
|
1994-06-08 15:41:58 +04:00
|
|
|
fs = VFSTOUFS(mp)->um_lfs;
|
2005-04-02 01:59:46 +04:00
|
|
|
ASSERT_MAYBE_SEGLOCK(fs);
|
1994-06-08 15:41:58 +04:00
|
|
|
|
2000-07-03 05:45:46 +04:00
|
|
|
if (fs->lfs_ronly)
|
|
|
|
return EROFS;
|
|
|
|
|
1999-03-10 03:20:00 +03:00
|
|
|
lfs_imtime(fs);
|
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
|
|
|
|
1994-06-08 15:41:58 +04:00
|
|
|
/*
|
|
|
|
* Allocate a segment structure and enough space to hold pointers to
|
|
|
|
* the maximum possible number of buffers which can be described in a
|
|
|
|
* single summary block.
|
|
|
|
*/
|
2006-03-24 23:05:32 +03:00
|
|
|
do_ckp = LFS_SHOULD_CHECKPOINT(fs, flags);
|
|
|
|
|
1994-06-08 15:41:58 +04:00
|
|
|
lfs_seglock(fs, flags | (do_ckp ? SEGM_CKP : 0));
|
|
|
|
sp = fs->lfs_sp;
|
Changes to help the roll-forward agent, to wit:
* Mark being-deleted files in the Ifile so we can finish deleting them
at fs mount time.
* Flag the Ifile with "cleaner must clean" when writers are waiting for
the cleaner, rather than relying solely on the cleaner's estimation of
whether it should clean or not.
* Note partial segments written by a user agent (in particular,
fsck_lfs) so that repeated rolls forward don't interfere with one
another.
* Add a new fcntl, LFCNPASS, that allows the log to wrap exactly once,
for better testing of the validity of checkpoints.
* Keep track of the on-disk nlink count when cleaning, so that we don't
partially complete directory operations while cleaning.
* Ensure that every single Ifile inode write represents a consistent
view of the filesystem. In particular, the accounting for the segment
we are writing the inode into must be correct, and the accounting for
the segment that inode used to reside in must be correct. Rather than
just rewriting the inode if we wrote it wrong, rewrite the necessary
ifile blocks before writing the inode so we never write it wrong.
* Don't unmark any VDIROP vnodes if we haven't written them to disk,
avoiding yet another problem with the "wait for the cleaner" error
return from lfs_putpages().
Also, move the last callback to an aiodone call, so we no longer do any
memory management from interrupt context.
2006-09-01 23:41:28 +04:00
|
|
|
if (sp->seg_flags & (SEGM_CLEAN | SEGM_CKP))
|
|
|
|
do_ckp = 1;
|
1994-06-08 15:41:58 +04:00
|
|
|
|
1999-03-10 03:20:00 +03:00
|
|
|
/*
|
1999-03-26 00:39:18 +03:00
|
|
|
* If lfs_flushvp is non-NULL, we are called from lfs_vflush,
|
|
|
|
* in which case we have to flush *all* buffers off of this vnode.
|
1999-12-04 00:47:44 +03:00
|
|
|
* We don't care about other nodes, but write any non-dirop nodes
|
|
|
|
* anyway in anticipation of another getnewvnode().
|
|
|
|
*
|
|
|
|
* If we're cleaning we only write cleaning and ifile blocks, and
|
|
|
|
* no dirops, since otherwise we'd risk corruption in a crash.
|
1999-03-10 03:20:00 +03:00
|
|
|
*/
|
2001-11-24 00:44:25 +03:00
|
|
|
if (sp->seg_flags & SEGM_CLEAN)
|
1999-03-10 03:20:00 +03:00
|
|
|
lfs_writevnodes(fs, mp, sp, VN_CLEAN);
|
2003-03-02 07:34:30 +03:00
|
|
|
else if (!(sp->seg_flags & SEGM_FORCE_CKP)) {
|
2006-03-24 23:05:32 +03:00
|
|
|
do {
|
|
|
|
um_error = lfs_writevnodes(fs, mp, sp, VN_REG);
|
Install a new sysctl, vfs.lfs.ignore_lazy_sync, which causes LFS to ignore
the "smooth" syncer, as if vfs.sync.*delay = 0, but only for LFS. The
default is "on", i.e., ignore lazy sync.
Reduce the amount of polling/busy-waiting done by lfs_putpages(). To
accomplish this, copied genfs_putpages() and modified it to indicate which
page it was that caused it to return with EDEADLK. fsync()/fdatasync()
should no longer ever fail with EAGAIN, and should not consume huge
quantities of cpu.
Also, try to make dirops less likely to be written as the result of a
VOP_PUTPAGES(), while ensuring that they are written regularly.
2007-04-17 05:16:46 +04:00
|
|
|
if (do_ckp ||
|
|
|
|
(sp->seg_flags & SEGM_W_DIROPS && !fs->lfs_dirops)) {
|
2006-03-24 23:05:32 +03:00
|
|
|
if (!writer_set) {
|
|
|
|
lfs_writer_enter(fs, "lfs writer");
|
|
|
|
writer_set = 1;
|
|
|
|
}
|
|
|
|
error = lfs_writevnodes(fs, mp, sp, VN_DIROP);
|
|
|
|
if (um_error == 0)
|
|
|
|
um_error = error;
|
2006-05-01 23:47:29 +04:00
|
|
|
/* In case writevnodes errored out */
|
|
|
|
lfs_flush_dirops(fs);
|
2006-03-24 23:05:32 +03:00
|
|
|
((SEGSUM *)(sp->segsum))->ss_flags &= ~(SS_CONT);
|
2006-05-01 01:19:42 +04:00
|
|
|
lfs_finalize_fs_seguse(fs);
|
2003-07-02 17:40:51 +04:00
|
|
|
}
|
2006-03-24 23:05:32 +03:00
|
|
|
if (do_ckp && um_error) {
|
|
|
|
lfs_segunlock_relock(fs);
|
|
|
|
sp = fs->lfs_sp;
|
|
|
|
}
|
|
|
|
} while (do_ckp && um_error != 0);
|
2005-02-27 01:31:44 +03:00
|
|
|
}
|
1994-06-08 15:41:58 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* If we are doing a checkpoint, mark everything since the
|
|
|
|
* last checkpoint as no longer ACTIVE.
|
|
|
|
*/
|
Changes to help the roll-forward agent, to wit:
* Mark being-deleted files in the Ifile so we can finish deleting them
at fs mount time.
* Flag the Ifile with "cleaner must clean" when writers are waiting for
the cleaner, rather than relying solely on the cleaner's estimation of
whether it should clean or not.
* Note partial segments written by a user agent (in particular,
fsck_lfs) so that repeated rolls forward don't interfere with one
another.
* Add a new fcntl, LFCNPASS, that allows the log to wrap exactly once,
for better testing of the validity of checkpoints.
* Keep track of the on-disk nlink count when cleaning, so that we don't
partially complete directory operations while cleaning.
* Ensure that every single Ifile inode write represents a consistent
view of the filesystem. In particular, the accounting for the segment
we are writing the inode into must be correct, and the accounting for
the segment that inode used to reside in must be correct. Rather than
just rewriting the inode if we wrote it wrong, rewrite the necessary
ifile blocks before writing the inode so we never write it wrong.
* Don't unmark any VDIROP vnodes if we haven't written them to disk,
avoiding yet another problem with the "wait for the cleaner" error
return from lfs_putpages().
Also, move the last callback to an aiodone call, so we no longer do any
memory management from interrupt context.
2006-09-01 23:41:28 +04:00
|
|
|
if (do_ckp || fs->lfs_doifile) {
|
2003-03-29 01:39:42 +03:00
|
|
|
segleft = fs->lfs_nseg;
|
|
|
|
curseg = 0;
|
|
|
|
for (n = 0; n < fs->lfs_segtabsz; n++) {
|
2000-11-12 10:58:36 +03:00
|
|
|
dirty = 0;
|
2005-02-27 01:31:44 +03:00
|
|
|
if (bread(fs->lfs_ivnode,
|
2003-03-29 01:39:42 +03:00
|
|
|
fs->lfs_cleansz + n, fs->lfs_bsize, NOCRED, &bp))
|
1999-03-10 03:20:00 +03:00
|
|
|
panic("lfs_segwrite: ifile read");
|
1994-06-08 15:41:58 +04:00
|
|
|
segusep = (SEGUSE *)bp->b_data;
|
2003-03-29 01:39:42 +03:00
|
|
|
maxseg = min(segleft, fs->lfs_sepb);
|
|
|
|
for (i = 0; i < maxseg; i++) {
|
|
|
|
sn = curseg + i;
|
2003-10-03 17:02:54 +04:00
|
|
|
if (sn != dtosn(fs, fs->lfs_curseg) &&
|
2003-03-29 01:39:42 +03:00
|
|
|
segusep->su_flags & SEGUSE_ACTIVE) {
|
2000-11-12 10:58:36 +03:00
|
|
|
segusep->su_flags &= ~SEGUSE_ACTIVE;
|
2003-03-02 07:34:30 +03:00
|
|
|
--fs->lfs_nactive;
|
2000-11-12 10:58:36 +03:00
|
|
|
++dirty;
|
|
|
|
}
|
2003-03-02 07:34:30 +03:00
|
|
|
fs->lfs_suflags[fs->lfs_activesb][sn] =
|
|
|
|
segusep->su_flags;
|
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 (fs->lfs_version > 1)
|
|
|
|
++segusep;
|
|
|
|
else
|
|
|
|
segusep = (SEGUSE *)
|
|
|
|
((SEGUSE_V1 *)segusep + 1);
|
2000-11-12 10:58:36 +03:00
|
|
|
}
|
2005-02-27 01:31:44 +03:00
|
|
|
|
2000-11-12 10:58:36 +03:00
|
|
|
if (dirty)
|
2002-05-15 00:03:53 +04:00
|
|
|
error = LFS_BWRITE_LOG(bp); /* Ifile */
|
2000-11-12 10:58:36 +03:00
|
|
|
else
|
|
|
|
brelse(bp);
|
2003-03-29 01:39:42 +03:00
|
|
|
segleft -= fs->lfs_sepb;
|
|
|
|
curseg += fs->lfs_sepb;
|
1994-06-08 15:41:58 +04:00
|
|
|
}
|
1999-03-10 03:20:00 +03:00
|
|
|
}
|
2000-11-12 10:58:36 +03:00
|
|
|
|
2005-04-02 01:59:46 +04:00
|
|
|
LOCK_ASSERT(LFS_SEGLOCK_HELD(fs));
|
|
|
|
|
2000-11-12 10:58:36 +03:00
|
|
|
did_ckp = 0;
|
1994-06-08 15:41:58 +04:00
|
|
|
if (do_ckp || fs->lfs_doifile) {
|
2005-04-02 01:59:46 +04:00
|
|
|
vp = fs->lfs_ivnode;
|
|
|
|
vn_lock(vp, LK_EXCLUSIVE);
|
Changes to help the roll-forward agent, to wit:
* Mark being-deleted files in the Ifile so we can finish deleting them
at fs mount time.
* Flag the Ifile with "cleaner must clean" when writers are waiting for
the cleaner, rather than relying solely on the cleaner's estimation of
whether it should clean or not.
* Note partial segments written by a user agent (in particular,
fsck_lfs) so that repeated rolls forward don't interfere with one
another.
* Add a new fcntl, LFCNPASS, that allows the log to wrap exactly once,
for better testing of the validity of checkpoints.
* Keep track of the on-disk nlink count when cleaning, so that we don't
partially complete directory operations while cleaning.
* Ensure that every single Ifile inode write represents a consistent
view of the filesystem. In particular, the accounting for the segment
we are writing the inode into must be correct, and the accounting for
the segment that inode used to reside in must be correct. Rather than
just rewriting the inode if we wrote it wrong, rewrite the necessary
ifile blocks before writing the inode so we never write it wrong.
* Don't unmark any VDIROP vnodes if we haven't written them to disk,
avoiding yet another problem with the "wait for the cleaner" error
return from lfs_putpages().
Also, move the last callback to an aiodone call, so we no longer do any
memory management from interrupt context.
2006-09-01 23:41:28 +04:00
|
|
|
loopcount = 0;
|
2000-11-27 06:33:57 +03:00
|
|
|
do {
|
2002-05-15 00:03:53 +04:00
|
|
|
#ifdef DEBUG
|
2005-04-02 01:59:46 +04:00
|
|
|
LFS_ENTER_LOG("pretend", __FILE__, __LINE__, 0, 0, curproc->p_pid);
|
2002-05-15 00:03:53 +04:00
|
|
|
#endif
|
2005-04-02 01:59:46 +04:00
|
|
|
simple_lock(&fs->lfs_interlock);
|
2002-05-15 00:03:53 +04:00
|
|
|
fs->lfs_flags &= ~LFS_IFDIRTY;
|
2005-04-02 01:59:46 +04:00
|
|
|
simple_unlock(&fs->lfs_interlock);
|
1999-03-10 03:20:00 +03:00
|
|
|
|
2000-11-27 06:33:57 +03:00
|
|
|
ip = VTOI(vp);
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
|
2006-03-24 23:05:32 +03:00
|
|
|
if (LIST_FIRST(&vp->v_dirtyblkhd) != NULL) {
|
|
|
|
/*
|
|
|
|
* Ifile has no pages, so we don't need
|
|
|
|
* to check error return here.
|
|
|
|
*/
|
2000-11-27 06:33:57 +03:00
|
|
|
lfs_writefile(fs, sp, vp);
|
2006-04-18 00:02:34 +04:00
|
|
|
/*
|
|
|
|
* Ensure the Ifile takes the current segment
|
|
|
|
* into account. See comment in lfs_vflush.
|
|
|
|
*/
|
|
|
|
lfs_writefile(fs, sp, vp);
|
|
|
|
lfs_writefile(fs, sp, vp);
|
2006-03-24 23:05:32 +03:00
|
|
|
}
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
|
2000-11-27 06:33:57 +03:00
|
|
|
if (ip->i_flag & IN_ALLMOD)
|
|
|
|
++did_ckp;
|
Changes to help the roll-forward agent, to wit:
* Mark being-deleted files in the Ifile so we can finish deleting them
at fs mount time.
* Flag the Ifile with "cleaner must clean" when writers are waiting for
the cleaner, rather than relying solely on the cleaner's estimation of
whether it should clean or not.
* Note partial segments written by a user agent (in particular,
fsck_lfs) so that repeated rolls forward don't interfere with one
another.
* Add a new fcntl, LFCNPASS, that allows the log to wrap exactly once,
for better testing of the validity of checkpoints.
* Keep track of the on-disk nlink count when cleaning, so that we don't
partially complete directory operations while cleaning.
* Ensure that every single Ifile inode write represents a consistent
view of the filesystem. In particular, the accounting for the segment
we are writing the inode into must be correct, and the accounting for
the segment that inode used to reside in must be correct. Rather than
just rewriting the inode if we wrote it wrong, rewrite the necessary
ifile blocks before writing the inode so we never write it wrong.
* Don't unmark any VDIROP vnodes if we haven't written them to disk,
avoiding yet another problem with the "wait for the cleaner" error
return from lfs_putpages().
Also, move the last callback to an aiodone call, so we no longer do any
memory management from interrupt context.
2006-09-01 23:41:28 +04:00
|
|
|
#if 0
|
|
|
|
redo = (do_ckp ? lfs_writeinode(fs, sp, ip) : 0);
|
|
|
|
#else
|
2002-05-15 00:03:53 +04:00
|
|
|
redo = lfs_writeinode(fs, sp, ip);
|
Changes to help the roll-forward agent, to wit:
* Mark being-deleted files in the Ifile so we can finish deleting them
at fs mount time.
* Flag the Ifile with "cleaner must clean" when writers are waiting for
the cleaner, rather than relying solely on the cleaner's estimation of
whether it should clean or not.
* Note partial segments written by a user agent (in particular,
fsck_lfs) so that repeated rolls forward don't interfere with one
another.
* Add a new fcntl, LFCNPASS, that allows the log to wrap exactly once,
for better testing of the validity of checkpoints.
* Keep track of the on-disk nlink count when cleaning, so that we don't
partially complete directory operations while cleaning.
* Ensure that every single Ifile inode write represents a consistent
view of the filesystem. In particular, the accounting for the segment
we are writing the inode into must be correct, and the accounting for
the segment that inode used to reside in must be correct. Rather than
just rewriting the inode if we wrote it wrong, rewrite the necessary
ifile blocks before writing the inode so we never write it wrong.
* Don't unmark any VDIROP vnodes if we haven't written them to disk,
avoiding yet another problem with the "wait for the cleaner" error
return from lfs_putpages().
Also, move the last callback to an aiodone call, so we no longer do any
memory management from interrupt context.
2006-09-01 23:41:28 +04:00
|
|
|
#endif
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
redo += lfs_writeseg(fs, sp);
|
2005-04-02 01:59:46 +04:00
|
|
|
simple_lock(&fs->lfs_interlock);
|
2002-05-15 00:03:53 +04:00
|
|
|
redo += (fs->lfs_flags & LFS_IFDIRTY);
|
2005-04-02 01:59:46 +04:00
|
|
|
simple_unlock(&fs->lfs_interlock);
|
Changes to help the roll-forward agent, to wit:
* Mark being-deleted files in the Ifile so we can finish deleting them
at fs mount time.
* Flag the Ifile with "cleaner must clean" when writers are waiting for
the cleaner, rather than relying solely on the cleaner's estimation of
whether it should clean or not.
* Note partial segments written by a user agent (in particular,
fsck_lfs) so that repeated rolls forward don't interfere with one
another.
* Add a new fcntl, LFCNPASS, that allows the log to wrap exactly once,
for better testing of the validity of checkpoints.
* Keep track of the on-disk nlink count when cleaning, so that we don't
partially complete directory operations while cleaning.
* Ensure that every single Ifile inode write represents a consistent
view of the filesystem. In particular, the accounting for the segment
we are writing the inode into must be correct, and the accounting for
the segment that inode used to reside in must be correct. Rather than
just rewriting the inode if we wrote it wrong, rewrite the necessary
ifile blocks before writing the inode so we never write it wrong.
* Don't unmark any VDIROP vnodes if we haven't written them to disk,
avoiding yet another problem with the "wait for the cleaner" error
return from lfs_putpages().
Also, move the last callback to an aiodone call, so we no longer do any
memory management from interrupt context.
2006-09-01 23:41:28 +04:00
|
|
|
#ifdef DEBUG
|
2006-09-29 03:08:23 +04:00
|
|
|
if (++loopcount > 2)
|
|
|
|
log(LOG_NOTICE, "lfs_segwrite: looping count=%d\n",
|
Changes to help the roll-forward agent, to wit:
* Mark being-deleted files in the Ifile so we can finish deleting them
at fs mount time.
* Flag the Ifile with "cleaner must clean" when writers are waiting for
the cleaner, rather than relying solely on the cleaner's estimation of
whether it should clean or not.
* Note partial segments written by a user agent (in particular,
fsck_lfs) so that repeated rolls forward don't interfere with one
another.
* Add a new fcntl, LFCNPASS, that allows the log to wrap exactly once,
for better testing of the validity of checkpoints.
* Keep track of the on-disk nlink count when cleaning, so that we don't
partially complete directory operations while cleaning.
* Ensure that every single Ifile inode write represents a consistent
view of the filesystem. In particular, the accounting for the segment
we are writing the inode into must be correct, and the accounting for
the segment that inode used to reside in must be correct. Rather than
just rewriting the inode if we wrote it wrong, rewrite the necessary
ifile blocks before writing the inode so we never write it wrong.
* Don't unmark any VDIROP vnodes if we haven't written them to disk,
avoiding yet another problem with the "wait for the cleaner" error
return from lfs_putpages().
Also, move the last callback to an aiodone call, so we no longer do any
memory management from interrupt context.
2006-09-01 23:41:28 +04:00
|
|
|
loopcount);
|
|
|
|
#endif
|
2003-03-20 09:51:17 +03:00
|
|
|
} while (redo && do_ckp);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Unless we are unmounting, the Ifile may continue to have
|
|
|
|
* dirty blocks even after a checkpoint, due to changes to
|
|
|
|
* inodes' atime. If we're checkpointing, it's "impossible"
|
|
|
|
* for other parts of the Ifile to be dirty after the loop
|
|
|
|
* above, since we hold the segment lock.
|
|
|
|
*/
|
2003-03-21 09:16:53 +03:00
|
|
|
s = splbio();
|
2003-03-20 09:51:17 +03:00
|
|
|
if (LIST_EMPTY(&vp->v_dirtyblkhd)) {
|
|
|
|
LFS_CLR_UINO(ip, IN_ALLMOD);
|
|
|
|
}
|
|
|
|
#ifdef DIAGNOSTIC
|
|
|
|
else if (do_ckp) {
|
2005-04-02 01:59:46 +04:00
|
|
|
int do_panic = 0;
|
2003-03-20 09:51:17 +03:00
|
|
|
LIST_FOREACH(bp, &vp->v_dirtyblkhd, b_vnbufs) {
|
|
|
|
if (bp->b_lblkno < fs->lfs_cleansz +
|
|
|
|
fs->lfs_segtabsz &&
|
|
|
|
!(bp->b_flags & B_GATHERED)) {
|
2005-04-02 01:59:46 +04:00
|
|
|
printf("ifile lbn %ld still dirty (flags %lx)\n",
|
|
|
|
(long)bp->b_lblkno,
|
|
|
|
(long)bp->b_flags);
|
|
|
|
++do_panic;
|
2002-05-15 00:03:53 +04:00
|
|
|
}
|
|
|
|
}
|
2005-04-02 01:59:46 +04:00
|
|
|
if (do_panic)
|
|
|
|
panic("dirty blocks");
|
2002-05-15 00:03:53 +04:00
|
|
|
}
|
2003-03-20 09:51:17 +03:00
|
|
|
#endif
|
2003-03-21 09:16:53 +03:00
|
|
|
splx(s);
|
2005-04-02 01:59:46 +04:00
|
|
|
VOP_UNLOCK(vp, 0);
|
1999-03-10 03:20:00 +03:00
|
|
|
} else {
|
1994-06-08 15:41:58 +04:00
|
|
|
(void) lfs_writeseg(fs, sp);
|
1999-03-10 03:20:00 +03:00
|
|
|
}
|
2005-02-27 01:31:44 +03:00
|
|
|
|
2003-03-20 09:51:17 +03:00
|
|
|
/* Note Ifile no longer needs to be written */
|
|
|
|
fs->lfs_doifile = 0;
|
2003-07-02 17:40:51 +04:00
|
|
|
if (writer_set)
|
|
|
|
lfs_writer_leave(fs);
|
2000-11-12 10:58:36 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* If we didn't write the Ifile, we didn't really do anything.
|
|
|
|
* That means that (1) there is a checkpoint on disk and (2)
|
|
|
|
* nothing has changed since it was written.
|
|
|
|
*
|
|
|
|
* Take the flags off of the segment so that lfs_segunlock
|
|
|
|
* doesn't have to write the superblock either.
|
|
|
|
*/
|
For synchronous writes, keep separate i/o counters for each write, so
processes don't have to wait for one another to finish (e.g., nfsd seems
to be a little happier now, though I haven't measured the difference).
Synchronous checkpoints, however, must always wait for all i/o to finish.
Take the contents of the callback functions and have them run in thread
context instead (aiodoned thread). lfs_iocount no longer has to be
protected in splbio(), and quite a bit less of the segment construction
loop needs to be in splbio() as well.
If lfs_markv is handed a block that is not the correct size according to
the inode, refuse to process it. (Formerly it was extended to the "correct"
size.) This is possibly more prone to deadlock, but less prone to corruption.
lfs_segclean now outright refuses to clean segments that appear to have live
bytes in them. Again this may be more prone to deadlock but avoids
corruption.
Replace ufsspec_close and ufsfifo_close with LFS equivalents; this means
that no UFS functions need to know about LFS_ITIMES any more. Remove
the reference from ufs/inode.h.
Tested on i386, test-compiled on alpha.
2002-06-16 04:13:15 +04:00
|
|
|
if (do_ckp && !did_ckp) {
|
|
|
|
sp->seg_flags &= ~SEGM_CKP;
|
2000-11-12 10:58:36 +03:00
|
|
|
}
|
|
|
|
|
2001-11-24 00:44:25 +03:00
|
|
|
if (lfs_dostats) {
|
1999-03-10 03:20:00 +03:00
|
|
|
++lfs_stats.nwrites;
|
|
|
|
if (sp->seg_flags & SEGM_SYNC)
|
|
|
|
++lfs_stats.nsync_writes;
|
|
|
|
if (sp->seg_flags & SEGM_CKP)
|
|
|
|
++lfs_stats.ncheckpoints;
|
|
|
|
}
|
1994-06-08 15:41:58 +04:00
|
|
|
lfs_segunlock(fs);
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Write the dirty blocks associated with a vnode.
|
|
|
|
*/
|
2006-03-24 23:05:32 +03: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_writefile(struct lfs *fs, struct segment *sp, struct vnode *vp)
|
1994-06-08 15:41:58 +04:00
|
|
|
{
|
|
|
|
struct finfo *fip;
|
2002-07-06 05:30:11 +04:00
|
|
|
struct inode *ip;
|
2006-05-20 05:10:18 +04:00
|
|
|
int i, frag;
|
2006-03-24 23:05:32 +03:00
|
|
|
int error;
|
2005-02-27 01:31:44 +03:00
|
|
|
|
2005-04-02 01:59:46 +04:00
|
|
|
ASSERT_SEGLOCK(fs);
|
2006-03-24 23:05:32 +03:00
|
|
|
error = 0;
|
2002-07-06 05:30:11 +04:00
|
|
|
ip = VTOI(vp);
|
|
|
|
|
1994-06-08 15:41:58 +04:00
|
|
|
fip = sp->fip;
|
2006-05-20 05:10:18 +04:00
|
|
|
lfs_acquire_finfo(fs, ip->i_number, ip->i_gen);
|
2006-05-19 03:15:09 +04:00
|
|
|
|
|
|
|
if (vp->v_flag & VDIROP)
|
|
|
|
((SEGSUM *)(sp->segsum))->ss_flags |= (SS_DIROP|SS_CONT);
|
2005-02-27 01:31:44 +03:00
|
|
|
|
2002-05-15 00:03:53 +04:00
|
|
|
if (sp->seg_flags & SEGM_CLEAN) {
|
2000-01-15 00:38:46 +03:00
|
|
|
lfs_gather(fs, sp, vp, lfs_match_fake);
|
|
|
|
/*
|
|
|
|
* For a file being flushed, we need to write *all* blocks.
|
|
|
|
* This means writing the cleaning blocks first, and then
|
|
|
|
* immediately following with any non-cleaning blocks.
|
|
|
|
* The same is true of the Ifile since checkpoints assume
|
|
|
|
* that all valid Ifile blocks are written.
|
|
|
|
*/
|
2006-05-13 03:36:11 +04:00
|
|
|
if (IS_FLUSHING(fs, vp) || vp == fs->lfs_ivnode) {
|
2000-01-15 00:38:46 +03:00
|
|
|
lfs_gather(fs, sp, vp, lfs_match_data);
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
/*
|
|
|
|
* Don't call VOP_PUTPAGES: if we're flushing,
|
|
|
|
* we've already done it, and the Ifile doesn't
|
|
|
|
* use the page cache.
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
} else {
|
2000-01-15 00:38:46 +03:00
|
|
|
lfs_gather(fs, sp, vp, lfs_match_data);
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
/*
|
|
|
|
* If we're flushing, we've already called VOP_PUTPAGES
|
|
|
|
* so don't do it again. Otherwise, we want to write
|
|
|
|
* everything we've got.
|
|
|
|
*/
|
|
|
|
if (!IS_FLUSHING(fs, vp)) {
|
2003-02-19 15:02:38 +03:00
|
|
|
simple_lock(&vp->v_interlock);
|
2006-03-24 23:05:32 +03:00
|
|
|
error = VOP_PUTPAGES(vp, 0, 0,
|
|
|
|
PGO_CLEANIT | PGO_ALLPAGES | PGO_LOCKED);
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
}
|
|
|
|
}
|
2000-01-15 00:38:46 +03:00
|
|
|
|
1994-06-08 15:41:58 +04:00
|
|
|
/*
|
|
|
|
* It may not be necessary to write the meta-data blocks at this point,
|
|
|
|
* as the roll-forward recovery code should be able to reconstruct the
|
|
|
|
* list.
|
1999-03-10 03:20:00 +03:00
|
|
|
*
|
|
|
|
* We have to write them anyway, though, under two conditions: (1) the
|
|
|
|
* vnode is being flushed (for reuse by vinvalbuf); or (2) we are
|
|
|
|
* checkpointing.
|
2002-07-06 05:30:11 +04:00
|
|
|
*
|
|
|
|
* BUT if we are cleaning, we might have indirect blocks that refer to
|
|
|
|
* new blocks not being written yet, in addition to fragments being
|
|
|
|
* moved out of a cleaned segment. If that is the case, don't
|
|
|
|
* write the indirect blocks, or the finfo will have a small block
|
|
|
|
* in the middle of it!
|
|
|
|
* XXX in this case isn't the inode size wrong too?
|
1994-06-08 15:41:58 +04:00
|
|
|
*/
|
2002-07-06 05:30:11 +04:00
|
|
|
frag = 0;
|
|
|
|
if (sp->seg_flags & SEGM_CLEAN) {
|
|
|
|
for (i = 0; i < NDADDR; i++)
|
|
|
|
if (ip->i_lfs_fragsize[i] > 0 &&
|
|
|
|
ip->i_lfs_fragsize[i] < fs->lfs_bsize)
|
|
|
|
++frag;
|
|
|
|
}
|
|
|
|
#ifdef DIAGNOSTIC
|
|
|
|
if (frag > 1)
|
|
|
|
panic("lfs_writefile: more than one fragment!");
|
|
|
|
#endif
|
|
|
|
if (IS_FLUSHING(fs, vp) ||
|
|
|
|
(frag == 0 && (lfs_writeindir || (sp->seg_flags & SEGM_CKP)))) {
|
1999-03-10 03:20:00 +03:00
|
|
|
lfs_gather(fs, sp, vp, lfs_match_indir);
|
|
|
|
lfs_gather(fs, sp, vp, lfs_match_dindir);
|
|
|
|
lfs_gather(fs, sp, vp, lfs_match_tindir);
|
|
|
|
}
|
1994-06-08 15:41:58 +04:00
|
|
|
fip = sp->fip;
|
2006-05-19 03:15:09 +04:00
|
|
|
lfs_release_finfo(fs);
|
2006-03-24 23:05:32 +03:00
|
|
|
|
|
|
|
return error;
|
1994-06-08 15:41:58 +04:00
|
|
|
}
|
|
|
|
|
Changes to help the roll-forward agent, to wit:
* Mark being-deleted files in the Ifile so we can finish deleting them
at fs mount time.
* Flag the Ifile with "cleaner must clean" when writers are waiting for
the cleaner, rather than relying solely on the cleaner's estimation of
whether it should clean or not.
* Note partial segments written by a user agent (in particular,
fsck_lfs) so that repeated rolls forward don't interfere with one
another.
* Add a new fcntl, LFCNPASS, that allows the log to wrap exactly once,
for better testing of the validity of checkpoints.
* Keep track of the on-disk nlink count when cleaning, so that we don't
partially complete directory operations while cleaning.
* Ensure that every single Ifile inode write represents a consistent
view of the filesystem. In particular, the accounting for the segment
we are writing the inode into must be correct, and the accounting for
the segment that inode used to reside in must be correct. Rather than
just rewriting the inode if we wrote it wrong, rewrite the necessary
ifile blocks before writing the inode so we never write it wrong.
* Don't unmark any VDIROP vnodes if we haven't written them to disk,
avoiding yet another problem with the "wait for the cleaner" error
return from lfs_putpages().
Also, move the last callback to an aiodone call, so we no longer do any
memory management from interrupt context.
2006-09-01 23:41:28 +04:00
|
|
|
/*
|
|
|
|
* Update segment accounting to reflect this inode's change of address.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
lfs_update_iaddr(struct lfs *fs, struct segment *sp, struct inode *ip, daddr_t ndaddr)
|
|
|
|
{
|
|
|
|
struct buf *bp;
|
|
|
|
daddr_t daddr;
|
|
|
|
IFILE *ifp;
|
|
|
|
SEGUSE *sup;
|
|
|
|
ino_t ino;
|
|
|
|
int redo_ifile, error;
|
|
|
|
u_int32_t sn;
|
|
|
|
|
|
|
|
redo_ifile = 0;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If updating the ifile, update the super-block. Update the disk
|
|
|
|
* address and access times for this inode in the ifile.
|
|
|
|
*/
|
|
|
|
ino = ip->i_number;
|
|
|
|
if (ino == LFS_IFILE_INUM) {
|
|
|
|
daddr = fs->lfs_idaddr;
|
|
|
|
fs->lfs_idaddr = dbtofsb(fs, ndaddr);
|
|
|
|
} else {
|
|
|
|
LFS_IENTRY(ifp, fs, ino, bp);
|
|
|
|
daddr = ifp->if_daddr;
|
|
|
|
ifp->if_daddr = dbtofsb(fs, ndaddr);
|
|
|
|
error = LFS_BWRITE_LOG(bp); /* Ifile */
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If this is the Ifile and lfs_offset is set to the first block
|
|
|
|
* in the segment, dirty the new segment's accounting block
|
|
|
|
* (XXX should already be dirty?) and tell the caller to do it again.
|
|
|
|
*/
|
|
|
|
if (ip->i_number == LFS_IFILE_INUM) {
|
|
|
|
sn = dtosn(fs, fs->lfs_offset);
|
|
|
|
if (sntod(fs, sn) + btofsb(fs, fs->lfs_sumsize) ==
|
|
|
|
fs->lfs_offset) {
|
|
|
|
LFS_SEGENTRY(sup, fs, sn, bp);
|
|
|
|
KASSERT(bp->b_flags & B_DELWRI);
|
|
|
|
LFS_WRITESEGENTRY(sup, fs, sn, bp);
|
|
|
|
/* fs->lfs_flags |= LFS_IFDIRTY; */
|
|
|
|
redo_ifile |= 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The inode's last address should not be in the current partial
|
|
|
|
* segment, except under exceptional circumstances (lfs_writevnodes
|
|
|
|
* had to start over, and in the meantime more blocks were written
|
|
|
|
* to a vnode). Both inodes will be accounted to this segment
|
|
|
|
* in lfs_writeseg so we need to subtract the earlier version
|
|
|
|
* here anyway. The segment count can temporarily dip below
|
|
|
|
* zero here; keep track of how many duplicates we have in
|
|
|
|
* "dupino" so we don't panic below.
|
|
|
|
*/
|
|
|
|
if (daddr >= fs->lfs_lastpseg && daddr <= fs->lfs_offset) {
|
|
|
|
++sp->ndupino;
|
|
|
|
DLOG((DLOG_SEG, "lfs_writeinode: last inode addr in current pseg "
|
|
|
|
"(ino %d daddr 0x%llx) ndupino=%d\n", ino,
|
|
|
|
(long long)daddr, sp->ndupino));
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Account the inode: it no longer belongs to its former segment,
|
|
|
|
* though it will not belong to the new segment until that segment
|
|
|
|
* is actually written.
|
|
|
|
*/
|
|
|
|
if (daddr != LFS_UNUSED_DADDR) {
|
|
|
|
u_int32_t oldsn = dtosn(fs, daddr);
|
|
|
|
#ifdef DIAGNOSTIC
|
|
|
|
int ndupino = (sp->seg_number == oldsn) ? sp->ndupino : 0;
|
|
|
|
#endif
|
|
|
|
LFS_SEGENTRY(sup, fs, oldsn, bp);
|
|
|
|
#ifdef DIAGNOSTIC
|
|
|
|
if (sup->su_nbytes +
|
|
|
|
sizeof (struct ufs1_dinode) * ndupino
|
|
|
|
< sizeof (struct ufs1_dinode)) {
|
|
|
|
printf("lfs_writeinode: negative bytes "
|
|
|
|
"(segment %" PRIu32 " short by %d, "
|
|
|
|
"oldsn=%" PRIu32 ", cursn=%" PRIu32
|
|
|
|
", daddr=%" PRId64 ", su_nbytes=%u, "
|
|
|
|
"ndupino=%d)\n",
|
|
|
|
dtosn(fs, daddr),
|
|
|
|
(int)sizeof (struct ufs1_dinode) *
|
|
|
|
(1 - sp->ndupino) - sup->su_nbytes,
|
|
|
|
oldsn, sp->seg_number, daddr,
|
|
|
|
(unsigned int)sup->su_nbytes,
|
|
|
|
sp->ndupino);
|
|
|
|
panic("lfs_writeinode: negative bytes");
|
|
|
|
sup->su_nbytes = sizeof (struct ufs1_dinode);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
DLOG((DLOG_SU, "seg %d -= %d for ino %d inode\n",
|
|
|
|
dtosn(fs, daddr), sizeof (struct ufs1_dinode), ino));
|
|
|
|
sup->su_nbytes -= sizeof (struct ufs1_dinode);
|
|
|
|
redo_ifile |=
|
|
|
|
(ino == LFS_IFILE_INUM && !(bp->b_flags & B_GATHERED));
|
|
|
|
if (redo_ifile) {
|
|
|
|
simple_lock(&fs->lfs_interlock);
|
|
|
|
fs->lfs_flags |= LFS_IFDIRTY;
|
|
|
|
simple_unlock(&fs->lfs_interlock);
|
|
|
|
/* Don't double-account */
|
|
|
|
fs->lfs_idaddr = 0x0;
|
|
|
|
}
|
|
|
|
LFS_WRITESEGENTRY(sup, fs, oldsn, bp); /* Ifile */
|
|
|
|
}
|
|
|
|
|
|
|
|
return redo_ifile;
|
|
|
|
}
|
|
|
|
|
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_writeinode(struct lfs *fs, struct segment *sp, struct inode *ip)
|
1994-06-08 15:41:58 +04:00
|
|
|
{
|
Changes to help the roll-forward agent, to wit:
* Mark being-deleted files in the Ifile so we can finish deleting them
at fs mount time.
* Flag the Ifile with "cleaner must clean" when writers are waiting for
the cleaner, rather than relying solely on the cleaner's estimation of
whether it should clean or not.
* Note partial segments written by a user agent (in particular,
fsck_lfs) so that repeated rolls forward don't interfere with one
another.
* Add a new fcntl, LFCNPASS, that allows the log to wrap exactly once,
for better testing of the validity of checkpoints.
* Keep track of the on-disk nlink count when cleaning, so that we don't
partially complete directory operations while cleaning.
* Ensure that every single Ifile inode write represents a consistent
view of the filesystem. In particular, the accounting for the segment
we are writing the inode into must be correct, and the accounting for
the segment that inode used to reside in must be correct. Rather than
just rewriting the inode if we wrote it wrong, rewrite the necessary
ifile blocks before writing the inode so we never write it wrong.
* Don't unmark any VDIROP vnodes if we haven't written them to disk,
avoiding yet another problem with the "wait for the cleaner" error
return from lfs_putpages().
Also, move the last callback to an aiodone call, so we no longer do any
memory management from interrupt context.
2006-09-01 23:41:28 +04:00
|
|
|
struct buf *bp;
|
2003-04-02 14:39:19 +04:00
|
|
|
struct ufs1_dinode *cdp;
|
2003-01-25 00:55:02 +03:00
|
|
|
daddr_t daddr;
|
|
|
|
int32_t *daddrp; /* XXX ondisk32 */
|
Changes to help the roll-forward agent, to wit:
* Mark being-deleted files in the Ifile so we can finish deleting them
at fs mount time.
* Flag the Ifile with "cleaner must clean" when writers are waiting for
the cleaner, rather than relying solely on the cleaner's estimation of
whether it should clean or not.
* Note partial segments written by a user agent (in particular,
fsck_lfs) so that repeated rolls forward don't interfere with one
another.
* Add a new fcntl, LFCNPASS, that allows the log to wrap exactly once,
for better testing of the validity of checkpoints.
* Keep track of the on-disk nlink count when cleaning, so that we don't
partially complete directory operations while cleaning.
* Ensure that every single Ifile inode write represents a consistent
view of the filesystem. In particular, the accounting for the segment
we are writing the inode into must be correct, and the accounting for
the segment that inode used to reside in must be correct. Rather than
just rewriting the inode if we wrote it wrong, rewrite the necessary
ifile blocks before writing the inode so we never write it wrong.
* Don't unmark any VDIROP vnodes if we haven't written them to disk,
avoiding yet another problem with the "wait for the cleaner" error
return from lfs_putpages().
Also, move the last callback to an aiodone call, so we no longer do any
memory management from interrupt context.
2006-09-01 23:41:28 +04:00
|
|
|
int i, ndx;
|
1994-06-08 15:41:58 +04:00
|
|
|
int redo_ifile = 0;
|
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 gotblk = 0;
|
Changes to help the roll-forward agent, to wit:
* Mark being-deleted files in the Ifile so we can finish deleting them
at fs mount time.
* Flag the Ifile with "cleaner must clean" when writers are waiting for
the cleaner, rather than relying solely on the cleaner's estimation of
whether it should clean or not.
* Note partial segments written by a user agent (in particular,
fsck_lfs) so that repeated rolls forward don't interfere with one
another.
* Add a new fcntl, LFCNPASS, that allows the log to wrap exactly once,
for better testing of the validity of checkpoints.
* Keep track of the on-disk nlink count when cleaning, so that we don't
partially complete directory operations while cleaning.
* Ensure that every single Ifile inode write represents a consistent
view of the filesystem. In particular, the accounting for the segment
we are writing the inode into must be correct, and the accounting for
the segment that inode used to reside in must be correct. Rather than
just rewriting the inode if we wrote it wrong, rewrite the necessary
ifile blocks before writing the inode so we never write it wrong.
* Don't unmark any VDIROP vnodes if we haven't written them to disk,
avoiding yet another problem with the "wait for the cleaner" error
return from lfs_putpages().
Also, move the last callback to an aiodone call, so we no longer do any
memory management from interrupt context.
2006-09-01 23:41:28 +04:00
|
|
|
int count;
|
2005-02-27 01:31:44 +03:00
|
|
|
|
2005-04-02 01:59:46 +04:00
|
|
|
ASSERT_SEGLOCK(fs);
|
2000-05-31 05:40:01 +04:00
|
|
|
if (!(ip->i_flag & IN_ALLMOD))
|
2001-11-24 00:44:25 +03:00
|
|
|
return (0);
|
2005-02-27 01:31:44 +03:00
|
|
|
|
Changes to help the roll-forward agent, to wit:
* Mark being-deleted files in the Ifile so we can finish deleting them
at fs mount time.
* Flag the Ifile with "cleaner must clean" when writers are waiting for
the cleaner, rather than relying solely on the cleaner's estimation of
whether it should clean or not.
* Note partial segments written by a user agent (in particular,
fsck_lfs) so that repeated rolls forward don't interfere with one
another.
* Add a new fcntl, LFCNPASS, that allows the log to wrap exactly once,
for better testing of the validity of checkpoints.
* Keep track of the on-disk nlink count when cleaning, so that we don't
partially complete directory operations while cleaning.
* Ensure that every single Ifile inode write represents a consistent
view of the filesystem. In particular, the accounting for the segment
we are writing the inode into must be correct, and the accounting for
the segment that inode used to reside in must be correct. Rather than
just rewriting the inode if we wrote it wrong, rewrite the necessary
ifile blocks before writing the inode so we never write it wrong.
* Don't unmark any VDIROP vnodes if we haven't written them to disk,
avoiding yet another problem with the "wait for the cleaner" error
return from lfs_putpages().
Also, move the last callback to an aiodone call, so we no longer do any
memory management from interrupt context.
2006-09-01 23:41:28 +04:00
|
|
|
/* Can't write ifile when writer is not set */
|
|
|
|
KASSERT(ip->i_number != LFS_IFILE_INUM || fs->lfs_writer > 0 ||
|
|
|
|
(sp->seg_flags & SEGM_CLEAN));
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If this is the Ifile, see if writing it here will generate a
|
|
|
|
* temporary misaccounting. If it will, do the accounting and write
|
|
|
|
* the blocks, postponing the inode write until the accounting is
|
|
|
|
* solid.
|
|
|
|
*/
|
|
|
|
count = 0;
|
|
|
|
while (ip->i_number == LFS_IFILE_INUM) {
|
|
|
|
int redo = 0;
|
|
|
|
|
|
|
|
if (sp->idp == NULL && sp->ibp == NULL &&
|
|
|
|
(sp->seg_bytes_left < fs->lfs_ibsize ||
|
|
|
|
sp->sum_bytes_left < sizeof(int32_t))) {
|
|
|
|
(void) lfs_writeseg(fs, sp);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Look for dirty Ifile blocks */
|
|
|
|
LIST_FOREACH(bp, &fs->lfs_ivnode->v_dirtyblkhd, b_vnbufs) {
|
|
|
|
if (!(bp->b_flags & B_GATHERED)) {
|
|
|
|
redo = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (redo == 0)
|
|
|
|
redo = lfs_update_iaddr(fs, sp, ip, 0x0);
|
|
|
|
if (redo == 0)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (sp->idp) {
|
|
|
|
sp->idp->di_inumber = 0;
|
|
|
|
sp->idp = NULL;
|
|
|
|
}
|
|
|
|
++count;
|
2006-09-29 03:08:23 +04:00
|
|
|
if (count > 2)
|
|
|
|
log(LOG_NOTICE, "lfs_writeinode: looping count=%d\n", count);
|
Changes to help the roll-forward agent, to wit:
* Mark being-deleted files in the Ifile so we can finish deleting them
at fs mount time.
* Flag the Ifile with "cleaner must clean" when writers are waiting for
the cleaner, rather than relying solely on the cleaner's estimation of
whether it should clean or not.
* Note partial segments written by a user agent (in particular,
fsck_lfs) so that repeated rolls forward don't interfere with one
another.
* Add a new fcntl, LFCNPASS, that allows the log to wrap exactly once,
for better testing of the validity of checkpoints.
* Keep track of the on-disk nlink count when cleaning, so that we don't
partially complete directory operations while cleaning.
* Ensure that every single Ifile inode write represents a consistent
view of the filesystem. In particular, the accounting for the segment
we are writing the inode into must be correct, and the accounting for
the segment that inode used to reside in must be correct. Rather than
just rewriting the inode if we wrote it wrong, rewrite the necessary
ifile blocks before writing the inode so we never write it wrong.
* Don't unmark any VDIROP vnodes if we haven't written them to disk,
avoiding yet another problem with the "wait for the cleaner" error
return from lfs_putpages().
Also, move the last callback to an aiodone call, so we no longer do any
memory management from interrupt context.
2006-09-01 23:41:28 +04:00
|
|
|
lfs_writefile(fs, sp, fs->lfs_ivnode);
|
|
|
|
}
|
|
|
|
|
1994-06-08 15:41:58 +04:00
|
|
|
/* Allocate a new inode block if necessary. */
|
2003-07-12 20:17:52 +04:00
|
|
|
if ((ip->i_number != LFS_IFILE_INUM || sp->idp == NULL) &&
|
|
|
|
sp->ibp == NULL) {
|
1994-06-08 15:41:58 +04:00
|
|
|
/* Allocate a new segment if necessary. */
|
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 (sp->seg_bytes_left < fs->lfs_ibsize ||
|
2003-01-29 16:14:33 +03:00
|
|
|
sp->sum_bytes_left < sizeof(int32_t))
|
1994-06-08 15:41:58 +04:00
|
|
|
(void) lfs_writeseg(fs, sp);
|
|
|
|
|
|
|
|
/* Get next inode block. */
|
|
|
|
daddr = fs->lfs_offset;
|
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_offset += btofsb(fs, fs->lfs_ibsize);
|
1994-06-08 15:41:58 +04:00
|
|
|
sp->ibp = *sp->cbpp++ =
|
2003-07-12 20:17:52 +04:00
|
|
|
getblk(VTOI(fs->lfs_ivnode)->i_devvp,
|
|
|
|
fsbtodb(fs, daddr), fs->lfs_ibsize, 0, 0);
|
1999-04-12 04:04:21 +04:00
|
|
|
gotblk++;
|
|
|
|
|
1994-06-08 15:41:58 +04:00
|
|
|
/* Zero out inode numbers */
|
|
|
|
for (i = 0; i < INOPB(fs); ++i)
|
2003-07-12 20:17:52 +04:00
|
|
|
((struct ufs1_dinode *)sp->ibp->b_data)[i].di_inumber =
|
|
|
|
0;
|
1999-03-10 03:20:00 +03:00
|
|
|
|
1994-06-08 15:41:58 +04:00
|
|
|
++sp->start_bpp;
|
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, fs->lfs_ibsize);
|
1994-06-08 15:41:58 +04:00
|
|
|
/* Set remaining space counters. */
|
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
|
|
|
sp->seg_bytes_left -= fs->lfs_ibsize;
|
2003-01-29 16:14:33 +03:00
|
|
|
sp->sum_bytes_left -= sizeof(int32_t);
|
|
|
|
ndx = fs->lfs_sumsize / sizeof(int32_t) -
|
1999-03-10 03:20:00 +03:00
|
|
|
sp->ninodes / INOPB(fs) - 1;
|
2003-01-29 16:14:33 +03:00
|
|
|
((int32_t *)(sp->segsum))[ndx] = daddr;
|
1994-06-08 15:41:58 +04:00
|
|
|
}
|
1999-06-16 02:25:41 +04:00
|
|
|
|
Changes to help the roll-forward agent, to wit:
* Mark being-deleted files in the Ifile so we can finish deleting them
at fs mount time.
* Flag the Ifile with "cleaner must clean" when writers are waiting for
the cleaner, rather than relying solely on the cleaner's estimation of
whether it should clean or not.
* Note partial segments written by a user agent (in particular,
fsck_lfs) so that repeated rolls forward don't interfere with one
another.
* Add a new fcntl, LFCNPASS, that allows the log to wrap exactly once,
for better testing of the validity of checkpoints.
* Keep track of the on-disk nlink count when cleaning, so that we don't
partially complete directory operations while cleaning.
* Ensure that every single Ifile inode write represents a consistent
view of the filesystem. In particular, the accounting for the segment
we are writing the inode into must be correct, and the accounting for
the segment that inode used to reside in must be correct. Rather than
just rewriting the inode if we wrote it wrong, rewrite the necessary
ifile blocks before writing the inode so we never write it wrong.
* Don't unmark any VDIROP vnodes if we haven't written them to disk,
avoiding yet another problem with the "wait for the cleaner" error
return from lfs_putpages().
Also, move the last callback to an aiodone call, so we no longer do any
memory management from interrupt context.
2006-09-01 23:41:28 +04:00
|
|
|
/* Check VDIROP in case there is a new file with no data blocks */
|
|
|
|
if (ITOV(ip)->v_flag & VDIROP)
|
|
|
|
((SEGSUM *)(sp->segsum))->ss_flags |= (SS_DIROP|SS_CONT);
|
|
|
|
|
1994-06-08 15:41:58 +04:00
|
|
|
/* Update the inode times and copy the inode onto the inode page. */
|
2002-05-15 00:03:53 +04:00
|
|
|
/* XXX kludge --- don't redirty the ifile just to put times on it */
|
|
|
|
if (ip->i_number != LFS_IFILE_INUM)
|
2005-09-12 20:24:41 +04:00
|
|
|
LFS_ITIMES(ip, NULL, NULL, NULL);
|
1999-03-26 00:39:18 +03:00
|
|
|
|
1999-06-16 02:25:41 +04:00
|
|
|
/*
|
|
|
|
* If this is the Ifile, and we've already written the Ifile in this
|
|
|
|
* partial segment, just overwrite it (it's not on disk yet) and
|
|
|
|
* continue.
|
|
|
|
*
|
|
|
|
* XXX we know that the bp that we get the second time around has
|
|
|
|
* already been gathered.
|
|
|
|
*/
|
2001-11-24 00:44:25 +03:00
|
|
|
if (ip->i_number == LFS_IFILE_INUM && sp->idp) {
|
2003-04-02 14:39:19 +04:00
|
|
|
*(sp->idp) = *ip->i_din.ffs1_din;
|
|
|
|
ip->i_lfs_osize = ip->i_size;
|
1999-06-16 02:25:41 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1994-06-08 15:41:58 +04:00
|
|
|
bp = sp->ibp;
|
2003-04-02 14:39:19 +04:00
|
|
|
cdp = ((struct ufs1_dinode *)bp->b_data) + (sp->ninodes % INOPB(fs));
|
|
|
|
*cdp = *ip->i_din.ffs1_din;
|
2000-07-03 05:45:46 +04:00
|
|
|
|
Changes to help the roll-forward agent, to wit:
* Mark being-deleted files in the Ifile so we can finish deleting them
at fs mount time.
* Flag the Ifile with "cleaner must clean" when writers are waiting for
the cleaner, rather than relying solely on the cleaner's estimation of
whether it should clean or not.
* Note partial segments written by a user agent (in particular,
fsck_lfs) so that repeated rolls forward don't interfere with one
another.
* Add a new fcntl, LFCNPASS, that allows the log to wrap exactly once,
for better testing of the validity of checkpoints.
* Keep track of the on-disk nlink count when cleaning, so that we don't
partially complete directory operations while cleaning.
* Ensure that every single Ifile inode write represents a consistent
view of the filesystem. In particular, the accounting for the segment
we are writing the inode into must be correct, and the accounting for
the segment that inode used to reside in must be correct. Rather than
just rewriting the inode if we wrote it wrong, rewrite the necessary
ifile blocks before writing the inode so we never write it wrong.
* Don't unmark any VDIROP vnodes if we haven't written them to disk,
avoiding yet another problem with the "wait for the cleaner" error
return from lfs_putpages().
Also, move the last callback to an aiodone call, so we no longer do any
memory management from interrupt context.
2006-09-01 23:41:28 +04:00
|
|
|
/*
|
|
|
|
* If cleaning, link counts and directory file sizes cannot change,
|
|
|
|
* since those would be directory operations---even if the file
|
|
|
|
* we are writing is marked VDIROP we should write the old values.
|
|
|
|
* If we're not cleaning, of course, update the values so we get
|
|
|
|
* current values the next time we clean.
|
|
|
|
*/
|
|
|
|
if (sp->seg_flags & SEGM_CLEAN) {
|
|
|
|
if (ITOV(ip)->v_flag & VDIROP) {
|
|
|
|
cdp->di_nlink = ip->i_lfs_odnlink;
|
|
|
|
/* if (ITOV(ip)->v_type == VDIR) */
|
|
|
|
cdp->di_size = ip->i_lfs_osize;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
ip->i_lfs_odnlink = cdp->di_nlink;
|
|
|
|
ip->i_lfs_osize = ip->i_size;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-05-01 01:19:42 +04:00
|
|
|
/* We can finish the segment accounting for truncations now */
|
|
|
|
lfs_finalize_ino_seguse(fs, ip);
|
|
|
|
|
2000-07-03 05:45:46 +04:00
|
|
|
/*
|
|
|
|
* If we are cleaning, ensure that we don't write UNWRITTEN disk
|
2005-04-14 04:02:46 +04:00
|
|
|
* addresses to disk; possibly change the on-disk record of
|
|
|
|
* the inode size, either by reverting to the previous size
|
|
|
|
* (in the case of cleaning) or by verifying the inode's block
|
|
|
|
* holdings (in the case of files being allocated as they are being
|
|
|
|
* written).
|
|
|
|
* XXX By not writing UNWRITTEN blocks, we are making the lfs_avail
|
2003-02-20 07:27:23 +03:00
|
|
|
* XXX count on disk wrong by the same amount. We should be
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
* XXX able to "borrow" from lfs_avail and return it after the
|
|
|
|
* XXX Ifile is written. See also in lfs_writeseg.
|
2000-07-03 05:45:46 +04:00
|
|
|
*/
|
2005-04-14 04:02:46 +04:00
|
|
|
|
|
|
|
/* Check file size based on highest allocated block */
|
|
|
|
if (((ip->i_ffs1_mode & IFMT) == IFREG ||
|
2005-04-19 03:03:08 +04:00
|
|
|
(ip->i_ffs1_mode & IFMT) == IFDIR) &&
|
2005-04-14 04:02:46 +04:00
|
|
|
ip->i_size > ((ip->i_lfs_hiblk + 1) << fs->lfs_bshift)) {
|
|
|
|
cdp->di_size = (ip->i_lfs_hiblk + 1) << fs->lfs_bshift;
|
|
|
|
DLOG((DLOG_SEG, "lfs_writeinode: ino %d size %" PRId64 " -> %"
|
|
|
|
PRId64 "\n", (int)ip->i_number, ip->i_size, cdp->di_size));
|
|
|
|
}
|
2003-04-02 14:39:19 +04:00
|
|
|
if (ip->i_lfs_effnblks != ip->i_ffs1_blocks) {
|
2005-04-14 04:02:46 +04:00
|
|
|
DLOG((DLOG_SEG, "lfs_writeinode: cleansing ino %d eff %d != nblk %d)"
|
|
|
|
" at %x\n", ip->i_number, ip->i_lfs_effnblks,
|
|
|
|
ip->i_ffs1_blocks, fs->lfs_offset));
|
2000-07-03 05:45:46 +04:00
|
|
|
for (daddrp = cdp->di_db; daddrp < cdp->di_ib + NIADDR;
|
|
|
|
daddrp++) {
|
|
|
|
if (*daddrp == UNWRITTEN) {
|
2005-03-08 03:18:19 +03:00
|
|
|
DLOG((DLOG_SEG, "lfs_writeinode: wiping UNWRITTEN\n"));
|
2000-07-03 05:45:46 +04:00
|
|
|
*daddrp = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2005-02-27 01:31:44 +03:00
|
|
|
|
2005-04-14 04:02:46 +04:00
|
|
|
#ifdef DIAGNOSTIC
|
|
|
|
/*
|
|
|
|
* Check dinode held blocks against dinode size.
|
|
|
|
* This should be identical to the check in lfs_vget().
|
|
|
|
*/
|
|
|
|
for (i = (cdp->di_size + fs->lfs_bsize - 1) >> fs->lfs_bshift;
|
|
|
|
i < NDADDR; i++) {
|
|
|
|
KASSERT(i >= 0);
|
|
|
|
if ((cdp->di_mode & IFMT) == IFLNK)
|
|
|
|
continue;
|
|
|
|
if (((cdp->di_mode & IFMT) == IFBLK ||
|
|
|
|
(cdp->di_mode & IFMT) == IFCHR) && i == 0)
|
|
|
|
continue;
|
|
|
|
if (cdp->di_db[i] != 0) {
|
|
|
|
# ifdef DEBUG
|
|
|
|
lfs_dump_dinode(cdp);
|
|
|
|
# endif
|
|
|
|
panic("writing inconsistent inode");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif /* DIAGNOSTIC */
|
|
|
|
|
2001-11-24 00:44:25 +03:00
|
|
|
if (ip->i_flag & IN_CLEANING)
|
2000-07-06 02:25:43 +04:00
|
|
|
LFS_CLR_UINO(ip, IN_CLEANING);
|
2000-07-05 02:30:37 +04:00
|
|
|
else {
|
2000-07-06 02:25:43 +04:00
|
|
|
/* XXX IN_ALLMOD */
|
|
|
|
LFS_CLR_UINO(ip, IN_ACCESSED | IN_ACCESS | IN_CHANGE |
|
2004-08-14 05:08:02 +04:00
|
|
|
IN_UPDATE | IN_MODIFY);
|
2003-04-02 14:39:19 +04:00
|
|
|
if (ip->i_lfs_effnblks == ip->i_ffs1_blocks)
|
2000-07-06 02:25:43 +04:00
|
|
|
LFS_CLR_UINO(ip, IN_MODIFIED);
|
2006-10-04 19:53:24 +04:00
|
|
|
else {
|
|
|
|
DLOG((DLOG_VNODE, "lfs_writeinode: ino %d: real "
|
|
|
|
"blks=%d, eff=%d\n", ip->i_number,
|
|
|
|
ip->i_ffs1_blocks, ip->i_lfs_effnblks));
|
|
|
|
}
|
2000-07-05 02:30:37 +04:00
|
|
|
}
|
|
|
|
|
Changes to help the roll-forward agent, to wit:
* Mark being-deleted files in the Ifile so we can finish deleting them
at fs mount time.
* Flag the Ifile with "cleaner must clean" when writers are waiting for
the cleaner, rather than relying solely on the cleaner's estimation of
whether it should clean or not.
* Note partial segments written by a user agent (in particular,
fsck_lfs) so that repeated rolls forward don't interfere with one
another.
* Add a new fcntl, LFCNPASS, that allows the log to wrap exactly once,
for better testing of the validity of checkpoints.
* Keep track of the on-disk nlink count when cleaning, so that we don't
partially complete directory operations while cleaning.
* Ensure that every single Ifile inode write represents a consistent
view of the filesystem. In particular, the accounting for the segment
we are writing the inode into must be correct, and the accounting for
the segment that inode used to reside in must be correct. Rather than
just rewriting the inode if we wrote it wrong, rewrite the necessary
ifile blocks before writing the inode so we never write it wrong.
* Don't unmark any VDIROP vnodes if we haven't written them to disk,
avoiding yet another problem with the "wait for the cleaner" error
return from lfs_putpages().
Also, move the last callback to an aiodone call, so we no longer do any
memory management from interrupt context.
2006-09-01 23:41:28 +04:00
|
|
|
if (ip->i_number == LFS_IFILE_INUM) {
|
|
|
|
/* We know sp->idp == NULL */
|
2005-02-27 01:31:44 +03:00
|
|
|
sp->idp = ((struct ufs1_dinode *)bp->b_data) +
|
2000-07-03 05:45:46 +04:00
|
|
|
(sp->ninodes % INOPB(fs));
|
Changes to help the roll-forward agent, to wit:
* Mark being-deleted files in the Ifile so we can finish deleting them
at fs mount time.
* Flag the Ifile with "cleaner must clean" when writers are waiting for
the cleaner, rather than relying solely on the cleaner's estimation of
whether it should clean or not.
* Note partial segments written by a user agent (in particular,
fsck_lfs) so that repeated rolls forward don't interfere with one
another.
* Add a new fcntl, LFCNPASS, that allows the log to wrap exactly once,
for better testing of the validity of checkpoints.
* Keep track of the on-disk nlink count when cleaning, so that we don't
partially complete directory operations while cleaning.
* Ensure that every single Ifile inode write represents a consistent
view of the filesystem. In particular, the accounting for the segment
we are writing the inode into must be correct, and the accounting for
the segment that inode used to reside in must be correct. Rather than
just rewriting the inode if we wrote it wrong, rewrite the necessary
ifile blocks before writing the inode so we never write it wrong.
* Don't unmark any VDIROP vnodes if we haven't written them to disk,
avoiding yet another problem with the "wait for the cleaner" error
return from lfs_putpages().
Also, move the last callback to an aiodone call, so we no longer do any
memory management from interrupt context.
2006-09-01 23:41:28 +04:00
|
|
|
|
|
|
|
/* Not dirty any more */
|
|
|
|
simple_lock(&fs->lfs_interlock);
|
|
|
|
fs->lfs_flags &= ~LFS_IFDIRTY;
|
|
|
|
simple_unlock(&fs->lfs_interlock);
|
|
|
|
}
|
|
|
|
|
2001-11-24 00:44:25 +03:00
|
|
|
if (gotblk) {
|
2000-11-17 22:14:41 +03:00
|
|
|
LFS_LOCK_BUF(bp);
|
1999-04-12 04:04:21 +04:00
|
|
|
brelse(bp);
|
|
|
|
}
|
2005-02-27 01:31:44 +03:00
|
|
|
|
1994-06-08 15:41:58 +04:00
|
|
|
/* Increment inode count in segment summary block. */
|
|
|
|
++((SEGSUM *)(sp->segsum))->ss_ninos;
|
2005-02-27 01:31:44 +03:00
|
|
|
|
1994-06-08 15:41:58 +04:00
|
|
|
/* If this page is full, set flag to allocate a new page. */
|
|
|
|
if (++sp->ninodes % INOPB(fs) == 0)
|
|
|
|
sp->ibp = NULL;
|
2005-02-27 01:31:44 +03:00
|
|
|
|
Changes to help the roll-forward agent, to wit:
* Mark being-deleted files in the Ifile so we can finish deleting them
at fs mount time.
* Flag the Ifile with "cleaner must clean" when writers are waiting for
the cleaner, rather than relying solely on the cleaner's estimation of
whether it should clean or not.
* Note partial segments written by a user agent (in particular,
fsck_lfs) so that repeated rolls forward don't interfere with one
another.
* Add a new fcntl, LFCNPASS, that allows the log to wrap exactly once,
for better testing of the validity of checkpoints.
* Keep track of the on-disk nlink count when cleaning, so that we don't
partially complete directory operations while cleaning.
* Ensure that every single Ifile inode write represents a consistent
view of the filesystem. In particular, the accounting for the segment
we are writing the inode into must be correct, and the accounting for
the segment that inode used to reside in must be correct. Rather than
just rewriting the inode if we wrote it wrong, rewrite the necessary
ifile blocks before writing the inode so we never write it wrong.
* Don't unmark any VDIROP vnodes if we haven't written them to disk,
avoiding yet another problem with the "wait for the cleaner" error
return from lfs_putpages().
Also, move the last callback to an aiodone call, so we no longer do any
memory management from interrupt context.
2006-09-01 23:41:28 +04:00
|
|
|
redo_ifile = lfs_update_iaddr(fs, sp, ip, bp->b_blkno);
|
2005-02-27 01:31:44 +03:00
|
|
|
|
Changes to help the roll-forward agent, to wit:
* Mark being-deleted files in the Ifile so we can finish deleting them
at fs mount time.
* Flag the Ifile with "cleaner must clean" when writers are waiting for
the cleaner, rather than relying solely on the cleaner's estimation of
whether it should clean or not.
* Note partial segments written by a user agent (in particular,
fsck_lfs) so that repeated rolls forward don't interfere with one
another.
* Add a new fcntl, LFCNPASS, that allows the log to wrap exactly once,
for better testing of the validity of checkpoints.
* Keep track of the on-disk nlink count when cleaning, so that we don't
partially complete directory operations while cleaning.
* Ensure that every single Ifile inode write represents a consistent
view of the filesystem. In particular, the accounting for the segment
we are writing the inode into must be correct, and the accounting for
the segment that inode used to reside in must be correct. Rather than
just rewriting the inode if we wrote it wrong, rewrite the necessary
ifile blocks before writing the inode so we never write it wrong.
* Don't unmark any VDIROP vnodes if we haven't written them to disk,
avoiding yet another problem with the "wait for the cleaner" error
return from lfs_putpages().
Also, move the last callback to an aiodone call, so we no longer do any
memory management from interrupt context.
2006-09-01 23:41:28 +04:00
|
|
|
KASSERT(redo_ifile == 0);
|
1994-06-08 15:41:58 +04:00
|
|
|
return (redo_ifile);
|
|
|
|
}
|
|
|
|
|
|
|
|
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_gatherblock(struct segment *sp, struct buf *bp, int *sptr)
|
1994-06-08 15:41:58 +04:00
|
|
|
{
|
|
|
|
struct lfs *fs;
|
2005-05-30 01:25:24 +04:00
|
|
|
int vers;
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
int j, blksinblk;
|
|
|
|
|
2005-04-02 01:59:46 +04:00
|
|
|
ASSERT_SEGLOCK(sp->fs);
|
1994-06-08 15:41:58 +04:00
|
|
|
/*
|
|
|
|
* If full, finish this segment. We may be doing I/O, so
|
|
|
|
* release and reacquire the splbio().
|
|
|
|
*/
|
|
|
|
#ifdef DIAGNOSTIC
|
|
|
|
if (sp->vp == NULL)
|
|
|
|
panic ("lfs_gatherblock: Null vp in segment");
|
|
|
|
#endif
|
|
|
|
fs = sp->fs;
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
blksinblk = howmany(bp->b_bcount, fs->lfs_bsize);
|
|
|
|
if (sp->sum_bytes_left < sizeof(int32_t) * blksinblk ||
|
1998-03-01 05:20:01 +03:00
|
|
|
sp->seg_bytes_left < bp->b_bcount) {
|
1994-06-08 15:41:58 +04:00
|
|
|
if (sptr)
|
|
|
|
splx(*sptr);
|
|
|
|
lfs_updatemeta(sp);
|
2005-02-27 01:31:44 +03:00
|
|
|
|
2005-05-30 01:25:24 +04:00
|
|
|
vers = sp->fip->fi_version;
|
1994-06-08 15:41:58 +04:00
|
|
|
(void) lfs_writeseg(fs, sp);
|
2005-02-27 01:31:44 +03:00
|
|
|
|
1994-06-08 15:41:58 +04:00
|
|
|
/* Add the current file to the segment summary. */
|
2006-05-19 03:15:09 +04:00
|
|
|
lfs_acquire_finfo(fs, VTOI(sp->vp)->i_number, vers);
|
2005-02-27 01:31:44 +03:00
|
|
|
|
1994-06-08 15:41:58 +04:00
|
|
|
if (sptr)
|
|
|
|
*sptr = splbio();
|
2001-11-24 00:44:25 +03:00
|
|
|
return (1);
|
1994-06-08 15:41:58 +04:00
|
|
|
}
|
2005-02-27 01:31:44 +03:00
|
|
|
|
2001-11-24 00:44:25 +03:00
|
|
|
if (bp->b_flags & B_GATHERED) {
|
2005-03-08 03:18:19 +03:00
|
|
|
DLOG((DLOG_SEG, "lfs_gatherblock: already gathered! Ino %d,"
|
|
|
|
" lbn %" PRId64 "\n",
|
|
|
|
sp->fip->fi_ino, bp->b_lblkno));
|
2001-11-24 00:44:25 +03:00
|
|
|
return (0);
|
1999-03-10 03:20:00 +03:00
|
|
|
}
|
2005-03-08 03:18:19 +03:00
|
|
|
|
1994-06-08 15:41:58 +04:00
|
|
|
/* Insert into the buffer list, update the FINFO block. */
|
|
|
|
bp->b_flags |= B_GATHERED;
|
2002-05-15 00:03:53 +04:00
|
|
|
|
1994-06-08 15:41:58 +04:00
|
|
|
*sp->cbpp++ = bp;
|
2005-04-20 00:59:05 +04:00
|
|
|
for (j = 0; j < blksinblk; j++) {
|
2003-02-23 03:22:33 +03:00
|
|
|
sp->fip->fi_blocks[sp->fip->fi_nblocks++] = bp->b_lblkno + j;
|
2005-04-20 00:59:05 +04:00
|
|
|
/* This block's accounting moves from lfs_favail to lfs_avail */
|
|
|
|
lfs_deregister_block(sp->vp, bp->b_lblkno + j);
|
|
|
|
}
|
2005-02-27 01:31:44 +03:00
|
|
|
|
2003-02-23 03:22:33 +03:00
|
|
|
sp->sum_bytes_left -= sizeof(int32_t) * blksinblk;
|
1998-03-01 05:20:01 +03:00
|
|
|
sp->seg_bytes_left -= bp->b_bcount;
|
2001-11-24 00:44:25 +03:00
|
|
|
return (0);
|
1994-06-08 15:41:58 +04:00
|
|
|
}
|
|
|
|
|
1999-03-10 03:20:00 +03:00
|
|
|
int
|
2003-07-12 20:17:52 +04:00
|
|
|
lfs_gather(struct lfs *fs, struct segment *sp, struct vnode *vp,
|
|
|
|
int (*match)(struct lfs *, struct buf *))
|
1994-06-08 15:41:58 +04:00
|
|
|
{
|
2002-05-24 03:05:25 +04:00
|
|
|
struct buf *bp, *nbp;
|
2001-11-24 00:44:25 +03:00
|
|
|
int s, count = 0;
|
2005-02-27 01:31:44 +03:00
|
|
|
|
2005-04-02 01:59:46 +04:00
|
|
|
ASSERT_SEGLOCK(fs);
|
2006-04-08 03:59:28 +04:00
|
|
|
if (vp->v_type == VBLK)
|
|
|
|
return 0;
|
2003-10-18 19:52:42 +04:00
|
|
|
KASSERT(sp->vp == NULL);
|
1994-06-08 15:41:58 +04:00
|
|
|
sp->vp = vp;
|
|
|
|
s = splbio();
|
1998-03-01 05:20:01 +03:00
|
|
|
|
1999-03-10 03:20:00 +03:00
|
|
|
#ifndef LFS_NO_BACKBUF_HACK
|
|
|
|
/* This is a hack to see if ordering the blocks in LFS makes a difference. */
|
2003-07-12 20:17:52 +04:00
|
|
|
# define BUF_OFFSET \
|
2007-03-04 08:59:00 +03:00
|
|
|
(((char *)&LIST_NEXT(bp, b_vnbufs)) - (char *)bp)
|
2003-07-12 20:17:52 +04:00
|
|
|
# define BACK_BUF(BP) \
|
2007-03-04 08:59:00 +03:00
|
|
|
((struct buf *)(((char *)(BP)->b_vnbufs.le_prev) - BUF_OFFSET))
|
2003-07-12 20:17:52 +04:00
|
|
|
# define BEG_OF_LIST \
|
2007-03-04 08:59:00 +03:00
|
|
|
((struct buf *)(((char *)&LIST_FIRST(&vp->v_dirtyblkhd)) - BUF_OFFSET))
|
2003-07-12 20:17:52 +04:00
|
|
|
|
|
|
|
loop:
|
|
|
|
/* Find last buffer. */
|
|
|
|
for (bp = LIST_FIRST(&vp->v_dirtyblkhd);
|
|
|
|
bp && LIST_NEXT(bp, b_vnbufs) != NULL;
|
|
|
|
bp = LIST_NEXT(bp, b_vnbufs))
|
|
|
|
/* nothing */;
|
2002-05-24 03:05:25 +04:00
|
|
|
for (; bp && bp != BEG_OF_LIST; bp = nbp) {
|
|
|
|
nbp = BACK_BUF(bp);
|
|
|
|
#else /* LFS_NO_BACKBUF_HACK */
|
2003-07-12 20:17:52 +04:00
|
|
|
loop:
|
|
|
|
for (bp = LIST_FIRST(&vp->v_dirtyblkhd); bp; bp = nbp) {
|
2002-05-24 03:05:25 +04:00
|
|
|
nbp = LIST_NEXT(bp, b_vnbufs);
|
1999-03-10 03:20:00 +03:00
|
|
|
#endif /* LFS_NO_BACKBUF_HACK */
|
2002-05-15 00:03:53 +04:00
|
|
|
if ((bp->b_flags & (B_BUSY|B_GATHERED)) || !match(fs, bp)) {
|
2005-03-08 03:18:19 +03:00
|
|
|
#ifdef DEBUG
|
2003-07-12 20:17:52 +04:00
|
|
|
if (vp == fs->lfs_ivnode &&
|
|
|
|
(bp->b_flags & (B_BUSY|B_GATHERED)) == B_BUSY)
|
Changes to help the roll-forward agent, to wit:
* Mark being-deleted files in the Ifile so we can finish deleting them
at fs mount time.
* Flag the Ifile with "cleaner must clean" when writers are waiting for
the cleaner, rather than relying solely on the cleaner's estimation of
whether it should clean or not.
* Note partial segments written by a user agent (in particular,
fsck_lfs) so that repeated rolls forward don't interfere with one
another.
* Add a new fcntl, LFCNPASS, that allows the log to wrap exactly once,
for better testing of the validity of checkpoints.
* Keep track of the on-disk nlink count when cleaning, so that we don't
partially complete directory operations while cleaning.
* Ensure that every single Ifile inode write represents a consistent
view of the filesystem. In particular, the accounting for the segment
we are writing the inode into must be correct, and the accounting for
the segment that inode used to reside in must be correct. Rather than
just rewriting the inode if we wrote it wrong, rewrite the necessary
ifile blocks before writing the inode so we never write it wrong.
* Don't unmark any VDIROP vnodes if we haven't written them to disk,
avoiding yet another problem with the "wait for the cleaner" error
return from lfs_putpages().
Also, move the last callback to an aiodone call, so we no longer do any
memory management from interrupt context.
2006-09-01 23:41:28 +04:00
|
|
|
log(LOG_NOTICE, "lfs_gather: ifile lbn %"
|
|
|
|
PRId64 " busy (%x) at 0x%x",
|
|
|
|
bp->b_lblkno, bp->b_flags,
|
|
|
|
(unsigned)fs->lfs_offset);
|
2002-05-15 00:03:53 +04:00
|
|
|
#endif
|
1994-06-08 15:41:58 +04:00
|
|
|
continue;
|
2002-05-15 00:03:53 +04:00
|
|
|
}
|
1994-06-08 15:41:58 +04:00
|
|
|
#ifdef DIAGNOSTIC
|
2003-03-11 05:47:39 +03:00
|
|
|
# ifdef LFS_USE_B_INVAL
|
2006-04-08 03:59:28 +04:00
|
|
|
if ((bp->b_flags & (B_CALL|B_INVAL)) == B_INVAL) {
|
|
|
|
DLOG((DLOG_SEG, "lfs_gather: lbn %" PRId64
|
|
|
|
" is B_INVAL\n", bp->b_lblkno));
|
|
|
|
VOP_PRINT(bp->b_vp);
|
|
|
|
}
|
2003-03-11 05:47:39 +03:00
|
|
|
# endif /* LFS_USE_B_INVAL */
|
2006-04-08 03:59:28 +04:00
|
|
|
if (!(bp->b_flags & B_DELWRI))
|
|
|
|
panic("lfs_gather: bp not B_DELWRI");
|
|
|
|
if (!(bp->b_flags & B_LOCKED)) {
|
|
|
|
DLOG((DLOG_SEG, "lfs_gather: lbn %" PRId64
|
|
|
|
" blk %" PRId64 " not B_LOCKED\n",
|
|
|
|
bp->b_lblkno,
|
|
|
|
dbtofsb(fs, bp->b_blkno)));
|
|
|
|
VOP_PRINT(bp->b_vp);
|
|
|
|
panic("lfs_gather: bp not B_LOCKED");
|
|
|
|
}
|
1994-06-08 15:41:58 +04:00
|
|
|
#endif
|
2006-04-08 03:59:28 +04:00
|
|
|
if (lfs_gatherblock(sp, bp, &s)) {
|
|
|
|
goto loop;
|
1999-03-10 03:20:00 +03:00
|
|
|
}
|
1999-09-04 02:48:51 +04:00
|
|
|
count++;
|
1994-06-08 15:41:58 +04:00
|
|
|
}
|
|
|
|
splx(s);
|
|
|
|
lfs_updatemeta(sp);
|
2003-10-18 19:52:42 +04:00
|
|
|
KASSERT(sp->vp == vp);
|
1994-06-08 15:41:58 +04:00
|
|
|
sp->vp = NULL;
|
1999-03-10 03:20:00 +03:00
|
|
|
return count;
|
1994-06-08 15:41:58 +04:00
|
|
|
}
|
|
|
|
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
#if DEBUG
|
|
|
|
# define DEBUG_OOFF(n) do { \
|
|
|
|
if (ooff == 0) { \
|
2005-03-08 03:18:19 +03:00
|
|
|
DLOG((DLOG_SEG, "lfs_updatemeta[%d]: warning: writing " \
|
2003-03-02 07:34:30 +03:00
|
|
|
"ino %d lbn %" PRId64 " at 0x%" PRIx32 \
|
|
|
|
", was 0x0 (or %" PRId64 ")\n", \
|
2005-03-08 03:18:19 +03:00
|
|
|
(n), ip->i_number, lbn, ndaddr, daddr)); \
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
} \
|
2003-03-21 09:26:36 +03:00
|
|
|
} while (0)
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
#else
|
|
|
|
# define DEBUG_OOFF(n)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Change the given block's address to ndaddr, finding its previous
|
|
|
|
* location using ufs_bmaparray().
|
|
|
|
*
|
|
|
|
* Account for this change in the segment table.
|
2003-11-07 20:55:29 +03:00
|
|
|
*
|
|
|
|
* called with sp == NULL by roll-forwarding code.
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
*/
|
|
|
|
void
|
2006-11-16 04:32:37 +03:00
|
|
|
lfs_update_single(struct lfs *fs, struct segment *sp,
|
2006-10-12 05:30:41 +04:00
|
|
|
struct vnode *vp, daddr_t lbn, int32_t ndaddr, int size)
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
{
|
|
|
|
SEGUSE *sup;
|
|
|
|
struct buf *bp;
|
|
|
|
struct indir a[NIADDR + 2], *ap;
|
|
|
|
struct inode *ip;
|
|
|
|
daddr_t daddr, ooff;
|
2003-02-23 03:22:33 +03:00
|
|
|
int num, error;
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
int bb, osize, obb;
|
2005-02-27 01:31:44 +03:00
|
|
|
|
2005-04-02 01:59:46 +04:00
|
|
|
ASSERT_SEGLOCK(fs);
|
2003-11-07 20:55:29 +03:00
|
|
|
KASSERT(sp == NULL || sp->vp == vp);
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
ip = VTOI(vp);
|
|
|
|
|
2003-05-18 16:59:05 +04:00
|
|
|
error = ufs_bmaparray(vp, lbn, &daddr, a, &num, NULL, NULL);
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
if (error)
|
|
|
|
panic("lfs_updatemeta: ufs_bmaparray returned %d", error);
|
2003-03-28 11:03:38 +03:00
|
|
|
|
Various minor LFS improvements:
* Note when lfs_putpages(9) thinks it is not going to be writing any
pages before calling genfs_putpages(9). This prevents a situation in
which blocks can be queued for writing without a segment header.
* Correct computation of NRESERVE(), though it is still a gross
overestimate in most cases. Note that if NRESERVE() is too high, it
may be impossible to create files on the filesystem. We catch this
case on filesystem mount and refuse to mount r/w.
* Allow filesystems to be mounted whose block size is == MAXBSIZE.
* Somewhere along the line, ufs_bmaparray(9) started mangling UNWRITTEN
entries in indirect blocks again, triggering a failed assertion "daddr
<= LFS_MAX_DADDR". Explicitly convert to and from int32_t to correct
this.
* Add a high-water mark for the number of dirty pages any given LFS can
hold before triggering a flush. This is settable by sysctl, but off
(zero) by default.
* Be more careful about the MAX_BYTES and MAX_BUFS computations so we
shouldn't see "please increase to at least zero" messages.
* Note that VBLK and VCHR vnodes can have nonzero values in di_db[0]
even though their v_size == 0. Don't panic when we see this.
* Change lfs_bfree to a signed quantity. The manner in which it is
processed before being passed to the cleaner means that sometimes it
may drop below zero, and the cleaner must be aware of this.
* Never report bfree < 0 (or higher than lfs_dsize) through
lfs_statvfs(9). This prevents df(1) from ever telling us that our full
filesystems have 16TB free.
* Account space allocated through lfs_balloc(9) that does not have
associated buffer headers, so that the pagedaemon doesn't run us out
of segments.
* Return ENOSPC from lfs_balloc(9) when bfree drops to zero.
* Address a deadlock in lfs_bmapv/lfs_markv when the filesystem is being
unmounted. Because vfs_busy() is a shared lock, and
lfs_bmapv/lfs_markv mark the filesystem vfs_busy(), the cleaner can be
holding the lock that umount() is blocking on, then try to vfs_busy()
again in getnewvnode().
2005-02-26 08:40:42 +03:00
|
|
|
daddr = (daddr_t)((int32_t)daddr); /* XXX ondisk32 */
|
2003-03-28 11:03:38 +03:00
|
|
|
KASSERT(daddr <= LFS_MAX_DADDR);
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
if (daddr > 0)
|
|
|
|
daddr = dbtofsb(fs, daddr);
|
2005-02-27 01:31:44 +03:00
|
|
|
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
bb = fragstofsb(fs, numfrags(fs, size));
|
|
|
|
switch (num) {
|
|
|
|
case 0:
|
2003-04-02 14:39:19 +04:00
|
|
|
ooff = ip->i_ffs1_db[lbn];
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
DEBUG_OOFF(0);
|
|
|
|
if (ooff == UNWRITTEN)
|
2003-04-02 14:39:19 +04:00
|
|
|
ip->i_ffs1_blocks += bb;
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
else {
|
|
|
|
/* possible fragment truncation or extension */
|
|
|
|
obb = btofsb(fs, ip->i_lfs_fragsize[lbn]);
|
2003-04-02 14:39:19 +04:00
|
|
|
ip->i_ffs1_blocks += (bb - obb);
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
}
|
2003-04-02 14:39:19 +04:00
|
|
|
ip->i_ffs1_db[lbn] = ndaddr;
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
break;
|
|
|
|
case 1:
|
2003-04-02 14:39:19 +04:00
|
|
|
ooff = ip->i_ffs1_ib[a[0].in_off];
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
DEBUG_OOFF(1);
|
|
|
|
if (ooff == UNWRITTEN)
|
2003-04-02 14:39:19 +04:00
|
|
|
ip->i_ffs1_blocks += bb;
|
|
|
|
ip->i_ffs1_ib[a[0].in_off] = ndaddr;
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ap = &a[num - 1];
|
|
|
|
if (bread(vp, ap->in_lbn, fs->lfs_bsize, NOCRED, &bp))
|
|
|
|
panic("lfs_updatemeta: bread bno %" PRId64,
|
|
|
|
ap->in_lbn);
|
|
|
|
|
|
|
|
/* XXX ondisk32 */
|
|
|
|
ooff = ((int32_t *)bp->b_data)[ap->in_off];
|
|
|
|
DEBUG_OOFF(num);
|
|
|
|
if (ooff == UNWRITTEN)
|
2003-04-02 14:39:19 +04:00
|
|
|
ip->i_ffs1_blocks += bb;
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
/* XXX ondisk32 */
|
|
|
|
((int32_t *)bp->b_data)[ap->in_off] = ndaddr;
|
|
|
|
(void) VOP_BWRITE(bp);
|
|
|
|
}
|
2003-03-04 22:19:43 +03:00
|
|
|
|
2004-01-29 15:10:07 +03:00
|
|
|
KASSERT(ooff == 0 || ooff == UNWRITTEN || ooff == daddr);
|
|
|
|
|
2005-04-14 04:02:46 +04:00
|
|
|
/* Update hiblk when extending the file */
|
|
|
|
if (lbn > ip->i_lfs_hiblk)
|
|
|
|
ip->i_lfs_hiblk = lbn;
|
|
|
|
|
2003-03-04 22:19:43 +03:00
|
|
|
/*
|
|
|
|
* Though we'd rather it couldn't, this *can* happen right now
|
|
|
|
* if cleaning blocks and regular blocks coexist.
|
|
|
|
*/
|
|
|
|
/* KASSERT(daddr < fs->lfs_lastpseg || daddr > ndaddr); */
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Update segment usage information, based on old size
|
|
|
|
* and location.
|
|
|
|
*/
|
|
|
|
if (daddr > 0) {
|
|
|
|
u_int32_t oldsn = dtosn(fs, daddr);
|
|
|
|
#ifdef DIAGNOSTIC
|
2003-11-07 20:55:29 +03:00
|
|
|
int ndupino;
|
|
|
|
|
|
|
|
if (sp && sp->seg_number == oldsn) {
|
|
|
|
ndupino = sp->ndupino;
|
|
|
|
} else {
|
|
|
|
ndupino = 0;
|
|
|
|
}
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
#endif
|
2006-09-02 10:46:04 +04:00
|
|
|
KASSERT(oldsn < fs->lfs_nseg);
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
if (lbn >= 0 && lbn < NDADDR)
|
|
|
|
osize = ip->i_lfs_fragsize[lbn];
|
|
|
|
else
|
|
|
|
osize = fs->lfs_bsize;
|
|
|
|
LFS_SEGENTRY(sup, fs, oldsn, bp);
|
|
|
|
#ifdef DIAGNOSTIC
|
2003-04-02 14:39:19 +04:00
|
|
|
if (sup->su_nbytes + sizeof (struct ufs1_dinode) * ndupino
|
|
|
|
< osize) {
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
printf("lfs_updatemeta: negative bytes "
|
|
|
|
"(segment %" PRIu32 " short by %" PRId64
|
|
|
|
")\n", dtosn(fs, daddr),
|
|
|
|
(int64_t)osize -
|
2003-11-07 20:55:29 +03:00
|
|
|
(sizeof (struct ufs1_dinode) * ndupino +
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
sup->su_nbytes));
|
2005-08-19 06:04:03 +04:00
|
|
|
printf("lfs_updatemeta: ino %llu, lbn %" PRId64
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
", addr = 0x%" PRIx64 "\n",
|
2005-08-19 06:04:03 +04:00
|
|
|
(unsigned long long)ip->i_number, lbn, daddr);
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
printf("lfs_updatemeta: ndupino=%d\n", ndupino);
|
|
|
|
panic("lfs_updatemeta: negative bytes");
|
2003-04-02 14:39:19 +04:00
|
|
|
sup->su_nbytes = osize -
|
2003-11-07 20:55:29 +03:00
|
|
|
sizeof (struct ufs1_dinode) * ndupino;
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
}
|
|
|
|
#endif
|
2005-03-08 03:18:19 +03:00
|
|
|
DLOG((DLOG_SU, "seg %" PRIu32 " -= %d for ino %d lbn %" PRId64
|
|
|
|
" db 0x%" PRIx64 "\n",
|
|
|
|
dtosn(fs, daddr), osize,
|
|
|
|
ip->i_number, lbn, daddr));
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
sup->su_nbytes -= osize;
|
2005-04-02 01:59:46 +04:00
|
|
|
if (!(bp->b_flags & B_GATHERED)) {
|
|
|
|
simple_lock(&fs->lfs_interlock);
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
fs->lfs_flags |= LFS_IFDIRTY;
|
2005-04-02 01:59:46 +04:00
|
|
|
simple_unlock(&fs->lfs_interlock);
|
|
|
|
}
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
LFS_WRITESEGENTRY(sup, fs, oldsn, bp);
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Now that this block has a new address, and its old
|
|
|
|
* segment no longer owns it, we can forget about its
|
|
|
|
* old size.
|
|
|
|
*/
|
|
|
|
if (lbn >= 0 && lbn < NDADDR)
|
|
|
|
ip->i_lfs_fragsize[lbn] = size;
|
|
|
|
}
|
|
|
|
|
1994-06-08 15:41:58 +04:00
|
|
|
/*
|
|
|
|
* Update the metadata that points to the blocks listed in the FINFO
|
|
|
|
* array.
|
|
|
|
*/
|
|
|
|
void
|
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_updatemeta(struct segment *sp)
|
1994-06-08 15:41:58 +04:00
|
|
|
{
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
struct buf *sbp;
|
1994-06-08 15:41:58 +04:00
|
|
|
struct lfs *fs;
|
|
|
|
struct vnode *vp;
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
daddr_t lbn;
|
|
|
|
int i, nblocks, num;
|
|
|
|
int bb;
|
|
|
|
int bytesleft, size;
|
2005-02-27 01:31:44 +03:00
|
|
|
|
2005-04-02 01:59:46 +04:00
|
|
|
ASSERT_SEGLOCK(sp->fs);
|
1994-06-08 15:41:58 +04:00
|
|
|
vp = sp->vp;
|
|
|
|
nblocks = &sp->fip->fi_blocks[sp->fip->fi_nblocks] - sp->start_lbp;
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
KASSERT(nblocks >= 0);
|
2003-10-18 19:52:42 +04:00
|
|
|
KASSERT(vp != NULL);
|
|
|
|
if (nblocks == 0)
|
1994-06-08 15:41:58 +04:00
|
|
|
return;
|
2003-02-23 03:22:33 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* This count may be high due to oversize blocks from lfs_gop_write.
|
|
|
|
* Correct for this. (XXX we should be able to keep track of these.)
|
|
|
|
*/
|
|
|
|
fs = sp->fs;
|
|
|
|
for (i = 0; i < nblocks; i++) {
|
|
|
|
if (sp->start_bpp[i] == NULL) {
|
2005-03-08 03:18:19 +03:00
|
|
|
DLOG((DLOG_SEG, "lfs_updatemeta: nblocks = %d, not %d\n", i, nblocks));
|
2003-02-23 03:22:33 +03:00
|
|
|
nblocks = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
num = howmany(sp->start_bpp[i]->b_bcount, fs->lfs_bsize);
|
2003-04-01 18:58:43 +04:00
|
|
|
KASSERT(sp->start_bpp[i]->b_lblkno >= 0 || num == 1);
|
2003-02-23 03:22:33 +03:00
|
|
|
nblocks -= num - 1;
|
|
|
|
}
|
2003-04-01 18:58:43 +04:00
|
|
|
|
|
|
|
KASSERT(vp->v_type == VREG ||
|
|
|
|
nblocks == &sp->fip->fi_blocks[sp->fip->fi_nblocks] - sp->start_lbp);
|
|
|
|
KASSERT(nblocks == sp->cbpp - sp->start_bpp);
|
2005-02-27 01:31:44 +03:00
|
|
|
|
1999-03-10 03:20:00 +03:00
|
|
|
/*
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
* Sort the blocks.
|
|
|
|
*
|
|
|
|
* We have to sort even if the blocks come from the
|
1999-03-10 03:20:00 +03:00
|
|
|
* cleaner, because there might be other pending blocks on the
|
|
|
|
* same inode...and if we don't sort, and there are fragments
|
|
|
|
* present, blocks may be written in the wrong place.
|
|
|
|
*/
|
2003-02-23 03:22:33 +03:00
|
|
|
lfs_shellsort(sp->start_bpp, sp->start_lbp, nblocks, fs->lfs_bsize);
|
2005-02-27 01:31:44 +03:00
|
|
|
|
1998-03-01 05:20:01 +03:00
|
|
|
/*
|
|
|
|
* Record the length of the last block in case it's a fragment.
|
|
|
|
* If there are indirect blocks present, they sort last. An
|
|
|
|
* indirect block will be lfs_bsize and its presence indicates
|
|
|
|
* that you cannot have fragments.
|
2002-07-06 05:30:11 +04:00
|
|
|
*
|
|
|
|
* XXX This last is a lie. A cleaned fragment can coexist with
|
2003-02-20 07:27:23 +03:00
|
|
|
* XXX a later indirect block. This will continue to be
|
2002-07-06 05:30:11 +04:00
|
|
|
* XXX true until lfs_markv is fixed to do everything with
|
|
|
|
* XXX fake blocks (including fake inodes and fake indirect blocks).
|
1998-03-01 05:20:01 +03:00
|
|
|
*/
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
sp->fip->fi_lastlength = ((sp->start_bpp[nblocks - 1]->b_bcount - 1) &
|
|
|
|
fs->lfs_bmask) + 1;
|
2005-02-27 01:31:44 +03:00
|
|
|
|
1994-06-08 15:41:58 +04:00
|
|
|
/*
|
|
|
|
* Assign disk addresses, and update references to the logical
|
|
|
|
* block and the segment usage information.
|
|
|
|
*/
|
|
|
|
for (i = nblocks; i--; ++sp->start_bpp) {
|
2002-07-06 05:30:11 +04:00
|
|
|
sbp = *sp->start_bpp;
|
2003-02-23 03:22:33 +03:00
|
|
|
lbn = *sp->start_lbp;
|
2003-04-01 18:58:43 +04:00
|
|
|
KASSERT(sbp->b_lblkno == lbn);
|
2003-02-23 03:22:33 +03:00
|
|
|
|
2002-07-06 05:30:11 +04:00
|
|
|
sbp->b_blkno = fsbtodb(fs, fs->lfs_offset);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If we write a frag in the wrong place, the cleaner won't
|
|
|
|
* be able to correctly identify its size later, and the
|
2003-02-20 07:27:23 +03:00
|
|
|
* segment will be uncleanable. (Even worse, it will assume
|
2002-07-06 05:30:11 +04:00
|
|
|
* that the indirect block that actually ends the list
|
|
|
|
* is of a smaller size!)
|
|
|
|
*/
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
if ((sbp->b_bcount & fs->lfs_bmask) && i != 0)
|
2002-09-27 19:35:29 +04:00
|
|
|
panic("lfs_updatemeta: fragment is not last block");
|
2003-04-02 14:39:19 +04:00
|
|
|
|
2002-07-06 05:30:11 +04:00
|
|
|
/*
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
* For each subblock in this possibly oversized block,
|
|
|
|
* update its address on disk.
|
2002-07-06 05:30:11 +04:00
|
|
|
*/
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
KASSERT(lbn >= 0 || sbp->b_bcount == fs->lfs_bsize);
|
2003-10-18 19:52:42 +04:00
|
|
|
KASSERT(vp == sbp->b_vp);
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
for (bytesleft = sbp->b_bcount; bytesleft > 0;
|
|
|
|
bytesleft -= fs->lfs_bsize) {
|
|
|
|
size = MIN(bytesleft, fs->lfs_bsize);
|
|
|
|
bb = fragstofsb(fs, numfrags(fs, size));
|
2003-02-23 03:22:33 +03:00
|
|
|
lbn = *sp->start_lbp++;
|
2003-11-07 20:55:29 +03:00
|
|
|
lfs_update_single(fs, sp, sp->vp, lbn, fs->lfs_offset,
|
|
|
|
size);
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
fs->lfs_offset += bb;
|
1994-06-08 15:41:58 +04:00
|
|
|
}
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
|
1994-06-08 15:41:58 +04:00
|
|
|
}
|
Install a new sysctl, vfs.lfs.ignore_lazy_sync, which causes LFS to ignore
the "smooth" syncer, as if vfs.sync.*delay = 0, but only for LFS. The
default is "on", i.e., ignore lazy sync.
Reduce the amount of polling/busy-waiting done by lfs_putpages(). To
accomplish this, copied genfs_putpages() and modified it to indicate which
page it was that caused it to return with EDEADLK. fsync()/fdatasync()
should no longer ever fail with EAGAIN, and should not consume huge
quantities of cpu.
Also, try to make dirops less likely to be written as the result of a
VOP_PUTPAGES(), while ensuring that they are written regularly.
2007-04-17 05:16:46 +04:00
|
|
|
|
|
|
|
/* This inode has been modified */
|
|
|
|
LFS_SET_UINO(VTOI(vp), IN_MODIFIED);
|
1994-06-08 15:41:58 +04:00
|
|
|
}
|
|
|
|
|
2005-04-23 23:47:51 +04:00
|
|
|
/*
|
|
|
|
* Move lfs_offset to a segment earlier than sn.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
lfs_rewind(struct lfs *fs, int newsn)
|
|
|
|
{
|
|
|
|
int sn, osn, isdirty;
|
|
|
|
struct buf *bp;
|
|
|
|
SEGUSE *sup;
|
|
|
|
|
|
|
|
ASSERT_SEGLOCK(fs);
|
|
|
|
|
|
|
|
osn = dtosn(fs, fs->lfs_offset);
|
|
|
|
if (osn < newsn)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* lfs_avail eats the remaining space in this segment */
|
|
|
|
fs->lfs_avail -= fs->lfs_fsbpseg - (fs->lfs_offset - fs->lfs_curseg);
|
|
|
|
|
|
|
|
/* Find a low-numbered segment */
|
|
|
|
for (sn = 0; sn < fs->lfs_nseg; ++sn) {
|
|
|
|
LFS_SEGENTRY(sup, fs, sn, bp);
|
|
|
|
isdirty = sup->su_flags & SEGUSE_DIRTY;
|
|
|
|
brelse(bp);
|
|
|
|
|
|
|
|
if (!isdirty)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (sn == fs->lfs_nseg)
|
|
|
|
panic("lfs_rewind: no clean segments");
|
2006-06-24 09:28:54 +04:00
|
|
|
if (newsn >= 0 && sn >= newsn)
|
2005-04-23 23:47:51 +04:00
|
|
|
return ENOENT;
|
|
|
|
fs->lfs_nextseg = sn;
|
|
|
|
lfs_newseg(fs);
|
|
|
|
fs->lfs_offset = fs->lfs_curseg;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1994-06-08 15:41:58 +04:00
|
|
|
/*
|
2003-10-17 18:20:12 +04:00
|
|
|
* Start a new partial segment.
|
|
|
|
*
|
|
|
|
* Return 1 when we entered to a new segment.
|
|
|
|
* Otherwise, 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_initseg(struct lfs *fs)
|
1994-06-08 15:41:58 +04:00
|
|
|
{
|
2003-10-17 18:20:12 +04:00
|
|
|
struct segment *sp = fs->lfs_sp;
|
1994-06-08 15:41:58 +04:00
|
|
|
SEGSUM *ssp;
|
2003-10-17 18:20:12 +04:00
|
|
|
struct buf *sbp; /* buffer for SEGSUM */
|
|
|
|
int repeat = 0; /* return value */
|
2003-03-08 05:55:47 +03:00
|
|
|
|
2005-04-02 01:59:46 +04:00
|
|
|
ASSERT_SEGLOCK(fs);
|
1994-06-08 15:41:58 +04:00
|
|
|
/* Advance to the next segment. */
|
|
|
|
if (!LFS_PARTIAL_FITS(fs)) {
|
2003-10-17 18:20:12 +04:00
|
|
|
SEGUSE *sup;
|
|
|
|
struct buf *bp;
|
|
|
|
|
2000-07-05 02:30:37 +04:00
|
|
|
/* lfs_avail eats the remaining space */
|
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 -= fs->lfs_fsbpseg - (fs->lfs_offset -
|
2000-07-05 02:30:37 +04:00
|
|
|
fs->lfs_curseg);
|
1994-06-08 15:41:58 +04:00
|
|
|
/* Wake up any cleaning procs waiting on this file system. */
|
2006-06-29 23:28:21 +04:00
|
|
|
lfs_wakeup_cleaner(fs);
|
1994-06-08 15:41:58 +04:00
|
|
|
lfs_newseg(fs);
|
|
|
|
repeat = 1;
|
|
|
|
fs->lfs_offset = fs->lfs_curseg;
|
2005-02-27 01:31:44 +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
|
|
|
sp->seg_number = dtosn(fs, fs->lfs_curseg);
|
|
|
|
sp->seg_bytes_left = fsbtob(fs, fs->lfs_fsbpseg);
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
|
1994-06-08 15:41:58 +04:00
|
|
|
/*
|
|
|
|
* If the segment contains a superblock, update the offset
|
|
|
|
* and summary address to skip over it.
|
|
|
|
*/
|
|
|
|
LFS_SEGENTRY(sup, fs, sp->seg_number, bp);
|
|
|
|
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_offset += btofsb(fs, LFS_SBPAD);
|
1994-06-08 15:41:58 +04:00
|
|
|
sp->seg_bytes_left -= LFS_SBPAD;
|
|
|
|
}
|
|
|
|
brelse(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
|
|
|
/* Segment zero could also contain the labelpad */
|
|
|
|
if (fs->lfs_version > 1 && sp->seg_number == 0 &&
|
|
|
|
fs->lfs_start < btofsb(fs, LFS_LABELPAD)) {
|
2003-07-12 20:17:52 +04:00
|
|
|
fs->lfs_offset +=
|
|
|
|
btofsb(fs, LFS_LABELPAD) - fs->lfs_start;
|
|
|
|
sp->seg_bytes_left -=
|
|
|
|
LFS_LABELPAD - fsbtob(fs, fs->lfs_start);
|
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
|
|
|
}
|
1994-06-08 15:41:58 +04: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
|
|
|
sp->seg_number = dtosn(fs, fs->lfs_curseg);
|
|
|
|
sp->seg_bytes_left = fsbtob(fs, fs->lfs_fsbpseg -
|
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_offset - fs->lfs_curseg));
|
1994-06-08 15:41:58 +04:00
|
|
|
}
|
|
|
|
fs->lfs_lastpseg = fs->lfs_offset;
|
2005-02-27 01:31:44 +03:00
|
|
|
|
2003-03-08 05:55:47 +03:00
|
|
|
/* Record first address of this partial segment */
|
|
|
|
if (sp->seg_flags & SEGM_CLEAN) {
|
|
|
|
fs->lfs_cleanint[fs->lfs_cleanind] = fs->lfs_offset;
|
|
|
|
if (++fs->lfs_cleanind >= LFS_MAX_CLEANIND) {
|
|
|
|
/* "1" is the artificial inc in lfs_seglock */
|
2005-04-02 01:59:46 +04:00
|
|
|
simple_lock(&fs->lfs_interlock);
|
2003-03-08 05:55:47 +03:00
|
|
|
while (fs->lfs_iocount > 1) {
|
2005-04-02 01:59:46 +04:00
|
|
|
ltsleep(&fs->lfs_iocount, PRIBIO + 1,
|
|
|
|
"lfs_initseg", 0, &fs->lfs_interlock);
|
2003-03-08 05:55:47 +03:00
|
|
|
}
|
2005-04-02 01:59:46 +04:00
|
|
|
simple_unlock(&fs->lfs_interlock);
|
2003-03-08 05:55:47 +03:00
|
|
|
fs->lfs_cleanind = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1994-06-08 15:41:58 +04:00
|
|
|
sp->fs = fs;
|
|
|
|
sp->ibp = NULL;
|
1999-06-16 02:25:41 +04:00
|
|
|
sp->idp = NULL;
|
1994-06-08 15:41:58 +04:00
|
|
|
sp->ninodes = 0;
|
2002-07-06 05:30:11 +04:00
|
|
|
sp->ndupino = 0;
|
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
|
|
|
|
1994-06-08 15:41:58 +04:00
|
|
|
sp->cbpp = sp->bpp;
|
2003-10-17 18:20:12 +04:00
|
|
|
|
|
|
|
/* Get a new buffer for SEGSUM */
|
2003-12-17 10:14:03 +03:00
|
|
|
sbp = lfs_newbuf(fs, VTOI(fs->lfs_ivnode)->i_devvp,
|
2003-07-12 20:17:52 +04:00
|
|
|
fsbtodb(fs, fs->lfs_offset), fs->lfs_sumsize, LFS_NB_SUMMARY);
|
2003-10-17 18:20:12 +04:00
|
|
|
|
|
|
|
/* ... and enter it into the buffer list. */
|
|
|
|
*sp->cbpp = sbp;
|
|
|
|
sp->cbpp++;
|
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_offset += btofsb(fs, fs->lfs_sumsize);
|
2003-10-17 18:20:12 +04:00
|
|
|
|
|
|
|
sp->start_bpp = sp->cbpp;
|
2005-02-27 01:31:44 +03:00
|
|
|
|
1994-06-08 15:41:58 +04:00
|
|
|
/* Set point to SEGSUM, initialize it. */
|
2003-10-17 18:20:12 +04:00
|
|
|
ssp = sp->segsum = sbp->b_data;
|
|
|
|
memset(ssp, 0, fs->lfs_sumsize);
|
1994-06-08 15:41:58 +04:00
|
|
|
ssp->ss_next = fs->lfs_nextseg;
|
|
|
|
ssp->ss_nfinfo = ssp->ss_ninos = 0;
|
1998-03-01 05:20:01 +03:00
|
|
|
ssp->ss_magic = SS_MAGIC;
|
1994-06-08 15:41:58 +04:00
|
|
|
|
|
|
|
/* Set pointer to first FINFO, initialize it. */
|
2007-03-04 08:59:00 +03:00
|
|
|
sp->fip = (struct finfo *)((char *)sp->segsum + SEGSUM_SIZE(fs));
|
1994-06-08 15:41:58 +04:00
|
|
|
sp->fip->fi_nblocks = 0;
|
|
|
|
sp->start_lbp = &sp->fip->fi_blocks[0];
|
1998-03-01 05:20:01 +03:00
|
|
|
sp->fip->fi_lastlength = 0;
|
2005-02-27 01:31:44 +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
|
|
|
sp->seg_bytes_left -= fs->lfs_sumsize;
|
|
|
|
sp->sum_bytes_left = fs->lfs_sumsize - SEGSUM_SIZE(fs);
|
2003-02-23 03:22:33 +03:00
|
|
|
|
2001-11-24 00:44:25 +03:00
|
|
|
return (repeat);
|
1994-06-08 15:41:58 +04:00
|
|
|
}
|
|
|
|
|
2005-04-23 23:47:51 +04:00
|
|
|
/*
|
|
|
|
* Remove SEGUSE_INVAL from all segments.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
lfs_unset_inval_all(struct lfs *fs)
|
|
|
|
{
|
|
|
|
SEGUSE *sup;
|
|
|
|
struct buf *bp;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < fs->lfs_nseg; i++) {
|
|
|
|
LFS_SEGENTRY(sup, fs, i, bp);
|
|
|
|
if (sup->su_flags & SEGUSE_INVAL) {
|
|
|
|
sup->su_flags &= ~SEGUSE_INVAL;
|
Changes to help the roll-forward agent, to wit:
* Mark being-deleted files in the Ifile so we can finish deleting them
at fs mount time.
* Flag the Ifile with "cleaner must clean" when writers are waiting for
the cleaner, rather than relying solely on the cleaner's estimation of
whether it should clean or not.
* Note partial segments written by a user agent (in particular,
fsck_lfs) so that repeated rolls forward don't interfere with one
another.
* Add a new fcntl, LFCNPASS, that allows the log to wrap exactly once,
for better testing of the validity of checkpoints.
* Keep track of the on-disk nlink count when cleaning, so that we don't
partially complete directory operations while cleaning.
* Ensure that every single Ifile inode write represents a consistent
view of the filesystem. In particular, the accounting for the segment
we are writing the inode into must be correct, and the accounting for
the segment that inode used to reside in must be correct. Rather than
just rewriting the inode if we wrote it wrong, rewrite the necessary
ifile blocks before writing the inode so we never write it wrong.
* Don't unmark any VDIROP vnodes if we haven't written them to disk,
avoiding yet another problem with the "wait for the cleaner" error
return from lfs_putpages().
Also, move the last callback to an aiodone call, so we no longer do any
memory management from interrupt context.
2006-09-01 23:41:28 +04:00
|
|
|
LFS_WRITESEGENTRY(sup, fs, i, bp);
|
2005-04-23 23:47:51 +04:00
|
|
|
} else
|
|
|
|
brelse(bp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1994-06-08 15:41:58 +04:00
|
|
|
/*
|
|
|
|
* Return the next segment to write.
|
|
|
|
*/
|
|
|
|
void
|
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_newseg(struct lfs *fs)
|
1994-06-08 15:41:58 +04:00
|
|
|
{
|
|
|
|
CLEANERINFO *cip;
|
|
|
|
SEGUSE *sup;
|
|
|
|
struct buf *bp;
|
2005-04-23 23:47:51 +04:00
|
|
|
int curseg, isdirty, sn, skip_inval;
|
2005-02-27 01:31:44 +03:00
|
|
|
|
2005-04-02 01:59:46 +04:00
|
|
|
ASSERT_SEGLOCK(fs);
|
2006-04-22 04:10:54 +04:00
|
|
|
|
|
|
|
/* Honor LFCNWRAPSTOP */
|
|
|
|
simple_lock(&fs->lfs_interlock);
|
Changes to help the roll-forward agent, to wit:
* Mark being-deleted files in the Ifile so we can finish deleting them
at fs mount time.
* Flag the Ifile with "cleaner must clean" when writers are waiting for
the cleaner, rather than relying solely on the cleaner's estimation of
whether it should clean or not.
* Note partial segments written by a user agent (in particular,
fsck_lfs) so that repeated rolls forward don't interfere with one
another.
* Add a new fcntl, LFCNPASS, that allows the log to wrap exactly once,
for better testing of the validity of checkpoints.
* Keep track of the on-disk nlink count when cleaning, so that we don't
partially complete directory operations while cleaning.
* Ensure that every single Ifile inode write represents a consistent
view of the filesystem. In particular, the accounting for the segment
we are writing the inode into must be correct, and the accounting for
the segment that inode used to reside in must be correct. Rather than
just rewriting the inode if we wrote it wrong, rewrite the necessary
ifile blocks before writing the inode so we never write it wrong.
* Don't unmark any VDIROP vnodes if we haven't written them to disk,
avoiding yet another problem with the "wait for the cleaner" error
return from lfs_putpages().
Also, move the last callback to an aiodone call, so we no longer do any
memory management from interrupt context.
2006-09-01 23:41:28 +04:00
|
|
|
while (fs->lfs_nextseg < fs->lfs_curseg && fs->lfs_nowrap) {
|
|
|
|
if (fs->lfs_wrappass) {
|
|
|
|
log(LOG_NOTICE, "%s: wrappass=%d\n",
|
|
|
|
fs->lfs_fsmnt, fs->lfs_wrappass);
|
|
|
|
fs->lfs_wrappass = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
fs->lfs_wrapstatus = LFS_WRAP_WAITING;
|
2006-04-22 04:10:54 +04:00
|
|
|
wakeup(&fs->lfs_nowrap);
|
Changes to help the roll-forward agent, to wit:
* Mark being-deleted files in the Ifile so we can finish deleting them
at fs mount time.
* Flag the Ifile with "cleaner must clean" when writers are waiting for
the cleaner, rather than relying solely on the cleaner's estimation of
whether it should clean or not.
* Note partial segments written by a user agent (in particular,
fsck_lfs) so that repeated rolls forward don't interfere with one
another.
* Add a new fcntl, LFCNPASS, that allows the log to wrap exactly once,
for better testing of the validity of checkpoints.
* Keep track of the on-disk nlink count when cleaning, so that we don't
partially complete directory operations while cleaning.
* Ensure that every single Ifile inode write represents a consistent
view of the filesystem. In particular, the accounting for the segment
we are writing the inode into must be correct, and the accounting for
the segment that inode used to reside in must be correct. Rather than
just rewriting the inode if we wrote it wrong, rewrite the necessary
ifile blocks before writing the inode so we never write it wrong.
* Don't unmark any VDIROP vnodes if we haven't written them to disk,
avoiding yet another problem with the "wait for the cleaner" error
return from lfs_putpages().
Also, move the last callback to an aiodone call, so we no longer do any
memory management from interrupt context.
2006-09-01 23:41:28 +04:00
|
|
|
log(LOG_NOTICE, "%s: waiting at log wrap\n", fs->lfs_fsmnt);
|
|
|
|
ltsleep(&fs->lfs_wrappass, PVFS, "newseg", 10 * hz,
|
2006-04-22 04:10:54 +04:00
|
|
|
&fs->lfs_interlock);
|
|
|
|
}
|
Changes to help the roll-forward agent, to wit:
* Mark being-deleted files in the Ifile so we can finish deleting them
at fs mount time.
* Flag the Ifile with "cleaner must clean" when writers are waiting for
the cleaner, rather than relying solely on the cleaner's estimation of
whether it should clean or not.
* Note partial segments written by a user agent (in particular,
fsck_lfs) so that repeated rolls forward don't interfere with one
another.
* Add a new fcntl, LFCNPASS, that allows the log to wrap exactly once,
for better testing of the validity of checkpoints.
* Keep track of the on-disk nlink count when cleaning, so that we don't
partially complete directory operations while cleaning.
* Ensure that every single Ifile inode write represents a consistent
view of the filesystem. In particular, the accounting for the segment
we are writing the inode into must be correct, and the accounting for
the segment that inode used to reside in must be correct. Rather than
just rewriting the inode if we wrote it wrong, rewrite the necessary
ifile blocks before writing the inode so we never write it wrong.
* Don't unmark any VDIROP vnodes if we haven't written them to disk,
avoiding yet another problem with the "wait for the cleaner" error
return from lfs_putpages().
Also, move the last callback to an aiodone call, so we no longer do any
memory management from interrupt context.
2006-09-01 23:41:28 +04:00
|
|
|
fs->lfs_wrapstatus = LFS_WRAP_GOING;
|
2006-04-22 04:10:54 +04:00
|
|
|
simple_unlock(&fs->lfs_interlock);
|
|
|
|
|
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_SEGENTRY(sup, fs, dtosn(fs, fs->lfs_nextseg), bp);
|
2005-03-08 03:18:19 +03:00
|
|
|
DLOG((DLOG_SU, "lfs_newseg: seg %d := 0 in newseg\n",
|
|
|
|
dtosn(fs, fs->lfs_nextseg)));
|
1999-03-10 03:20:00 +03:00
|
|
|
sup->su_flags |= SEGUSE_DIRTY | SEGUSE_ACTIVE;
|
1994-06-08 15:41:58 +04:00
|
|
|
sup->su_nbytes = 0;
|
|
|
|
sup->su_nsums = 0;
|
|
|
|
sup->su_ninos = 0;
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
LFS_WRITESEGENTRY(sup, fs, dtosn(fs, fs->lfs_nextseg), 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;
|
2000-11-12 10:58:36 +03:00
|
|
|
LFS_SYNC_CLEANERINFO(cip, fs, bp, 1);
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
|
1994-06-08 15:41:58 +04:00
|
|
|
fs->lfs_lastseg = fs->lfs_curseg;
|
|
|
|
fs->lfs_curseg = fs->lfs_nextseg;
|
2005-04-23 23:47:51 +04:00
|
|
|
skip_inval = 1;
|
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 (sn = curseg = dtosn(fs, fs->lfs_curseg) + fs->lfs_interleave;;) {
|
1994-06-08 15:41:58 +04:00
|
|
|
sn = (sn + 1) % fs->lfs_nseg;
|
2006-04-18 00:02:34 +04:00
|
|
|
|
2005-04-23 23:47:51 +04:00
|
|
|
if (sn == curseg) {
|
|
|
|
if (skip_inval)
|
|
|
|
skip_inval = 0;
|
|
|
|
else
|
|
|
|
panic("lfs_nextseg: no clean segments");
|
|
|
|
}
|
1994-06-08 15:41:58 +04:00
|
|
|
LFS_SEGENTRY(sup, fs, sn, bp);
|
2005-04-23 23:47:51 +04:00
|
|
|
isdirty = sup->su_flags & (SEGUSE_DIRTY | (skip_inval ? SEGUSE_INVAL : 0));
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
/* Check SEGUSE_EMPTY as we go along */
|
2003-07-12 20:17:52 +04:00
|
|
|
if (isdirty && sup->su_nbytes == 0 &&
|
|
|
|
!(sup->su_flags & SEGUSE_EMPTY))
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
LFS_WRITESEGENTRY(sup, fs, sn, bp);
|
|
|
|
else
|
|
|
|
brelse(bp);
|
|
|
|
|
1994-06-08 15:41:58 +04:00
|
|
|
if (!isdirty)
|
|
|
|
break;
|
|
|
|
}
|
2005-04-23 23:47:51 +04:00
|
|
|
if (skip_inval == 0)
|
|
|
|
lfs_unset_inval_all(fs);
|
2005-02-27 01:31:44 +03:00
|
|
|
|
1994-06-08 15:41:58 +04:00
|
|
|
++fs->lfs_nactive;
|
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_nextseg = sntod(fs, sn);
|
2001-11-24 00:44:25 +03:00
|
|
|
if (lfs_dostats) {
|
1999-03-10 03:20:00 +03:00
|
|
|
++lfs_stats.segsused;
|
|
|
|
}
|
1994-06-08 15:41:58 +04:00
|
|
|
}
|
|
|
|
|
2002-05-15 00:03:53 +04:00
|
|
|
static struct buf *
|
2006-10-12 05:30:41 +04:00
|
|
|
lfs_newclusterbuf(struct lfs *fs, struct vnode *vp, daddr_t addr,
|
2006-11-16 04:32:37 +03:00
|
|
|
int n)
|
2002-05-15 00:03:53 +04:00
|
|
|
{
|
|
|
|
struct lfs_cluster *cl;
|
|
|
|
struct buf **bpp, *bp;
|
|
|
|
|
2005-04-02 01:59:46 +04:00
|
|
|
ASSERT_SEGLOCK(fs);
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
cl = (struct lfs_cluster *)pool_get(&fs->lfs_clpool, PR_WAITOK);
|
|
|
|
bpp = (struct buf **)pool_get(&fs->lfs_bpppool, PR_WAITOK);
|
For synchronous writes, keep separate i/o counters for each write, so
processes don't have to wait for one another to finish (e.g., nfsd seems
to be a little happier now, though I haven't measured the difference).
Synchronous checkpoints, however, must always wait for all i/o to finish.
Take the contents of the callback functions and have them run in thread
context instead (aiodoned thread). lfs_iocount no longer has to be
protected in splbio(), and quite a bit less of the segment construction
loop needs to be in splbio() as well.
If lfs_markv is handed a block that is not the correct size according to
the inode, refuse to process it. (Formerly it was extended to the "correct"
size.) This is possibly more prone to deadlock, but less prone to corruption.
lfs_segclean now outright refuses to clean segments that appear to have live
bytes in them. Again this may be more prone to deadlock but avoids
corruption.
Replace ufsspec_close and ufsfifo_close with LFS equivalents; this means
that no UFS functions need to know about LFS_ITIMES any more. Remove
the reference from ufs/inode.h.
Tested on i386, test-compiled on alpha.
2002-06-16 04:13:15 +04:00
|
|
|
memset(cl, 0, sizeof(*cl));
|
2002-05-15 00:03:53 +04:00
|
|
|
cl->fs = fs;
|
|
|
|
cl->bpp = bpp;
|
|
|
|
cl->bufcount = 0;
|
|
|
|
cl->bufsize = 0;
|
|
|
|
|
For synchronous writes, keep separate i/o counters for each write, so
processes don't have to wait for one another to finish (e.g., nfsd seems
to be a little happier now, though I haven't measured the difference).
Synchronous checkpoints, however, must always wait for all i/o to finish.
Take the contents of the callback functions and have them run in thread
context instead (aiodoned thread). lfs_iocount no longer has to be
protected in splbio(), and quite a bit less of the segment construction
loop needs to be in splbio() as well.
If lfs_markv is handed a block that is not the correct size according to
the inode, refuse to process it. (Formerly it was extended to the "correct"
size.) This is possibly more prone to deadlock, but less prone to corruption.
lfs_segclean now outright refuses to clean segments that appear to have live
bytes in them. Again this may be more prone to deadlock but avoids
corruption.
Replace ufsspec_close and ufsfifo_close with LFS equivalents; this means
that no UFS functions need to know about LFS_ITIMES any more. Remove
the reference from ufs/inode.h.
Tested on i386, test-compiled on alpha.
2002-06-16 04:13:15 +04:00
|
|
|
/* If this segment is being written synchronously, note that */
|
|
|
|
if (fs->lfs_sp->seg_flags & SEGM_SYNC) {
|
|
|
|
cl->flags |= LFS_CL_SYNC;
|
|
|
|
cl->seg = fs->lfs_sp;
|
|
|
|
++cl->seg->seg_iocount;
|
|
|
|
}
|
|
|
|
|
2002-05-15 00:03:53 +04:00
|
|
|
/* Get an empty buffer header, or maybe one with something on it */
|
2006-01-04 13:13:05 +03:00
|
|
|
bp = getiobuf();
|
2003-07-30 17:36:40 +04:00
|
|
|
bp->b_flags = B_BUSY | B_CALL;
|
|
|
|
bp->b_dev = NODEV;
|
|
|
|
bp->b_blkno = bp->b_lblkno = addr;
|
2002-05-15 00:03:53 +04:00
|
|
|
bp->b_iodone = lfs_cluster_callback;
|
2003-12-04 17:57:47 +03:00
|
|
|
bp->b_private = cl;
|
2003-07-30 17:36:40 +04:00
|
|
|
bp->b_vp = vp;
|
2002-05-15 00:03:53 +04:00
|
|
|
|
|
|
|
return bp;
|
|
|
|
}
|
|
|
|
|
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_writeseg(struct lfs *fs, struct segment *sp)
|
1994-06-08 15:41:58 +04:00
|
|
|
{
|
2003-03-11 05:47:39 +03:00
|
|
|
struct buf **bpp, *bp, *cbp, *newbp;
|
1994-06-08 15:41:58 +04:00
|
|
|
SEGUSE *sup;
|
|
|
|
SEGSUM *ssp;
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
int i, s;
|
|
|
|
int do_again, nblocks, byteoffset;
|
2001-07-27 00:20:15 +04:00
|
|
|
size_t el_size;
|
2003-02-20 07:27:23 +03:00
|
|
|
struct lfs_cluster *cl;
|
1994-06-08 15:41:58 +04:00
|
|
|
u_short ninos;
|
1999-03-10 03:20:00 +03:00
|
|
|
struct vnode *devvp;
|
2003-10-25 22:26:46 +04:00
|
|
|
char *p = 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
|
|
|
struct vnode *vp;
|
2003-01-25 00:55:02 +03:00
|
|
|
int32_t *daddrp; /* XXX ondisk32 */
|
2000-07-05 02:30:37 +04:00
|
|
|
int changed;
|
2004-03-09 10:43:49 +03:00
|
|
|
u_int32_t sum;
|
2006-05-19 03:15:09 +04:00
|
|
|
#ifdef DEBUG
|
|
|
|
FINFO *fip;
|
|
|
|
int findex;
|
|
|
|
#endif
|
2002-05-15 00:03:53 +04:00
|
|
|
|
2005-04-02 01:59:46 +04:00
|
|
|
ASSERT_SEGLOCK(fs);
|
2006-07-21 03:16:50 +04:00
|
|
|
|
Changes to help the roll-forward agent, to wit:
* Mark being-deleted files in the Ifile so we can finish deleting them
at fs mount time.
* Flag the Ifile with "cleaner must clean" when writers are waiting for
the cleaner, rather than relying solely on the cleaner's estimation of
whether it should clean or not.
* Note partial segments written by a user agent (in particular,
fsck_lfs) so that repeated rolls forward don't interfere with one
another.
* Add a new fcntl, LFCNPASS, that allows the log to wrap exactly once,
for better testing of the validity of checkpoints.
* Keep track of the on-disk nlink count when cleaning, so that we don't
partially complete directory operations while cleaning.
* Ensure that every single Ifile inode write represents a consistent
view of the filesystem. In particular, the accounting for the segment
we are writing the inode into must be correct, and the accounting for
the segment that inode used to reside in must be correct. Rather than
just rewriting the inode if we wrote it wrong, rewrite the necessary
ifile blocks before writing the inode so we never write it wrong.
* Don't unmark any VDIROP vnodes if we haven't written them to disk,
avoiding yet another problem with the "wait for the cleaner" error
return from lfs_putpages().
Also, move the last callback to an aiodone call, so we no longer do any
memory management from interrupt context.
2006-09-01 23:41:28 +04:00
|
|
|
ssp = (SEGSUM *)sp->segsum;
|
2006-07-21 03:16:50 +04:00
|
|
|
|
1994-06-08 15:41:58 +04:00
|
|
|
/*
|
Changes to help the roll-forward agent, to wit:
* Mark being-deleted files in the Ifile so we can finish deleting them
at fs mount time.
* Flag the Ifile with "cleaner must clean" when writers are waiting for
the cleaner, rather than relying solely on the cleaner's estimation of
whether it should clean or not.
* Note partial segments written by a user agent (in particular,
fsck_lfs) so that repeated rolls forward don't interfere with one
another.
* Add a new fcntl, LFCNPASS, that allows the log to wrap exactly once,
for better testing of the validity of checkpoints.
* Keep track of the on-disk nlink count when cleaning, so that we don't
partially complete directory operations while cleaning.
* Ensure that every single Ifile inode write represents a consistent
view of the filesystem. In particular, the accounting for the segment
we are writing the inode into must be correct, and the accounting for
the segment that inode used to reside in must be correct. Rather than
just rewriting the inode if we wrote it wrong, rewrite the necessary
ifile blocks before writing the inode so we never write it wrong.
* Don't unmark any VDIROP vnodes if we haven't written them to disk,
avoiding yet another problem with the "wait for the cleaner" error
return from lfs_putpages().
Also, move the last callback to an aiodone call, so we no longer do any
memory management from interrupt context.
2006-09-01 23:41:28 +04:00
|
|
|
* If there are no buffers other than the segment summary to write,
|
|
|
|
* don't do anything. If we are the end of a dirop sequence, however,
|
|
|
|
* write the empty segment summary anyway, to help out the
|
|
|
|
* roll-forward agent.
|
1994-06-08 15:41:58 +04:00
|
|
|
*/
|
Changes to help the roll-forward agent, to wit:
* Mark being-deleted files in the Ifile so we can finish deleting them
at fs mount time.
* Flag the Ifile with "cleaner must clean" when writers are waiting for
the cleaner, rather than relying solely on the cleaner's estimation of
whether it should clean or not.
* Note partial segments written by a user agent (in particular,
fsck_lfs) so that repeated rolls forward don't interfere with one
another.
* Add a new fcntl, LFCNPASS, that allows the log to wrap exactly once,
for better testing of the validity of checkpoints.
* Keep track of the on-disk nlink count when cleaning, so that we don't
partially complete directory operations while cleaning.
* Ensure that every single Ifile inode write represents a consistent
view of the filesystem. In particular, the accounting for the segment
we are writing the inode into must be correct, and the accounting for
the segment that inode used to reside in must be correct. Rather than
just rewriting the inode if we wrote it wrong, rewrite the necessary
ifile blocks before writing the inode so we never write it wrong.
* Don't unmark any VDIROP vnodes if we haven't written them to disk,
avoiding yet another problem with the "wait for the cleaner" error
return from lfs_putpages().
Also, move the last callback to an aiodone call, so we no longer do any
memory management from interrupt context.
2006-09-01 23:41:28 +04:00
|
|
|
if ((nblocks = sp->cbpp - sp->bpp) == 1) {
|
|
|
|
if ((ssp->ss_flags & (SS_DIROP | SS_CONT)) != SS_DIROP)
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Note if partial segment is being written by the cleaner */
|
|
|
|
if (sp->seg_flags & SEGM_CLEAN)
|
|
|
|
ssp->ss_flags |= SS_CLEAN;
|
2005-02-27 01:31:44 +03:00
|
|
|
|
1999-06-16 02:25:41 +04:00
|
|
|
devvp = VTOI(fs->lfs_ivnode)->i_devvp;
|
|
|
|
|
1994-06-08 15:41:58 +04:00
|
|
|
/* Update the segment usage information. */
|
|
|
|
LFS_SEGENTRY(sup, fs, sp->seg_number, bp);
|
2005-02-27 01:31:44 +03:00
|
|
|
|
1998-03-01 05:20:01 +03:00
|
|
|
/* Loop through all blocks, except the segment summary. */
|
1999-06-16 02:25:41 +04:00
|
|
|
for (bpp = sp->bpp; ++bpp < sp->cbpp; ) {
|
2001-11-24 00:44:25 +03:00
|
|
|
if ((*bpp)->b_vp != devvp) {
|
1999-06-16 02:25:41 +04:00
|
|
|
sup->su_nbytes += (*bpp)->b_bcount;
|
2005-03-08 03:18:19 +03:00
|
|
|
DLOG((DLOG_SU, "seg %" PRIu32 " += %ld for ino %d"
|
|
|
|
" lbn %" PRId64 " db 0x%" PRIx64 "\n",
|
|
|
|
sp->seg_number, (*bpp)->b_bcount,
|
|
|
|
VTOI((*bpp)->b_vp)->i_number, (*bpp)->b_lblkno,
|
|
|
|
(*bpp)->b_blkno));
|
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
|
|
|
}
|
1999-06-16 02:25:41 +04:00
|
|
|
}
|
2005-02-27 01:31:44 +03:00
|
|
|
|
2006-05-19 03:15:09 +04:00
|
|
|
#ifdef DEBUG
|
2006-05-20 05:10:18 +04:00
|
|
|
/* Check for zero-length and zero-version FINFO entries. */
|
2007-03-04 08:59:00 +03:00
|
|
|
fip = (struct finfo *)((char *)ssp + SEGSUM_SIZE(fs));
|
2006-05-19 03:15:09 +04:00
|
|
|
for (findex = 0; findex < ssp->ss_nfinfo; findex++) {
|
|
|
|
KDASSERT(fip->fi_nblocks > 0);
|
2006-05-20 05:10:18 +04:00
|
|
|
KDASSERT(fip->fi_version > 0);
|
2007-03-04 08:59:00 +03:00
|
|
|
fip = (FINFO *)((char *)fip + FINFOSIZE +
|
2006-05-19 03:15:09 +04:00
|
|
|
sizeof(int32_t) * fip->fi_nblocks);
|
|
|
|
}
|
|
|
|
#endif /* DEBUG */
|
|
|
|
|
1994-06-08 15:41:58 +04:00
|
|
|
ninos = (ssp->ss_ninos + INOPB(fs) - 1) / INOPB(fs);
|
2005-03-08 03:18:19 +03:00
|
|
|
DLOG((DLOG_SU, "seg %d += %d for %d inodes\n",
|
|
|
|
sp->seg_number, ssp->ss_ninos * sizeof (struct ufs1_dinode),
|
|
|
|
ssp->ss_ninos));
|
2003-04-02 14:39:19 +04:00
|
|
|
sup->su_nbytes += ssp->ss_ninos * sizeof (struct ufs1_dinode);
|
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
|
|
|
/* sup->su_nbytes += fs->lfs_sumsize; */
|
|
|
|
if (fs->lfs_version == 1)
|
2006-06-08 02:33:33 +04:00
|
|
|
sup->su_olastmod = time_second;
|
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
|
|
|
else
|
2006-06-08 02:33:33 +04:00
|
|
|
sup->su_lastmod = time_second;
|
1994-06-08 15:41:58 +04:00
|
|
|
sup->su_ninos += ninos;
|
|
|
|
++sup->su_nsums;
|
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, fs->lfs_sumsize);
|
1999-03-10 03:20:00 +03:00
|
|
|
|
1994-06-08 15:41:58 +04:00
|
|
|
do_again = !(bp->b_flags & B_GATHERED);
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
LFS_WRITESEGENTRY(sup, fs, sp->seg_number, bp); /* Ifile */
|
|
|
|
|
2000-07-03 05:45:46 +04:00
|
|
|
/*
|
|
|
|
* Mark blocks B_BUSY, to prevent then from being changed between
|
|
|
|
* the checksum computation and the actual write.
|
|
|
|
*
|
|
|
|
* If we are cleaning, check indirect blocks for UNWRITTEN, and if
|
|
|
|
* there are any, replace them with copies that have UNASSIGNED
|
|
|
|
* instead.
|
|
|
|
*/
|
|
|
|
for (bpp = sp->bpp, i = nblocks - 1; i--;) {
|
|
|
|
++bpp;
|
|
|
|
bp = *bpp;
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
if (bp->b_flags & B_CALL) { /* UBC or malloced buffer */
|
|
|
|
bp->b_flags |= B_BUSY;
|
|
|
|
continue;
|
|
|
|
}
|
2005-04-02 01:59:46 +04:00
|
|
|
|
|
|
|
simple_lock(&bp->b_interlock);
|
2000-07-03 05:45:46 +04:00
|
|
|
s = splbio();
|
2005-04-02 01:59:46 +04:00
|
|
|
while (bp->b_flags & B_BUSY) {
|
2005-03-08 03:18:19 +03:00
|
|
|
DLOG((DLOG_SEG, "lfs_writeseg: avoiding potential"
|
|
|
|
" data summary corruption for ino %d, lbn %"
|
|
|
|
PRId64 "\n",
|
|
|
|
VTOI(bp->b_vp)->i_number, bp->b_lblkno));
|
2000-07-03 05:45:46 +04:00
|
|
|
bp->b_flags |= B_WANTED;
|
2005-04-02 01:59:46 +04:00
|
|
|
ltsleep(bp, (PRIBIO + 1), "lfs_writeseg", 0,
|
|
|
|
&bp->b_interlock);
|
2000-07-03 05:45:46 +04:00
|
|
|
splx(s);
|
2005-04-02 01:59:46 +04:00
|
|
|
s = splbio();
|
2000-07-03 05:45:46 +04:00
|
|
|
}
|
|
|
|
bp->b_flags |= B_BUSY;
|
|
|
|
splx(s);
|
2005-04-02 01:59:46 +04:00
|
|
|
simple_unlock(&bp->b_interlock);
|
|
|
|
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
/*
|
|
|
|
* Check and replace indirect block UNWRITTEN bogosity.
|
|
|
|
* XXX See comment in lfs_writefile.
|
|
|
|
*/
|
2001-11-24 00:44:25 +03:00
|
|
|
if (bp->b_lblkno < 0 && bp->b_vp != devvp && bp->b_vp &&
|
2003-04-02 14:39:19 +04:00
|
|
|
VTOI(bp->b_vp)->i_ffs1_blocks !=
|
2000-07-03 05:45:46 +04:00
|
|
|
VTOI(bp->b_vp)->i_lfs_effnblks) {
|
2005-03-08 03:18:19 +03:00
|
|
|
DLOG((DLOG_VNODE, "lfs_writeseg: cleansing ino %d (%d != %d)\n",
|
|
|
|
VTOI(bp->b_vp)->i_number,
|
|
|
|
VTOI(bp->b_vp)->i_lfs_effnblks,
|
|
|
|
VTOI(bp->b_vp)->i_ffs1_blocks));
|
2000-07-03 05:45:46 +04:00
|
|
|
/* Make a copy we'll make changes to */
|
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
|
|
|
newbp = lfs_newbuf(fs, bp->b_vp, bp->b_lblkno,
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
bp->b_bcount, LFS_NB_IBLOCK);
|
2000-07-03 05:45:46 +04:00
|
|
|
newbp->b_blkno = bp->b_blkno;
|
|
|
|
memcpy(newbp->b_data, bp->b_data,
|
|
|
|
newbp->b_bcount);
|
|
|
|
|
2000-07-05 02:30:37 +04:00
|
|
|
changed = 0;
|
2003-01-25 00:55:02 +03:00
|
|
|
/* XXX ondisk32 */
|
|
|
|
for (daddrp = (int32_t *)(newbp->b_data);
|
2007-03-04 08:59:00 +03:00
|
|
|
daddrp < (int32_t *)((char *)newbp->b_data +
|
2000-07-03 05:45:46 +04:00
|
|
|
newbp->b_bcount); daddrp++) {
|
|
|
|
if (*daddrp == UNWRITTEN) {
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
++changed;
|
2000-07-03 05:45:46 +04:00
|
|
|
*daddrp = 0;
|
|
|
|
}
|
|
|
|
}
|
2000-07-05 02:30:37 +04:00
|
|
|
/*
|
|
|
|
* Get rid of the old buffer. Don't mark it clean,
|
|
|
|
* though, if it still has dirty data on it.
|
|
|
|
*/
|
|
|
|
if (changed) {
|
2005-03-08 03:18:19 +03:00
|
|
|
DLOG((DLOG_SEG, "lfs_writeseg: replacing UNWRITTEN(%d):"
|
|
|
|
" bp = %p newbp = %p\n", changed, bp,
|
|
|
|
newbp));
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
*bpp = newbp;
|
2003-04-23 11:20:37 +04:00
|
|
|
bp->b_flags &= ~(B_ERROR | B_GATHERED);
|
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 (bp->b_flags & B_CALL) {
|
2005-03-08 03:18:19 +03:00
|
|
|
DLOG((DLOG_SEG, "lfs_writeseg: "
|
|
|
|
"indir bp should not be B_CALL\n"));
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
s = splbio();
|
|
|
|
biodone(bp);
|
|
|
|
splx(s);
|
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 = NULL;
|
|
|
|
} else {
|
2000-09-09 08:13:43 +04:00
|
|
|
/* Still on free list, leave it there */
|
|
|
|
s = splbio();
|
|
|
|
bp->b_flags &= ~B_BUSY;
|
|
|
|
if (bp->b_flags & B_WANTED)
|
|
|
|
wakeup(bp);
|
2003-02-20 07:27:23 +03:00
|
|
|
splx(s);
|
2000-11-17 22:14:41 +03:00
|
|
|
/*
|
|
|
|
* We have to re-decrement lfs_avail
|
|
|
|
* since this block is going to come
|
|
|
|
* back around to us in the next
|
|
|
|
* segment.
|
|
|
|
*/
|
2003-07-12 20:17:52 +04:00
|
|
|
fs->lfs_avail -=
|
|
|
|
btofsb(fs, bp->b_bcount);
|
2000-09-09 08:13:43 +04:00
|
|
|
}
|
2000-07-05 02:30:37 +04:00
|
|
|
} else {
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
lfs_freebuf(fs, newbp);
|
2000-07-05 02:30:37 +04:00
|
|
|
}
|
2000-07-03 05:45:46 +04:00
|
|
|
}
|
|
|
|
}
|
1994-06-08 15:41:58 +04:00
|
|
|
/*
|
|
|
|
* Compute checksum across data and then across summary; the first
|
|
|
|
* block (the summary block) is skipped. Set the create time here
|
|
|
|
* so that it's guaranteed to be later than the inode mod times.
|
|
|
|
*/
|
2004-03-09 10:43:49 +03:00
|
|
|
sum = 0;
|
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 (fs->lfs_version == 1)
|
|
|
|
el_size = sizeof(u_long);
|
|
|
|
else
|
|
|
|
el_size = sizeof(u_int32_t);
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
for (bpp = sp->bpp, i = nblocks - 1; i--; ) {
|
|
|
|
++bpp;
|
|
|
|
/* Loop through gop_write cluster blocks */
|
|
|
|
for (byteoffset = 0; byteoffset < (*bpp)->b_bcount;
|
|
|
|
byteoffset += fs->lfs_bsize) {
|
2003-03-11 05:47:39 +03:00
|
|
|
#ifdef LFS_USE_B_INVAL
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
if (((*bpp)->b_flags & (B_CALL | B_INVAL)) ==
|
|
|
|
(B_CALL | B_INVAL)) {
|
2007-03-04 08:59:00 +03:00
|
|
|
if (copyin((void *)(*bpp)->b_saveaddr +
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
byteoffset, dp, el_size)) {
|
2003-07-12 20:17:52 +04:00
|
|
|
panic("lfs_writeseg: copyin failed [1]:"
|
|
|
|
" ino %d blk %" PRId64,
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
VTOI((*bpp)->b_vp)->i_number,
|
|
|
|
(*bpp)->b_lblkno);
|
|
|
|
}
|
2003-03-11 05:47:39 +03:00
|
|
|
} else
|
|
|
|
#endif /* LFS_USE_B_INVAL */
|
|
|
|
{
|
2007-03-04 08:59:00 +03:00
|
|
|
sum = lfs_cksum_part((char *)
|
2004-03-09 10:43:49 +03:00
|
|
|
(*bpp)->b_data + byteoffset, el_size, sum);
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +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 (fs->lfs_version == 1)
|
2006-06-08 02:33:33 +04:00
|
|
|
ssp->ss_ocreate = time_second;
|
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
|
|
|
else {
|
2006-06-08 02:33:33 +04:00
|
|
|
ssp->ss_create = time_second;
|
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
|
|
|
ssp->ss_serial = ++fs->lfs_serial;
|
|
|
|
ssp->ss_ident = fs->lfs_ident;
|
1994-06-08 15:41:58 +04:00
|
|
|
}
|
2004-03-09 10:43:49 +03:00
|
|
|
ssp->ss_datasum = lfs_cksum_fold(sum);
|
|
|
|
ssp->ss_sumsum = cksum(&ssp->ss_datasum,
|
|
|
|
fs->lfs_sumsize - sizeof(ssp->ss_sumsum));
|
Various minor LFS improvements:
* Note when lfs_putpages(9) thinks it is not going to be writing any
pages before calling genfs_putpages(9). This prevents a situation in
which blocks can be queued for writing without a segment header.
* Correct computation of NRESERVE(), though it is still a gross
overestimate in most cases. Note that if NRESERVE() is too high, it
may be impossible to create files on the filesystem. We catch this
case on filesystem mount and refuse to mount r/w.
* Allow filesystems to be mounted whose block size is == MAXBSIZE.
* Somewhere along the line, ufs_bmaparray(9) started mangling UNWRITTEN
entries in indirect blocks again, triggering a failed assertion "daddr
<= LFS_MAX_DADDR". Explicitly convert to and from int32_t to correct
this.
* Add a high-water mark for the number of dirty pages any given LFS can
hold before triggering a flush. This is settable by sysctl, but off
(zero) by default.
* Be more careful about the MAX_BYTES and MAX_BUFS computations so we
shouldn't see "please increase to at least zero" messages.
* Note that VBLK and VCHR vnodes can have nonzero values in di_db[0]
even though their v_size == 0. Don't panic when we see this.
* Change lfs_bfree to a signed quantity. The manner in which it is
processed before being passed to the cleaner means that sometimes it
may drop below zero, and the cleaner must be aware of this.
* Never report bfree < 0 (or higher than lfs_dsize) through
lfs_statvfs(9). This prevents df(1) from ever telling us that our full
filesystems have 16TB free.
* Account space allocated through lfs_balloc(9) that does not have
associated buffer headers, so that the pagedaemon doesn't run us out
of segments.
* Return ENOSPC from lfs_balloc(9) when bfree drops to zero.
* Address a deadlock in lfs_bmapv/lfs_markv when the filesystem is being
unmounted. Because vfs_busy() is a shared lock, and
lfs_bmapv/lfs_markv mark the filesystem vfs_busy(), the cleaner can be
holding the lock that umount() is blocking on, then try to vfs_busy()
again in getnewvnode().
2005-02-26 08:40:42 +03:00
|
|
|
|
2005-04-02 01:59:46 +04:00
|
|
|
simple_lock(&fs->lfs_interlock);
|
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_bfree -= (btofsb(fs, ninos * fs->lfs_ibsize) +
|
|
|
|
btofsb(fs, fs->lfs_sumsize));
|
2006-03-18 02:21:01 +03:00
|
|
|
fs->lfs_dmeta += (btofsb(fs, ninos * fs->lfs_ibsize) +
|
|
|
|
btofsb(fs, fs->lfs_sumsize));
|
2005-04-02 01:59:46 +04:00
|
|
|
simple_unlock(&fs->lfs_interlock);
|
1994-06-08 15:41:58 +04:00
|
|
|
|
|
|
|
/*
|
2003-02-20 07:27:23 +03:00
|
|
|
* When we simply write the blocks we lose a rotation for every block
|
2003-03-11 05:47:39 +03:00
|
|
|
* written. To avoid this problem, we cluster the buffers into a
|
|
|
|
* chunk and write the chunk. MAXPHYS is the largest size I/O
|
|
|
|
* devices can handle, use that for the size of the chunks.
|
2003-02-20 07:27:23 +03:00
|
|
|
*
|
2003-03-11 05:47:39 +03:00
|
|
|
* Blocks that are already clusters (from GOP_WRITE), however, we
|
|
|
|
* don't bother to copy into other clusters.
|
1994-06-08 15:41:58 +04:00
|
|
|
*/
|
1999-03-10 03:20:00 +03:00
|
|
|
|
|
|
|
#define CHUNKSIZE MAXPHYS
|
|
|
|
|
2001-11-24 00:44:25 +03:00
|
|
|
if (devvp == NULL)
|
1999-03-10 03:20:00 +03:00
|
|
|
panic("devvp is NULL");
|
2002-05-15 00:03:53 +04:00
|
|
|
for (bpp = sp->bpp, i = nblocks; i;) {
|
|
|
|
cbp = lfs_newclusterbuf(fs, devvp, (*bpp)->b_blkno, i);
|
2003-12-04 17:57:47 +03:00
|
|
|
cl = cbp->b_private;
|
2002-05-15 00:03:53 +04:00
|
|
|
|
1994-06-08 15:41:58 +04:00
|
|
|
cbp->b_flags |= B_ASYNC | B_BUSY;
|
1998-03-01 05:20:01 +03:00
|
|
|
cbp->b_bcount = 0;
|
1994-06-08 15:41:58 +04:00
|
|
|
|
2002-05-15 00:03:53 +04:00
|
|
|
#if defined(DEBUG) && defined(DIAGNOSTIC)
|
2003-02-23 03:22:33 +03:00
|
|
|
if (bpp - sp->bpp > (fs->lfs_sumsize - SEGSUM_SIZE(fs))
|
|
|
|
/ sizeof(int32_t)) {
|
|
|
|
panic("lfs_writeseg: real bpp overwrite");
|
|
|
|
}
|
2004-03-09 09:43:18 +03:00
|
|
|
if (bpp - sp->bpp > segsize(fs) / fs->lfs_fsize) {
|
2003-02-23 03:22:33 +03:00
|
|
|
panic("lfs_writeseg: theoretical bpp overwrite");
|
|
|
|
}
|
1999-03-26 00:54:10 +03:00
|
|
|
#endif
|
|
|
|
|
2002-05-15 00:03:53 +04:00
|
|
|
/*
|
|
|
|
* Construct the cluster.
|
|
|
|
*/
|
2005-04-02 01:59:46 +04:00
|
|
|
simple_lock(&fs->lfs_interlock);
|
1994-06-08 15:41:58 +04:00
|
|
|
++fs->lfs_iocount;
|
2005-04-02 01:59:46 +04:00
|
|
|
simple_unlock(&fs->lfs_interlock);
|
2003-03-21 09:26:36 +03:00
|
|
|
while (i && cbp->b_bcount < CHUNKSIZE) {
|
1998-03-01 05:20:01 +03:00
|
|
|
bp = *bpp;
|
1999-03-10 03:20:00 +03:00
|
|
|
|
|
|
|
if (bp->b_bcount > (CHUNKSIZE - cbp->b_bcount))
|
1998-03-01 05:20:01 +03:00
|
|
|
break;
|
2003-03-11 05:47:39 +03:00
|
|
|
if (cbp->b_bcount > 0 && !(cl->flags & LFS_CL_MALLOC))
|
|
|
|
break;
|
1998-03-01 05:20:01 +03:00
|
|
|
|
2003-03-11 05:47:39 +03:00
|
|
|
/* Clusters from GOP_WRITE are expedited */
|
|
|
|
if (bp->b_bcount > fs->lfs_bsize) {
|
|
|
|
if (cbp->b_bcount > 0)
|
|
|
|
/* Put in its own buffer */
|
|
|
|
break;
|
|
|
|
else {
|
|
|
|
cbp->b_data = bp->b_data;
|
|
|
|
}
|
|
|
|
} else if (cbp->b_bcount == 0) {
|
|
|
|
p = cbp->b_data = lfs_malloc(fs, CHUNKSIZE,
|
|
|
|
LFS_NB_CLUSTER);
|
|
|
|
cl->flags |= LFS_CL_MALLOC;
|
|
|
|
}
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
#ifdef DIAGNOSTIC
|
|
|
|
if (dtosn(fs, dbtofsb(fs, bp->b_blkno +
|
|
|
|
btodb(bp->b_bcount - 1))) !=
|
|
|
|
sp->seg_number) {
|
2004-09-18 20:40:11 +04:00
|
|
|
printf("blk size %d daddr %" PRIx64
|
2003-07-12 20:17:52 +04:00
|
|
|
" not in seg %d\n",
|
|
|
|
bp->b_bcount, bp->b_blkno,
|
|
|
|
sp->seg_number);
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
panic("segment overwrite");
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2003-03-11 05:47:39 +03:00
|
|
|
#ifdef LFS_USE_B_INVAL
|
1994-06-08 15:41:58 +04:00
|
|
|
/*
|
|
|
|
* Fake buffers from the cleaner are marked as B_INVAL.
|
|
|
|
* We need to copy the data from user space rather than
|
|
|
|
* from the buffer indicated.
|
|
|
|
* XXX == what do I do on an error?
|
|
|
|
*/
|
2003-07-12 20:17:52 +04:00
|
|
|
if ((bp->b_flags & (B_CALL|B_INVAL)) ==
|
|
|
|
(B_CALL|B_INVAL)) {
|
1994-06-08 15:41:58 +04:00
|
|
|
if (copyin(bp->b_saveaddr, p, bp->b_bcount))
|
2003-07-12 20:17:52 +04:00
|
|
|
panic("lfs_writeseg: "
|
|
|
|
"copyin failed [2]");
|
2003-03-11 05:47:39 +03:00
|
|
|
} else
|
|
|
|
#endif /* LFS_USE_B_INVAL */
|
|
|
|
if (cl->flags & LFS_CL_MALLOC) {
|
2003-10-08 19:07:25 +04:00
|
|
|
/* copy data into our cluster. */
|
|
|
|
memcpy(p, bp->b_data, bp->b_bcount);
|
|
|
|
p += bp->b_bcount;
|
2003-02-20 07:27:23 +03:00
|
|
|
}
|
2005-02-27 01:31:44 +03:00
|
|
|
|
2003-03-11 05:47:39 +03:00
|
|
|
cbp->b_bcount += bp->b_bcount;
|
|
|
|
cl->bufsize += bp->b_bcount;
|
|
|
|
|
2002-05-15 00:03:53 +04:00
|
|
|
bp->b_flags &= ~(B_ERROR | B_READ | B_DELWRI | B_DONE);
|
|
|
|
cl->bpp[cl->bufcount++] = bp;
|
|
|
|
vp = bp->b_vp;
|
For synchronous writes, keep separate i/o counters for each write, so
processes don't have to wait for one another to finish (e.g., nfsd seems
to be a little happier now, though I haven't measured the difference).
Synchronous checkpoints, however, must always wait for all i/o to finish.
Take the contents of the callback functions and have them run in thread
context instead (aiodoned thread). lfs_iocount no longer has to be
protected in splbio(), and quite a bit less of the segment construction
loop needs to be in splbio() as well.
If lfs_markv is handed a block that is not the correct size according to
the inode, refuse to process it. (Formerly it was extended to the "correct"
size.) This is possibly more prone to deadlock, but less prone to corruption.
lfs_segclean now outright refuses to clean segments that appear to have live
bytes in them. Again this may be more prone to deadlock but avoids
corruption.
Replace ufsspec_close and ufsfifo_close with LFS equivalents; this means
that no UFS functions need to know about LFS_ITIMES any more. Remove
the reference from ufs/inode.h.
Tested on i386, test-compiled on alpha.
2002-06-16 04:13:15 +04:00
|
|
|
s = splbio();
|
2003-10-03 19:35:03 +04:00
|
|
|
reassignbuf(bp, vp);
|
2003-02-06 00:38:38 +03:00
|
|
|
V_INCR_NUMOUTPUT(vp);
|
For synchronous writes, keep separate i/o counters for each write, so
processes don't have to wait for one another to finish (e.g., nfsd seems
to be a little happier now, though I haven't measured the difference).
Synchronous checkpoints, however, must always wait for all i/o to finish.
Take the contents of the callback functions and have them run in thread
context instead (aiodoned thread). lfs_iocount no longer has to be
protected in splbio(), and quite a bit less of the segment construction
loop needs to be in splbio() as well.
If lfs_markv is handed a block that is not the correct size according to
the inode, refuse to process it. (Formerly it was extended to the "correct"
size.) This is possibly more prone to deadlock, but less prone to corruption.
lfs_segclean now outright refuses to clean segments that appear to have live
bytes in them. Again this may be more prone to deadlock but avoids
corruption.
Replace ufsspec_close and ufsfifo_close with LFS equivalents; this means
that no UFS functions need to know about LFS_ITIMES any more. Remove
the reference from ufs/inode.h.
Tested on i386, test-compiled on alpha.
2002-06-16 04:13:15 +04:00
|
|
|
splx(s);
|
1999-04-12 04:25:13 +04:00
|
|
|
|
|
|
|
bpp++;
|
2003-03-11 05:47:39 +03:00
|
|
|
i--;
|
1994-06-08 15:41:58 +04:00
|
|
|
}
|
2004-01-10 17:39:50 +03:00
|
|
|
if (fs->lfs_sp->seg_flags & SEGM_SYNC)
|
|
|
|
BIO_SETPRIO(cbp, BPRIO_TIMECRITICAL);
|
|
|
|
else
|
|
|
|
BIO_SETPRIO(cbp, BPRIO_TIMELIMITED);
|
For synchronous writes, keep separate i/o counters for each write, so
processes don't have to wait for one another to finish (e.g., nfsd seems
to be a little happier now, though I haven't measured the difference).
Synchronous checkpoints, however, must always wait for all i/o to finish.
Take the contents of the callback functions and have them run in thread
context instead (aiodoned thread). lfs_iocount no longer has to be
protected in splbio(), and quite a bit less of the segment construction
loop needs to be in splbio() as well.
If lfs_markv is handed a block that is not the correct size according to
the inode, refuse to process it. (Formerly it was extended to the "correct"
size.) This is possibly more prone to deadlock, but less prone to corruption.
lfs_segclean now outright refuses to clean segments that appear to have live
bytes in them. Again this may be more prone to deadlock but avoids
corruption.
Replace ufsspec_close and ufsfifo_close with LFS equivalents; this means
that no UFS functions need to know about LFS_ITIMES any more. Remove
the reference from ufs/inode.h.
Tested on i386, test-compiled on alpha.
2002-06-16 04:13:15 +04:00
|
|
|
s = splbio();
|
2003-03-11 05:47:39 +03:00
|
|
|
V_INCR_NUMOUTPUT(devvp);
|
1994-06-08 15:41:58 +04:00
|
|
|
splx(s);
|
2004-01-28 13:53:12 +03:00
|
|
|
VOP_STRATEGY(devvp, cbp);
|
2003-03-11 05:47:39 +03:00
|
|
|
curproc->p_stats->p_ru.ru_oublock++;
|
1994-06-08 15:41:58 +04:00
|
|
|
}
|
2002-05-15 00:03:53 +04:00
|
|
|
|
2001-11-24 00:44:25 +03:00
|
|
|
if (lfs_dostats) {
|
1999-03-10 03:20:00 +03:00
|
|
|
++lfs_stats.psegwrites;
|
|
|
|
lfs_stats.blocktot += nblocks - 1;
|
|
|
|
if (fs->lfs_sp->seg_flags & SEGM_SYNC)
|
|
|
|
++lfs_stats.psyncwrites;
|
|
|
|
if (fs->lfs_sp->seg_flags & SEGM_CLEAN) {
|
|
|
|
++lfs_stats.pcleanwrites;
|
|
|
|
lfs_stats.cleanblocks += nblocks - 1;
|
|
|
|
}
|
1994-06-08 15:41:58 +04:00
|
|
|
}
|
Install a new sysctl, vfs.lfs.ignore_lazy_sync, which causes LFS to ignore
the "smooth" syncer, as if vfs.sync.*delay = 0, but only for LFS. The
default is "on", i.e., ignore lazy sync.
Reduce the amount of polling/busy-waiting done by lfs_putpages(). To
accomplish this, copied genfs_putpages() and modified it to indicate which
page it was that caused it to return with EDEADLK. fsync()/fdatasync()
should no longer ever fail with EAGAIN, and should not consume huge
quantities of cpu.
Also, try to make dirops less likely to be written as the result of a
VOP_PUTPAGES(), while ensuring that they are written regularly.
2007-04-17 05:16:46 +04:00
|
|
|
|
1994-06-08 15:41:58 +04:00
|
|
|
return (lfs_initseg(fs) || do_again);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
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_writesuper(struct lfs *fs, daddr_t daddr)
|
1994-06-08 15:41:58 +04:00
|
|
|
{
|
|
|
|
struct buf *bp;
|
|
|
|
int s;
|
2004-01-28 13:53:12 +03:00
|
|
|
struct vnode *devvp = VTOI(fs->lfs_ivnode)->i_devvp;
|
1994-06-08 15:41:58 +04:00
|
|
|
|
2005-04-02 01:59:46 +04:00
|
|
|
ASSERT_MAYBE_SEGLOCK(fs);
|
Various minor LFS improvements:
* Note when lfs_putpages(9) thinks it is not going to be writing any
pages before calling genfs_putpages(9). This prevents a situation in
which blocks can be queued for writing without a segment header.
* Correct computation of NRESERVE(), though it is still a gross
overestimate in most cases. Note that if NRESERVE() is too high, it
may be impossible to create files on the filesystem. We catch this
case on filesystem mount and refuse to mount r/w.
* Allow filesystems to be mounted whose block size is == MAXBSIZE.
* Somewhere along the line, ufs_bmaparray(9) started mangling UNWRITTEN
entries in indirect blocks again, triggering a failed assertion "daddr
<= LFS_MAX_DADDR". Explicitly convert to and from int32_t to correct
this.
* Add a high-water mark for the number of dirty pages any given LFS can
hold before triggering a flush. This is settable by sysctl, but off
(zero) by default.
* Be more careful about the MAX_BYTES and MAX_BUFS computations so we
shouldn't see "please increase to at least zero" messages.
* Note that VBLK and VCHR vnodes can have nonzero values in di_db[0]
even though their v_size == 0. Don't panic when we see this.
* Change lfs_bfree to a signed quantity. The manner in which it is
processed before being passed to the cleaner means that sometimes it
may drop below zero, and the cleaner must be aware of this.
* Never report bfree < 0 (or higher than lfs_dsize) through
lfs_statvfs(9). This prevents df(1) from ever telling us that our full
filesystems have 16TB free.
* Account space allocated through lfs_balloc(9) that does not have
associated buffer headers, so that the pagedaemon doesn't run us out
of segments.
* Return ENOSPC from lfs_balloc(9) when bfree drops to zero.
* Address a deadlock in lfs_bmapv/lfs_markv when the filesystem is being
unmounted. Because vfs_busy() is a shared lock, and
lfs_bmapv/lfs_markv mark the filesystem vfs_busy(), the cleaner can be
holding the lock that umount() is blocking on, then try to vfs_busy()
again in getnewvnode().
2005-02-26 08:40:42 +03:00
|
|
|
#ifdef DIAGNOSTIC
|
|
|
|
KASSERT(fs->lfs_magic == LFS_MAGIC);
|
|
|
|
#endif
|
1999-03-10 03:20:00 +03:00
|
|
|
/*
|
|
|
|
* If we can write one superblock while another is in
|
|
|
|
* progress, we risk not having a complete checkpoint if we crash.
|
|
|
|
* So, block here if a superblock write is in progress.
|
|
|
|
*/
|
2005-04-02 01:59:46 +04:00
|
|
|
simple_lock(&fs->lfs_interlock);
|
1999-11-17 23:08:30 +03:00
|
|
|
s = splbio();
|
2001-11-24 00:44:25 +03:00
|
|
|
while (fs->lfs_sbactive) {
|
2005-04-02 01:59:46 +04:00
|
|
|
ltsleep(&fs->lfs_sbactive, PRIBIO+1, "lfs sb", 0,
|
|
|
|
&fs->lfs_interlock);
|
1999-03-10 03:20:00 +03:00
|
|
|
}
|
|
|
|
fs->lfs_sbactive = daddr;
|
1999-11-17 23:08:30 +03:00
|
|
|
splx(s);
|
2005-04-02 01:59:46 +04:00
|
|
|
simple_unlock(&fs->lfs_interlock);
|
1994-06-08 15:41:58 +04:00
|
|
|
|
1999-03-10 03:20:00 +03:00
|
|
|
/* Set timestamp of this version of the 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
|
|
|
if (fs->lfs_version == 1)
|
2006-06-08 02:33:33 +04:00
|
|
|
fs->lfs_otstamp = time_second;
|
|
|
|
fs->lfs_tstamp = time_second;
|
1999-03-10 03:20:00 +03:00
|
|
|
|
1994-06-08 15:41:58 +04:00
|
|
|
/* Checksum the superblock and copy it into a buffer. */
|
1998-09-12 01:27:12 +04:00
|
|
|
fs->lfs_cksum = lfs_sb_cksum(&(fs->lfs_dlfs));
|
2004-01-28 13:53:12 +03:00
|
|
|
bp = lfs_newbuf(fs, devvp,
|
2003-07-12 20:17:52 +04:00
|
|
|
fsbtodb(fs, daddr), LFS_SBPAD, LFS_NB_SBLOCK);
|
2007-03-04 08:59:00 +03:00
|
|
|
memset((char *)bp->b_data + sizeof(struct dlfs), 0,
|
2003-07-12 20:17:52 +04:00
|
|
|
LFS_SBPAD - sizeof(struct dlfs));
|
1998-09-12 01:27:12 +04:00
|
|
|
*(struct dlfs *)bp->b_data = fs->lfs_dlfs;
|
2005-02-27 01:31:44 +03:00
|
|
|
|
1994-06-08 15:41:58 +04:00
|
|
|
bp->b_flags |= B_BUSY | B_CALL | B_ASYNC;
|
|
|
|
bp->b_flags &= ~(B_DONE | B_ERROR | B_READ | B_DELWRI);
|
|
|
|
bp->b_iodone = lfs_supercallback;
|
1999-03-10 03:20:00 +03:00
|
|
|
|
2004-01-10 17:39:50 +03:00
|
|
|
if (fs->lfs_sp != NULL && fs->lfs_sp->seg_flags & SEGM_SYNC)
|
|
|
|
BIO_SETPRIO(bp, BPRIO_TIMECRITICAL);
|
|
|
|
else
|
|
|
|
BIO_SETPRIO(bp, BPRIO_TIMELIMITED);
|
2003-03-11 05:47:39 +03:00
|
|
|
curproc->p_stats->p_ru.ru_oublock++;
|
1994-06-08 15:41:58 +04:00
|
|
|
s = splbio();
|
2003-02-06 00:38:38 +03:00
|
|
|
V_INCR_NUMOUTPUT(bp->b_vp);
|
1994-06-08 15:41:58 +04:00
|
|
|
splx(s);
|
2005-04-02 01:59:46 +04:00
|
|
|
simple_lock(&fs->lfs_interlock);
|
For synchronous writes, keep separate i/o counters for each write, so
processes don't have to wait for one another to finish (e.g., nfsd seems
to be a little happier now, though I haven't measured the difference).
Synchronous checkpoints, however, must always wait for all i/o to finish.
Take the contents of the callback functions and have them run in thread
context instead (aiodoned thread). lfs_iocount no longer has to be
protected in splbio(), and quite a bit less of the segment construction
loop needs to be in splbio() as well.
If lfs_markv is handed a block that is not the correct size according to
the inode, refuse to process it. (Formerly it was extended to the "correct"
size.) This is possibly more prone to deadlock, but less prone to corruption.
lfs_segclean now outright refuses to clean segments that appear to have live
bytes in them. Again this may be more prone to deadlock but avoids
corruption.
Replace ufsspec_close and ufsfifo_close with LFS equivalents; this means
that no UFS functions need to know about LFS_ITIMES any more. Remove
the reference from ufs/inode.h.
Tested on i386, test-compiled on alpha.
2002-06-16 04:13:15 +04:00
|
|
|
++fs->lfs_iocount;
|
2005-04-02 01:59:46 +04:00
|
|
|
simple_unlock(&fs->lfs_interlock);
|
2004-01-28 13:53:12 +03:00
|
|
|
VOP_STRATEGY(devvp, bp);
|
1994-06-08 15:41:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Logical block number match routines used when traversing the dirty block
|
|
|
|
* chain.
|
|
|
|
*/
|
1999-03-10 03:20:00 +03: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_match_fake(struct lfs *fs, struct buf *bp)
|
1999-03-10 03:20:00 +03:00
|
|
|
{
|
2003-07-23 17:53:51 +04:00
|
|
|
|
2005-04-02 01:59:46 +04:00
|
|
|
ASSERT_SEGLOCK(fs);
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
return LFS_IS_MALLOC_BUF(bp);
|
|
|
|
}
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
int
|
|
|
|
lfs_match_real(struct lfs *fs, struct buf *bp)
|
|
|
|
{
|
2003-07-23 17:53:51 +04:00
|
|
|
|
2005-04-02 01:59:46 +04:00
|
|
|
ASSERT_SEGLOCK(fs);
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
return (lfs_match_data(fs, bp) && !lfs_match_fake(fs, bp));
|
1999-03-10 03:20:00 +03:00
|
|
|
}
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
#endif
|
1999-03-10 03:20:00 +03:00
|
|
|
|
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_match_data(struct lfs *fs, struct buf *bp)
|
1994-06-08 15:41:58 +04:00
|
|
|
{
|
2003-07-23 17:53:51 +04:00
|
|
|
|
2005-04-02 01:59:46 +04:00
|
|
|
ASSERT_SEGLOCK(fs);
|
1994-06-08 15:41:58 +04:00
|
|
|
return (bp->b_lblkno >= 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
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_match_indir(struct lfs *fs, struct buf *bp)
|
1994-06-08 15:41:58 +04:00
|
|
|
{
|
2003-01-25 00:55:02 +03:00
|
|
|
daddr_t lbn;
|
1994-06-08 15:41:58 +04:00
|
|
|
|
2005-04-02 01:59:46 +04:00
|
|
|
ASSERT_SEGLOCK(fs);
|
1994-06-08 15:41:58 +04:00
|
|
|
lbn = bp->b_lblkno;
|
|
|
|
return (lbn < 0 && (-lbn - NDADDR) % NINDIR(fs) == 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
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_match_dindir(struct lfs *fs, struct buf *bp)
|
1994-06-08 15:41:58 +04:00
|
|
|
{
|
2003-01-25 00:55:02 +03:00
|
|
|
daddr_t lbn;
|
1994-06-08 15:41:58 +04:00
|
|
|
|
2005-04-02 01:59:46 +04:00
|
|
|
ASSERT_SEGLOCK(fs);
|
1994-06-08 15:41:58 +04:00
|
|
|
lbn = bp->b_lblkno;
|
|
|
|
return (lbn < 0 && (-lbn - NDADDR) % NINDIR(fs) == 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
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_match_tindir(struct lfs *fs, struct buf *bp)
|
1994-06-08 15:41:58 +04:00
|
|
|
{
|
2003-01-25 00:55:02 +03:00
|
|
|
daddr_t lbn;
|
1994-06-08 15:41:58 +04:00
|
|
|
|
2005-04-02 01:59:46 +04:00
|
|
|
ASSERT_SEGLOCK(fs);
|
1994-06-08 15:41:58 +04:00
|
|
|
lbn = bp->b_lblkno;
|
|
|
|
return (lbn < 0 && (-lbn - NDADDR) % NINDIR(fs) == 2);
|
|
|
|
}
|
|
|
|
|
Changes to help the roll-forward agent, to wit:
* Mark being-deleted files in the Ifile so we can finish deleting them
at fs mount time.
* Flag the Ifile with "cleaner must clean" when writers are waiting for
the cleaner, rather than relying solely on the cleaner's estimation of
whether it should clean or not.
* Note partial segments written by a user agent (in particular,
fsck_lfs) so that repeated rolls forward don't interfere with one
another.
* Add a new fcntl, LFCNPASS, that allows the log to wrap exactly once,
for better testing of the validity of checkpoints.
* Keep track of the on-disk nlink count when cleaning, so that we don't
partially complete directory operations while cleaning.
* Ensure that every single Ifile inode write represents a consistent
view of the filesystem. In particular, the accounting for the segment
we are writing the inode into must be correct, and the accounting for
the segment that inode used to reside in must be correct. Rather than
just rewriting the inode if we wrote it wrong, rewrite the necessary
ifile blocks before writing the inode so we never write it wrong.
* Don't unmark any VDIROP vnodes if we haven't written them to disk,
avoiding yet another problem with the "wait for the cleaner" error
return from lfs_putpages().
Also, move the last callback to an aiodone call, so we no longer do any
memory management from interrupt context.
2006-09-01 23:41:28 +04:00
|
|
|
static void
|
|
|
|
lfs_free_aiodone(struct buf *bp)
|
1994-06-08 15:41:58 +04:00
|
|
|
{
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
struct lfs *fs;
|
|
|
|
|
2003-12-04 17:57:47 +03:00
|
|
|
fs = bp->b_private;
|
2005-04-02 01:59:46 +04:00
|
|
|
ASSERT_NO_SEGLOCK(fs);
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
lfs_freebuf(fs, bp);
|
1994-06-08 15:41:58 +04:00
|
|
|
}
|
|
|
|
|
For synchronous writes, keep separate i/o counters for each write, so
processes don't have to wait for one another to finish (e.g., nfsd seems
to be a little happier now, though I haven't measured the difference).
Synchronous checkpoints, however, must always wait for all i/o to finish.
Take the contents of the callback functions and have them run in thread
context instead (aiodoned thread). lfs_iocount no longer has to be
protected in splbio(), and quite a bit less of the segment construction
loop needs to be in splbio() as well.
If lfs_markv is handed a block that is not the correct size according to
the inode, refuse to process it. (Formerly it was extended to the "correct"
size.) This is possibly more prone to deadlock, but less prone to corruption.
lfs_segclean now outright refuses to clean segments that appear to have live
bytes in them. Again this may be more prone to deadlock but avoids
corruption.
Replace ufsspec_close and ufsfifo_close with LFS equivalents; this means
that no UFS functions need to know about LFS_ITIMES any more. Remove
the reference from ufs/inode.h.
Tested on i386, test-compiled on alpha.
2002-06-16 04:13:15 +04:00
|
|
|
static void
|
|
|
|
lfs_super_aiodone(struct buf *bp)
|
1994-06-08 15:41:58 +04:00
|
|
|
{
|
1999-03-10 03:20:00 +03:00
|
|
|
struct lfs *fs;
|
|
|
|
|
2003-12-04 17:57:47 +03:00
|
|
|
fs = bp->b_private;
|
2005-04-02 01:59:46 +04:00
|
|
|
ASSERT_NO_SEGLOCK(fs);
|
|
|
|
simple_lock(&fs->lfs_interlock);
|
2000-05-19 08:34:39 +04:00
|
|
|
fs->lfs_sbactive = 0;
|
2003-03-08 05:55:47 +03:00
|
|
|
if (--fs->lfs_iocount <= 1)
|
2000-06-28 00:57:11 +04:00
|
|
|
wakeup(&fs->lfs_iocount);
|
2005-04-02 01:59:46 +04:00
|
|
|
simple_unlock(&fs->lfs_interlock);
|
|
|
|
wakeup(&fs->lfs_sbactive);
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
lfs_freebuf(fs, bp);
|
1994-06-08 15:41:58 +04:00
|
|
|
}
|
|
|
|
|
2002-05-15 00:03:53 +04:00
|
|
|
static void
|
For synchronous writes, keep separate i/o counters for each write, so
processes don't have to wait for one another to finish (e.g., nfsd seems
to be a little happier now, though I haven't measured the difference).
Synchronous checkpoints, however, must always wait for all i/o to finish.
Take the contents of the callback functions and have them run in thread
context instead (aiodoned thread). lfs_iocount no longer has to be
protected in splbio(), and quite a bit less of the segment construction
loop needs to be in splbio() as well.
If lfs_markv is handed a block that is not the correct size according to
the inode, refuse to process it. (Formerly it was extended to the "correct"
size.) This is possibly more prone to deadlock, but less prone to corruption.
lfs_segclean now outright refuses to clean segments that appear to have live
bytes in them. Again this may be more prone to deadlock but avoids
corruption.
Replace ufsspec_close and ufsfifo_close with LFS equivalents; this means
that no UFS functions need to know about LFS_ITIMES any more. Remove
the reference from ufs/inode.h.
Tested on i386, test-compiled on alpha.
2002-06-16 04:13:15 +04:00
|
|
|
lfs_cluster_aiodone(struct buf *bp)
|
2002-05-15 00:03:53 +04:00
|
|
|
{
|
|
|
|
struct lfs_cluster *cl;
|
|
|
|
struct lfs *fs;
|
2003-03-11 05:47:39 +03:00
|
|
|
struct buf *tbp, *fbp;
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
struct vnode *vp, *devvp;
|
2003-03-11 05:47:39 +03:00
|
|
|
struct inode *ip;
|
For synchronous writes, keep separate i/o counters for each write, so
processes don't have to wait for one another to finish (e.g., nfsd seems
to be a little happier now, though I haven't measured the difference).
Synchronous checkpoints, however, must always wait for all i/o to finish.
Take the contents of the callback functions and have them run in thread
context instead (aiodoned thread). lfs_iocount no longer has to be
protected in splbio(), and quite a bit less of the segment construction
loop needs to be in splbio() as well.
If lfs_markv is handed a block that is not the correct size according to
the inode, refuse to process it. (Formerly it was extended to the "correct"
size.) This is possibly more prone to deadlock, but less prone to corruption.
lfs_segclean now outright refuses to clean segments that appear to have live
bytes in them. Again this may be more prone to deadlock but avoids
corruption.
Replace ufsspec_close and ufsfifo_close with LFS equivalents; this means
that no UFS functions need to know about LFS_ITIMES any more. Remove
the reference from ufs/inode.h.
Tested on i386, test-compiled on alpha.
2002-06-16 04:13:15 +04:00
|
|
|
int s, error=0;
|
2002-05-15 00:03:53 +04:00
|
|
|
|
2003-03-21 09:26:36 +03:00
|
|
|
if (bp->b_flags & B_ERROR)
|
2002-05-15 00:03:53 +04:00
|
|
|
error = bp->b_error;
|
|
|
|
|
2003-12-04 17:57:47 +03:00
|
|
|
cl = bp->b_private;
|
2002-05-15 00:03:53 +04:00
|
|
|
fs = cl->fs;
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
devvp = VTOI(fs->lfs_ivnode)->i_devvp;
|
2005-04-02 01:59:46 +04:00
|
|
|
ASSERT_NO_SEGLOCK(fs);
|
2002-05-15 00:03:53 +04:00
|
|
|
|
|
|
|
/* Put the pages back, and release the buffer */
|
2003-03-21 09:26:36 +03:00
|
|
|
while (cl->bufcount--) {
|
2002-05-15 00:03:53 +04:00
|
|
|
tbp = cl->bpp[cl->bufcount];
|
2004-05-19 15:29:32 +04:00
|
|
|
KASSERT(tbp->b_flags & B_BUSY);
|
2003-03-21 09:26:36 +03:00
|
|
|
if (error) {
|
2002-05-15 00:03:53 +04:00
|
|
|
tbp->b_flags |= B_ERROR;
|
|
|
|
tbp->b_error = error;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2003-02-20 07:27:23 +03:00
|
|
|
* We're done with tbp. If it has not been re-dirtied since
|
2002-05-15 00:03:53 +04:00
|
|
|
* the cluster was written, free it. Otherwise, keep it on
|
|
|
|
* the locked list to be written again.
|
|
|
|
*/
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
vp = tbp->b_vp;
|
2003-03-21 09:16:53 +03:00
|
|
|
|
2002-05-15 00:03:53 +04:00
|
|
|
tbp->b_flags &= ~B_GATHERED;
|
|
|
|
|
|
|
|
LFS_BCLEAN_LOG(fs, tbp);
|
|
|
|
|
2003-03-21 09:26:36 +03:00
|
|
|
if (!(tbp->b_flags & B_CALL)) {
|
2003-10-03 19:35:54 +04:00
|
|
|
KASSERT(tbp->b_flags & B_LOCKED);
|
For synchronous writes, keep separate i/o counters for each write, so
processes don't have to wait for one another to finish (e.g., nfsd seems
to be a little happier now, though I haven't measured the difference).
Synchronous checkpoints, however, must always wait for all i/o to finish.
Take the contents of the callback functions and have them run in thread
context instead (aiodoned thread). lfs_iocount no longer has to be
protected in splbio(), and quite a bit less of the segment construction
loop needs to be in splbio() as well.
If lfs_markv is handed a block that is not the correct size according to
the inode, refuse to process it. (Formerly it was extended to the "correct"
size.) This is possibly more prone to deadlock, but less prone to corruption.
lfs_segclean now outright refuses to clean segments that appear to have live
bytes in them. Again this may be more prone to deadlock but avoids
corruption.
Replace ufsspec_close and ufsfifo_close with LFS equivalents; this means
that no UFS functions need to know about LFS_ITIMES any more. Remove
the reference from ufs/inode.h.
Tested on i386, test-compiled on alpha.
2002-06-16 04:13:15 +04:00
|
|
|
s = splbio();
|
2003-09-07 15:47:07 +04:00
|
|
|
simple_lock(&bqueue_slock);
|
|
|
|
bremfree(tbp);
|
|
|
|
simple_unlock(&bqueue_slock);
|
2003-03-21 09:26:36 +03:00
|
|
|
if (vp)
|
2002-05-15 00:03:53 +04:00
|
|
|
reassignbuf(tbp, vp);
|
For synchronous writes, keep separate i/o counters for each write, so
processes don't have to wait for one another to finish (e.g., nfsd seems
to be a little happier now, though I haven't measured the difference).
Synchronous checkpoints, however, must always wait for all i/o to finish.
Take the contents of the callback functions and have them run in thread
context instead (aiodoned thread). lfs_iocount no longer has to be
protected in splbio(), and quite a bit less of the segment construction
loop needs to be in splbio() as well.
If lfs_markv is handed a block that is not the correct size according to
the inode, refuse to process it. (Formerly it was extended to the "correct"
size.) This is possibly more prone to deadlock, but less prone to corruption.
lfs_segclean now outright refuses to clean segments that appear to have live
bytes in them. Again this may be more prone to deadlock but avoids
corruption.
Replace ufsspec_close and ufsfifo_close with LFS equivalents; this means
that no UFS functions need to know about LFS_ITIMES any more. Remove
the reference from ufs/inode.h.
Tested on i386, test-compiled on alpha.
2002-06-16 04:13:15 +04:00
|
|
|
splx(s);
|
2002-05-15 00:03:53 +04:00
|
|
|
tbp->b_flags |= B_ASYNC; /* for biodone */
|
|
|
|
}
|
2003-09-07 15:47:07 +04:00
|
|
|
|
|
|
|
if ((tbp->b_flags & (B_LOCKED | B_DELWRI)) == B_LOCKED)
|
|
|
|
LFS_UNLOCK_BUF(tbp);
|
|
|
|
|
2002-05-15 00:03:53 +04:00
|
|
|
if (tbp->b_flags & B_DONE) {
|
2005-03-08 03:18:19 +03:00
|
|
|
DLOG((DLOG_SEG, "blk %d biodone already (flags %lx)\n",
|
|
|
|
cl->bufcount, (long)tbp->b_flags));
|
2002-05-15 00:03:53 +04:00
|
|
|
}
|
2003-03-11 05:47:39 +03:00
|
|
|
|
2004-05-19 15:29:32 +04:00
|
|
|
if ((tbp->b_flags & B_CALL) && !LFS_IS_MALLOC_BUF(tbp)) {
|
2003-03-11 05:47:39 +03:00
|
|
|
/*
|
2004-05-19 15:29:32 +04:00
|
|
|
* A buffer from the page daemon.
|
|
|
|
* We use the same iodone as it does,
|
|
|
|
* so we must manually disassociate its
|
|
|
|
* buffers from the vp.
|
2003-03-11 05:47:39 +03:00
|
|
|
*/
|
2004-05-19 15:29:32 +04:00
|
|
|
if (tbp->b_vp) {
|
|
|
|
/* This is just silly */
|
|
|
|
s = splbio();
|
|
|
|
brelvp(tbp);
|
|
|
|
tbp->b_vp = vp;
|
|
|
|
splx(s);
|
|
|
|
}
|
|
|
|
/* Put it back the way it was */
|
|
|
|
tbp->b_flags |= B_ASYNC;
|
|
|
|
/* Master buffers have B_AGE */
|
|
|
|
if (tbp->b_private == tbp)
|
|
|
|
tbp->b_flags |= B_AGE;
|
|
|
|
}
|
|
|
|
s = splbio();
|
|
|
|
biodone(tbp);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If this is the last block for this vnode, but
|
|
|
|
* there are other blocks on its dirty list,
|
|
|
|
* set IN_MODIFIED/IN_CLEANING depending on what
|
|
|
|
* sort of block. Only do this for our mount point,
|
|
|
|
* not for, e.g., inode blocks that are attached to
|
|
|
|
* the devvp.
|
|
|
|
* XXX KS - Shouldn't we set *both* if both types
|
|
|
|
* of blocks are present (traverse the dirty list?)
|
|
|
|
*/
|
|
|
|
simple_lock(&global_v_numoutput_slock);
|
|
|
|
if (vp != devvp && vp->v_numoutput == 0 &&
|
|
|
|
(fbp = LIST_FIRST(&vp->v_dirtyblkhd)) != NULL) {
|
|
|
|
ip = VTOI(vp);
|
2005-03-08 03:18:19 +03:00
|
|
|
DLOG((DLOG_SEG, "lfs_cluster_aiodone: mark ino %d\n",
|
|
|
|
ip->i_number));
|
2004-05-19 15:29:32 +04:00
|
|
|
if (LFS_IS_MALLOC_BUF(fbp))
|
|
|
|
LFS_SET_UINO(ip, IN_CLEANING);
|
|
|
|
else
|
|
|
|
LFS_SET_UINO(ip, IN_MODIFIED);
|
2002-05-15 00:03:53 +04:00
|
|
|
}
|
2004-05-19 15:29:32 +04:00
|
|
|
simple_unlock(&global_v_numoutput_slock);
|
|
|
|
splx(s);
|
|
|
|
wakeup(vp);
|
2002-05-15 00:03:53 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Fix up the cluster buffer, and release it */
|
2003-03-11 05:47:39 +03:00
|
|
|
if (cl->flags & LFS_CL_MALLOC)
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
lfs_free(fs, bp->b_data, LFS_NB_CLUSTER);
|
2006-01-04 13:13:05 +03:00
|
|
|
putiobuf(bp);
|
2002-05-15 00:03:53 +04:00
|
|
|
|
For synchronous writes, keep separate i/o counters for each write, so
processes don't have to wait for one another to finish (e.g., nfsd seems
to be a little happier now, though I haven't measured the difference).
Synchronous checkpoints, however, must always wait for all i/o to finish.
Take the contents of the callback functions and have them run in thread
context instead (aiodoned thread). lfs_iocount no longer has to be
protected in splbio(), and quite a bit less of the segment construction
loop needs to be in splbio() as well.
If lfs_markv is handed a block that is not the correct size according to
the inode, refuse to process it. (Formerly it was extended to the "correct"
size.) This is possibly more prone to deadlock, but less prone to corruption.
lfs_segclean now outright refuses to clean segments that appear to have live
bytes in them. Again this may be more prone to deadlock but avoids
corruption.
Replace ufsspec_close and ufsfifo_close with LFS equivalents; this means
that no UFS functions need to know about LFS_ITIMES any more. Remove
the reference from ufs/inode.h.
Tested on i386, test-compiled on alpha.
2002-06-16 04:13:15 +04:00
|
|
|
/* Note i/o done */
|
|
|
|
if (cl->flags & LFS_CL_SYNC) {
|
2005-02-27 01:31:44 +03:00
|
|
|
if (--cl->seg->seg_iocount == 0)
|
For synchronous writes, keep separate i/o counters for each write, so
processes don't have to wait for one another to finish (e.g., nfsd seems
to be a little happier now, though I haven't measured the difference).
Synchronous checkpoints, however, must always wait for all i/o to finish.
Take the contents of the callback functions and have them run in thread
context instead (aiodoned thread). lfs_iocount no longer has to be
protected in splbio(), and quite a bit less of the segment construction
loop needs to be in splbio() as well.
If lfs_markv is handed a block that is not the correct size according to
the inode, refuse to process it. (Formerly it was extended to the "correct"
size.) This is possibly more prone to deadlock, but less prone to corruption.
lfs_segclean now outright refuses to clean segments that appear to have live
bytes in them. Again this may be more prone to deadlock but avoids
corruption.
Replace ufsspec_close and ufsfifo_close with LFS equivalents; this means
that no UFS functions need to know about LFS_ITIMES any more. Remove
the reference from ufs/inode.h.
Tested on i386, test-compiled on alpha.
2002-06-16 04:13:15 +04:00
|
|
|
wakeup(&cl->seg->seg_iocount);
|
|
|
|
}
|
2005-04-02 01:59:46 +04:00
|
|
|
simple_lock(&fs->lfs_interlock);
|
2002-05-15 00:03:53 +04:00
|
|
|
#ifdef DIAGNOSTIC
|
|
|
|
if (fs->lfs_iocount == 0)
|
2002-09-27 19:35:29 +04:00
|
|
|
panic("lfs_cluster_aiodone: zero iocount");
|
2002-05-15 00:03:53 +04:00
|
|
|
#endif
|
2003-03-08 05:55:47 +03:00
|
|
|
if (--fs->lfs_iocount <= 1)
|
2002-05-15 00:03:53 +04:00
|
|
|
wakeup(&fs->lfs_iocount);
|
2005-04-02 01:59:46 +04:00
|
|
|
simple_unlock(&fs->lfs_interlock);
|
For synchronous writes, keep separate i/o counters for each write, so
processes don't have to wait for one another to finish (e.g., nfsd seems
to be a little happier now, though I haven't measured the difference).
Synchronous checkpoints, however, must always wait for all i/o to finish.
Take the contents of the callback functions and have them run in thread
context instead (aiodoned thread). lfs_iocount no longer has to be
protected in splbio(), and quite a bit less of the segment construction
loop needs to be in splbio() as well.
If lfs_markv is handed a block that is not the correct size according to
the inode, refuse to process it. (Formerly it was extended to the "correct"
size.) This is possibly more prone to deadlock, but less prone to corruption.
lfs_segclean now outright refuses to clean segments that appear to have live
bytes in them. Again this may be more prone to deadlock but avoids
corruption.
Replace ufsspec_close and ufsfifo_close with LFS equivalents; this means
that no UFS functions need to know about LFS_ITIMES any more. Remove
the reference from ufs/inode.h.
Tested on i386, test-compiled on alpha.
2002-06-16 04:13:15 +04:00
|
|
|
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
pool_put(&fs->lfs_bpppool, cl->bpp);
|
|
|
|
cl->bpp = NULL;
|
|
|
|
pool_put(&fs->lfs_clpool, cl);
|
For synchronous writes, keep separate i/o counters for each write, so
processes don't have to wait for one another to finish (e.g., nfsd seems
to be a little happier now, though I haven't measured the difference).
Synchronous checkpoints, however, must always wait for all i/o to finish.
Take the contents of the callback functions and have them run in thread
context instead (aiodoned thread). lfs_iocount no longer has to be
protected in splbio(), and quite a bit less of the segment construction
loop needs to be in splbio() as well.
If lfs_markv is handed a block that is not the correct size according to
the inode, refuse to process it. (Formerly it was extended to the "correct"
size.) This is possibly more prone to deadlock, but less prone to corruption.
lfs_segclean now outright refuses to clean segments that appear to have live
bytes in them. Again this may be more prone to deadlock but avoids
corruption.
Replace ufsspec_close and ufsfifo_close with LFS equivalents; this means
that no UFS functions need to know about LFS_ITIMES any more. Remove
the reference from ufs/inode.h.
Tested on i386, test-compiled on alpha.
2002-06-16 04:13:15 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
lfs_generic_callback(struct buf *bp, void (*aiodone)(struct buf *))
|
|
|
|
{
|
|
|
|
/* reset b_iodone for when this is a single-buf i/o. */
|
|
|
|
bp->b_iodone = aiodone;
|
|
|
|
|
2006-12-21 18:55:21 +03:00
|
|
|
workqueue_enqueue(uvm.aiodone_queue, &bp->b_work);
|
For synchronous writes, keep separate i/o counters for each write, so
processes don't have to wait for one another to finish (e.g., nfsd seems
to be a little happier now, though I haven't measured the difference).
Synchronous checkpoints, however, must always wait for all i/o to finish.
Take the contents of the callback functions and have them run in thread
context instead (aiodoned thread). lfs_iocount no longer has to be
protected in splbio(), and quite a bit less of the segment construction
loop needs to be in splbio() as well.
If lfs_markv is handed a block that is not the correct size according to
the inode, refuse to process it. (Formerly it was extended to the "correct"
size.) This is possibly more prone to deadlock, but less prone to corruption.
lfs_segclean now outright refuses to clean segments that appear to have live
bytes in them. Again this may be more prone to deadlock but avoids
corruption.
Replace ufsspec_close and ufsfifo_close with LFS equivalents; this means
that no UFS functions need to know about LFS_ITIMES any more. Remove
the reference from ufs/inode.h.
Tested on i386, test-compiled on alpha.
2002-06-16 04:13:15 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
lfs_cluster_callback(struct buf *bp)
|
|
|
|
{
|
2003-07-23 17:53:51 +04:00
|
|
|
|
For synchronous writes, keep separate i/o counters for each write, so
processes don't have to wait for one another to finish (e.g., nfsd seems
to be a little happier now, though I haven't measured the difference).
Synchronous checkpoints, however, must always wait for all i/o to finish.
Take the contents of the callback functions and have them run in thread
context instead (aiodoned thread). lfs_iocount no longer has to be
protected in splbio(), and quite a bit less of the segment construction
loop needs to be in splbio() as well.
If lfs_markv is handed a block that is not the correct size according to
the inode, refuse to process it. (Formerly it was extended to the "correct"
size.) This is possibly more prone to deadlock, but less prone to corruption.
lfs_segclean now outright refuses to clean segments that appear to have live
bytes in them. Again this may be more prone to deadlock but avoids
corruption.
Replace ufsspec_close and ufsfifo_close with LFS equivalents; this means
that no UFS functions need to know about LFS_ITIMES any more. Remove
the reference from ufs/inode.h.
Tested on i386, test-compiled on alpha.
2002-06-16 04:13:15 +04:00
|
|
|
lfs_generic_callback(bp, lfs_cluster_aiodone);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
lfs_supercallback(struct buf *bp)
|
|
|
|
{
|
2003-07-23 17:53:51 +04:00
|
|
|
|
For synchronous writes, keep separate i/o counters for each write, so
processes don't have to wait for one another to finish (e.g., nfsd seems
to be a little happier now, though I haven't measured the difference).
Synchronous checkpoints, however, must always wait for all i/o to finish.
Take the contents of the callback functions and have them run in thread
context instead (aiodoned thread). lfs_iocount no longer has to be
protected in splbio(), and quite a bit less of the segment construction
loop needs to be in splbio() as well.
If lfs_markv is handed a block that is not the correct size according to
the inode, refuse to process it. (Formerly it was extended to the "correct"
size.) This is possibly more prone to deadlock, but less prone to corruption.
lfs_segclean now outright refuses to clean segments that appear to have live
bytes in them. Again this may be more prone to deadlock but avoids
corruption.
Replace ufsspec_close and ufsfifo_close with LFS equivalents; this means
that no UFS functions need to know about LFS_ITIMES any more. Remove
the reference from ufs/inode.h.
Tested on i386, test-compiled on alpha.
2002-06-16 04:13:15 +04:00
|
|
|
lfs_generic_callback(bp, lfs_super_aiodone);
|
2002-05-15 00:03:53 +04:00
|
|
|
}
|
|
|
|
|
Changes to help the roll-forward agent, to wit:
* Mark being-deleted files in the Ifile so we can finish deleting them
at fs mount time.
* Flag the Ifile with "cleaner must clean" when writers are waiting for
the cleaner, rather than relying solely on the cleaner's estimation of
whether it should clean or not.
* Note partial segments written by a user agent (in particular,
fsck_lfs) so that repeated rolls forward don't interfere with one
another.
* Add a new fcntl, LFCNPASS, that allows the log to wrap exactly once,
for better testing of the validity of checkpoints.
* Keep track of the on-disk nlink count when cleaning, so that we don't
partially complete directory operations while cleaning.
* Ensure that every single Ifile inode write represents a consistent
view of the filesystem. In particular, the accounting for the segment
we are writing the inode into must be correct, and the accounting for
the segment that inode used to reside in must be correct. Rather than
just rewriting the inode if we wrote it wrong, rewrite the necessary
ifile blocks before writing the inode so we never write it wrong.
* Don't unmark any VDIROP vnodes if we haven't written them to disk,
avoiding yet another problem with the "wait for the cleaner" error
return from lfs_putpages().
Also, move the last callback to an aiodone call, so we no longer do any
memory management from interrupt context.
2006-09-01 23:41:28 +04:00
|
|
|
/*
|
|
|
|
* The only buffers that are going to hit these functions are the
|
|
|
|
* segment write blocks, or the segment summaries, or the superblocks.
|
|
|
|
*
|
|
|
|
* All of the above are created by lfs_newbuf, and so do not need to be
|
|
|
|
* released via brelse.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
lfs_callback(struct buf *bp)
|
|
|
|
{
|
|
|
|
|
|
|
|
lfs_generic_callback(bp, lfs_free_aiodone);
|
|
|
|
}
|
|
|
|
|
1994-06-08 15:41:58 +04:00
|
|
|
/*
|
|
|
|
* Shellsort (diminishing increment sort) from Data Structures and
|
|
|
|
* Algorithms, Aho, Hopcraft and Ullman, 1983 Edition, page 290;
|
|
|
|
* see also Knuth Vol. 3, page 84. The increments are selected from
|
|
|
|
* formula (8), page 95. Roughly O(N^3/2).
|
|
|
|
*/
|
|
|
|
/*
|
|
|
|
* This is our own private copy of shellsort because we want to sort
|
|
|
|
* two parallel arrays (the array of buffer pointers and the array of
|
|
|
|
* logical block numbers) simultaneously. Note that we cast the array
|
|
|
|
* of logical block numbers to a unsigned in this routine so that the
|
|
|
|
* negative block numbers (meta data blocks) sort AFTER the data blocks.
|
|
|
|
*/
|
1999-03-10 03:20:00 +03:00
|
|
|
|
1994-06-08 15:41:58 +04:00
|
|
|
void
|
2003-02-23 03:22:33 +03:00
|
|
|
lfs_shellsort(struct buf **bp_array, int32_t *lb_array, int nmemb, int size)
|
1994-06-08 15:41:58 +04:00
|
|
|
{
|
|
|
|
static int __rsshell_increments[] = { 4, 1, 0 };
|
2000-03-30 16:41:09 +04:00
|
|
|
int incr, *incrp, t1, t2;
|
1994-06-08 15:41:58 +04:00
|
|
|
struct buf *bp_temp;
|
|
|
|
|
2003-04-01 18:58:43 +04:00
|
|
|
#ifdef DEBUG
|
|
|
|
incr = 0;
|
|
|
|
for (t1 = 0; t1 < nmemb; t1++) {
|
|
|
|
for (t2 = 0; t2 * size < bp_array[t1]->b_bcount; t2++) {
|
|
|
|
if (lb_array[incr++] != bp_array[t1]->b_lblkno + t2) {
|
|
|
|
/* dump before panic */
|
|
|
|
printf("lfs_shellsort: nmemb=%d, size=%d\n",
|
|
|
|
nmemb, size);
|
|
|
|
incr = 0;
|
|
|
|
for (t1 = 0; t1 < nmemb; t1++) {
|
|
|
|
const struct buf *bp = bp_array[t1];
|
|
|
|
|
|
|
|
printf("bp[%d]: lbn=%" PRIu64 ", size=%"
|
|
|
|
PRIu64 "\n", t1,
|
|
|
|
(uint64_t)bp->b_bcount,
|
|
|
|
(uint64_t)bp->b_lblkno);
|
|
|
|
printf("lbns:");
|
|
|
|
for (t2 = 0; t2 * size < bp->b_bcount;
|
|
|
|
t2++) {
|
|
|
|
printf(" %" PRId32,
|
|
|
|
lb_array[incr++]);
|
|
|
|
}
|
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
panic("lfs_shellsort: inconsistent input");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
1996-02-10 01:28:45 +03:00
|
|
|
for (incrp = __rsshell_increments; (incr = *incrp++) != 0;)
|
1994-06-08 15:41:58 +04:00
|
|
|
for (t1 = incr; t1 < nmemb; ++t1)
|
|
|
|
for (t2 = t1 - incr; t2 >= 0;)
|
2003-02-23 03:22:33 +03:00
|
|
|
if ((u_int32_t)bp_array[t2]->b_lblkno >
|
|
|
|
(u_int32_t)bp_array[t2 + incr]->b_lblkno) {
|
1994-06-08 15:41:58 +04:00
|
|
|
bp_temp = bp_array[t2];
|
|
|
|
bp_array[t2] = bp_array[t2 + incr];
|
|
|
|
bp_array[t2 + incr] = bp_temp;
|
|
|
|
t2 -= incr;
|
|
|
|
} else
|
|
|
|
break;
|
2003-02-23 03:22:33 +03:00
|
|
|
|
|
|
|
/* Reform the list of logical blocks */
|
|
|
|
incr = 0;
|
|
|
|
for (t1 = 0; t1 < nmemb; t1++) {
|
|
|
|
for (t2 = 0; t2 * size < bp_array[t1]->b_bcount; t2++) {
|
|
|
|
lb_array[incr++] = bp_array[t1]->b_lblkno + t2;
|
|
|
|
}
|
|
|
|
}
|
1994-06-08 15:41:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2006-04-14 03:46:28 +04:00
|
|
|
* Call vget with LK_NOWAIT. If we are the one who holds VXLOCK/VFREEING,
|
|
|
|
* however, we must press on. Just fake success in that case.
|
1994-06-08 15:41:58 +04:00
|
|
|
*/
|
1996-02-10 01:28:45 +03: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_vref(struct vnode *vp)
|
1994-06-08 15:41:58 +04:00
|
|
|
{
|
2006-04-14 03:46:28 +04:00
|
|
|
int error;
|
|
|
|
struct lfs *fs;
|
|
|
|
|
|
|
|
fs = VTOI(vp)->i_lfs;
|
|
|
|
|
|
|
|
ASSERT_MAYBE_SEGLOCK(fs);
|
|
|
|
|
1999-03-10 03:20:00 +03:00
|
|
|
/*
|
|
|
|
* If we return 1 here during a flush, we risk vinvalbuf() not
|
|
|
|
* being able to flush all of the pages from this vnode, which
|
|
|
|
* will cause it to panic. So, return 0 if a flush is in progress.
|
|
|
|
*/
|
2006-04-14 03:46:28 +04:00
|
|
|
error = vget(vp, LK_NOWAIT);
|
|
|
|
if (error == EBUSY && IS_FLUSHING(VTOI(vp)->i_lfs, vp)) {
|
|
|
|
++fs->lfs_flushvp_fakevref;
|
|
|
|
return 0;
|
1999-03-10 03:20:00 +03:00
|
|
|
}
|
2006-04-14 03:46:28 +04:00
|
|
|
return error;
|
1994-06-08 15:41:58 +04:00
|
|
|
}
|
|
|
|
|
1998-03-01 05:20:01 +03:00
|
|
|
/*
|
|
|
|
* This is vrele except that we do not want to VOP_INACTIVE this vnode. We
|
|
|
|
* inline vrele here to avoid the vn_lock and VOP_INACTIVE call at the end.
|
|
|
|
*/
|
1994-06-08 15:41:58 +04:00
|
|
|
void
|
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_vunref(struct vnode *vp)
|
1994-06-08 15:41:58 +04:00
|
|
|
{
|
2006-04-14 03:46:28 +04:00
|
|
|
struct lfs *fs;
|
|
|
|
|
|
|
|
fs = VTOI(vp)->i_lfs;
|
|
|
|
ASSERT_MAYBE_SEGLOCK(fs);
|
|
|
|
|
1999-03-26 00:54:10 +03:00
|
|
|
/*
|
|
|
|
* Analogous to lfs_vref, if the node is flushing, fake it.
|
|
|
|
*/
|
2006-04-14 03:46:28 +04:00
|
|
|
if (IS_FLUSHING(fs, vp) && fs->lfs_flushvp_fakevref) {
|
|
|
|
--fs->lfs_flushvp_fakevref;
|
1999-03-26 00:54:10 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
1998-03-01 05:20:01 +03:00
|
|
|
simple_lock(&vp->v_interlock);
|
1999-03-10 03:20:00 +03:00
|
|
|
#ifdef DIAGNOSTIC
|
2001-11-24 00:44:25 +03:00
|
|
|
if (vp->v_usecount <= 0) {
|
2005-08-19 06:04:03 +04:00
|
|
|
printf("lfs_vunref: inum is %llu\n", (unsigned long long)
|
|
|
|
VTOI(vp)->i_number);
|
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
|
|
|
printf("lfs_vunref: flags are 0x%lx\n", (u_long)vp->v_flag);
|
|
|
|
printf("lfs_vunref: usecount = %ld\n", (long)vp->v_usecount);
|
2005-03-08 03:18:19 +03:00
|
|
|
panic("lfs_vunref: v_usecount < 0");
|
1999-03-10 03:20:00 +03:00
|
|
|
}
|
|
|
|
#endif
|
1998-03-01 05:20:01 +03:00
|
|
|
vp->v_usecount--;
|
|
|
|
if (vp->v_usecount > 0) {
|
|
|
|
simple_unlock(&vp->v_interlock);
|
|
|
|
return;
|
|
|
|
}
|
1994-06-08 15:41:58 +04:00
|
|
|
/*
|
1998-03-01 05:20:01 +03:00
|
|
|
* insert at tail of LRU list
|
1994-06-08 15:41:58 +04:00
|
|
|
*/
|
1998-03-01 05:20:01 +03:00
|
|
|
simple_lock(&vnode_free_list_slock);
|
2000-01-19 03:03:04 +03:00
|
|
|
if (vp->v_holdcnt > 0)
|
|
|
|
TAILQ_INSERT_TAIL(&vnode_hold_list, vp, v_freelist);
|
|
|
|
else
|
|
|
|
TAILQ_INSERT_TAIL(&vnode_free_list, vp, v_freelist);
|
1998-03-01 05:20:01 +03:00
|
|
|
simple_unlock(&vnode_free_list_slock);
|
|
|
|
simple_unlock(&vp->v_interlock);
|
1994-06-08 15:41:58 +04:00
|
|
|
}
|
1999-03-10 03:20:00 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* We use this when we have vnodes that were loaded in solely for cleaning.
|
|
|
|
* There is no reason to believe that these vnodes will be referenced again
|
|
|
|
* soon, since the cleaning process is unrelated to normal filesystem
|
|
|
|
* activity. Putting cleaned vnodes at the tail of the list has the effect
|
|
|
|
* of flushing the vnode LRU. So, put vnodes that were loaded only for
|
|
|
|
* cleaning at the head of the list, instead.
|
|
|
|
*/
|
|
|
|
void
|
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_vunref_head(struct vnode *vp)
|
1999-03-10 03:20:00 +03:00
|
|
|
{
|
2003-07-23 17:53:51 +04:00
|
|
|
|
2005-04-02 01:59:46 +04:00
|
|
|
ASSERT_SEGLOCK(VTOI(vp)->i_lfs);
|
1999-03-10 03:20:00 +03:00
|
|
|
simple_lock(&vp->v_interlock);
|
|
|
|
#ifdef DIAGNOSTIC
|
2001-11-24 00:44:25 +03:00
|
|
|
if (vp->v_usecount == 0) {
|
1999-03-10 03:20:00 +03:00
|
|
|
panic("lfs_vunref: v_usecount<0");
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
vp->v_usecount--;
|
|
|
|
if (vp->v_usecount > 0) {
|
|
|
|
simple_unlock(&vp->v_interlock);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* insert at head of LRU list
|
|
|
|
*/
|
|
|
|
simple_lock(&vnode_free_list_slock);
|
2002-05-24 03:05:25 +04:00
|
|
|
if (vp->v_holdcnt > 0)
|
|
|
|
TAILQ_INSERT_TAIL(&vnode_hold_list, vp, v_freelist);
|
|
|
|
else
|
|
|
|
TAILQ_INSERT_HEAD(&vnode_free_list, vp, v_freelist);
|
1999-03-10 03:20:00 +03:00
|
|
|
simple_unlock(&vnode_free_list_slock);
|
|
|
|
simple_unlock(&vp->v_interlock);
|
|
|
|
}
|
|
|
|
|
2006-05-19 03:15:09 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Set up an FINFO entry for a new file. The fip pointer is assumed to
|
|
|
|
* point at uninitialized space.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
lfs_acquire_finfo(struct lfs *fs, ino_t ino, int vers)
|
|
|
|
{
|
|
|
|
struct segment *sp = fs->lfs_sp;
|
|
|
|
|
2006-05-20 05:10:18 +04:00
|
|
|
KASSERT(vers > 0);
|
|
|
|
|
2006-05-19 03:15:09 +04:00
|
|
|
if (sp->seg_bytes_left < fs->lfs_bsize ||
|
|
|
|
sp->sum_bytes_left < sizeof(struct finfo))
|
|
|
|
(void) lfs_writeseg(fs, fs->lfs_sp);
|
|
|
|
|
|
|
|
sp->sum_bytes_left -= FINFOSIZE;
|
|
|
|
++((SEGSUM *)(sp->segsum))->ss_nfinfo;
|
|
|
|
sp->fip->fi_nblocks = 0;
|
|
|
|
sp->fip->fi_ino = ino;
|
|
|
|
sp->fip->fi_version = vers;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Release the FINFO entry, either clearing out an unused entry or
|
|
|
|
* advancing us to the next available entry.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
lfs_release_finfo(struct lfs *fs)
|
|
|
|
{
|
|
|
|
struct segment *sp = fs->lfs_sp;
|
|
|
|
|
|
|
|
if (sp->fip->fi_nblocks != 0) {
|
2007-03-04 08:59:00 +03:00
|
|
|
sp->fip = (FINFO*)((char *)sp->fip + FINFOSIZE +
|
2006-05-19 03:15:09 +04:00
|
|
|
sizeof(int32_t) * sp->fip->fi_nblocks);
|
|
|
|
sp->start_lbp = &sp->fip->fi_blocks[0];
|
|
|
|
} else {
|
|
|
|
sp->sum_bytes_left += FINFOSIZE;
|
|
|
|
--((SEGSUM *)(sp->segsum))->ss_nfinfo;
|
|
|
|
}
|
|
|
|
}
|