2009-01-11 05:45:45 +03:00
|
|
|
/* $NetBSD: lfs_syscalls.c,v 1.134 2009/01/11 02:45:56 christos Exp $ */
|
1994-06-29 10:39:25 +04:00
|
|
|
|
1999-03-10 03:20:00 +03:00
|
|
|
/*-
|
2008-04-21 15:45:34 +04:00
|
|
|
* Copyright (c) 1999, 2000, 2001, 2002, 2003, 2007, 2007, 2008
|
2008-01-30 14:46:59 +03:00
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
|
|
|
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
|
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
|
|
|
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
1994-06-08 15:41:58 +04:00
|
|
|
/*-
|
|
|
|
* Copyright (c) 1991, 1993, 1994
|
|
|
|
* The Regents of the University of California. All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
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_syscalls.c 8.10 (Berkeley) 5/14/95
|
1994-06-08 15:41:58 +04:00
|
|
|
*/
|
|
|
|
|
2001-11-08 05:39:06 +03:00
|
|
|
#include <sys/cdefs.h>
|
2009-01-11 05:45:45 +03:00
|
|
|
__KERNEL_RCSID(0, "$NetBSD: lfs_syscalls.c,v 1.134 2009/01/11 02:45:56 christos Exp $");
|
2001-11-08 05:39:06 +03:00
|
|
|
|
2003-03-09 02:18:54 +03:00
|
|
|
#ifndef LFS
|
|
|
|
# define LFS /* for prototypes in syscallargs.h */
|
|
|
|
#endif
|
1998-02-19 03:54:39 +03:00
|
|
|
|
1994-06-08 15:41:58 +04:00
|
|
|
#include <sys/param.h>
|
1994-10-20 07:20:55 +03:00
|
|
|
#include <sys/systm.h>
|
1994-06-08 15:41:58 +04:00
|
|
|
#include <sys/proc.h>
|
|
|
|
#include <sys/buf.h>
|
|
|
|
#include <sys/mount.h>
|
|
|
|
#include <sys/vnode.h>
|
|
|
|
#include <sys/kernel.h>
|
2006-05-15 01:31:52 +04:00
|
|
|
#include <sys/kauth.h>
|
1994-10-20 07:20:55 +03:00
|
|
|
#include <sys/syscallargs.h>
|
|
|
|
|
1994-06-08 15:41:58 +04:00
|
|
|
#include <ufs/ufs/inode.h>
|
|
|
|
#include <ufs/ufs/ufsmount.h>
|
|
|
|
#include <ufs/ufs/ufs_extern.h>
|
|
|
|
|
|
|
|
#include <ufs/lfs/lfs.h>
|
|
|
|
#include <ufs/lfs/lfs_extern.h>
|
1996-02-10 01:28:45 +03:00
|
|
|
|
2007-03-04 08:59:00 +03:00
|
|
|
struct buf *lfs_fakebuf(struct lfs *, struct vnode *, int, size_t, void *);
|
2002-12-17 17:37:49 +03:00
|
|
|
int lfs_fasthashget(dev_t, ino_t, struct vnode **);
|
1994-06-08 15:41:58 +04:00
|
|
|
|
1999-03-10 03:20:00 +03:00
|
|
|
pid_t lfs_cleaner_pid = 0;
|
|
|
|
|
1994-06-08 15:41:58 +04:00
|
|
|
/*
|
1999-06-09 08:52:11 +04:00
|
|
|
* sys_lfs_markv:
|
1994-06-08 15:41:58 +04:00
|
|
|
*
|
|
|
|
* This will mark inodes and blocks dirty, so they are written into the log.
|
|
|
|
* It will block until all the blocks have been written. The segment create
|
|
|
|
* time passed in the block_info and inode_info structures is used to decide
|
|
|
|
* if the data is valid for each block (in case some process dirtied a block
|
|
|
|
* or inode that is being cleaned between the determination that a block is
|
|
|
|
* live and the lfs_markv call).
|
|
|
|
*
|
|
|
|
* 0 on success
|
|
|
|
* -1/errno is return on error.
|
|
|
|
*/
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
#ifdef USE_64BIT_SYSCALLS
|
|
|
|
int
|
2007-12-21 02:02:38 +03:00
|
|
|
sys_lfs_markv(struct lwp *l, const struct sys_lfs_markv_args *uap, register_t *retval)
|
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
|
|
|
{
|
2007-12-21 02:02:38 +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
|
|
|
syscallarg(fsid_t *) fsidp;
|
|
|
|
syscallarg(struct block_info *) blkiov;
|
|
|
|
syscallarg(int) blkcnt;
|
2007-12-21 02:02:38 +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
|
|
|
BLOCK_INFO *blkiov;
|
|
|
|
int blkcnt, error;
|
|
|
|
fsid_t fsid;
|
2005-04-16 21:28:37 +04:00
|
|
|
struct lfs *fs;
|
|
|
|
struct mount *mntp;
|
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
|
|
|
|
2006-07-24 02:06:03 +04:00
|
|
|
if ((error = kauth_authorize_generic(l->l_cred, KAUTH_GENERIC_ISSUSER,
|
2007-01-04 19:55:29 +03:00
|
|
|
NULL)) != 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
|
|
|
return (error);
|
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
|
|
|
if ((error = copyin(SCARG(uap, fsidp), &fsid, sizeof(fsid_t))) != 0)
|
|
|
|
return (error);
|
|
|
|
|
2005-04-16 21:28:37 +04:00
|
|
|
if ((mntp = vfs_getvfs(fsidp)) == NULL)
|
|
|
|
return (ENOENT);
|
|
|
|
fs = VFSTOUFS(mntp)->um_lfs;
|
|
|
|
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
blkcnt = SCARG(uap, blkcnt);
|
2003-02-24 11:42:49 +03:00
|
|
|
if ((u_int) blkcnt > LFS_MARKV_MAXBLKCNT)
|
2001-08-03 10:02:42 +04:00
|
|
|
return (EINVAL);
|
|
|
|
|
2008-04-21 15:45:34 +04:00
|
|
|
KERNEL_LOCK(1, NULL);
|
2005-04-16 21:28:37 +04:00
|
|
|
blkiov = lfs_malloc(fs, blkcnt * sizeof(BLOCK_INFO), LFS_NB_BLKIOV);
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
if ((error = copyin(SCARG(uap, blkiov), blkiov,
|
|
|
|
blkcnt * sizeof(BLOCK_INFO))) != 0)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
if ((error = lfs_markv(p, &fsid, blkiov, blkcnt)) == 0)
|
|
|
|
copyout(blkiov, SCARG(uap, blkiov),
|
|
|
|
blkcnt * sizeof(BLOCK_INFO));
|
|
|
|
out:
|
2005-04-16 21:28:37 +04:00
|
|
|
lfs_free(fs, blkiov, LFS_NB_BLKIOV);
|
2008-04-21 15:45:34 +04:00
|
|
|
KERNEL_UNLOCK_ONE(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
|
|
|
return error;
|
|
|
|
}
|
|
|
|
#else
|
1994-06-08 15:41:58 +04:00
|
|
|
int
|
2007-12-21 02:02:38 +03:00
|
|
|
sys_lfs_markv(struct lwp *l, const struct sys_lfs_markv_args *uap, register_t *retval)
|
1995-09-22 03:39:20 +04:00
|
|
|
{
|
2007-12-21 02:02:38 +03:00
|
|
|
/* {
|
1994-10-20 07:20:55 +03:00
|
|
|
syscallarg(fsid_t *) fsidp;
|
|
|
|
syscallarg(struct block_info *) blkiov;
|
|
|
|
syscallarg(int) blkcnt;
|
2007-12-21 02:02:38 +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
|
|
|
BLOCK_INFO *blkiov;
|
|
|
|
BLOCK_INFO_15 *blkiov15;
|
|
|
|
int i, blkcnt, error;
|
|
|
|
fsid_t fsid;
|
2005-04-16 21:28:37 +04:00
|
|
|
struct lfs *fs;
|
|
|
|
struct mount *mntp;
|
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
|
|
|
|
2006-07-24 02:06:03 +04:00
|
|
|
if ((error = kauth_authorize_generic(l->l_cred, KAUTH_GENERIC_ISSUSER,
|
2007-01-04 19:55:29 +03:00
|
|
|
NULL)) != 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
|
|
|
return (error);
|
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
|
|
|
if ((error = copyin(SCARG(uap, fsidp), &fsid, sizeof(fsid_t))) != 0)
|
|
|
|
return (error);
|
|
|
|
|
2005-04-16 21:28:37 +04:00
|
|
|
if ((mntp = vfs_getvfs(&fsid)) == NULL)
|
|
|
|
return (ENOENT);
|
|
|
|
fs = VFSTOUFS(mntp)->um_lfs;
|
|
|
|
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
blkcnt = SCARG(uap, blkcnt);
|
2003-02-24 11:42:49 +03:00
|
|
|
if ((u_int) blkcnt > LFS_MARKV_MAXBLKCNT)
|
2001-08-03 10:02:42 +04:00
|
|
|
return (EINVAL);
|
|
|
|
|
2008-04-21 15:45:34 +04:00
|
|
|
KERNEL_LOCK(1, NULL);
|
2005-04-16 21:28:37 +04:00
|
|
|
blkiov = lfs_malloc(fs, blkcnt * sizeof(BLOCK_INFO), LFS_NB_BLKIOV);
|
|
|
|
blkiov15 = lfs_malloc(fs, blkcnt * sizeof(BLOCK_INFO_15), LFS_NB_BLKIOV);
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
if ((error = copyin(SCARG(uap, blkiov), blkiov15,
|
|
|
|
blkcnt * sizeof(BLOCK_INFO_15))) != 0)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
for (i = 0; i < blkcnt; i++) {
|
|
|
|
blkiov[i].bi_inode = blkiov15[i].bi_inode;
|
|
|
|
blkiov[i].bi_lbn = blkiov15[i].bi_lbn;
|
|
|
|
blkiov[i].bi_daddr = blkiov15[i].bi_daddr;
|
|
|
|
blkiov[i].bi_segcreate = blkiov15[i].bi_segcreate;
|
|
|
|
blkiov[i].bi_version = blkiov15[i].bi_version;
|
2003-02-20 07:27:23 +03:00
|
|
|
blkiov[i].bi_bp = blkiov15[i].bi_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
|
|
|
blkiov[i].bi_size = blkiov15[i].bi_size;
|
|
|
|
}
|
|
|
|
|
2006-07-24 02:06:03 +04:00
|
|
|
if ((error = lfs_markv(l->l_proc, &fsid, blkiov, blkcnt)) == 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
|
|
|
for (i = 0; i < blkcnt; i++) {
|
2003-02-20 07:27:23 +03:00
|
|
|
blkiov15[i].bi_inode = blkiov[i].bi_inode;
|
|
|
|
blkiov15[i].bi_lbn = blkiov[i].bi_lbn;
|
|
|
|
blkiov15[i].bi_daddr = blkiov[i].bi_daddr;
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
blkiov15[i].bi_segcreate = blkiov[i].bi_segcreate;
|
2003-02-20 07:27:23 +03:00
|
|
|
blkiov15[i].bi_version = blkiov[i].bi_version;
|
|
|
|
blkiov15[i].bi_bp = blkiov[i].bi_bp;
|
|
|
|
blkiov15[i].bi_size = blkiov[i].bi_size;
|
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
|
|
|
}
|
|
|
|
copyout(blkiov15, SCARG(uap, blkiov),
|
|
|
|
blkcnt * sizeof(BLOCK_INFO_15));
|
|
|
|
}
|
|
|
|
out:
|
2005-04-16 21:28:37 +04:00
|
|
|
lfs_free(fs, blkiov, LFS_NB_BLKIOV);
|
|
|
|
lfs_free(fs, blkiov15, LFS_NB_BLKIOV);
|
2008-04-21 15:45:34 +04:00
|
|
|
KERNEL_UNLOCK_ONE(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
|
|
|
return error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2002-12-26 16:04:39 +03:00
|
|
|
#define LFS_MARKV_MAX_BLOCKS (LFS_MAX_BUFS)
|
|
|
|
|
2003-02-24 11:42:49 +03:00
|
|
|
int
|
2006-11-16 04:32:37 +03:00
|
|
|
lfs_markv(struct proc *p, fsid_t *fsidp, BLOCK_INFO *blkiov,
|
2006-10-12 05:30:41 +04:00
|
|
|
int blkcnt)
|
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
|
|
|
BLOCK_INFO *blkp;
|
|
|
|
IFILE *ifp;
|
2003-07-30 16:38:53 +04:00
|
|
|
struct buf *bp;
|
1996-02-10 01:28:45 +03:00
|
|
|
struct inode *ip = NULL;
|
1994-06-08 15:41:58 +04:00
|
|
|
struct lfs *fs;
|
|
|
|
struct mount *mntp;
|
2006-03-19 07:10:02 +03:00
|
|
|
struct vnode *vp = NULL;
|
1994-06-08 15:41:58 +04:00
|
|
|
ino_t lastino;
|
2003-01-25 00:55:02 +03:00
|
|
|
daddr_t b_daddr, v_daddr;
|
2002-12-17 17:37:49 +03:00
|
|
|
int cnt, error;
|
2001-11-24 00:44:25 +03:00
|
|
|
int do_again = 0;
|
2002-12-17 17:37:49 +03:00
|
|
|
int numrefed = 0;
|
Various bug-fixes to LFS, to wit:
Kernel:
* Add runtime quantity lfs_ravail, the number of disk-blocks reserved
for writing. Writes to the filesystem first reserve a maximum amount
of blocks before their write is allowed to proceed; after the blocks
are allocated the reserved total is reduced by a corresponding amount.
If the lfs_reserve function cannot immediately reserve the requested
number of blocks, the inode is unlocked, and the thread sleeps until
the cleaner has made enough space available for the blocks to be
reserved. In this way large files can be written to the filesystem
(or, smaller files can be written to a nearly-full but thoroughly
clean filesystem) and the cleaner can still function properly.
* Remove explicit switching on dlfs_minfreeseg from the kernel code; it
is now merely a fs-creation parameter used to compute dlfs_avail and
dlfs_bfree (and used by fsck_lfs(8) to check their accuracy). Its
former role is better assumed by a properly computed dlfs_avail.
* Bounds-check inode numbers submitted through lfs_bmapv and lfs_markv.
This prevents a panic, but, if the cleaner is feeding the filesystem
the wrong data, you are still in a world of hurt.
* Cleanup: remove explicit references of DEV_BSIZE in favor of
btodb()/dbtob().
lfs_cleanerd:
* Make -n mean "send N segments' blocks through a single call to
lfs_markv". Previously it had meant "clean N segments though N calls
to lfs_markv, before looking again to see if more need to be cleaned".
The new behavior gives better packing of direct data on disk with as
little metadata as possible, largely alleviating the problem that the
cleaner can consume more disk through inefficient use of metadata than
it frees by moving dirty data away from clean "holes" to produce
entirely clean segments.
* Make -b mean "read as many segments as necessary to write N segments
of dirty data back to disk", rather than its former meaning of "read
as many segments as necessary to free N segments worth of space". The
new meaning, combined with the new -n behavior described above,
further aids in cleaning storage efficiency as entire segments can be
written at once, using as few blocks as possible for segment summaries
and inode blocks.
* Make the cleaner take note of segments which could not be cleaned due
to error, and not attempt to clean them until they are entirely free
of dirty blocks. This prevents the case in which a cleanerd running
with -n 1 and without -b (formerly the default) would spin trying
repeatedly to clean a corrupt segment, while the remaining space
filled and deadlocked the filesystem.
* Update the lfs_cleanerd manual page to describe all the options,
including the changes mentioned here (in particular, the -b and -n
flags were previously undocumented).
fsck_lfs:
* Check, and optionally fix, lfs_avail (to an exact figure) and
lfs_bfree (within a margin of error) in pass 5.
newfs_lfs:
* Reduce the default dlfs_minfreeseg to 1/20 of the total segments.
* Add a warning if the sgs disklabel field is 16 (the default for FFS'
cpg, but not usually desirable for LFS' sgs: 5--8 is a better range).
* Change the calculation of lfs_avail and lfs_bfree, corresponding to
the kernel changes mentioned above.
mount_lfs:
* Add -N and -b options to pass corresponding -n and -b options to
lfs_cleanerd.
* Default to calling lfs_cleanerd with "-b -n 4".
[All of these changes were largely tested in the 1.5 branch, with the
idea that they (along with previous un-pulled-up work) could be applied
to the branch while it was still in ALPHA2; however my test system has
experienced corruption on another filesystem (/dev/console has gone
missing :^), and, while I believe this unrelated to the LFS changes, I
cannot with good conscience request that the changes be pulled up.]
2000-09-09 08:49:54 +04:00
|
|
|
ino_t maxino;
|
2002-07-06 05:30:11 +04:00
|
|
|
size_t obsize;
|
1994-06-08 15:41:58 +04:00
|
|
|
|
2002-12-26 16:04:39 +03:00
|
|
|
/* number of blocks/inodes that we have already bwrite'ed */
|
|
|
|
int nblkwritten, ninowritten;
|
|
|
|
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
if ((mntp = vfs_getvfs(fsidp)) == NULL)
|
2000-11-23 01:11:34 +03:00
|
|
|
return (ENOENT);
|
1994-06-08 15:41:58 +04:00
|
|
|
|
1999-03-10 03:20:00 +03:00
|
|
|
fs = VFSTOUFS(mntp)->um_lfs;
|
2003-07-30 16:38:53 +04:00
|
|
|
|
|
|
|
if (fs->lfs_ronly)
|
|
|
|
return EROFS;
|
|
|
|
|
2003-04-02 14:39:19 +04:00
|
|
|
maxino = (fragstoblks(fs, fsbtofrags(fs, VTOI(fs->lfs_ivnode)->i_ffs1_blocks)) -
|
Various bug-fixes to LFS, to wit:
Kernel:
* Add runtime quantity lfs_ravail, the number of disk-blocks reserved
for writing. Writes to the filesystem first reserve a maximum amount
of blocks before their write is allowed to proceed; after the blocks
are allocated the reserved total is reduced by a corresponding amount.
If the lfs_reserve function cannot immediately reserve the requested
number of blocks, the inode is unlocked, and the thread sleeps until
the cleaner has made enough space available for the blocks to be
reserved. In this way large files can be written to the filesystem
(or, smaller files can be written to a nearly-full but thoroughly
clean filesystem) and the cleaner can still function properly.
* Remove explicit switching on dlfs_minfreeseg from the kernel code; it
is now merely a fs-creation parameter used to compute dlfs_avail and
dlfs_bfree (and used by fsck_lfs(8) to check their accuracy). Its
former role is better assumed by a properly computed dlfs_avail.
* Bounds-check inode numbers submitted through lfs_bmapv and lfs_markv.
This prevents a panic, but, if the cleaner is feeding the filesystem
the wrong data, you are still in a world of hurt.
* Cleanup: remove explicit references of DEV_BSIZE in favor of
btodb()/dbtob().
lfs_cleanerd:
* Make -n mean "send N segments' blocks through a single call to
lfs_markv". Previously it had meant "clean N segments though N calls
to lfs_markv, before looking again to see if more need to be cleaned".
The new behavior gives better packing of direct data on disk with as
little metadata as possible, largely alleviating the problem that the
cleaner can consume more disk through inefficient use of metadata than
it frees by moving dirty data away from clean "holes" to produce
entirely clean segments.
* Make -b mean "read as many segments as necessary to write N segments
of dirty data back to disk", rather than its former meaning of "read
as many segments as necessary to free N segments worth of space". The
new meaning, combined with the new -n behavior described above,
further aids in cleaning storage efficiency as entire segments can be
written at once, using as few blocks as possible for segment summaries
and inode blocks.
* Make the cleaner take note of segments which could not be cleaned due
to error, and not attempt to clean them until they are entirely free
of dirty blocks. This prevents the case in which a cleanerd running
with -n 1 and without -b (formerly the default) would spin trying
repeatedly to clean a corrupt segment, while the remaining space
filled and deadlocked the filesystem.
* Update the lfs_cleanerd manual page to describe all the options,
including the changes mentioned here (in particular, the -b and -n
flags were previously undocumented).
fsck_lfs:
* Check, and optionally fix, lfs_avail (to an exact figure) and
lfs_bfree (within a margin of error) in pass 5.
newfs_lfs:
* Reduce the default dlfs_minfreeseg to 1/20 of the total segments.
* Add a warning if the sgs disklabel field is 16 (the default for FFS'
cpg, but not usually desirable for LFS' sgs: 5--8 is a better range).
* Change the calculation of lfs_avail and lfs_bfree, corresponding to
the kernel changes mentioned above.
mount_lfs:
* Add -N and -b options to pass corresponding -n and -b options to
lfs_cleanerd.
* Default to calling lfs_cleanerd with "-b -n 4".
[All of these changes were largely tested in the 1.5 branch, with the
idea that they (along with previous un-pulled-up work) could be applied
to the branch while it was still in ALPHA2; however my test system has
experienced corruption on another filesystem (/dev/console has gone
missing :^), and, while I believe this unrelated to the LFS changes, I
cannot with good conscience request that the changes be pulled up.]
2000-09-09 08:49:54 +04:00
|
|
|
fs->lfs_cleansz - fs->lfs_segtabsz) * fs->lfs_ifpb;
|
|
|
|
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
cnt = blkcnt;
|
2005-02-27 01:31:44 +03:00
|
|
|
|
PR kern/38141 lookup/vfs_busy acquire rwlock recursively
Simplify the mount locking. Remove all the crud to deal with recursion on
the mount lock, and crud to deal with unmount as another weirdo lock.
Hopefully this will once and for all fix the deadlocks with this. With this
commit there are two locks on each mount:
- krwlock_t mnt_unmounting. This is used to prevent unmount across critical
sections like getnewvnode(). It's only ever read locked with rw_tryenter(),
and is only ever write locked in dounmount(). A write hold can't be taken
on this lock if the current LWP could hold a vnode lock.
- kmutex_t mnt_updating. This is taken by threads updating the mount, for
example when going r/o -> r/w, and is only present to serialize updates.
In order to take this lock, a read hold must first be taken on
mnt_unmounting, and the two need to be held across the operation.
One effect of this change: previously if an unmount failed, we would make a
half hearted attempt to back out of it gracefully, but that was unlikely to
work in a lot of cases. Now while an unmount that will be aborted is in
progress, new file operations within the mount will fail instead of being
delayed. That is unlikely to be a problem though, because if the admin
requests unmount of a file system then s(he) has made a decision to deny
access to the resource.
2008-05-06 22:43:44 +04:00
|
|
|
if ((error = vfs_busy(mntp, NULL)) != 0)
|
2000-11-23 01:11:34 +03:00
|
|
|
return (error);
|
|
|
|
|
1999-03-10 03:20:00 +03:00
|
|
|
/*
|
|
|
|
* This seglock is just to prevent the fact that we might have to sleep
|
|
|
|
* from allowing the possibility that our blocks might become
|
|
|
|
* invalid.
|
|
|
|
*
|
|
|
|
* It is also important to note here that unless we specify SEGM_CKP,
|
|
|
|
* any Ifile blocks that we might be asked to clean will never get
|
|
|
|
* to the disk.
|
|
|
|
*/
|
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_seglock(fs, SEGM_CLEAN | SEGM_CKP | SEGM_SYNC);
|
2005-02-27 01:31:44 +03:00
|
|
|
|
1994-06-08 15:41:58 +04:00
|
|
|
/* Mark blocks/inodes dirty. */
|
|
|
|
error = 0;
|
|
|
|
|
1999-03-10 03:20:00 +03:00
|
|
|
/* these were inside the initialization for the for loop */
|
|
|
|
v_daddr = LFS_UNUSED_DADDR;
|
|
|
|
lastino = LFS_UNUSED_INUM;
|
2002-12-26 16:04:39 +03:00
|
|
|
nblkwritten = ninowritten = 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
|
|
|
for (blkp = blkiov; cnt--; ++blkp)
|
1999-03-10 03:20:00 +03:00
|
|
|
{
|
Various bug-fixes to LFS, to wit:
Kernel:
* Add runtime quantity lfs_ravail, the number of disk-blocks reserved
for writing. Writes to the filesystem first reserve a maximum amount
of blocks before their write is allowed to proceed; after the blocks
are allocated the reserved total is reduced by a corresponding amount.
If the lfs_reserve function cannot immediately reserve the requested
number of blocks, the inode is unlocked, and the thread sleeps until
the cleaner has made enough space available for the blocks to be
reserved. In this way large files can be written to the filesystem
(or, smaller files can be written to a nearly-full but thoroughly
clean filesystem) and the cleaner can still function properly.
* Remove explicit switching on dlfs_minfreeseg from the kernel code; it
is now merely a fs-creation parameter used to compute dlfs_avail and
dlfs_bfree (and used by fsck_lfs(8) to check their accuracy). Its
former role is better assumed by a properly computed dlfs_avail.
* Bounds-check inode numbers submitted through lfs_bmapv and lfs_markv.
This prevents a panic, but, if the cleaner is feeding the filesystem
the wrong data, you are still in a world of hurt.
* Cleanup: remove explicit references of DEV_BSIZE in favor of
btodb()/dbtob().
lfs_cleanerd:
* Make -n mean "send N segments' blocks through a single call to
lfs_markv". Previously it had meant "clean N segments though N calls
to lfs_markv, before looking again to see if more need to be cleaned".
The new behavior gives better packing of direct data on disk with as
little metadata as possible, largely alleviating the problem that the
cleaner can consume more disk through inefficient use of metadata than
it frees by moving dirty data away from clean "holes" to produce
entirely clean segments.
* Make -b mean "read as many segments as necessary to write N segments
of dirty data back to disk", rather than its former meaning of "read
as many segments as necessary to free N segments worth of space". The
new meaning, combined with the new -n behavior described above,
further aids in cleaning storage efficiency as entire segments can be
written at once, using as few blocks as possible for segment summaries
and inode blocks.
* Make the cleaner take note of segments which could not be cleaned due
to error, and not attempt to clean them until they are entirely free
of dirty blocks. This prevents the case in which a cleanerd running
with -n 1 and without -b (formerly the default) would spin trying
repeatedly to clean a corrupt segment, while the remaining space
filled and deadlocked the filesystem.
* Update the lfs_cleanerd manual page to describe all the options,
including the changes mentioned here (in particular, the -b and -n
flags were previously undocumented).
fsck_lfs:
* Check, and optionally fix, lfs_avail (to an exact figure) and
lfs_bfree (within a margin of error) in pass 5.
newfs_lfs:
* Reduce the default dlfs_minfreeseg to 1/20 of the total segments.
* Add a warning if the sgs disklabel field is 16 (the default for FFS'
cpg, but not usually desirable for LFS' sgs: 5--8 is a better range).
* Change the calculation of lfs_avail and lfs_bfree, corresponding to
the kernel changes mentioned above.
mount_lfs:
* Add -N and -b options to pass corresponding -n and -b options to
lfs_cleanerd.
* Default to calling lfs_cleanerd with "-b -n 4".
[All of these changes were largely tested in the 1.5 branch, with the
idea that they (along with previous un-pulled-up work) could be applied
to the branch while it was still in ALPHA2; however my test system has
experienced corruption on another filesystem (/dev/console has gone
missing :^), and, while I believe this unrelated to the LFS changes, I
cannot with good conscience request that the changes be pulled up.]
2000-09-09 08:49:54 +04:00
|
|
|
/* Bounds-check incoming data, avoid panic for failed VGET */
|
|
|
|
if (blkp->bi_inode <= 0 || blkp->bi_inode >= maxino) {
|
|
|
|
error = EINVAL;
|
2003-07-30 16:38:53 +04:00
|
|
|
goto err3;
|
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
|
|
|
/*
|
|
|
|
* Get the IFILE entry (only once) and see if the file still
|
|
|
|
* exists.
|
|
|
|
*/
|
|
|
|
if (lastino != blkp->bi_inode) {
|
1999-03-10 03:20:00 +03:00
|
|
|
/*
|
|
|
|
* Finish the old file, if there was one. The presence
|
|
|
|
* of a usable vnode in vp is signaled by a valid v_daddr.
|
|
|
|
*/
|
2001-11-24 00:44:25 +03:00
|
|
|
if (v_daddr != LFS_UNUSED_DADDR) {
|
1994-06-08 15:41:58 +04:00
|
|
|
lfs_vunref(vp);
|
1999-03-10 03:20:00 +03:00
|
|
|
numrefed--;
|
1994-06-08 15:41:58 +04:00
|
|
|
}
|
|
|
|
|
1999-03-10 03:20:00 +03:00
|
|
|
/*
|
|
|
|
* Start a new file
|
|
|
|
*/
|
1994-06-08 15:41:58 +04:00
|
|
|
lastino = blkp->bi_inode;
|
|
|
|
if (blkp->bi_inode == LFS_IFILE_INUM)
|
|
|
|
v_daddr = fs->lfs_idaddr;
|
|
|
|
else {
|
|
|
|
LFS_IENTRY(ifp, fs, blkp->bi_inode, bp);
|
1999-03-10 03:20:00 +03:00
|
|
|
/* XXX fix for force write */
|
1994-06-08 15:41:58 +04:00
|
|
|
v_daddr = ifp->if_daddr;
|
2007-10-08 22:01:27 +04:00
|
|
|
brelse(bp, 0);
|
1994-06-08 15:41:58 +04:00
|
|
|
}
|
2006-04-19 02:42:33 +04:00
|
|
|
if (v_daddr == LFS_UNUSED_DADDR)
|
1994-06-08 15:41:58 +04:00
|
|
|
continue;
|
|
|
|
|
|
|
|
/* Get the vnode/inode. */
|
2005-02-27 01:31:44 +03:00
|
|
|
error = lfs_fastvget(mntp, blkp->bi_inode, v_daddr,
|
1999-03-10 03:20:00 +03:00
|
|
|
&vp,
|
2001-11-24 00:44:25 +03:00
|
|
|
(blkp->bi_lbn == LFS_UNUSED_LBN
|
1999-03-10 03:20:00 +03:00
|
|
|
? blkp->bi_bp
|
2002-12-17 17:37:49 +03:00
|
|
|
: NULL));
|
1999-03-10 03:20:00 +03:00
|
|
|
|
2001-11-24 00:44:25 +03:00
|
|
|
if (!error) {
|
1999-03-10 03:20:00 +03:00
|
|
|
numrefed++;
|
|
|
|
}
|
2001-11-24 00:44:25 +03:00
|
|
|
if (error) {
|
2005-03-08 03:18:19 +03:00
|
|
|
DLOG((DLOG_CLEAN, "lfs_markv: lfs_fastvget"
|
|
|
|
" failed with %d (ino %d, segment %d)\n",
|
|
|
|
error, blkp->bi_inode,
|
|
|
|
dtosn(fs, blkp->bi_daddr)));
|
1999-03-10 03:20:00 +03:00
|
|
|
/*
|
|
|
|
* If we got EAGAIN, that means that the
|
|
|
|
* Inode was locked. This is
|
|
|
|
* recoverable: just clean the rest of
|
|
|
|
* this segment, and let the cleaner try
|
2003-02-20 07:27:23 +03:00
|
|
|
* again with another. (When the
|
1999-03-10 03:20:00 +03:00
|
|
|
* cleaner runs again, this segment will
|
|
|
|
* sort high on the list, since it is
|
|
|
|
* now almost entirely empty.) But, we
|
|
|
|
* still set v_daddr = LFS_UNUSED_ADDR
|
|
|
|
* so as not to test this over and over
|
|
|
|
* again.
|
|
|
|
*/
|
2001-11-24 00:44:25 +03:00
|
|
|
if (error == EAGAIN) {
|
1999-03-10 03:20:00 +03:00
|
|
|
error = 0;
|
|
|
|
do_again++;
|
|
|
|
}
|
1994-06-08 15:41:58 +04:00
|
|
|
#ifdef DIAGNOSTIC
|
2001-11-24 00:44:25 +03:00
|
|
|
else if (error != ENOENT)
|
1999-03-10 03:20:00 +03:00
|
|
|
panic("lfs_markv VFS_VGET FAILED");
|
1994-06-08 15:41:58 +04:00
|
|
|
#endif
|
1999-03-10 03:20:00 +03:00
|
|
|
/* lastino = LFS_UNUSED_INUM; */
|
1994-06-08 15:41:58 +04:00
|
|
|
v_daddr = LFS_UNUSED_DADDR;
|
1999-03-10 03:20:00 +03:00
|
|
|
vp = NULL;
|
|
|
|
ip = NULL;
|
1994-06-08 15:41:58 +04:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
ip = VTOI(vp);
|
2002-12-26 16:04:39 +03:00
|
|
|
ninowritten++;
|
1999-03-10 03:20:00 +03:00
|
|
|
} else if (v_daddr == LFS_UNUSED_DADDR) {
|
|
|
|
/*
|
|
|
|
* This can only happen if the vnode is dead (or
|
|
|
|
* in any case we can't get it...e.g., it is
|
|
|
|
* inlocked). Keep going.
|
|
|
|
*/
|
1994-06-08 15:41:58 +04:00
|
|
|
continue;
|
1999-03-10 03:20:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Past this point we are guaranteed that vp, ip are valid. */
|
1994-06-08 15:41:58 +04:00
|
|
|
|
2007-10-11 00:42:20 +04:00
|
|
|
/* Can't clean VU_DIROP directories in case of truncation */
|
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
|
|
|
/* XXX - maybe we should mark removed dirs specially? */
|
2007-10-11 00:42:20 +04:00
|
|
|
if (vp->v_type == VDIR && (vp->v_uflag & VU_DIROP)) {
|
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
|
|
|
do_again++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
1994-06-08 15:41:58 +04:00
|
|
|
/* If this BLOCK_INFO didn't contain a block, keep going. */
|
1999-03-10 03:20:00 +03:00
|
|
|
if (blkp->bi_lbn == LFS_UNUSED_LBN) {
|
|
|
|
/* XXX need to make sure that the inode gets written in this case */
|
|
|
|
/* XXX but only write the inode if it's the right one */
|
2000-11-23 01:11:34 +03:00
|
|
|
if (blkp->bi_inode != LFS_IFILE_INUM) {
|
|
|
|
LFS_IENTRY(ifp, fs, blkp->bi_inode, bp);
|
2008-01-02 14:48:20 +03:00
|
|
|
if (ifp->if_daddr == blkp->bi_daddr) {
|
|
|
|
mutex_enter(&lfs_lock);
|
2000-07-06 02:25:43 +04:00
|
|
|
LFS_SET_UINO(ip, IN_CLEANING);
|
2008-01-02 14:48:20 +03:00
|
|
|
mutex_exit(&lfs_lock);
|
|
|
|
}
|
2007-10-08 22:01:27 +04:00
|
|
|
brelse(bp, 0);
|
2000-11-23 01:11:34 +03:00
|
|
|
}
|
1994-06-08 15:41:58 +04:00
|
|
|
continue;
|
1999-03-10 03:20:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
b_daddr = 0;
|
2006-04-19 02:42:33 +04:00
|
|
|
if (VOP_BMAP(vp, blkp->bi_lbn, NULL, &b_daddr, NULL) ||
|
|
|
|
dbtofsb(fs, b_daddr) != blkp->bi_daddr)
|
|
|
|
{
|
|
|
|
if (dtosn(fs, dbtofsb(fs, b_daddr)) ==
|
|
|
|
dtosn(fs, blkp->bi_daddr))
|
1999-03-10 03:20:00 +03:00
|
|
|
{
|
2006-04-19 02:42:33 +04:00
|
|
|
DLOG((DLOG_CLEAN, "lfs_markv: wrong da same seg: %llx vs %llx\n",
|
|
|
|
(long long)blkp->bi_daddr, (long long)dbtofsb(fs, b_daddr)));
|
1999-03-10 03:20:00 +03:00
|
|
|
}
|
2006-04-19 02:42:33 +04:00
|
|
|
do_again++;
|
|
|
|
continue;
|
1999-03-10 03:20:00 +03:00
|
|
|
}
|
2002-07-06 05:30:11 +04:00
|
|
|
|
1999-03-10 03:20:00 +03:00
|
|
|
/*
|
2002-07-06 05:30:11 +04:00
|
|
|
* Check block sizes. The blocks being cleaned come from
|
|
|
|
* disk, so they should have the same size as their on-disk
|
|
|
|
* counterparts.
|
|
|
|
*/
|
2002-11-24 11:27:00 +03:00
|
|
|
if (blkp->bi_lbn >= 0)
|
|
|
|
obsize = blksize(fs, ip, blkp->bi_lbn);
|
|
|
|
else
|
|
|
|
obsize = fs->lfs_bsize;
|
2002-07-06 05:30:11 +04:00
|
|
|
/* Check for fragment size change */
|
|
|
|
if (blkp->bi_lbn >= 0 && blkp->bi_lbn < NDADDR) {
|
|
|
|
obsize = ip->i_lfs_fragsize[blkp->bi_lbn];
|
|
|
|
}
|
|
|
|
if (obsize != blkp->bi_size) {
|
2005-03-08 03:18:19 +03:00
|
|
|
DLOG((DLOG_CLEAN, "lfs_markv: ino %d lbn %lld wrong"
|
|
|
|
" size (%ld != %d), try again\n",
|
|
|
|
blkp->bi_inode, (long long)blkp->bi_lbn,
|
|
|
|
(long) obsize, blkp->bi_size));
|
2002-07-06 05:30:11 +04:00
|
|
|
do_again++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If we get to here, then we are keeping the block. If
|
1999-03-10 03:20:00 +03:00
|
|
|
* it is an indirect block, we want to actually put it
|
|
|
|
* in the buffer cache so that it can be updated in the
|
2003-02-20 07:27:23 +03:00
|
|
|
* finish_meta section. If it's not, we need to
|
1999-03-10 03:20:00 +03:00
|
|
|
* allocate a fake buffer so that writeseg can perform
|
|
|
|
* the copyin and write the buffer.
|
|
|
|
*/
|
2000-01-15 00:41:11 +03:00
|
|
|
if (ip->i_number != LFS_IFILE_INUM && blkp->bi_lbn >= 0) {
|
|
|
|
/* Data Block */
|
2002-05-15 00:03:53 +04:00
|
|
|
bp = lfs_fakebuf(fs, vp, blkp->bi_lbn,
|
1999-03-26 00:39:18 +03:00
|
|
|
blkp->bi_size, blkp->bi_bp);
|
|
|
|
/* Pretend we used bread() to get it */
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
bp->b_blkno = fsbtodb(fs, blkp->bi_daddr);
|
2000-01-15 00:41:11 +03:00
|
|
|
} else {
|
2002-12-18 17:05:50 +03:00
|
|
|
/* Indirect block or ifile */
|
|
|
|
if (blkp->bi_size != fs->lfs_bsize &&
|
|
|
|
ip->i_number != LFS_IFILE_INUM)
|
2002-11-24 11:27:00 +03:00
|
|
|
panic("lfs_markv: partial indirect block?"
|
|
|
|
" size=%d\n", blkp->bi_size);
|
1999-03-10 03:20:00 +03:00
|
|
|
bp = getblk(vp, blkp->bi_lbn, blkp->bi_size, 0, 0);
|
2008-01-02 14:48:20 +03:00
|
|
|
if (!(bp->b_oflags & (BO_DONE|BO_DELWRI))) {
|
1999-03-10 03:20:00 +03:00
|
|
|
/*
|
|
|
|
* The block in question was not found
|
|
|
|
* in the cache; i.e., the block that
|
2003-02-20 07:27:23 +03:00
|
|
|
* getblk() returned is empty. So, we
|
1999-03-10 03:20:00 +03:00
|
|
|
* can (and should) copy in the
|
|
|
|
* contents, because we've already
|
|
|
|
* determined that this was the right
|
|
|
|
* version of this block on disk.
|
|
|
|
*
|
|
|
|
* And, it can't have changed underneath
|
|
|
|
* us, because we have the segment lock.
|
|
|
|
*/
|
|
|
|
error = copyin(blkp->bi_bp, bp->b_data, blkp->bi_size);
|
2001-11-24 00:44:25 +03:00
|
|
|
if (error)
|
1999-03-10 03:20:00 +03:00
|
|
|
goto err2;
|
|
|
|
}
|
|
|
|
}
|
2003-07-30 16:38:53 +04:00
|
|
|
if ((error = lfs_bwrite_ext(bp, BW_CLEAN)) != 0)
|
1999-03-10 03:20:00 +03:00
|
|
|
goto err2;
|
2002-12-26 16:04:39 +03:00
|
|
|
|
|
|
|
nblkwritten++;
|
|
|
|
/*
|
|
|
|
* XXX should account indirect blocks and ifile pages as well
|
|
|
|
*/
|
2003-04-02 14:39:19 +04:00
|
|
|
if (nblkwritten + lblkno(fs, ninowritten * sizeof (struct ufs1_dinode))
|
2002-12-26 16:04:39 +03:00
|
|
|
> LFS_MARKV_MAX_BLOCKS) {
|
2005-03-08 03:18:19 +03:00
|
|
|
DLOG((DLOG_CLEAN, "lfs_markv: writing %d blks %d inos\n",
|
|
|
|
nblkwritten, ninowritten));
|
2002-12-26 16:04:39 +03:00
|
|
|
lfs_segwrite(mntp, SEGM_CLEAN);
|
|
|
|
nblkwritten = ninowritten = 0;
|
|
|
|
}
|
1999-03-10 03:20:00 +03:00
|
|
|
}
|
2005-02-27 01:31:44 +03:00
|
|
|
|
1999-03-10 03:20:00 +03:00
|
|
|
/*
|
|
|
|
* Finish the old file, if there was one
|
|
|
|
*/
|
2001-11-24 00:44:25 +03:00
|
|
|
if (v_daddr != LFS_UNUSED_DADDR) {
|
1999-03-10 03:20:00 +03:00
|
|
|
lfs_vunref(vp);
|
|
|
|
numrefed--;
|
|
|
|
}
|
2005-02-27 01:31:44 +03:00
|
|
|
|
2005-03-08 03:18:19 +03:00
|
|
|
#ifdef DIAGNOSTIC
|
|
|
|
if (numrefed != 0)
|
2002-12-17 17:37:49 +03:00
|
|
|
panic("lfs_markv: numrefed=%d", numrefed);
|
|
|
|
#endif
|
2005-03-08 03:18:19 +03:00
|
|
|
DLOG((DLOG_CLEAN, "lfs_markv: writing %d blks %d inos (check point)\n",
|
|
|
|
nblkwritten, ninowritten));
|
2005-02-27 01:31:44 +03:00
|
|
|
|
1999-03-10 03:20:00 +03:00
|
|
|
/*
|
|
|
|
* The last write has to be SEGM_SYNC, because of calling semantics.
|
|
|
|
* It also has to be SEGM_CKP, because otherwise we could write
|
|
|
|
* over the newly cleaned data contained in a checkpoint, and then
|
|
|
|
* we'd be unhappy at recovery time.
|
|
|
|
*/
|
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_segwrite(mntp, SEGM_CLEAN | SEGM_CKP | SEGM_SYNC);
|
2005-02-27 01:31:44 +03:00
|
|
|
|
1994-06-08 15:41:58 +04:00
|
|
|
lfs_segunlock(fs);
|
|
|
|
|
2008-04-30 16:49:16 +04:00
|
|
|
vfs_unbusy(mntp, false, NULL);
|
2001-11-24 00:44:25 +03:00
|
|
|
if (error)
|
1999-03-10 03:20:00 +03:00
|
|
|
return (error);
|
2001-11-24 00:44:25 +03:00
|
|
|
else if (do_again)
|
1999-03-10 03:20:00 +03:00
|
|
|
return EAGAIN;
|
1994-06-08 15:41:58 +04:00
|
|
|
|
1999-03-10 03:20:00 +03:00
|
|
|
return 0;
|
2005-02-27 01:31:44 +03:00
|
|
|
|
2003-07-30 16:38:53 +04:00
|
|
|
err2:
|
2005-03-08 03:18:19 +03:00
|
|
|
DLOG((DLOG_CLEAN, "lfs_markv err2\n"));
|
2003-07-30 16:38:53 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* XXX we're here because copyin() failed.
|
|
|
|
* XXX it means that we can't trust the cleanerd. too bad.
|
|
|
|
* XXX how can we recover from this?
|
|
|
|
*/
|
|
|
|
|
|
|
|
err3:
|
2008-04-21 15:45:34 +04:00
|
|
|
KERNEL_UNLOCK_ONE(NULL);
|
2003-07-30 16:38:53 +04:00
|
|
|
/*
|
|
|
|
* XXX should do segwrite here anyway?
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (v_daddr != LFS_UNUSED_DADDR) {
|
|
|
|
lfs_vunref(vp);
|
|
|
|
--numrefed;
|
1999-03-10 03:20:00 +03:00
|
|
|
}
|
2003-07-30 16:38:53 +04:00
|
|
|
|
1994-06-08 15:41:58 +04:00
|
|
|
lfs_segunlock(fs);
|
2008-04-30 16:49:16 +04:00
|
|
|
vfs_unbusy(mntp, false, NULL);
|
2005-03-08 03:18:19 +03:00
|
|
|
#ifdef DIAGNOSTIC
|
|
|
|
if (numrefed != 0)
|
2002-12-17 17:37:49 +03:00
|
|
|
panic("lfs_markv: numrefed=%d", numrefed);
|
2000-11-23 01:11:34 +03:00
|
|
|
#endif
|
|
|
|
|
1999-03-10 03:20:00 +03:00
|
|
|
return (error);
|
1994-06-08 15:41:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1999-06-09 08:52:11 +04:00
|
|
|
* sys_lfs_bmapv:
|
1994-06-08 15:41:58 +04:00
|
|
|
*
|
|
|
|
* This will fill in the current disk address for arrays of blocks.
|
|
|
|
*
|
|
|
|
* 0 on success
|
|
|
|
* -1/errno is return on error.
|
|
|
|
*/
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
#ifdef USE_64BIT_SYSCALLS
|
|
|
|
int
|
2007-12-21 02:02:38 +03:00
|
|
|
sys_lfs_bmapv(struct lwp *l, const struct sys_lfs_bmapv_args *uap, register_t *retval)
|
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
|
|
|
{
|
2007-12-21 02:02:38 +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
|
|
|
syscallarg(fsid_t *) fsidp;
|
|
|
|
syscallarg(struct block_info *) blkiov;
|
|
|
|
syscallarg(int) blkcnt;
|
2007-12-21 02:02:38 +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
|
|
|
BLOCK_INFO *blkiov;
|
|
|
|
int blkcnt, error;
|
|
|
|
fsid_t fsid;
|
2005-04-16 21:28:37 +04:00
|
|
|
struct lfs *fs;
|
|
|
|
struct mount *mntp;
|
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
|
|
|
|
2006-07-24 02:06:03 +04:00
|
|
|
if ((error = kauth_authorize_generic(l->l_cred, KAUTH_GENERIC_ISSUSER,
|
2007-01-04 19:55:29 +03:00
|
|
|
NULL)) != 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
|
|
|
return (error);
|
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
|
|
|
if ((error = copyin(SCARG(uap, fsidp), &fsid, sizeof(fsid_t))) != 0)
|
|
|
|
return (error);
|
|
|
|
|
2005-04-16 21:28:37 +04:00
|
|
|
if ((mntp = vfs_getvfs(&fsid)) == NULL)
|
|
|
|
return (ENOENT);
|
|
|
|
fs = VFSTOUFS(mntp)->um_lfs;
|
|
|
|
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
blkcnt = SCARG(uap, blkcnt);
|
2002-08-03 04:12:48 +04:00
|
|
|
if ((u_int) blkcnt > SIZE_T_MAX / sizeof(BLOCK_INFO))
|
|
|
|
return (EINVAL);
|
2008-04-21 15:45:34 +04:00
|
|
|
KERNEL_LOCK(1, NULL);
|
2005-04-16 21:28:37 +04:00
|
|
|
blkiov = lfs_malloc(fs, blkcnt * sizeof(BLOCK_INFO), LFS_NB_BLKIOV);
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
if ((error = copyin(SCARG(uap, blkiov), blkiov,
|
|
|
|
blkcnt * sizeof(BLOCK_INFO))) != 0)
|
|
|
|
goto out;
|
1999-03-10 03:20:00 +03:00
|
|
|
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
if ((error = lfs_bmapv(p, &fsid, blkiov, blkcnt)) == 0)
|
|
|
|
copyout(blkiov, SCARG(uap, blkiov),
|
|
|
|
blkcnt * sizeof(BLOCK_INFO));
|
|
|
|
out:
|
2005-04-16 21:28:37 +04:00
|
|
|
lfs_free(fs, blkiov, LFS_NB_BLKIOV);
|
2008-04-21 15:45:34 +04:00
|
|
|
KERNEL_UNLOCK_ONE(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
|
|
|
return error;
|
|
|
|
}
|
|
|
|
#else
|
1994-06-08 15:41:58 +04:00
|
|
|
int
|
2007-12-21 02:02:38 +03:00
|
|
|
sys_lfs_bmapv(struct lwp *l, const struct sys_lfs_bmapv_args *uap, register_t *retval)
|
1995-09-22 03:39:20 +04:00
|
|
|
{
|
2007-12-21 02:02:38 +03:00
|
|
|
/* {
|
1999-06-09 16:18:19 +04:00
|
|
|
syscallarg(fsid_t *) fsidp;
|
|
|
|
syscallarg(struct block_info *) blkiov;
|
|
|
|
syscallarg(int) blkcnt;
|
2007-12-21 02:02:38 +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
|
|
|
BLOCK_INFO *blkiov;
|
|
|
|
BLOCK_INFO_15 *blkiov15;
|
|
|
|
int i, blkcnt, error;
|
|
|
|
fsid_t fsid;
|
2005-04-16 21:28:37 +04:00
|
|
|
struct lfs *fs;
|
|
|
|
struct mount *mntp;
|
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
|
|
|
|
2006-07-24 02:06:03 +04:00
|
|
|
if ((error = kauth_authorize_generic(l->l_cred, KAUTH_GENERIC_ISSUSER,
|
2007-01-04 19:55:29 +03:00
|
|
|
NULL)) != 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
|
|
|
return (error);
|
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
|
|
|
if ((error = copyin(SCARG(uap, fsidp), &fsid, sizeof(fsid_t))) != 0)
|
|
|
|
return (error);
|
|
|
|
|
2005-04-16 21:28:37 +04:00
|
|
|
if ((mntp = vfs_getvfs(&fsid)) == NULL)
|
|
|
|
return (ENOENT);
|
|
|
|
fs = VFSTOUFS(mntp)->um_lfs;
|
|
|
|
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
blkcnt = SCARG(uap, blkcnt);
|
2003-05-17 05:44:39 +04:00
|
|
|
if ((size_t) blkcnt > SIZE_T_MAX / sizeof(BLOCK_INFO))
|
2002-08-03 04:12:48 +04:00
|
|
|
return (EINVAL);
|
2008-04-21 15:45:34 +04:00
|
|
|
KERNEL_LOCK(1, NULL);
|
2005-04-16 21:28:37 +04:00
|
|
|
blkiov = lfs_malloc(fs, blkcnt * sizeof(BLOCK_INFO), LFS_NB_BLKIOV);
|
|
|
|
blkiov15 = lfs_malloc(fs, blkcnt * sizeof(BLOCK_INFO_15), LFS_NB_BLKIOV);
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
if ((error = copyin(SCARG(uap, blkiov), blkiov15,
|
|
|
|
blkcnt * sizeof(BLOCK_INFO_15))) != 0)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
for (i = 0; i < blkcnt; i++) {
|
|
|
|
blkiov[i].bi_inode = blkiov15[i].bi_inode;
|
|
|
|
blkiov[i].bi_lbn = blkiov15[i].bi_lbn;
|
|
|
|
blkiov[i].bi_daddr = blkiov15[i].bi_daddr;
|
|
|
|
blkiov[i].bi_segcreate = blkiov15[i].bi_segcreate;
|
|
|
|
blkiov[i].bi_version = blkiov15[i].bi_version;
|
2003-02-20 07:27:23 +03:00
|
|
|
blkiov[i].bi_bp = blkiov15[i].bi_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
|
|
|
blkiov[i].bi_size = blkiov15[i].bi_size;
|
|
|
|
}
|
|
|
|
|
2006-07-24 02:06:03 +04:00
|
|
|
if ((error = lfs_bmapv(l->l_proc, &fsid, blkiov, blkcnt)) == 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
|
|
|
for (i = 0; i < blkcnt; i++) {
|
2003-02-20 07:27:23 +03:00
|
|
|
blkiov15[i].bi_inode = blkiov[i].bi_inode;
|
|
|
|
blkiov15[i].bi_lbn = blkiov[i].bi_lbn;
|
|
|
|
blkiov15[i].bi_daddr = blkiov[i].bi_daddr;
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
blkiov15[i].bi_segcreate = blkiov[i].bi_segcreate;
|
2003-02-20 07:27:23 +03:00
|
|
|
blkiov15[i].bi_version = blkiov[i].bi_version;
|
|
|
|
blkiov15[i].bi_bp = blkiov[i].bi_bp;
|
|
|
|
blkiov15[i].bi_size = blkiov[i].bi_size;
|
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
|
|
|
}
|
|
|
|
copyout(blkiov15, SCARG(uap, blkiov),
|
|
|
|
blkcnt * sizeof(BLOCK_INFO_15));
|
|
|
|
}
|
|
|
|
out:
|
2005-04-16 21:28:37 +04:00
|
|
|
lfs_free(fs, blkiov, LFS_NB_BLKIOV);
|
|
|
|
lfs_free(fs, blkiov15, LFS_NB_BLKIOV);
|
2008-04-21 15:45:34 +04:00
|
|
|
KERNEL_UNLOCK_ONE(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
|
|
|
return error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2003-02-24 11:42:49 +03:00
|
|
|
int
|
2003-06-30 02:28:00 +04:00
|
|
|
lfs_bmapv(struct proc *p, fsid_t *fsidp, BLOCK_INFO *blkiov, int blkcnt)
|
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
|
|
|
BLOCK_INFO *blkp;
|
1999-03-10 03:20:00 +03:00
|
|
|
IFILE *ifp;
|
|
|
|
struct buf *bp;
|
|
|
|
struct inode *ip = NULL;
|
|
|
|
struct lfs *fs;
|
1994-06-08 15:41:58 +04:00
|
|
|
struct mount *mntp;
|
1998-03-01 05:20:01 +03:00
|
|
|
struct ufsmount *ump;
|
1994-06-08 15:41:58 +04:00
|
|
|
struct vnode *vp;
|
1999-03-10 03:20:00 +03:00
|
|
|
ino_t lastino;
|
2003-01-25 00:55:02 +03:00
|
|
|
daddr_t v_daddr;
|
2002-12-17 17:37:49 +03:00
|
|
|
int cnt, error;
|
|
|
|
int numrefed = 0;
|
1994-06-08 15:41:58 +04:00
|
|
|
|
2003-06-30 02:28:00 +04:00
|
|
|
lfs_cleaner_pid = p->p_pid;
|
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
|
|
|
if ((mntp = vfs_getvfs(fsidp)) == NULL)
|
2000-11-23 01:11:34 +03:00
|
|
|
return (ENOENT);
|
2005-02-27 01:31:44 +03:00
|
|
|
|
1999-03-10 03:20:00 +03:00
|
|
|
ump = VFSTOUFS(mntp);
|
PR kern/38141 lookup/vfs_busy acquire rwlock recursively
Simplify the mount locking. Remove all the crud to deal with recursion on
the mount lock, and crud to deal with unmount as another weirdo lock.
Hopefully this will once and for all fix the deadlocks with this. With this
commit there are two locks on each mount:
- krwlock_t mnt_unmounting. This is used to prevent unmount across critical
sections like getnewvnode(). It's only ever read locked with rw_tryenter(),
and is only ever write locked in dounmount(). A write hold can't be taken
on this lock if the current LWP could hold a vnode lock.
- kmutex_t mnt_updating. This is taken by threads updating the mount, for
example when going r/o -> r/w, and is only present to serialize updates.
In order to take this lock, a read hold must first be taken on
mnt_unmounting, and the two need to be held across the operation.
One effect of this change: previously if an unmount failed, we would make a
half hearted attempt to back out of it gracefully, but that was unlikely to
work in a lot of cases. Now while an unmount that will be aborted is in
progress, new file operations within the mount will fail instead of being
delayed. That is unlikely to be a problem though, because if the admin
requests unmount of a file system then s(he) has made a decision to deny
access to the resource.
2008-05-06 22:43:44 +04:00
|
|
|
if ((error = vfs_busy(mntp, NULL)) != 0)
|
2000-11-23 01:11:34 +03:00
|
|
|
return (error);
|
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
|
|
|
cnt = blkcnt;
|
2005-02-27 01:31:44 +03:00
|
|
|
|
1999-03-10 03:20:00 +03:00
|
|
|
fs = VFSTOUFS(mntp)->um_lfs;
|
2005-02-27 01:31:44 +03:00
|
|
|
|
1999-03-10 03:20:00 +03:00
|
|
|
error = 0;
|
2005-02-27 01:31:44 +03:00
|
|
|
|
1999-03-10 03:20:00 +03:00
|
|
|
/* these were inside the initialization for the for loop */
|
|
|
|
v_daddr = LFS_UNUSED_DADDR;
|
|
|
|
lastino = LFS_UNUSED_INUM;
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
for (blkp = blkiov; cnt--; ++blkp)
|
1999-03-10 03:20:00 +03:00
|
|
|
{
|
1998-03-01 05:20:01 +03:00
|
|
|
/*
|
1999-03-10 03:20:00 +03:00
|
|
|
* Get the IFILE entry (only once) and see if the file still
|
|
|
|
* exists.
|
1998-03-01 05:20:01 +03:00
|
|
|
*/
|
1999-03-10 03:20:00 +03:00
|
|
|
if (lastino != blkp->bi_inode) {
|
|
|
|
/*
|
|
|
|
* Finish the old file, if there was one. The presence
|
|
|
|
* of a usable vnode in vp is signaled by a valid
|
|
|
|
* v_daddr.
|
|
|
|
*/
|
2001-11-24 00:44:25 +03:00
|
|
|
if (v_daddr != LFS_UNUSED_DADDR) {
|
1999-03-10 03:20:00 +03:00
|
|
|
lfs_vunref(vp);
|
|
|
|
numrefed--;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Start a new file
|
|
|
|
*/
|
|
|
|
lastino = blkp->bi_inode;
|
|
|
|
if (blkp->bi_inode == LFS_IFILE_INUM)
|
|
|
|
v_daddr = fs->lfs_idaddr;
|
|
|
|
else {
|
|
|
|
LFS_IENTRY(ifp, fs, blkp->bi_inode, bp);
|
|
|
|
v_daddr = ifp->if_daddr;
|
2007-10-08 22:01:27 +04:00
|
|
|
brelse(bp, 0);
|
1999-03-10 03:20:00 +03:00
|
|
|
}
|
|
|
|
if (v_daddr == LFS_UNUSED_DADDR) {
|
|
|
|
blkp->bi_daddr = LFS_UNUSED_DADDR;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* A regular call to VFS_VGET could deadlock
|
|
|
|
* here. Instead, we try an unlocked access.
|
|
|
|
*/
|
2008-01-02 14:48:20 +03:00
|
|
|
mutex_enter(&ufs_ihash_lock);
|
1999-03-10 03:20:00 +03:00
|
|
|
vp = ufs_ihashlookup(ump->um_dev, blkp->bi_inode);
|
2007-10-11 00:42:20 +04:00
|
|
|
if (vp != NULL && !(vp->v_iflag & VI_XLOCK)) {
|
1999-03-10 03:20:00 +03:00
|
|
|
ip = VTOI(vp);
|
2008-01-02 14:48:20 +03:00
|
|
|
mutex_enter(&vp->v_interlock);
|
|
|
|
mutex_exit(&ufs_ihash_lock);
|
2000-06-22 22:11:45 +04:00
|
|
|
if (lfs_vref(vp)) {
|
|
|
|
v_daddr = LFS_UNUSED_DADDR;
|
|
|
|
continue;
|
|
|
|
}
|
2000-06-28 00:57:11 +04:00
|
|
|
numrefed++;
|
1999-03-10 03:20:00 +03:00
|
|
|
} else {
|
2008-01-02 14:48:20 +03:00
|
|
|
mutex_exit(&ufs_ihash_lock);
|
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
|
|
|
/*
|
|
|
|
* Don't VFS_VGET if we're being unmounted,
|
|
|
|
* since we hold vfs_busy().
|
|
|
|
*/
|
|
|
|
if (mntp->mnt_iflag & IMNT_UNMOUNT) {
|
|
|
|
v_daddr = LFS_UNUSED_DADDR;
|
|
|
|
continue;
|
|
|
|
}
|
2003-06-29 22:43:21 +04:00
|
|
|
error = VFS_VGET(mntp, blkp->bi_inode, &vp);
|
2001-11-24 00:44:25 +03:00
|
|
|
if (error) {
|
2005-03-08 03:18:19 +03:00
|
|
|
DLOG((DLOG_CLEAN, "lfs_bmapv: vget ino"
|
|
|
|
"%d failed with %d",
|
|
|
|
blkp->bi_inode,error));
|
2000-06-28 00:57:11 +04:00
|
|
|
v_daddr = LFS_UNUSED_DADDR;
|
1999-03-10 03:20:00 +03:00
|
|
|
continue;
|
|
|
|
} else {
|
2002-12-17 17:37:49 +03:00
|
|
|
KASSERT(VOP_ISLOCKED(vp));
|
|
|
|
VOP_UNLOCK(vp, 0);
|
1999-03-10 03:20:00 +03:00
|
|
|
numrefed++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ip = VTOI(vp);
|
|
|
|
} else if (v_daddr == LFS_UNUSED_DADDR) {
|
|
|
|
/*
|
|
|
|
* This can only happen if the vnode is dead.
|
2003-02-20 07:27:23 +03:00
|
|
|
* Keep going. Note that we DO NOT set the
|
1999-03-10 03:20:00 +03:00
|
|
|
* bi_addr to anything -- if we failed to get
|
|
|
|
* the vnode, for example, we want to assume
|
|
|
|
* conservatively that all of its blocks *are*
|
|
|
|
* located in the segment in question.
|
|
|
|
* lfs_markv will throw them out if we are
|
|
|
|
* wrong.
|
|
|
|
*/
|
|
|
|
/* blkp->bi_daddr = LFS_UNUSED_DADDR; */
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Past this point we are guaranteed that vp, ip are valid. */
|
|
|
|
|
2001-11-24 00:44:25 +03:00
|
|
|
if (blkp->bi_lbn == LFS_UNUSED_LBN) {
|
1999-03-10 03:20:00 +03:00
|
|
|
/*
|
|
|
|
* We just want the inode address, which is
|
|
|
|
* conveniently in v_daddr.
|
|
|
|
*/
|
|
|
|
blkp->bi_daddr = v_daddr;
|
|
|
|
} else {
|
2003-01-25 00:55:02 +03:00
|
|
|
daddr_t bi_daddr;
|
|
|
|
|
|
|
|
/* XXX ondisk32 */
|
1999-03-10 03:20:00 +03:00
|
|
|
error = VOP_BMAP(vp, blkp->bi_lbn, NULL,
|
2003-01-25 00:55:02 +03:00
|
|
|
&bi_daddr, NULL);
|
2001-11-24 00:44:25 +03:00
|
|
|
if (error)
|
1999-03-10 03:20:00 +03:00
|
|
|
{
|
|
|
|
blkp->bi_daddr = LFS_UNUSED_DADDR;
|
|
|
|
continue;
|
|
|
|
}
|
2003-01-25 00:55:02 +03:00
|
|
|
blkp->bi_daddr = dbtofsb(fs, bi_daddr);
|
2002-06-06 04:46:24 +04:00
|
|
|
/* Fill in the block size, too */
|
2002-11-24 11:27:00 +03:00
|
|
|
if (blkp->bi_lbn >= 0)
|
|
|
|
blkp->bi_size = blksize(fs, ip, blkp->bi_lbn);
|
|
|
|
else
|
|
|
|
blkp->bi_size = fs->lfs_bsize;
|
1999-03-10 03:20:00 +03:00
|
|
|
}
|
|
|
|
}
|
2005-02-27 01:31:44 +03:00
|
|
|
|
1999-03-10 03:20:00 +03:00
|
|
|
/*
|
|
|
|
* Finish the old file, if there was one. The presence
|
|
|
|
* of a usable vnode in vp is signaled by a valid v_daddr.
|
|
|
|
*/
|
2001-11-24 00:44:25 +03:00
|
|
|
if (v_daddr != LFS_UNUSED_DADDR) {
|
1999-03-10 03:20:00 +03:00
|
|
|
lfs_vunref(vp);
|
|
|
|
numrefed--;
|
|
|
|
}
|
2005-02-27 01:31:44 +03:00
|
|
|
|
2005-03-08 03:18:19 +03:00
|
|
|
#ifdef DIAGNOSTIC
|
|
|
|
if (numrefed != 0)
|
2002-12-17 17:37:49 +03:00
|
|
|
panic("lfs_bmapv: numrefed=%d", numrefed);
|
|
|
|
#endif
|
2005-02-27 01:31:44 +03:00
|
|
|
|
2008-04-30 16:49:16 +04:00
|
|
|
vfs_unbusy(mntp, false, NULL);
|
2005-02-27 01:31:44 +03:00
|
|
|
|
1999-03-10 03:20:00 +03:00
|
|
|
return 0;
|
1994-06-08 15:41:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1999-06-09 08:52:11 +04:00
|
|
|
* sys_lfs_segclean:
|
1994-06-08 15:41:58 +04:00
|
|
|
*
|
|
|
|
* Mark the segment clean.
|
|
|
|
*
|
|
|
|
* 0 on success
|
|
|
|
* -1/errno is return on error.
|
|
|
|
*/
|
|
|
|
int
|
2007-12-21 02:02:38 +03:00
|
|
|
sys_lfs_segclean(struct lwp *l, const struct sys_lfs_segclean_args *uap, register_t *retval)
|
1995-09-22 03:39:20 +04:00
|
|
|
{
|
2007-12-21 02:02:38 +03:00
|
|
|
/* {
|
1999-06-09 16:18:19 +04:00
|
|
|
syscallarg(fsid_t *) fsidp;
|
|
|
|
syscallarg(u_long) segment;
|
2007-12-21 02:02:38 +03:00
|
|
|
} */
|
1994-06-08 15:41:58 +04:00
|
|
|
struct lfs *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
|
|
|
struct mount *mntp;
|
1994-06-08 15:41:58 +04:00
|
|
|
fsid_t fsid;
|
|
|
|
int error;
|
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
|
|
|
unsigned long segnum;
|
2005-02-27 01:31:44 +03:00
|
|
|
|
2006-07-24 02:06:03 +04:00
|
|
|
if ((error = kauth_authorize_generic(l->l_cred, KAUTH_GENERIC_ISSUSER,
|
2007-01-04 19:55:29 +03:00
|
|
|
NULL)) != 0)
|
1994-06-08 15:41:58 +04:00
|
|
|
return (error);
|
2005-02-27 01:31:44 +03:00
|
|
|
|
1996-02-10 01:28:45 +03:00
|
|
|
if ((error = copyin(SCARG(uap, fsidp), &fsid, sizeof(fsid_t))) != 0)
|
1994-06-08 15:41:58 +04:00
|
|
|
return (error);
|
1998-03-01 05:20:01 +03:00
|
|
|
if ((mntp = vfs_getvfs(&fsid)) == NULL)
|
2000-11-23 01:11:34 +03:00
|
|
|
return (ENOENT);
|
2005-02-27 01:31:44 +03:00
|
|
|
|
1994-06-08 15:41:58 +04:00
|
|
|
fs = VFSTOUFS(mntp)->um_lfs;
|
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
|
|
|
segnum = SCARG(uap, segment);
|
2005-02-27 01:31:44 +03:00
|
|
|
|
PR kern/38141 lookup/vfs_busy acquire rwlock recursively
Simplify the mount locking. Remove all the crud to deal with recursion on
the mount lock, and crud to deal with unmount as another weirdo lock.
Hopefully this will once and for all fix the deadlocks with this. With this
commit there are two locks on each mount:
- krwlock_t mnt_unmounting. This is used to prevent unmount across critical
sections like getnewvnode(). It's only ever read locked with rw_tryenter(),
and is only ever write locked in dounmount(). A write hold can't be taken
on this lock if the current LWP could hold a vnode lock.
- kmutex_t mnt_updating. This is taken by threads updating the mount, for
example when going r/o -> r/w, and is only present to serialize updates.
In order to take this lock, a read hold must first be taken on
mnt_unmounting, and the two need to be held across the operation.
One effect of this change: previously if an unmount failed, we would make a
half hearted attempt to back out of it gracefully, but that was unlikely to
work in a lot of cases. Now while an unmount that will be aborted is in
progress, new file operations within the mount will fail instead of being
delayed. That is unlikely to be a problem though, because if the admin
requests unmount of a file system then s(he) has made a decision to deny
access to the resource.
2008-05-06 22:43:44 +04:00
|
|
|
if ((error = vfs_busy(mntp, NULL)) != 0)
|
2000-11-23 01:11:34 +03:00
|
|
|
return (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
|
|
|
|
2008-04-21 15:45:34 +04:00
|
|
|
KERNEL_LOCK(1, NULL);
|
2002-05-15 00:03:53 +04:00
|
|
|
lfs_seglock(fs, SEGM_PROT);
|
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
|
|
|
error = lfs_do_segclean(fs, segnum);
|
|
|
|
lfs_segunlock(fs);
|
2008-04-21 15:45:34 +04:00
|
|
|
KERNEL_UNLOCK_ONE(NULL);
|
2008-04-30 16:49:16 +04:00
|
|
|
vfs_unbusy(mntp, false, 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
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Actually mark the segment clean.
|
|
|
|
* Must be called with the segment lock held.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
lfs_do_segclean(struct lfs *fs, unsigned long segnum)
|
|
|
|
{
|
2005-05-25 05:50:01 +04:00
|
|
|
extern int 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
|
|
|
struct buf *bp;
|
|
|
|
CLEANERINFO *cip;
|
|
|
|
SEGUSE *sup;
|
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 (dtosn(fs, fs->lfs_curseg) == segnum) {
|
|
|
|
return (EBUSY);
|
|
|
|
}
|
2005-02-27 01:31:44 +03: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_SEGENTRY(sup, fs, segnum, bp);
|
|
|
|
if (sup->su_nbytes) {
|
2005-03-08 03:18:19 +03:00
|
|
|
DLOG((DLOG_CLEAN, "lfs_segclean: not cleaning segment %lu:"
|
|
|
|
" %d live bytes\n", segnum, sup->su_nbytes));
|
2007-10-08 22:01:27 +04:00
|
|
|
brelse(bp, 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
|
|
|
return (EBUSY);
|
|
|
|
}
|
1994-06-08 15:41:58 +04:00
|
|
|
if (sup->su_flags & SEGUSE_ACTIVE) {
|
2005-05-20 23:48:25 +04:00
|
|
|
DLOG((DLOG_CLEAN, "lfs_segclean: not cleaning segment %lu:"
|
|
|
|
" segment is active\n", segnum));
|
2007-10-08 22:01:27 +04:00
|
|
|
brelse(bp, 0);
|
1994-06-08 15:41:58 +04:00
|
|
|
return (EBUSY);
|
|
|
|
}
|
2000-10-20 21:48:05 +04:00
|
|
|
if (!(sup->su_flags & SEGUSE_DIRTY)) {
|
2005-05-20 23:48:25 +04:00
|
|
|
DLOG((DLOG_CLEAN, "lfs_segclean: not cleaning segment %lu:"
|
|
|
|
" segment is already clean\n", segnum));
|
2007-10-08 22:01:27 +04:00
|
|
|
brelse(bp, 0);
|
2000-10-20 21:48:05 +04:00
|
|
|
return (EALREADY);
|
|
|
|
}
|
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
|
|
|
fs->lfs_avail += segtod(fs, 1);
|
2000-07-05 02:30:37 +04:00
|
|
|
if (sup->su_flags & SEGUSE_SUPERBLOCK)
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
fs->lfs_avail -= btofsb(fs, LFS_SBPAD);
|
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 (fs->lfs_version > 1 && segnum == 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
|
|
|
fs->lfs_start < btofsb(fs, LFS_LABELPAD))
|
|
|
|
fs->lfs_avail -= btofsb(fs, LFS_LABELPAD) - fs->lfs_start;
|
2008-01-02 14:48:20 +03:00
|
|
|
mutex_enter(&lfs_lock);
|
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 += sup->su_nsums * btofsb(fs, fs->lfs_sumsize) +
|
|
|
|
btofsb(fs, sup->su_ninos * fs->lfs_ibsize);
|
|
|
|
fs->lfs_dmeta -= sup->su_nsums * btofsb(fs, fs->lfs_sumsize) +
|
|
|
|
btofsb(fs, sup->su_ninos * fs->lfs_ibsize);
|
2000-06-28 00:57:11 +04:00
|
|
|
if (fs->lfs_dmeta < 0)
|
|
|
|
fs->lfs_dmeta = 0;
|
2008-01-02 14:48:20 +03:00
|
|
|
mutex_exit(&lfs_lock);
|
1994-06-08 15:41:58 +04:00
|
|
|
sup->su_flags &= ~SEGUSE_DIRTY;
|
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, segnum, bp);
|
2005-02-27 01:31:44 +03:00
|
|
|
|
1994-06-08 15:41:58 +04:00
|
|
|
LFS_CLEANERINFO(cip, fs, bp);
|
|
|
|
++cip->clean;
|
|
|
|
--cip->dirty;
|
1999-03-10 03:20:00 +03:00
|
|
|
fs->lfs_nclean = cip->clean;
|
Various bug-fixes to LFS, to wit:
Kernel:
* Add runtime quantity lfs_ravail, the number of disk-blocks reserved
for writing. Writes to the filesystem first reserve a maximum amount
of blocks before their write is allowed to proceed; after the blocks
are allocated the reserved total is reduced by a corresponding amount.
If the lfs_reserve function cannot immediately reserve the requested
number of blocks, the inode is unlocked, and the thread sleeps until
the cleaner has made enough space available for the blocks to be
reserved. In this way large files can be written to the filesystem
(or, smaller files can be written to a nearly-full but thoroughly
clean filesystem) and the cleaner can still function properly.
* Remove explicit switching on dlfs_minfreeseg from the kernel code; it
is now merely a fs-creation parameter used to compute dlfs_avail and
dlfs_bfree (and used by fsck_lfs(8) to check their accuracy). Its
former role is better assumed by a properly computed dlfs_avail.
* Bounds-check inode numbers submitted through lfs_bmapv and lfs_markv.
This prevents a panic, but, if the cleaner is feeding the filesystem
the wrong data, you are still in a world of hurt.
* Cleanup: remove explicit references of DEV_BSIZE in favor of
btodb()/dbtob().
lfs_cleanerd:
* Make -n mean "send N segments' blocks through a single call to
lfs_markv". Previously it had meant "clean N segments though N calls
to lfs_markv, before looking again to see if more need to be cleaned".
The new behavior gives better packing of direct data on disk with as
little metadata as possible, largely alleviating the problem that the
cleaner can consume more disk through inefficient use of metadata than
it frees by moving dirty data away from clean "holes" to produce
entirely clean segments.
* Make -b mean "read as many segments as necessary to write N segments
of dirty data back to disk", rather than its former meaning of "read
as many segments as necessary to free N segments worth of space". The
new meaning, combined with the new -n behavior described above,
further aids in cleaning storage efficiency as entire segments can be
written at once, using as few blocks as possible for segment summaries
and inode blocks.
* Make the cleaner take note of segments which could not be cleaned due
to error, and not attempt to clean them until they are entirely free
of dirty blocks. This prevents the case in which a cleanerd running
with -n 1 and without -b (formerly the default) would spin trying
repeatedly to clean a corrupt segment, while the remaining space
filled and deadlocked the filesystem.
* Update the lfs_cleanerd manual page to describe all the options,
including the changes mentioned here (in particular, the -b and -n
flags were previously undocumented).
fsck_lfs:
* Check, and optionally fix, lfs_avail (to an exact figure) and
lfs_bfree (within a margin of error) in pass 5.
newfs_lfs:
* Reduce the default dlfs_minfreeseg to 1/20 of the total segments.
* Add a warning if the sgs disklabel field is 16 (the default for FFS'
cpg, but not usually desirable for LFS' sgs: 5--8 is a better range).
* Change the calculation of lfs_avail and lfs_bfree, corresponding to
the kernel changes mentioned above.
mount_lfs:
* Add -N and -b options to pass corresponding -n and -b options to
lfs_cleanerd.
* Default to calling lfs_cleanerd with "-b -n 4".
[All of these changes were largely tested in the 1.5 branch, with the
idea that they (along with previous un-pulled-up work) could be applied
to the branch while it was still in ALPHA2; however my test system has
experienced corruption on another filesystem (/dev/console has gone
missing :^), and, while I believe this unrelated to the LFS changes, I
cannot with good conscience request that the changes be pulled up.]
2000-09-09 08:49:54 +04:00
|
|
|
cip->bfree = fs->lfs_bfree;
|
2008-01-02 14:48:20 +03:00
|
|
|
mutex_enter(&lfs_lock);
|
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
|
|
|
cip->avail = fs->lfs_avail - fs->lfs_ravail - fs->lfs_favail;
|
2006-04-08 03:59:28 +04:00
|
|
|
wakeup(&fs->lfs_avail);
|
2008-01-02 14:48:20 +03:00
|
|
|
mutex_exit(&lfs_lock);
|
2002-05-15 00:03:53 +04:00
|
|
|
(void) LFS_BWRITE_LOG(bp);
|
1999-03-10 03:20:00 +03:00
|
|
|
|
2005-05-25 05:50:01 +04:00
|
|
|
if (lfs_dostats)
|
|
|
|
++lfs_stats.segs_reclaimed;
|
2005-05-20 23:48:25 +04:00
|
|
|
|
1994-06-08 15:41:58 +04:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This will block until a segment in file system fsid is written. A timeout
|
|
|
|
* in milliseconds may be specified which will awake the cleaner automatically.
|
|
|
|
* An fsid of -1 means any file system, and a timeout of 0 means forever.
|
2003-02-24 11:42:49 +03:00
|
|
|
*/
|
|
|
|
int
|
|
|
|
lfs_segwait(fsid_t *fsidp, struct timeval *tv)
|
|
|
|
{
|
|
|
|
struct mount *mntp;
|
|
|
|
void *addr;
|
|
|
|
u_long timeout;
|
2006-06-08 02:33:33 +04:00
|
|
|
int error;
|
2003-02-24 11:42:49 +03:00
|
|
|
|
2008-04-21 15:45:34 +04:00
|
|
|
KERNEL_LOCK(1, NULL);
|
2005-05-20 23:48:25 +04:00
|
|
|
if (fsidp == NULL || (mntp = vfs_getvfs(fsidp)) == NULL)
|
2003-02-24 11:42:49 +03:00
|
|
|
addr = &lfs_allclean_wakeup;
|
|
|
|
else
|
|
|
|
addr = &VFSTOUFS(mntp)->um_lfs->lfs_nextseg;
|
|
|
|
/*
|
|
|
|
* XXX THIS COULD SLEEP FOREVER IF TIMEOUT IS {0,0}!
|
|
|
|
* XXX IS THAT WHAT IS INTENDED?
|
|
|
|
*/
|
2006-06-08 02:33:33 +04:00
|
|
|
timeout = tvtohz(tv);
|
2006-04-08 03:59:28 +04:00
|
|
|
error = tsleep(addr, PCATCH | PVFS, "segment", timeout);
|
2008-04-21 15:45:34 +04:00
|
|
|
KERNEL_UNLOCK_ONE(NULL);
|
2003-02-24 11:42:49 +03:00
|
|
|
return (error == ERESTART ? EINTR : 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* sys_lfs_segwait:
|
|
|
|
*
|
|
|
|
* System call wrapper around lfs_segwait().
|
1994-06-08 15:41:58 +04:00
|
|
|
*
|
|
|
|
* 0 on success
|
|
|
|
* 1 on timeout
|
|
|
|
* -1/errno is return on error.
|
|
|
|
*/
|
|
|
|
int
|
2009-01-11 05:45:45 +03:00
|
|
|
sys___lfs_segwait50(struct lwp *l, const struct sys___lfs_segwait50_args *uap,
|
|
|
|
register_t *retval)
|
1995-09-22 03:39:20 +04:00
|
|
|
{
|
2007-12-21 02:02:38 +03:00
|
|
|
/* {
|
1999-06-09 16:18:19 +04:00
|
|
|
syscallarg(fsid_t *) fsidp;
|
|
|
|
syscallarg(struct timeval *) tv;
|
2007-12-21 02:02:38 +03:00
|
|
|
} */
|
1994-06-08 15:41:58 +04:00
|
|
|
struct timeval atv;
|
|
|
|
fsid_t fsid;
|
2003-02-24 11:42:49 +03:00
|
|
|
int error;
|
2005-02-27 01:31:44 +03:00
|
|
|
|
2003-02-24 11:42:49 +03:00
|
|
|
/* XXX need we be su to segwait? */
|
2006-07-24 02:06:03 +04:00
|
|
|
if ((error = kauth_authorize_generic(l->l_cred, KAUTH_GENERIC_ISSUSER,
|
2007-01-04 19:55:29 +03:00
|
|
|
NULL)) != 0)
|
1994-06-08 15:41:58 +04:00
|
|
|
return (error);
|
1996-02-10 01:28:45 +03:00
|
|
|
if ((error = copyin(SCARG(uap, fsidp), &fsid, sizeof(fsid_t))) != 0)
|
1994-06-08 15:41:58 +04:00
|
|
|
return (error);
|
2005-02-27 01:31:44 +03:00
|
|
|
|
1994-10-20 07:20:55 +03:00
|
|
|
if (SCARG(uap, tv)) {
|
1996-02-10 01:28:45 +03:00
|
|
|
error = copyin(SCARG(uap, tv), &atv, sizeof(struct timeval));
|
|
|
|
if (error)
|
1994-06-08 15:41:58 +04:00
|
|
|
return (error);
|
|
|
|
if (itimerfix(&atv))
|
|
|
|
return (EINVAL);
|
2003-02-24 11:42:49 +03:00
|
|
|
} else /* NULL or invalid */
|
|
|
|
atv.tv_sec = atv.tv_usec = 0;
|
|
|
|
return lfs_segwait(&fsid, &atv);
|
1994-06-08 15:41:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* VFS_VGET call specialized for the cleaner. The cleaner already knows the
|
|
|
|
* daddr from the ifile, so don't look it up again. If the cleaner is
|
|
|
|
* processing IINFO structures, it may have the ondisk inode already, so
|
|
|
|
* don't go retrieving it again.
|
1999-03-10 03:20:00 +03:00
|
|
|
*
|
2002-12-17 17:37:49 +03:00
|
|
|
* we lfs_vref, and it is the caller's responsibility to lfs_vunref
|
|
|
|
* when finished.
|
1994-06-08 15:41:58 +04:00
|
|
|
*/
|
2007-02-15 18:40:50 +03:00
|
|
|
extern kmutex_t ufs_hashlock;
|
1999-03-10 03:20:00 +03:00
|
|
|
|
2000-07-01 00:45:38 +04:00
|
|
|
int
|
2002-12-17 17:37:49 +03:00
|
|
|
lfs_fasthashget(dev_t dev, ino_t ino, struct vnode **vpp)
|
2000-07-01 00:45:38 +04:00
|
|
|
{
|
2008-01-02 14:48:20 +03:00
|
|
|
struct vnode *vp;
|
|
|
|
|
|
|
|
mutex_enter(&ufs_ihash_lock);
|
|
|
|
if ((vp = ufs_ihashlookup(dev, ino)) != NULL) {
|
|
|
|
mutex_enter(&vp->v_interlock);
|
|
|
|
mutex_exit(&ufs_ihash_lock);
|
|
|
|
if (vp->v_iflag & VI_XLOCK) {
|
2007-10-11 00:42:20 +04:00
|
|
|
DLOG((DLOG_CLEAN, "lfs_fastvget: ino %d VI_XLOCK\n",
|
2005-03-08 03:18:19 +03:00
|
|
|
ino));
|
|
|
|
lfs_stats.clean_vnlocked++;
|
2008-01-02 14:48:20 +03:00
|
|
|
mutex_exit(&vp->v_interlock);
|
2000-07-01 00:45:38 +04:00
|
|
|
return EAGAIN;
|
|
|
|
}
|
2008-01-02 14:48:20 +03:00
|
|
|
if (lfs_vref(vp)) {
|
2005-03-08 03:18:19 +03:00
|
|
|
DLOG((DLOG_CLEAN, "lfs_fastvget: lfs_vref failed"
|
|
|
|
" for ino %d\n", ino));
|
|
|
|
lfs_stats.clean_inlocked++;
|
2000-07-01 00:45:38 +04:00
|
|
|
return EAGAIN;
|
|
|
|
}
|
2008-01-02 14:48:20 +03:00
|
|
|
} else {
|
|
|
|
mutex_exit(&ufs_ihash_lock);
|
|
|
|
}
|
|
|
|
*vpp = vp;
|
2000-07-01 00:45:38 +04:00
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
1994-06-08 15:41:58 +04:00
|
|
|
int
|
2007-02-15 18:40:50 +03:00
|
|
|
lfs_fastvget(struct mount *mp, ino_t ino, daddr_t daddr, struct vnode **vpp,
|
|
|
|
struct ufs1_dinode *dinp)
|
1994-06-08 15:41:58 +04:00
|
|
|
{
|
2000-03-30 16:41:09 +04:00
|
|
|
struct inode *ip;
|
2003-04-02 14:39:19 +04:00
|
|
|
struct ufs1_dinode *dip;
|
1994-06-08 15:41:58 +04:00
|
|
|
struct vnode *vp;
|
|
|
|
struct ufsmount *ump;
|
|
|
|
dev_t dev;
|
2003-03-20 17:11:46 +03:00
|
|
|
int error, retries;
|
1999-03-10 03:20:00 +03:00
|
|
|
struct buf *bp;
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
struct lfs *fs;
|
2005-02-27 01:31:44 +03:00
|
|
|
|
1994-06-08 15:41:58 +04:00
|
|
|
ump = VFSTOUFS(mp);
|
|
|
|
dev = ump->um_dev;
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
fs = ump->um_lfs;
|
2000-07-01 00:45:38 +04:00
|
|
|
|
2000-11-27 06:33:57 +03:00
|
|
|
/*
|
|
|
|
* Wait until the filesystem is fully mounted before allowing vget
|
2003-02-20 07:27:23 +03:00
|
|
|
* to complete. This prevents possible problems with roll-forward.
|
2000-11-27 06:33:57 +03:00
|
|
|
*/
|
2008-01-02 14:48:20 +03:00
|
|
|
mutex_enter(&lfs_lock);
|
2001-11-24 00:44:25 +03:00
|
|
|
while (fs->lfs_flags & LFS_NOTYET) {
|
2008-01-02 14:48:20 +03:00
|
|
|
mtsleep(&fs->lfs_flags, PRIBIO+1, "lfs_fnotyet", 0,
|
|
|
|
&lfs_lock);
|
2000-11-27 06:33:57 +03:00
|
|
|
}
|
2008-01-02 14:48:20 +03:00
|
|
|
mutex_exit(&lfs_lock);
|
2005-04-02 01:59:46 +04:00
|
|
|
|
2000-11-27 06:33:57 +03:00
|
|
|
/*
|
|
|
|
* This is playing fast and loose. Someone may have the inode
|
|
|
|
* locked, in which case they are going to be distinctly unhappy
|
|
|
|
* if we trash something.
|
|
|
|
*/
|
|
|
|
|
2002-12-17 17:37:49 +03:00
|
|
|
error = lfs_fasthashget(dev, ino, vpp);
|
2000-07-01 00:45:38 +04:00
|
|
|
if (error != 0 || *vpp != NULL)
|
|
|
|
return (error);
|
|
|
|
|
2005-02-27 01:31:44 +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
|
|
|
* getnewvnode(9) will call vfs_busy, which will block if the
|
|
|
|
* filesystem is being unmounted; but umount(9) is waiting for
|
|
|
|
* us because we're already holding the fs busy.
|
|
|
|
* XXXMP
|
|
|
|
*/
|
|
|
|
if (mp->mnt_iflag & IMNT_UNMOUNT) {
|
|
|
|
*vpp = NULL;
|
|
|
|
return EDEADLK;
|
|
|
|
}
|
2000-07-03 22:22:10 +04:00
|
|
|
if ((error = getnewvnode(VT_LFS, mp, lfs_vnodeop_p, &vp)) != 0) {
|
2000-07-01 00:45:38 +04:00
|
|
|
*vpp = NULL;
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
2007-02-15 18:40:50 +03:00
|
|
|
mutex_enter(&ufs_hashlock);
|
|
|
|
error = lfs_fasthashget(dev, ino, vpp);
|
|
|
|
if (error != 0 || *vpp != NULL) {
|
|
|
|
mutex_exit(&ufs_hashlock);
|
|
|
|
ungetnewvnode(vp);
|
|
|
|
return (error);
|
|
|
|
}
|
1994-06-08 15:41:58 +04:00
|
|
|
|
|
|
|
/* Allocate new vnode/inode. */
|
2000-07-01 00:45:38 +04:00
|
|
|
lfs_vcreate(mp, ino, vp);
|
|
|
|
|
1994-06-08 15:41:58 +04:00
|
|
|
/*
|
|
|
|
* Put it onto its hash chain and lock it so that other requests for
|
|
|
|
* this inode will block if they arrive while we are sleeping waiting
|
|
|
|
* for old data structures to be purged or for the contents of the
|
|
|
|
* disk portion of this inode to be read.
|
|
|
|
*/
|
|
|
|
ip = VTOI(vp);
|
|
|
|
ufs_ihashins(ip);
|
2007-02-15 18:40:50 +03:00
|
|
|
mutex_exit(&ufs_hashlock);
|
2005-02-27 01:31:44 +03:00
|
|
|
|
1994-06-08 15:41:58 +04:00
|
|
|
/*
|
|
|
|
* XXX
|
|
|
|
* This may not need to be here, logically it should go down with
|
|
|
|
* the i_devvp initialization.
|
|
|
|
* Ask Kirk.
|
|
|
|
*/
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
ip->i_lfs = fs;
|
1994-06-08 15:41:58 +04:00
|
|
|
|
|
|
|
/* Read in the disk contents for the inode, copy into the inode. */
|
1996-02-10 01:28:45 +03:00
|
|
|
if (dinp) {
|
2003-04-02 14:39:19 +04:00
|
|
|
error = copyin(dinp, ip->i_din.ffs1_din, sizeof (struct ufs1_dinode));
|
1999-03-10 03:20:00 +03:00
|
|
|
if (error) {
|
2005-03-08 03:18:19 +03:00
|
|
|
DLOG((DLOG_CLEAN, "lfs_fastvget: dinode copyin failed"
|
|
|
|
" for ino %d\n", ino));
|
1999-03-10 03:20:00 +03:00
|
|
|
ufs_ihashrem(ip);
|
|
|
|
|
|
|
|
/* Unlock and discard unneeded inode. */
|
2008-01-30 12:50:19 +03:00
|
|
|
vlockmgr(&vp->v_lock, LK_RELEASE);
|
1999-03-10 03:20:00 +03:00
|
|
|
lfs_vunref(vp);
|
|
|
|
*vpp = NULL;
|
1994-06-08 15:41:58 +04:00
|
|
|
return (error);
|
1999-03-10 03:20:00 +03:00
|
|
|
}
|
2001-11-24 00:44:25 +03:00
|
|
|
if (ip->i_number != ino)
|
1999-03-10 03:20:00 +03:00
|
|
|
panic("lfs_fastvget: I was fed the wrong inode!");
|
|
|
|
} else {
|
2002-05-15 00:03:53 +04:00
|
|
|
retries = 0;
|
|
|
|
again:
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
error = bread(ump->um_devvp, fsbtodb(fs, daddr), fs->lfs_ibsize,
|
2008-05-16 13:21:59 +04:00
|
|
|
NOCRED, 0, &bp);
|
1996-02-10 01:28:45 +03:00
|
|
|
if (error) {
|
2005-03-08 03:18:19 +03:00
|
|
|
DLOG((DLOG_CLEAN, "lfs_fastvget: bread failed (%d)\n",
|
|
|
|
error));
|
1994-06-08 15:41:58 +04:00
|
|
|
/*
|
|
|
|
* The inode does not contain anything useful, so it
|
|
|
|
* would be misleading to leave it on its hash chain.
|
|
|
|
* Iput() will return it to the free list.
|
|
|
|
*/
|
|
|
|
ufs_ihashrem(ip);
|
2005-02-27 01:31:44 +03:00
|
|
|
|
1994-06-08 15:41:58 +04:00
|
|
|
/* Unlock and discard unneeded inode. */
|
2008-01-30 12:50:19 +03:00
|
|
|
vlockmgr(&vp->v_lock, LK_RELEASE);
|
1994-06-08 15:41:58 +04:00
|
|
|
lfs_vunref(vp);
|
2007-10-08 22:01:27 +04:00
|
|
|
brelse(bp, 0);
|
1994-06-08 15:41:58 +04:00
|
|
|
*vpp = NULL;
|
|
|
|
return (error);
|
|
|
|
}
|
2002-05-15 00:03:53 +04:00
|
|
|
dip = lfs_ifind(ump->um_lfs, ino, bp);
|
|
|
|
if (dip == NULL) {
|
|
|
|
/* Assume write has not completed yet; try again */
|
2007-10-08 22:01:27 +04:00
|
|
|
brelse(bp, BC_INVAL);
|
2002-05-15 00:03:53 +04:00
|
|
|
++retries;
|
|
|
|
if (retries > LFS_IFIND_RETRIES)
|
|
|
|
panic("lfs_fastvget: dinode not found");
|
2005-03-08 03:18:19 +03:00
|
|
|
DLOG((DLOG_CLEAN, "lfs_fastvget: dinode not found,"
|
|
|
|
" retrying...\n"));
|
2002-05-15 00:03:53 +04:00
|
|
|
goto again;
|
|
|
|
}
|
2003-04-02 14:39:19 +04:00
|
|
|
*ip->i_din.ffs1_din = *dip;
|
2007-10-08 22:01:27 +04:00
|
|
|
brelse(bp, 0);
|
1994-06-08 15:41:58 +04:00
|
|
|
}
|
2003-11-07 17:52:27 +03:00
|
|
|
lfs_vinit(mp, &vp);
|
1994-06-08 15:41:58 +04:00
|
|
|
|
|
|
|
*vpp = vp;
|
2003-03-20 17:11:46 +03:00
|
|
|
|
2002-12-17 17:37:49 +03:00
|
|
|
KASSERT(VOP_ISLOCKED(vp));
|
|
|
|
VOP_UNLOCK(vp, 0);
|
1999-03-10 03:20:00 +03:00
|
|
|
|
1994-06-08 15:41:58 +04:00
|
|
|
return (0);
|
|
|
|
}
|
1999-03-10 03:20:00 +03:00
|
|
|
|
2003-03-08 05:55:47 +03:00
|
|
|
/*
|
|
|
|
* Make up a "fake" cleaner buffer, copy the data from userland into it.
|
|
|
|
*/
|
1994-06-08 15:41:58 +04:00
|
|
|
struct buf *
|
2007-03-04 08:59:00 +03:00
|
|
|
lfs_fakebuf(struct lfs *fs, struct vnode *vp, int lbn, size_t size, void *uaddr)
|
1994-06-08 15:41:58 +04:00
|
|
|
{
|
|
|
|
struct buf *bp;
|
1999-03-26 01:26:52 +03:00
|
|
|
int error;
|
2002-11-24 19:39:13 +03:00
|
|
|
|
2002-12-18 17:05:50 +03:00
|
|
|
KASSERT(VTOI(vp)->i_number != LFS_IFILE_INUM);
|
|
|
|
|
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 = lfs_newbuf(VTOI(vp)->i_lfs, vp, lbn, size, LFS_NB_CLEAN);
|
1999-03-26 01:26:52 +03:00
|
|
|
error = copyin(uaddr, bp->b_data, size);
|
2001-11-24 00:44:25 +03:00
|
|
|
if (error) {
|
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);
|
1999-03-26 01:26:52 +03:00
|
|
|
return NULL;
|
1999-03-10 03:20:00 +03:00
|
|
|
}
|
2002-11-24 19:39:13 +03:00
|
|
|
KDASSERT(bp->b_iodone == lfs_callback);
|
|
|
|
|
2002-05-15 00:03:53 +04:00
|
|
|
#if 0
|
2008-01-02 14:48:20 +03:00
|
|
|
mutex_enter(&lfs_lock);
|
2002-05-15 00:03:53 +04:00
|
|
|
++fs->lfs_iocount;
|
2008-01-02 14:48:20 +03:00
|
|
|
mutex_exit(&lfs_lock);
|
2002-05-15 00:03:53 +04:00
|
|
|
#endif
|
1994-06-08 15:41:58 +04:00
|
|
|
bp->b_bufsize = size;
|
|
|
|
bp->b_bcount = size;
|
|
|
|
return (bp);
|
|
|
|
}
|