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
|
|
|
/* $NetBSD: lfs_vnops.c,v 1.84 2003/02/17 23:48:22 perseant Exp $ */
|
1994-06-29 10:39:25 +04:00
|
|
|
|
1999-03-10 03:20:00 +03:00
|
|
|
/*-
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
* Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
|
1999-03-10 03:20:00 +03:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This code is derived from software contributed to The NetBSD Foundation
|
|
|
|
* by Konrad E. Schroder <perseant@hhhh.org>.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by the NetBSD
|
|
|
|
* Foundation, Inc. and its contributors.
|
|
|
|
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
|
|
|
* contributors may be used to endorse or promote products derived
|
|
|
|
* from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
|
|
|
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
|
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
|
|
|
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
1994-06-08 15:41:58 +04:00
|
|
|
/*
|
1998-03-01 05:20:01 +03:00
|
|
|
* Copyright (c) 1986, 1989, 1991, 1993, 1995
|
1994-06-08 15:41:58 +04:00
|
|
|
* The Regents of the University of California. All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by the University of
|
|
|
|
* California, Berkeley and its contributors.
|
|
|
|
* 4. Neither the name of the University nor the names of its contributors
|
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
1998-03-01 05:20:01 +03:00
|
|
|
* @(#)lfs_vnops.c 8.13 (Berkeley) 6/10/95
|
1994-06-08 15:41:58 +04:00
|
|
|
*/
|
|
|
|
|
2001-11-08 05:39:06 +03:00
|
|
|
#include <sys/cdefs.h>
|
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
|
|
|
__KERNEL_RCSID(0, "$NetBSD: lfs_vnops.c,v 1.84 2003/02/17 23:48:22 perseant Exp $");
|
2001-11-08 05:39:06 +03:00
|
|
|
|
1994-06-08 15:41:58 +04:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/namei.h>
|
|
|
|
#include <sys/resourcevar.h>
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/file.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <sys/buf.h>
|
|
|
|
#include <sys/proc.h>
|
|
|
|
#include <sys/mount.h>
|
|
|
|
#include <sys/vnode.h>
|
|
|
|
#include <sys/malloc.h>
|
1998-09-01 07:26:05 +04:00
|
|
|
#include <sys/pool.h>
|
1996-02-10 01:28:45 +03:00
|
|
|
#include <sys/signalvar.h>
|
1994-06-08 15:41:58 +04:00
|
|
|
|
|
|
|
#include <miscfs/fifofs/fifo.h>
|
1996-09-02 03:47:48 +04:00
|
|
|
#include <miscfs/genfs/genfs.h>
|
|
|
|
#include <miscfs/specfs/specdev.h>
|
1994-06-08 15:41:58 +04:00
|
|
|
|
|
|
|
#include <ufs/ufs/inode.h>
|
|
|
|
#include <ufs/ufs/dir.h>
|
|
|
|
#include <ufs/ufs/ufsmount.h>
|
|
|
|
#include <ufs/ufs/ufs_extern.h>
|
|
|
|
|
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
|
|
|
#include <uvm/uvm.h>
|
|
|
|
#ifdef LFS_UBC
|
|
|
|
# include <uvm/uvm_pmap.h>
|
|
|
|
# include <uvm/uvm_stat.h>
|
|
|
|
# include <uvm/uvm_pager.h>
|
|
|
|
#endif
|
|
|
|
|
1994-06-08 15:41:58 +04:00
|
|
|
#include <ufs/lfs/lfs.h>
|
|
|
|
#include <ufs/lfs/lfs_extern.h>
|
|
|
|
|
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
|
|
|
extern int lfs_writer_daemon;
|
|
|
|
extern int lfs_subsys_pages;
|
|
|
|
|
1994-06-08 15:41:58 +04:00
|
|
|
/* Global vfs data structures for lfs. */
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
int (**lfs_vnodeop_p)(void *);
|
2001-01-22 15:17:35 +03:00
|
|
|
const struct vnodeopv_entry_desc lfs_vnodeop_entries[] = {
|
1994-06-08 15:41:58 +04:00
|
|
|
{ &vop_default_desc, vn_default_error },
|
|
|
|
{ &vop_lookup_desc, ufs_lookup }, /* lookup */
|
1999-03-10 03:20:00 +03:00
|
|
|
{ &vop_create_desc, lfs_create }, /* create */
|
2003-01-30 17:18:32 +03:00
|
|
|
{ &vop_whiteout_desc, ufs_whiteout }, /* whiteout */
|
1999-03-10 03:20:00 +03:00
|
|
|
{ &vop_mknod_desc, lfs_mknod }, /* mknod */
|
1994-06-08 15:41:58 +04:00
|
|
|
{ &vop_open_desc, ufs_open }, /* open */
|
|
|
|
{ &vop_close_desc, lfs_close }, /* close */
|
|
|
|
{ &vop_access_desc, ufs_access }, /* access */
|
|
|
|
{ &vop_getattr_desc, lfs_getattr }, /* getattr */
|
2002-02-11 05:47:29 +03:00
|
|
|
{ &vop_setattr_desc, lfs_setattr }, /* setattr */
|
1994-06-08 15:41:58 +04:00
|
|
|
{ &vop_read_desc, lfs_read }, /* read */
|
|
|
|
{ &vop_write_desc, lfs_write }, /* write */
|
1994-12-13 23:14:30 +03:00
|
|
|
{ &vop_lease_desc, ufs_lease_check }, /* lease */
|
1994-06-08 15:41:58 +04:00
|
|
|
{ &vop_ioctl_desc, ufs_ioctl }, /* ioctl */
|
1999-08-04 00:19:16 +04:00
|
|
|
{ &vop_fcntl_desc, ufs_fcntl }, /* fcntl */
|
1996-09-07 16:40:22 +04:00
|
|
|
{ &vop_poll_desc, ufs_poll }, /* poll */
|
2002-10-23 13:10:23 +04:00
|
|
|
{ &vop_kqfilter_desc, genfs_kqfilter }, /* kqfilter */
|
1998-03-01 05:20:01 +03:00
|
|
|
{ &vop_revoke_desc, ufs_revoke }, /* revoke */
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
#ifdef LFS_UBC
|
|
|
|
{ &vop_mmap_desc, lfs_mmap }, /* mmap */
|
|
|
|
#else
|
1994-06-08 15:41:58 +04:00
|
|
|
{ &vop_mmap_desc, ufs_mmap }, /* mmap */
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
#endif
|
1994-06-08 15:41:58 +04:00
|
|
|
{ &vop_fsync_desc, lfs_fsync }, /* fsync */
|
|
|
|
{ &vop_seek_desc, ufs_seek }, /* seek */
|
1999-03-10 03:20:00 +03:00
|
|
|
{ &vop_remove_desc, lfs_remove }, /* remove */
|
|
|
|
{ &vop_link_desc, lfs_link }, /* link */
|
|
|
|
{ &vop_rename_desc, lfs_rename }, /* rename */
|
|
|
|
{ &vop_mkdir_desc, lfs_mkdir }, /* mkdir */
|
|
|
|
{ &vop_rmdir_desc, lfs_rmdir }, /* rmdir */
|
|
|
|
{ &vop_symlink_desc, lfs_symlink }, /* symlink */
|
1994-06-08 15:41:58 +04:00
|
|
|
{ &vop_readdir_desc, ufs_readdir }, /* readdir */
|
|
|
|
{ &vop_readlink_desc, ufs_readlink }, /* readlink */
|
|
|
|
{ &vop_abortop_desc, ufs_abortop }, /* abortop */
|
2000-06-28 00:57:11 +04:00
|
|
|
{ &vop_inactive_desc, lfs_inactive }, /* inactive */
|
1994-06-08 15:41:58 +04:00
|
|
|
{ &vop_reclaim_desc, lfs_reclaim }, /* reclaim */
|
|
|
|
{ &vop_lock_desc, ufs_lock }, /* lock */
|
|
|
|
{ &vop_unlock_desc, ufs_unlock }, /* unlock */
|
|
|
|
{ &vop_bmap_desc, ufs_bmap }, /* bmap */
|
|
|
|
{ &vop_strategy_desc, ufs_strategy }, /* strategy */
|
|
|
|
{ &vop_print_desc, ufs_print }, /* print */
|
|
|
|
{ &vop_islocked_desc, ufs_islocked }, /* islocked */
|
|
|
|
{ &vop_pathconf_desc, ufs_pathconf }, /* pathconf */
|
|
|
|
{ &vop_advlock_desc, ufs_advlock }, /* advlock */
|
|
|
|
{ &vop_blkatoff_desc, lfs_blkatoff }, /* blkatoff */
|
|
|
|
{ &vop_valloc_desc, lfs_valloc }, /* valloc */
|
1999-11-15 21:49:07 +03:00
|
|
|
{ &vop_balloc_desc, lfs_balloc }, /* balloc */
|
1994-06-08 15:41:58 +04:00
|
|
|
{ &vop_vfree_desc, lfs_vfree }, /* vfree */
|
|
|
|
{ &vop_truncate_desc, lfs_truncate }, /* truncate */
|
|
|
|
{ &vop_update_desc, lfs_update }, /* update */
|
|
|
|
{ &vop_bwrite_desc, lfs_bwrite }, /* bwrite */
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
#ifdef LFS_UBC
|
|
|
|
{ &vop_getpages_desc, genfs_getpages }, /* getpages */
|
|
|
|
#else
|
2001-12-18 10:51:16 +03:00
|
|
|
{ &vop_getpages_desc, lfs_getpages }, /* getpages */
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
#endif
|
2001-12-18 10:51:16 +03:00
|
|
|
{ &vop_putpages_desc, lfs_putpages }, /* putpages */
|
2001-08-17 09:54:36 +04:00
|
|
|
{ NULL, NULL }
|
1994-06-08 15:41:58 +04:00
|
|
|
};
|
2001-01-22 15:17:35 +03:00
|
|
|
const struct vnodeopv_desc lfs_vnodeop_opv_desc =
|
1994-06-08 15:41:58 +04:00
|
|
|
{ &lfs_vnodeop_p, lfs_vnodeop_entries };
|
|
|
|
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
int (**lfs_specop_p)(void *);
|
2001-01-22 15:17:35 +03:00
|
|
|
const struct vnodeopv_entry_desc lfs_specop_entries[] = {
|
1994-06-08 15:41:58 +04:00
|
|
|
{ &vop_default_desc, vn_default_error },
|
|
|
|
{ &vop_lookup_desc, spec_lookup }, /* lookup */
|
|
|
|
{ &vop_create_desc, spec_create }, /* create */
|
|
|
|
{ &vop_mknod_desc, spec_mknod }, /* mknod */
|
|
|
|
{ &vop_open_desc, spec_open }, /* open */
|
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
|
|
|
{ &vop_close_desc, lfsspec_close }, /* close */
|
1994-06-08 15:41:58 +04:00
|
|
|
{ &vop_access_desc, ufs_access }, /* access */
|
|
|
|
{ &vop_getattr_desc, lfs_getattr }, /* getattr */
|
2002-02-11 05:47:29 +03:00
|
|
|
{ &vop_setattr_desc, lfs_setattr }, /* setattr */
|
1994-06-08 15:41:58 +04:00
|
|
|
{ &vop_read_desc, ufsspec_read }, /* read */
|
|
|
|
{ &vop_write_desc, ufsspec_write }, /* write */
|
1994-12-13 23:14:30 +03:00
|
|
|
{ &vop_lease_desc, spec_lease_check }, /* lease */
|
1994-06-08 15:41:58 +04:00
|
|
|
{ &vop_ioctl_desc, spec_ioctl }, /* ioctl */
|
1999-08-04 00:19:16 +04:00
|
|
|
{ &vop_fcntl_desc, ufs_fcntl }, /* fcntl */
|
1996-09-07 16:40:22 +04:00
|
|
|
{ &vop_poll_desc, spec_poll }, /* poll */
|
2002-10-23 13:10:23 +04:00
|
|
|
{ &vop_kqfilter_desc, spec_kqfilter }, /* kqfilter */
|
1998-03-01 05:20:01 +03:00
|
|
|
{ &vop_revoke_desc, spec_revoke }, /* revoke */
|
1994-06-08 15:41:58 +04:00
|
|
|
{ &vop_mmap_desc, spec_mmap }, /* mmap */
|
|
|
|
{ &vop_fsync_desc, spec_fsync }, /* fsync */
|
|
|
|
{ &vop_seek_desc, spec_seek }, /* seek */
|
|
|
|
{ &vop_remove_desc, spec_remove }, /* remove */
|
|
|
|
{ &vop_link_desc, spec_link }, /* link */
|
|
|
|
{ &vop_rename_desc, spec_rename }, /* rename */
|
|
|
|
{ &vop_mkdir_desc, spec_mkdir }, /* mkdir */
|
|
|
|
{ &vop_rmdir_desc, spec_rmdir }, /* rmdir */
|
|
|
|
{ &vop_symlink_desc, spec_symlink }, /* symlink */
|
|
|
|
{ &vop_readdir_desc, spec_readdir }, /* readdir */
|
|
|
|
{ &vop_readlink_desc, spec_readlink }, /* readlink */
|
|
|
|
{ &vop_abortop_desc, spec_abortop }, /* abortop */
|
2000-06-28 00:57:11 +04:00
|
|
|
{ &vop_inactive_desc, lfs_inactive }, /* inactive */
|
1994-06-08 15:41:58 +04:00
|
|
|
{ &vop_reclaim_desc, lfs_reclaim }, /* reclaim */
|
|
|
|
{ &vop_lock_desc, ufs_lock }, /* lock */
|
|
|
|
{ &vop_unlock_desc, ufs_unlock }, /* unlock */
|
|
|
|
{ &vop_bmap_desc, spec_bmap }, /* bmap */
|
|
|
|
{ &vop_strategy_desc, spec_strategy }, /* strategy */
|
|
|
|
{ &vop_print_desc, ufs_print }, /* print */
|
|
|
|
{ &vop_islocked_desc, ufs_islocked }, /* islocked */
|
|
|
|
{ &vop_pathconf_desc, spec_pathconf }, /* pathconf */
|
|
|
|
{ &vop_advlock_desc, spec_advlock }, /* advlock */
|
|
|
|
{ &vop_blkatoff_desc, spec_blkatoff }, /* blkatoff */
|
|
|
|
{ &vop_valloc_desc, spec_valloc }, /* valloc */
|
|
|
|
{ &vop_vfree_desc, lfs_vfree }, /* vfree */
|
|
|
|
{ &vop_truncate_desc, spec_truncate }, /* truncate */
|
|
|
|
{ &vop_update_desc, lfs_update }, /* update */
|
1999-09-04 02:48:51 +04:00
|
|
|
{ &vop_bwrite_desc, vn_bwrite }, /* bwrite */
|
2001-08-17 09:54:36 +04:00
|
|
|
{ &vop_getpages_desc, spec_getpages }, /* getpages */
|
|
|
|
{ &vop_putpages_desc, spec_putpages }, /* putpages */
|
|
|
|
{ NULL, NULL }
|
1994-06-08 15:41:58 +04:00
|
|
|
};
|
2001-01-22 15:17:35 +03:00
|
|
|
const struct vnodeopv_desc lfs_specop_opv_desc =
|
1994-06-08 15:41:58 +04:00
|
|
|
{ &lfs_specop_p, lfs_specop_entries };
|
|
|
|
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
int (**lfs_fifoop_p)(void *);
|
2001-01-22 15:17:35 +03:00
|
|
|
const struct vnodeopv_entry_desc lfs_fifoop_entries[] = {
|
1994-06-08 15:41:58 +04:00
|
|
|
{ &vop_default_desc, vn_default_error },
|
|
|
|
{ &vop_lookup_desc, fifo_lookup }, /* lookup */
|
|
|
|
{ &vop_create_desc, fifo_create }, /* create */
|
|
|
|
{ &vop_mknod_desc, fifo_mknod }, /* mknod */
|
|
|
|
{ &vop_open_desc, fifo_open }, /* open */
|
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
|
|
|
{ &vop_close_desc, lfsfifo_close }, /* close */
|
1994-06-08 15:41:58 +04:00
|
|
|
{ &vop_access_desc, ufs_access }, /* access */
|
|
|
|
{ &vop_getattr_desc, lfs_getattr }, /* getattr */
|
2002-02-11 05:47:29 +03:00
|
|
|
{ &vop_setattr_desc, lfs_setattr }, /* setattr */
|
1994-06-08 15:41:58 +04:00
|
|
|
{ &vop_read_desc, ufsfifo_read }, /* read */
|
|
|
|
{ &vop_write_desc, ufsfifo_write }, /* write */
|
1994-12-13 23:14:30 +03:00
|
|
|
{ &vop_lease_desc, fifo_lease_check }, /* lease */
|
1994-06-08 15:41:58 +04:00
|
|
|
{ &vop_ioctl_desc, fifo_ioctl }, /* ioctl */
|
1999-08-04 00:19:16 +04:00
|
|
|
{ &vop_fcntl_desc, ufs_fcntl }, /* fcntl */
|
1996-09-07 16:40:22 +04:00
|
|
|
{ &vop_poll_desc, fifo_poll }, /* poll */
|
2002-10-23 13:10:23 +04:00
|
|
|
{ &vop_kqfilter_desc, fifo_kqfilter }, /* kqfilter */
|
1998-03-01 05:20:01 +03:00
|
|
|
{ &vop_revoke_desc, fifo_revoke }, /* revoke */
|
1994-06-08 15:41:58 +04:00
|
|
|
{ &vop_mmap_desc, fifo_mmap }, /* mmap */
|
|
|
|
{ &vop_fsync_desc, fifo_fsync }, /* fsync */
|
|
|
|
{ &vop_seek_desc, fifo_seek }, /* seek */
|
|
|
|
{ &vop_remove_desc, fifo_remove }, /* remove */
|
|
|
|
{ &vop_link_desc, fifo_link }, /* link */
|
|
|
|
{ &vop_rename_desc, fifo_rename }, /* rename */
|
|
|
|
{ &vop_mkdir_desc, fifo_mkdir }, /* mkdir */
|
|
|
|
{ &vop_rmdir_desc, fifo_rmdir }, /* rmdir */
|
|
|
|
{ &vop_symlink_desc, fifo_symlink }, /* symlink */
|
|
|
|
{ &vop_readdir_desc, fifo_readdir }, /* readdir */
|
|
|
|
{ &vop_readlink_desc, fifo_readlink }, /* readlink */
|
|
|
|
{ &vop_abortop_desc, fifo_abortop }, /* abortop */
|
2000-06-28 00:57:11 +04:00
|
|
|
{ &vop_inactive_desc, lfs_inactive }, /* inactive */
|
1994-06-08 15:41:58 +04:00
|
|
|
{ &vop_reclaim_desc, lfs_reclaim }, /* reclaim */
|
|
|
|
{ &vop_lock_desc, ufs_lock }, /* lock */
|
|
|
|
{ &vop_unlock_desc, ufs_unlock }, /* unlock */
|
|
|
|
{ &vop_bmap_desc, fifo_bmap }, /* bmap */
|
|
|
|
{ &vop_strategy_desc, fifo_strategy }, /* strategy */
|
|
|
|
{ &vop_print_desc, ufs_print }, /* print */
|
|
|
|
{ &vop_islocked_desc, ufs_islocked }, /* islocked */
|
|
|
|
{ &vop_pathconf_desc, fifo_pathconf }, /* pathconf */
|
|
|
|
{ &vop_advlock_desc, fifo_advlock }, /* advlock */
|
|
|
|
{ &vop_blkatoff_desc, fifo_blkatoff }, /* blkatoff */
|
|
|
|
{ &vop_valloc_desc, fifo_valloc }, /* valloc */
|
|
|
|
{ &vop_vfree_desc, lfs_vfree }, /* vfree */
|
|
|
|
{ &vop_truncate_desc, fifo_truncate }, /* truncate */
|
|
|
|
{ &vop_update_desc, lfs_update }, /* update */
|
|
|
|
{ &vop_bwrite_desc, lfs_bwrite }, /* bwrite */
|
2001-09-23 02:35:18 +04:00
|
|
|
{ &vop_putpages_desc, fifo_putpages }, /* putpages */
|
2001-08-17 09:54:36 +04:00
|
|
|
{ NULL, NULL }
|
1994-06-08 15:41:58 +04:00
|
|
|
};
|
2001-01-22 15:17:35 +03:00
|
|
|
const struct vnodeopv_desc lfs_fifoop_opv_desc =
|
1994-06-08 15:41:58 +04:00
|
|
|
{ &lfs_fifoop_p, lfs_fifoop_entries };
|
|
|
|
|
2000-07-06 02:25:43 +04:00
|
|
|
/*
|
|
|
|
* A function version of LFS_ITIMES, for the UFS functions which call ITIMES
|
|
|
|
*/
|
|
|
|
void
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
lfs_itimes(struct inode *ip, struct timespec *acc, struct timespec *mod, struct timespec *cre)
|
2000-07-06 02:25:43 +04:00
|
|
|
{
|
|
|
|
LFS_ITIMES(ip, acc, mod, cre);
|
|
|
|
}
|
|
|
|
|
1994-06-08 15:41:58 +04:00
|
|
|
#define LFS_READWRITE
|
|
|
|
#include <ufs/ufs/ufs_readwrite.c>
|
|
|
|
#undef LFS_READWRITE
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Synch an open file.
|
|
|
|
*/
|
|
|
|
/* ARGSUSED */
|
1996-02-10 01:28:45 +03:00
|
|
|
int
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
lfs_fsync(void *v)
|
1996-02-10 01:28:45 +03:00
|
|
|
{
|
1994-06-08 15:41:58 +04:00
|
|
|
struct vop_fsync_args /* {
|
|
|
|
struct vnode *a_vp;
|
|
|
|
struct ucred *a_cred;
|
1999-03-10 03:20:00 +03:00
|
|
|
int a_flags;
|
2000-11-18 05:11:23 +03:00
|
|
|
off_t offlo;
|
|
|
|
off_t offhi;
|
1994-06-08 15:41:58 +04:00
|
|
|
struct proc *a_p;
|
1996-02-10 01:28:45 +03:00
|
|
|
} */ *ap = v;
|
2001-12-18 10:51:16 +03:00
|
|
|
struct vnode *vp = ap->a_vp;
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
int error, wait;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Trickle sync checks for need to do a checkpoint after possible
|
|
|
|
* activity from the pagedaemon.
|
|
|
|
*/
|
|
|
|
if (ap->a_flags & FSYNC_LAZY) {
|
|
|
|
wakeup(&lfs_writer_daemon);
|
2000-11-12 10:58:36 +03:00
|
|
|
return 0;
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
}
|
2000-11-12 10:58:36 +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
|
|
|
wait = (ap->a_flags & FSYNC_WAIT);
|
|
|
|
do {
|
2002-05-15 00:03:53 +04:00
|
|
|
#ifdef DEBUG
|
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;
|
2002-05-15 00:03:53 +04:00
|
|
|
#endif
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
|
|
|
|
simple_lock(&vp->v_interlock);
|
|
|
|
error = VOP_PUTPAGES(vp, trunc_page(ap->a_offlo),
|
|
|
|
round_page(ap->a_offhi),
|
|
|
|
PGO_CLEANIT | (wait ? PGO_SYNCIO : 0));
|
|
|
|
if (error)
|
|
|
|
return error;
|
|
|
|
error = VOP_UPDATE(vp, NULL, NULL, wait ? UPDATE_WAIT : 0);
|
|
|
|
if (wait && error == 0 && !VPISEMPTY(vp)) {
|
|
|
|
#ifdef DEBUG
|
|
|
|
printf("lfs_fsync: reflushing ino %d\n",
|
|
|
|
VTOI(vp)->i_number);
|
|
|
|
printf("vflags %x iflags %x npages %d\n",
|
|
|
|
vp->v_flag, VTOI(vp)->i_flag,
|
|
|
|
vp->v_uobj.uo_npages);
|
|
|
|
LIST_FOREACH(bp, &vp->v_dirtyblkhd, b_vnbufs)
|
|
|
|
printf("%" PRId64 " (%lx)", bp->b_lblkno,
|
|
|
|
bp->b_flags);
|
|
|
|
printf("\n");
|
|
|
|
#endif
|
|
|
|
VTOI(vp)->i_flag |= IN_MODIFIED;
|
|
|
|
}
|
|
|
|
} while (wait && error == 0 && !VPISEMPTY(vp));
|
|
|
|
|
2002-05-15 00:03:53 +04:00
|
|
|
return error;
|
1994-06-08 15:41:58 +04:00
|
|
|
}
|
|
|
|
|
2000-06-28 00:57:11 +04:00
|
|
|
/*
|
|
|
|
* Take IN_ADIROP off, then call ufs_inactive.
|
|
|
|
*/
|
|
|
|
int
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
lfs_inactive(void *v)
|
2000-06-28 00:57:11 +04:00
|
|
|
{
|
|
|
|
struct vop_inactive_args /* {
|
|
|
|
struct vnode *a_vp;
|
|
|
|
struct proc *a_p;
|
|
|
|
} */ *ap = v;
|
2002-12-28 18:12:26 +03:00
|
|
|
|
2003-01-08 18:40:54 +03:00
|
|
|
KASSERT(VTOI(ap->a_vp)->i_ffs_nlink == VTOI(ap->a_vp)->i_ffs_effnlink);
|
|
|
|
|
2003-01-08 18:40:04 +03:00
|
|
|
lfs_unmark_vnode(ap->a_vp);
|
|
|
|
|
2002-12-29 10:05:55 +03:00
|
|
|
return ufs_inactive(v);
|
2000-06-28 00:57:11 +04:00
|
|
|
}
|
|
|
|
|
1994-06-08 15:41:58 +04:00
|
|
|
/*
|
|
|
|
* These macros are used to bracket UFS directory ops, so that we can
|
|
|
|
* identify all the pages touched during directory ops which need to
|
|
|
|
* be ordered and flushed atomically, so that they may be recovered.
|
|
|
|
*/
|
1999-03-10 03:20:00 +03:00
|
|
|
/*
|
|
|
|
* XXX KS - Because we have to mark nodes VDIROP in order to prevent
|
|
|
|
* the cache from reclaiming them while a dirop is in progress, we must
|
|
|
|
* also manage the number of nodes so marked (otherwise we can run out).
|
|
|
|
* We do this by setting lfs_dirvcount to the number of marked vnodes; it
|
|
|
|
* is decremented during segment write, when VDIROP is taken off.
|
|
|
|
*/
|
2002-12-28 17:39:08 +03:00
|
|
|
#define SET_DIROP(vp) SET_DIROP2((vp), NULL)
|
|
|
|
#define SET_DIROP2(vp, vp2) lfs_set_dirop((vp), (vp2))
|
|
|
|
static int lfs_set_dirop(struct vnode *, struct vnode *);
|
1999-11-06 23:33:05 +03:00
|
|
|
extern int lfs_dirvcount;
|
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
|
|
|
extern int lfs_do_flush;
|
1999-03-26 01:33:03 +03:00
|
|
|
|
2002-12-26 16:37:18 +03:00
|
|
|
#define NRESERVE(fs) (btofsb(fs, (NIADDR + 3 + (2 * NIADDR + 3)) << fs->lfs_bshift))
|
|
|
|
|
2000-10-15 03:22:14 +04:00
|
|
|
static int
|
2002-12-28 17:39:08 +03:00
|
|
|
lfs_set_dirop(struct vnode *vp, struct vnode *vp2)
|
1999-03-26 01:33:03 +03:00
|
|
|
{
|
2000-06-28 00:57:11 +04:00
|
|
|
struct lfs *fs;
|
1999-03-26 01:33:03 +03:00
|
|
|
int error;
|
|
|
|
|
2002-12-28 17:39:08 +03:00
|
|
|
KASSERT(VOP_ISLOCKED(vp));
|
|
|
|
KASSERT(vp2 == NULL || VOP_ISLOCKED(vp2));
|
|
|
|
|
2000-06-28 00:57:11 +04:00
|
|
|
fs = VTOI(vp)->i_lfs;
|
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
|
|
|
/*
|
|
|
|
* We might need one directory block plus supporting indirect blocks,
|
|
|
|
* plus an inode block and ifile page for the new vnode.
|
|
|
|
*/
|
2002-12-28 17:39:08 +03:00
|
|
|
if ((error = lfs_reserve(fs, vp, vp2, NRESERVE(fs))) != 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
|
|
|
return (error);
|
2002-12-26 16:37:18 +03:00
|
|
|
|
2000-06-28 00:57:11 +04:00
|
|
|
if (fs->lfs_dirops == 0)
|
|
|
|
lfs_check(vp, LFS_UNUSED_LBN, 0);
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
while (fs->lfs_writer || lfs_dirvcount > LFS_MAX_DIROP) {
|
2001-11-24 00:44:25 +03:00
|
|
|
if (fs->lfs_writer)
|
2002-05-15 00:03:53 +04:00
|
|
|
tsleep(&fs->lfs_dirops, PRIBIO + 1, "lfs_sdirop", 0);
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
if (lfs_dirvcount > LFS_MAX_DIROP && fs->lfs_dirops == 0) {
|
|
|
|
wakeup(&lfs_writer_daemon);
|
|
|
|
preempt(NULL);
|
1999-12-04 00:47: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 (lfs_dirvcount > LFS_MAX_DIROP) {
|
1999-03-26 01:33:03 +03:00
|
|
|
#ifdef DEBUG_LFS
|
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
|
|
|
printf("lfs_set_dirop: sleeping with dirops=%d, "
|
|
|
|
"dirvcount=%d\n", fs->lfs_dirops,
|
|
|
|
lfs_dirvcount);
|
1999-03-26 01:33:03 +03:00
|
|
|
#endif
|
2001-11-24 00:44:25 +03:00
|
|
|
if ((error = tsleep(&lfs_dirvcount, PCATCH|PUSER,
|
|
|
|
"lfs_maxdirop", 0)) != 0) {
|
2002-12-26 16:37:18 +03:00
|
|
|
goto unreserve;
|
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
|
|
|
}
|
1999-03-26 01:33:03 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
++fs->lfs_dirops;
|
|
|
|
fs->lfs_doifile = 1;
|
|
|
|
|
2000-10-15 03:22:14 +04:00
|
|
|
/* Hold a reference so SET_ENDOP will be happy */
|
2003-01-08 18:43:29 +03:00
|
|
|
vref(vp);
|
|
|
|
if (vp2)
|
|
|
|
vref(vp2);
|
2000-10-15 03:22:14 +04:00
|
|
|
|
1999-03-26 01:33:03 +03:00
|
|
|
return 0;
|
2002-12-26 16:37:18 +03:00
|
|
|
|
|
|
|
unreserve:
|
2002-12-28 17:39:08 +03:00
|
|
|
lfs_reserve(fs, vp, vp2, -NRESERVE(fs));
|
2002-12-26 16:37:18 +03:00
|
|
|
return error;
|
1994-06-08 15:41:58 +04:00
|
|
|
}
|
|
|
|
|
2002-12-28 17:39:08 +03:00
|
|
|
#define SET_ENDOP(fs, vp, str) SET_ENDOP2((fs), (vp), NULL, (str))
|
|
|
|
#define SET_ENDOP2(fs, vp, vp2, str) { \
|
1994-06-08 15:41:58 +04:00
|
|
|
--(fs)->lfs_dirops; \
|
1999-03-10 03:20:00 +03:00
|
|
|
if (!(fs)->lfs_dirops) { \
|
2000-06-28 00:57:11 +04:00
|
|
|
if ((fs)->lfs_nadirop) { \
|
2002-09-27 19:35:29 +04:00
|
|
|
panic("SET_ENDOP: %s: no dirops but nadirop=%d", \
|
2000-06-28 00:57:11 +04:00
|
|
|
(str), (fs)->lfs_nadirop); \
|
|
|
|
} \
|
1994-06-08 15:41:58 +04:00
|
|
|
wakeup(&(fs)->lfs_writer); \
|
1999-04-12 04:36:47 +04:00
|
|
|
lfs_check((vp),LFS_UNUSED_LBN,0); \
|
1999-03-10 03:20:00 +03:00
|
|
|
} \
|
2002-12-28 17:39:08 +03:00
|
|
|
lfs_reserve((fs), vp, vp2, -NRESERVE(fs)); /* XXX */ \
|
2003-01-08 18:43:29 +03:00
|
|
|
vrele(vp); \
|
|
|
|
if (vp2) \
|
|
|
|
vrele(vp2); \
|
1994-06-08 15:41:58 +04:00
|
|
|
}
|
|
|
|
|
1999-03-10 03:20:00 +03:00
|
|
|
#define MARK_VNODE(dvp) do { \
|
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 inode *_ip = VTOI(dvp); \
|
|
|
|
struct lfs *_fs = _ip->i_lfs; \
|
|
|
|
\
|
2000-05-27 04:19:52 +04:00
|
|
|
if (!((dvp)->v_flag & VDIROP)) { \
|
2000-06-22 22:11:45 +04:00
|
|
|
(void)lfs_vref(dvp); \
|
1999-11-06 23:33:05 +03:00
|
|
|
++lfs_dirvcount; \
|
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
|
|
|
TAILQ_INSERT_TAIL(&_fs->lfs_dchainhd, _ip, i_lfs_dchain); \
|
1999-03-10 03:20:00 +03:00
|
|
|
} \
|
|
|
|
(dvp)->v_flag |= VDIROP; \
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
if (!(_ip->i_flag & IN_ADIROP)) { \
|
|
|
|
++_fs->lfs_nadirop; \
|
2000-05-27 04:19:52 +04:00
|
|
|
} \
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
_ip->i_flag |= IN_ADIROP; \
|
2001-11-24 00:44:25 +03:00
|
|
|
} while (0)
|
2000-05-27 04:19:52 +04:00
|
|
|
|
2000-06-28 00:57:11 +04:00
|
|
|
#define UNMARK_VNODE(vp) lfs_unmark_vnode(vp)
|
|
|
|
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
void lfs_unmark_vnode(struct vnode *vp)
|
2000-06-28 00:57:11 +04:00
|
|
|
{
|
|
|
|
struct inode *ip;
|
|
|
|
|
|
|
|
ip = VTOI(vp);
|
|
|
|
|
|
|
|
if (ip->i_flag & IN_ADIROP)
|
|
|
|
--ip->i_lfs->lfs_nadirop;
|
|
|
|
ip->i_flag &= ~IN_ADIROP;
|
|
|
|
}
|
1998-03-01 05:20:01 +03:00
|
|
|
|
1994-06-08 15:41:58 +04:00
|
|
|
int
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
lfs_symlink(void *v)
|
1996-02-10 01:28:45 +03:00
|
|
|
{
|
1994-06-08 15:41:58 +04:00
|
|
|
struct vop_symlink_args /* {
|
|
|
|
struct vnode *a_dvp;
|
|
|
|
struct vnode **a_vpp;
|
|
|
|
struct componentname *a_cnp;
|
|
|
|
struct vattr *a_vap;
|
|
|
|
char *a_target;
|
1996-02-10 01:28:45 +03:00
|
|
|
} */ *ap = v;
|
2000-05-27 04:19:52 +04:00
|
|
|
int error;
|
1994-06-08 15:41:58 +04:00
|
|
|
|
2000-06-28 00:57:11 +04:00
|
|
|
if ((error = SET_DIROP(ap->a_dvp)) != 0) {
|
1999-12-15 10:19:07 +03:00
|
|
|
vput(ap->a_dvp);
|
2000-05-27 04:19:52 +04:00
|
|
|
return error;
|
1999-12-15 10:19:07 +03:00
|
|
|
}
|
1994-06-08 15:41:58 +04:00
|
|
|
MARK_VNODE(ap->a_dvp);
|
2000-05-27 04:19:52 +04:00
|
|
|
error = ufs_symlink(ap);
|
|
|
|
UNMARK_VNODE(ap->a_dvp);
|
2000-06-28 00:57:11 +04:00
|
|
|
if (*(ap->a_vpp))
|
2000-05-27 04:19:52 +04:00
|
|
|
UNMARK_VNODE(*(ap->a_vpp));
|
|
|
|
SET_ENDOP(VTOI(ap->a_dvp)->i_lfs,ap->a_dvp,"symlink");
|
|
|
|
return (error);
|
1994-06-08 15:41:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
lfs_mknod(void *v)
|
1996-02-10 01:28:45 +03:00
|
|
|
{
|
1999-03-10 03:20:00 +03:00
|
|
|
struct vop_mknod_args /* {
|
1994-06-08 15:41:58 +04:00
|
|
|
struct vnode *a_dvp;
|
|
|
|
struct vnode **a_vpp;
|
|
|
|
struct componentname *a_cnp;
|
|
|
|
struct vattr *a_vap;
|
1999-03-10 03:20:00 +03:00
|
|
|
} */ *ap = v;
|
1999-09-04 02:48:51 +04:00
|
|
|
struct vattr *vap = ap->a_vap;
|
|
|
|
struct vnode **vpp = ap->a_vpp;
|
|
|
|
struct inode *ip;
|
|
|
|
int error;
|
2001-07-24 19:39:30 +04:00
|
|
|
struct mount *mp;
|
|
|
|
ino_t ino;
|
1994-06-08 15:41:58 +04:00
|
|
|
|
2000-06-28 00:57:11 +04:00
|
|
|
if ((error = SET_DIROP(ap->a_dvp)) != 0) {
|
1999-12-15 10:19:07 +03:00
|
|
|
vput(ap->a_dvp);
|
1999-09-04 02:48:51 +04:00
|
|
|
return error;
|
1999-12-15 10:19:07 +03:00
|
|
|
}
|
1994-06-08 15:41:58 +04:00
|
|
|
MARK_VNODE(ap->a_dvp);
|
1999-09-04 02:48:51 +04:00
|
|
|
error = ufs_makeinode(MAKEIMODE(vap->va_type, vap->va_mode),
|
|
|
|
ap->a_dvp, vpp, ap->a_cnp);
|
2000-05-27 04:19:52 +04:00
|
|
|
UNMARK_VNODE(ap->a_dvp);
|
2000-06-28 00:57:11 +04:00
|
|
|
if (*(ap->a_vpp))
|
2000-05-27 04:19:52 +04:00
|
|
|
UNMARK_VNODE(*(ap->a_vpp));
|
1999-09-04 02:48:51 +04:00
|
|
|
|
|
|
|
/* Either way we're done with the dirop at this point */
|
1999-04-12 04:36:47 +04:00
|
|
|
SET_ENDOP(VTOI(ap->a_dvp)->i_lfs,ap->a_dvp,"mknod");
|
1999-09-04 02:48:51 +04:00
|
|
|
|
|
|
|
if (error)
|
|
|
|
return (error);
|
|
|
|
|
|
|
|
ip = VTOI(*vpp);
|
2001-07-24 19:39:30 +04:00
|
|
|
mp = (*vpp)->v_mount;
|
|
|
|
ino = ip->i_number;
|
1999-09-04 02:48:51 +04:00
|
|
|
ip->i_flag |= IN_ACCESS | IN_CHANGE | IN_UPDATE;
|
|
|
|
if (vap->va_rdev != VNOVAL) {
|
|
|
|
/*
|
|
|
|
* Want to be able to use this to make badblock
|
|
|
|
* inodes, so don't truncate the dev number.
|
|
|
|
*/
|
|
|
|
#if 0
|
|
|
|
ip->i_ffs_rdev = ufs_rw32(vap->va_rdev,
|
|
|
|
UFS_MPNEEDSWAP((*vpp)->v_mount));
|
|
|
|
#else
|
|
|
|
ip->i_ffs_rdev = vap->va_rdev;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Call fsync to write the vnode so that we don't have to deal with
|
|
|
|
* flushing it when it's marked VDIROP|VXLOCK.
|
|
|
|
*
|
|
|
|
* XXX KS - If we can't flush we also can't call vgone(), so must
|
|
|
|
* return. But, that leaves this vnode in limbo, also not good.
|
|
|
|
* Can this ever happen (barring hardware failure)?
|
|
|
|
*/
|
2003-01-18 11:51:40 +03:00
|
|
|
if ((error = VOP_FSYNC(*vpp, NOCRED, FSYNC_WAIT, 0, 0,
|
|
|
|
curproc)) != 0) {
|
2000-06-28 00:57:11 +04:00
|
|
|
printf("Couldn't fsync in mknod (ino %d)---what do I do?\n",
|
|
|
|
VTOI(*vpp)->i_number);
|
1999-09-04 02:48:51 +04:00
|
|
|
return (error);
|
2000-06-28 00:57:11 +04:00
|
|
|
}
|
1999-09-04 02:48:51 +04:00
|
|
|
/*
|
2000-06-28 00:57:11 +04:00
|
|
|
* Remove vnode so that it will be reloaded by VFS_VGET and
|
1999-09-04 02:48:51 +04:00
|
|
|
* checked to see if it is an alias of an existing entry in
|
|
|
|
* the inode cache.
|
|
|
|
*/
|
|
|
|
/* Used to be vput, but that causes us to call VOP_INACTIVE twice. */
|
2000-06-28 00:57:11 +04:00
|
|
|
VOP_UNLOCK(*vpp, 0);
|
1999-09-04 02:48:51 +04:00
|
|
|
lfs_vunref(*vpp);
|
|
|
|
(*vpp)->v_type = VNON;
|
|
|
|
vgone(*vpp);
|
2001-07-24 19:39:30 +04:00
|
|
|
error = VFS_VGET(mp, ino, vpp);
|
|
|
|
if (error != 0) {
|
|
|
|
*vpp = NULL;
|
|
|
|
return (error);
|
|
|
|
}
|
1999-09-04 02:48:51 +04:00
|
|
|
return (0);
|
1994-06-08 15:41:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
lfs_create(void *v)
|
1996-02-10 01:28:45 +03:00
|
|
|
{
|
1999-03-10 03:20:00 +03:00
|
|
|
struct vop_create_args /* {
|
1994-06-08 15:41:58 +04:00
|
|
|
struct vnode *a_dvp;
|
|
|
|
struct vnode **a_vpp;
|
|
|
|
struct componentname *a_cnp;
|
|
|
|
struct vattr *a_vap;
|
1996-02-10 01:28:45 +03:00
|
|
|
} */ *ap = v;
|
2000-05-27 04:19:52 +04:00
|
|
|
int error;
|
1994-06-08 15:41:58 +04:00
|
|
|
|
2001-11-24 00:44:25 +03:00
|
|
|
if ((error = SET_DIROP(ap->a_dvp)) != 0) {
|
1999-12-15 10:19:07 +03:00
|
|
|
vput(ap->a_dvp);
|
2000-05-27 04:19:52 +04:00
|
|
|
return error;
|
1999-12-15 10:19:07 +03:00
|
|
|
}
|
1994-06-08 15:41:58 +04:00
|
|
|
MARK_VNODE(ap->a_dvp);
|
2000-05-27 04:19:52 +04:00
|
|
|
error = ufs_create(ap);
|
|
|
|
UNMARK_VNODE(ap->a_dvp);
|
2000-06-28 00:57:11 +04:00
|
|
|
if (*(ap->a_vpp))
|
2000-05-27 04:19:52 +04:00
|
|
|
UNMARK_VNODE(*(ap->a_vpp));
|
1999-04-12 04:36:47 +04:00
|
|
|
SET_ENDOP(VTOI(ap->a_dvp)->i_lfs,ap->a_dvp,"create");
|
2000-05-27 04:19:52 +04:00
|
|
|
return (error);
|
1994-06-08 15:41:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
lfs_mkdir(void *v)
|
1996-02-10 01:28:45 +03:00
|
|
|
{
|
1999-03-10 03:20:00 +03:00
|
|
|
struct vop_mkdir_args /* {
|
1994-06-08 15:41:58 +04:00
|
|
|
struct vnode *a_dvp;
|
|
|
|
struct vnode **a_vpp;
|
|
|
|
struct componentname *a_cnp;
|
|
|
|
struct vattr *a_vap;
|
1996-02-10 01:28:45 +03:00
|
|
|
} */ *ap = v;
|
2000-05-27 04:19:52 +04:00
|
|
|
int error;
|
1994-06-08 15:41:58 +04:00
|
|
|
|
2001-11-24 00:44:25 +03:00
|
|
|
if ((error = SET_DIROP(ap->a_dvp)) != 0) {
|
1999-12-15 10:19:07 +03:00
|
|
|
vput(ap->a_dvp);
|
2000-05-27 04:19:52 +04:00
|
|
|
return error;
|
1999-12-15 10:19:07 +03:00
|
|
|
}
|
1994-06-08 15:41:58 +04:00
|
|
|
MARK_VNODE(ap->a_dvp);
|
2000-05-27 04:19:52 +04:00
|
|
|
error = ufs_mkdir(ap);
|
|
|
|
UNMARK_VNODE(ap->a_dvp);
|
2000-06-28 00:57:11 +04:00
|
|
|
if (*(ap->a_vpp))
|
2000-05-27 04:19:52 +04:00
|
|
|
UNMARK_VNODE(*(ap->a_vpp));
|
1999-04-12 04:36:47 +04:00
|
|
|
SET_ENDOP(VTOI(ap->a_dvp)->i_lfs,ap->a_dvp,"mkdir");
|
2000-05-27 04:19:52 +04:00
|
|
|
return (error);
|
1994-06-08 15:41:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
lfs_remove(void *v)
|
1996-02-10 01:28:45 +03:00
|
|
|
{
|
1999-03-10 03:20:00 +03:00
|
|
|
struct vop_remove_args /* {
|
1994-06-08 15:41:58 +04:00
|
|
|
struct vnode *a_dvp;
|
|
|
|
struct vnode *a_vp;
|
|
|
|
struct componentname *a_cnp;
|
1996-02-10 01:28:45 +03:00
|
|
|
} */ *ap = v;
|
1999-12-15 10:19:07 +03:00
|
|
|
struct vnode *dvp, *vp;
|
2000-05-27 04:19:52 +04:00
|
|
|
int error;
|
1999-12-15 10:19:07 +03:00
|
|
|
|
|
|
|
dvp = ap->a_dvp;
|
|
|
|
vp = ap->a_vp;
|
2002-12-28 17:39:08 +03:00
|
|
|
if ((error = SET_DIROP2(dvp, vp)) != 0) {
|
1999-12-15 10:19:07 +03:00
|
|
|
if (dvp == vp)
|
|
|
|
vrele(vp);
|
|
|
|
else
|
|
|
|
vput(vp);
|
|
|
|
vput(dvp);
|
2000-05-27 04:19:52 +04:00
|
|
|
return error;
|
1999-12-15 10:19:07 +03:00
|
|
|
}
|
|
|
|
MARK_VNODE(dvp);
|
|
|
|
MARK_VNODE(vp);
|
2000-05-27 04:19:52 +04:00
|
|
|
error = ufs_remove(ap);
|
|
|
|
UNMARK_VNODE(dvp);
|
|
|
|
UNMARK_VNODE(vp);
|
2000-06-28 00:57:11 +04:00
|
|
|
|
2002-12-28 17:39:08 +03:00
|
|
|
SET_ENDOP2(VTOI(dvp)->i_lfs, dvp, vp, "remove");
|
2000-05-27 04:19:52 +04:00
|
|
|
return (error);
|
1994-06-08 15:41:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
lfs_rmdir(void *v)
|
1996-02-10 01:28:45 +03:00
|
|
|
{
|
1999-03-10 03:20:00 +03:00
|
|
|
struct vop_rmdir_args /* {
|
1994-06-08 15:41:58 +04:00
|
|
|
struct vnodeop_desc *a_desc;
|
|
|
|
struct vnode *a_dvp;
|
|
|
|
struct vnode *a_vp;
|
|
|
|
struct componentname *a_cnp;
|
1996-02-10 01:28:45 +03:00
|
|
|
} */ *ap = v;
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
struct vnode *vp;
|
2000-05-27 04:19:52 +04:00
|
|
|
int error;
|
1994-06-08 15:41:58 +04:00
|
|
|
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
vp = ap->a_vp;
|
2002-12-28 17:39:08 +03:00
|
|
|
if ((error = SET_DIROP2(ap->a_dvp, ap->a_vp)) != 0) {
|
1999-12-15 10:19:07 +03:00
|
|
|
vrele(ap->a_dvp);
|
2002-11-24 11:23:41 +03:00
|
|
|
if (ap->a_vp != ap->a_dvp)
|
1999-12-15 10:19:07 +03:00
|
|
|
VOP_UNLOCK(ap->a_dvp, 0);
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
vput(vp);
|
2000-05-27 04:19:52 +04:00
|
|
|
return error;
|
1999-12-15 10:19:07 +03:00
|
|
|
}
|
1994-06-08 15:41:58 +04:00
|
|
|
MARK_VNODE(ap->a_dvp);
|
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
|
|
|
MARK_VNODE(vp);
|
2000-05-27 04:19:52 +04:00
|
|
|
error = ufs_rmdir(ap);
|
|
|
|
UNMARK_VNODE(ap->a_dvp);
|
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
|
|
|
UNMARK_VNODE(vp);
|
2000-06-28 00:57:11 +04:00
|
|
|
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
SET_ENDOP2(VTOI(ap->a_dvp)->i_lfs, ap->a_dvp, vp, "rmdir");
|
2000-05-27 04:19:52 +04:00
|
|
|
return (error);
|
1994-06-08 15:41:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
lfs_link(void *v)
|
1996-02-10 01:28:45 +03:00
|
|
|
{
|
1999-03-10 03:20:00 +03:00
|
|
|
struct vop_link_args /* {
|
1996-02-09 17:45:36 +03:00
|
|
|
struct vnode *a_dvp;
|
1994-06-08 15:41:58 +04:00
|
|
|
struct vnode *a_vp;
|
|
|
|
struct componentname *a_cnp;
|
1996-02-10 01:28:45 +03:00
|
|
|
} */ *ap = v;
|
2000-05-27 04:19:52 +04:00
|
|
|
int error;
|
1994-06-08 15:41:58 +04:00
|
|
|
|
2000-06-28 00:57:11 +04:00
|
|
|
if ((error = SET_DIROP(ap->a_dvp)) != 0) {
|
1999-12-15 10:19:07 +03:00
|
|
|
vput(ap->a_dvp);
|
2000-05-27 04:19:52 +04:00
|
|
|
return error;
|
1999-12-15 10:19:07 +03:00
|
|
|
}
|
1996-02-09 17:45:36 +03:00
|
|
|
MARK_VNODE(ap->a_dvp);
|
2000-05-27 04:19:52 +04:00
|
|
|
error = ufs_link(ap);
|
|
|
|
UNMARK_VNODE(ap->a_dvp);
|
1999-04-12 04:36:47 +04:00
|
|
|
SET_ENDOP(VTOI(ap->a_dvp)->i_lfs,ap->a_dvp,"link");
|
2000-05-27 04:19:52 +04:00
|
|
|
return (error);
|
1994-06-08 15:41:58 +04:00
|
|
|
}
|
1999-03-10 03:20:00 +03:00
|
|
|
|
1994-06-08 15:41:58 +04:00
|
|
|
int
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
lfs_rename(void *v)
|
1996-02-10 01:28:45 +03:00
|
|
|
{
|
1999-03-10 03:20:00 +03:00
|
|
|
struct vop_rename_args /* {
|
1994-06-08 15:41:58 +04:00
|
|
|
struct vnode *a_fdvp;
|
|
|
|
struct vnode *a_fvp;
|
|
|
|
struct componentname *a_fcnp;
|
|
|
|
struct vnode *a_tdvp;
|
|
|
|
struct vnode *a_tvp;
|
|
|
|
struct componentname *a_tcnp;
|
1996-02-10 01:28:45 +03:00
|
|
|
} */ *ap = v;
|
1999-11-05 23:14:56 +03:00
|
|
|
struct vnode *tvp, *fvp, *tdvp, *fdvp;
|
2003-02-03 03:32:35 +03:00
|
|
|
struct componentname *tcnp, *fcnp;
|
1999-11-05 23:14:56 +03:00
|
|
|
int error;
|
1999-11-01 21:29:33 +03:00
|
|
|
struct lfs *fs;
|
|
|
|
|
|
|
|
fs = VTOI(ap->a_fdvp)->i_lfs;
|
1999-11-05 23:14:56 +03:00
|
|
|
tvp = ap->a_tvp;
|
|
|
|
tdvp = ap->a_tdvp;
|
2003-02-03 03:32:35 +03:00
|
|
|
tcnp = ap->a_tcnp;
|
1999-11-05 23:14:56 +03:00
|
|
|
fvp = ap->a_fvp;
|
|
|
|
fdvp = ap->a_fdvp;
|
2003-02-03 03:32:35 +03:00
|
|
|
fcnp = ap->a_fcnp;
|
1999-11-05 23:14:56 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Check for cross-device rename.
|
|
|
|
* If it is, we don't want to set dirops, just error out.
|
|
|
|
* (In particular note that MARK_VNODE(tdvp) will DTWT on
|
|
|
|
* a cross-device rename.)
|
|
|
|
*
|
|
|
|
* Copied from ufs_rename.
|
|
|
|
*/
|
|
|
|
if ((fvp->v_mount != tdvp->v_mount) ||
|
|
|
|
(tvp && (fvp->v_mount != tvp->v_mount))) {
|
|
|
|
error = EXDEV;
|
1999-12-15 10:19:07 +03:00
|
|
|
goto errout;
|
1999-11-05 23:14:56 +03:00
|
|
|
}
|
2003-02-03 03:32:35 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Check to make sure we're not renaming a vnode onto itself
|
|
|
|
* (deleting a hard link by renaming one name onto another);
|
|
|
|
* if we are we can't recursively call VOP_REMOVE since that
|
|
|
|
* would leave us with an unaccounted-for number of live dirops.
|
|
|
|
*
|
|
|
|
* Inline the relevant section of ufs_rename here, *before*
|
|
|
|
* calling SET_DIROP2.
|
|
|
|
*/
|
|
|
|
if (tvp && ((VTOI(tvp)->i_ffs_flags & (IMMUTABLE | APPEND)) ||
|
|
|
|
(VTOI(tdvp)->i_ffs_flags & APPEND))) {
|
|
|
|
error = EPERM;
|
|
|
|
goto errout;
|
|
|
|
}
|
|
|
|
if (fvp == tvp) {
|
|
|
|
if (fvp->v_type == VDIR) {
|
|
|
|
error = EINVAL;
|
|
|
|
goto errout;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Release destination completely. */
|
|
|
|
VOP_ABORTOP(tdvp, tcnp);
|
|
|
|
vput(tdvp);
|
|
|
|
vput(tvp);
|
|
|
|
|
|
|
|
/* Delete source. */
|
|
|
|
vrele(fvp);
|
|
|
|
fcnp->cn_flags &= ~(MODMASK | SAVESTART);
|
|
|
|
fcnp->cn_flags |= LOCKPARENT | LOCKLEAF;
|
|
|
|
fcnp->cn_nameiop = DELETE;
|
|
|
|
if ((error = relookup(fdvp, &fvp, fcnp))){
|
|
|
|
/* relookup blew away fdvp */
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
return (VOP_REMOVE(fdvp, fvp, fcnp));
|
|
|
|
}
|
|
|
|
|
2002-12-28 17:39:08 +03:00
|
|
|
if ((error = SET_DIROP2(tdvp, tvp)) != 0)
|
1999-12-15 10:19:07 +03:00
|
|
|
goto errout;
|
1999-11-05 23:14:56 +03:00
|
|
|
MARK_VNODE(fdvp);
|
|
|
|
MARK_VNODE(tdvp);
|
2002-12-28 17:39:08 +03:00
|
|
|
MARK_VNODE(fvp);
|
|
|
|
if (tvp) {
|
|
|
|
MARK_VNODE(tvp);
|
|
|
|
}
|
2003-02-03 03:32:35 +03:00
|
|
|
|
1999-11-05 23:14:56 +03:00
|
|
|
error = ufs_rename(ap);
|
2000-05-27 04:19:52 +04:00
|
|
|
UNMARK_VNODE(fdvp);
|
|
|
|
UNMARK_VNODE(tdvp);
|
2002-12-28 17:39:08 +03:00
|
|
|
UNMARK_VNODE(fvp);
|
|
|
|
if (tvp) {
|
|
|
|
UNMARK_VNODE(tvp);
|
|
|
|
}
|
|
|
|
SET_ENDOP2(fs, tdvp, tvp, "rename");
|
1999-11-05 23:14:56 +03:00
|
|
|
return (error);
|
1999-12-15 10:19:07 +03:00
|
|
|
|
|
|
|
errout:
|
|
|
|
VOP_ABORTOP(tdvp, ap->a_tcnp); /* XXX, why not in NFS? */
|
|
|
|
if (tdvp == tvp)
|
|
|
|
vrele(tdvp);
|
|
|
|
else
|
|
|
|
vput(tdvp);
|
|
|
|
if (tvp)
|
|
|
|
vput(tvp);
|
|
|
|
VOP_ABORTOP(fdvp, ap->a_fcnp); /* XXX, why not in NFS? */
|
|
|
|
vrele(fdvp);
|
|
|
|
vrele(fvp);
|
|
|
|
return (error);
|
1994-06-08 15:41:58 +04:00
|
|
|
}
|
1999-03-10 03:20:00 +03:00
|
|
|
|
1994-06-08 15:41:58 +04:00
|
|
|
/* XXX hack to avoid calling ITIMES in getattr */
|
|
|
|
int
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
lfs_getattr(void *v)
|
1996-02-10 01:28:45 +03:00
|
|
|
{
|
1994-06-08 15:41:58 +04:00
|
|
|
struct vop_getattr_args /* {
|
|
|
|
struct vnode *a_vp;
|
|
|
|
struct vattr *a_vap;
|
|
|
|
struct ucred *a_cred;
|
|
|
|
struct proc *a_p;
|
1996-02-10 01:28:45 +03:00
|
|
|
} */ *ap = v;
|
2000-03-30 16:41:09 +04:00
|
|
|
struct vnode *vp = ap->a_vp;
|
|
|
|
struct inode *ip = VTOI(vp);
|
|
|
|
struct vattr *vap = ap->a_vap;
|
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 = ip->i_lfs;
|
1994-06-08 15:41:58 +04:00
|
|
|
/*
|
|
|
|
* Copy from inode table
|
|
|
|
*/
|
|
|
|
vap->va_fsid = ip->i_dev;
|
|
|
|
vap->va_fileid = ip->i_number;
|
1997-06-11 14:09:37 +04:00
|
|
|
vap->va_mode = ip->i_ffs_mode & ~IFMT;
|
|
|
|
vap->va_nlink = ip->i_ffs_nlink;
|
|
|
|
vap->va_uid = ip->i_ffs_uid;
|
|
|
|
vap->va_gid = ip->i_ffs_gid;
|
|
|
|
vap->va_rdev = (dev_t)ip->i_ffs_rdev;
|
a whole bunch of changes to improve performance and robustness under load:
- remove special treatment of pager_map mappings in pmaps. this is
required now, since I've removed the globals that expose the address range.
pager_map now uses pmap_kenter_pa() instead of pmap_enter(), so there's
no longer any need to special-case it.
- eliminate struct uvm_vnode by moving its fields into struct vnode.
- rewrite the pageout path. the pager is now responsible for handling the
high-level requests instead of only getting control after a bunch of work
has already been done on its behalf. this will allow us to UBCify LFS,
which needs tighter control over its pages than other filesystems do.
writing a page to disk no longer requires making it read-only, which
allows us to write wired pages without causing all kinds of havoc.
- use a new PG_PAGEOUT flag to indicate that a page should be freed
on behalf of the pagedaemon when it's unlocked. this flag is very similar
to PG_RELEASED, but unlike PG_RELEASED, PG_PAGEOUT can be cleared if the
pageout fails due to eg. an indirect-block buffer being locked.
this allows us to remove the "version" field from struct vm_page,
and together with shrinking "loan_count" from 32 bits to 16,
struct vm_page is now 4 bytes smaller.
- no longer use PG_RELEASED for swap-backed pages. if the page is busy
because it's being paged out, we can't release the swap slot to be
reallocated until that write is complete, but unlike with vnodes we
don't keep a count of in-progress writes so there's no good way to
know when the write is done. instead, when we need to free a busy
swap-backed page, just sleep until we can get it busy ourselves.
- implement a fast-path for extending writes which allows us to avoid
zeroing new pages. this substantially reduces cpu usage.
- encapsulate the data used by the genfs code in a struct genfs_node,
which must be the first element of the filesystem-specific vnode data
for filesystems which use genfs_{get,put}pages().
- eliminate many of the UVM pagerops, since they aren't needed anymore
now that the pager "put" operation is a higher-level operation.
- enhance the genfs code to allow NFS to use the genfs_{get,put}pages
instead of a modified copy.
- clean up struct vnode by removing all the fields that used to be used by
the vfs_cluster.c code (which we don't use anymore with UBC).
- remove kmem_object and mb_object since they were useless.
instead of allocating pages to these objects, we now just allocate
pages with no object. such pages are mapped in the kernel until they
are freed, so we can use the mapping to find the page to free it.
this allows us to remove splvm() protection in several places.
The sum of all these changes improves write throughput on my
decstation 5000/200 to within 1% of the rate of NetBSD 1.5
and reduces the elapsed time for "make release" of a NetBSD 1.5
source tree on my 128MB pc to 10% less than a 1.5 kernel took.
2001-09-16 00:36:31 +04:00
|
|
|
vap->va_size = vp->v_size;
|
1997-06-11 14:09:37 +04:00
|
|
|
vap->va_atime.tv_sec = ip->i_ffs_atime;
|
|
|
|
vap->va_atime.tv_nsec = ip->i_ffs_atimensec;
|
|
|
|
vap->va_mtime.tv_sec = ip->i_ffs_mtime;
|
|
|
|
vap->va_mtime.tv_nsec = ip->i_ffs_mtimensec;
|
|
|
|
vap->va_ctime.tv_sec = ip->i_ffs_ctime;
|
|
|
|
vap->va_ctime.tv_nsec = ip->i_ffs_ctimensec;
|
|
|
|
vap->va_flags = ip->i_ffs_flags;
|
|
|
|
vap->va_gen = ip->i_ffs_gen;
|
1994-06-08 15:41:58 +04:00
|
|
|
/* this doesn't belong here */
|
|
|
|
if (vp->v_type == VBLK)
|
|
|
|
vap->va_blocksize = BLKDEV_IOSIZE;
|
|
|
|
else if (vp->v_type == VCHR)
|
|
|
|
vap->va_blocksize = MAXBSIZE;
|
|
|
|
else
|
|
|
|
vap->va_blocksize = vp->v_mount->mnt_stat.f_iosize;
|
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
|
|
|
vap->va_bytes = fsbtob(fs, (u_quad_t)ip->i_lfs_effnblks);
|
1994-06-08 15:41:58 +04:00
|
|
|
vap->va_type = vp->v_type;
|
|
|
|
vap->va_filerev = ip->i_modrev;
|
|
|
|
return (0);
|
|
|
|
}
|
1999-03-10 03:20:00 +03:00
|
|
|
|
2002-02-11 05:47:29 +03:00
|
|
|
/*
|
|
|
|
* Check to make sure the inode blocks won't choke the buffer
|
|
|
|
* cache, then call ufs_setattr as usual.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
lfs_setattr(void *v)
|
|
|
|
{
|
|
|
|
struct vop_getattr_args /* {
|
|
|
|
struct vnode *a_vp;
|
|
|
|
struct vattr *a_vap;
|
|
|
|
struct ucred *a_cred;
|
|
|
|
struct proc *a_p;
|
|
|
|
} */ *ap = v;
|
|
|
|
struct vnode *vp = ap->a_vp;
|
|
|
|
|
|
|
|
lfs_check(vp, LFS_UNUSED_LBN, 0);
|
|
|
|
return ufs_setattr(v);
|
|
|
|
}
|
|
|
|
|
1994-06-08 15:41:58 +04:00
|
|
|
/*
|
|
|
|
* Close called
|
|
|
|
*
|
|
|
|
* XXX -- we were using ufs_close, but since it updates the
|
|
|
|
* times on the inode, we might need to bump the uinodes
|
|
|
|
* count.
|
|
|
|
*/
|
|
|
|
/* ARGSUSED */
|
|
|
|
int
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
lfs_close(void *v)
|
1996-02-10 01:28:45 +03:00
|
|
|
{
|
1994-06-08 15:41:58 +04:00
|
|
|
struct vop_close_args /* {
|
|
|
|
struct vnode *a_vp;
|
|
|
|
int a_fflag;
|
|
|
|
struct ucred *a_cred;
|
|
|
|
struct proc *a_p;
|
1996-02-10 01:28:45 +03:00
|
|
|
} */ *ap = v;
|
2000-03-30 16:41:09 +04:00
|
|
|
struct vnode *vp = ap->a_vp;
|
|
|
|
struct inode *ip = VTOI(vp);
|
1996-09-02 03:47:48 +04:00
|
|
|
struct timespec ts;
|
1994-06-08 15:41:58 +04:00
|
|
|
|
1998-03-01 05:20:01 +03:00
|
|
|
if (vp->v_usecount > 1) {
|
1996-09-02 03:47:48 +04:00
|
|
|
TIMEVAL_TO_TIMESPEC(&time, &ts);
|
1999-03-10 03:20:00 +03:00
|
|
|
LFS_ITIMES(ip, &ts, &ts, &ts);
|
1994-06-08 15:41:58 +04:00
|
|
|
}
|
|
|
|
return (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
|
|
|
/*
|
|
|
|
* Close wrapper for special devices.
|
|
|
|
*
|
|
|
|
* Update the times on the inode then do device close.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
lfsspec_close(void *v)
|
|
|
|
{
|
|
|
|
struct vop_close_args /* {
|
|
|
|
struct vnode *a_vp;
|
|
|
|
int a_fflag;
|
|
|
|
struct ucred *a_cred;
|
|
|
|
struct proc *a_p;
|
|
|
|
} */ *ap = v;
|
|
|
|
struct vnode *vp;
|
|
|
|
struct inode *ip;
|
|
|
|
struct timespec ts;
|
|
|
|
|
|
|
|
vp = ap->a_vp;
|
|
|
|
ip = VTOI(vp);
|
|
|
|
if (vp->v_usecount > 1) {
|
|
|
|
TIMEVAL_TO_TIMESPEC(&time, &ts);
|
|
|
|
LFS_ITIMES(ip, &ts, &ts, &ts);
|
|
|
|
}
|
|
|
|
return (VOCALL (spec_vnodeop_p, VOFFSET(vop_close), ap));
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Close wrapper for fifo's.
|
|
|
|
*
|
|
|
|
* Update the times on the inode then do device close.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
lfsfifo_close(void *v)
|
|
|
|
{
|
|
|
|
struct vop_close_args /* {
|
|
|
|
struct vnode *a_vp;
|
|
|
|
int a_fflag;
|
|
|
|
struct ucred *a_cred;
|
|
|
|
struct proc *a_p;
|
|
|
|
} */ *ap = v;
|
|
|
|
struct vnode *vp;
|
|
|
|
struct inode *ip;
|
|
|
|
struct timespec ts;
|
|
|
|
|
|
|
|
vp = ap->a_vp;
|
|
|
|
ip = VTOI(vp);
|
|
|
|
if (ap->a_vp->v_usecount > 1) {
|
|
|
|
TIMEVAL_TO_TIMESPEC(&time, &ts);
|
|
|
|
LFS_ITIMES(ip, &ts, &ts, &ts);
|
|
|
|
}
|
|
|
|
return (VOCALL (fifo_vnodeop_p, VOFFSET(vop_close), ap));
|
|
|
|
}
|
|
|
|
|
1994-06-08 15:41:58 +04:00
|
|
|
/*
|
1998-03-01 05:20:01 +03:00
|
|
|
* Reclaim an inode so that it can be used for other purposes.
|
1994-06-08 15:41:58 +04:00
|
|
|
*/
|
|
|
|
int lfs_no_inactive = 0;
|
|
|
|
|
|
|
|
int
|
Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:
- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).
- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.
- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.
- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).
- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.
Other changes of note include:
- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.
- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
2001-07-14 00:30:18 +04:00
|
|
|
lfs_reclaim(void *v)
|
1996-02-10 01:28:45 +03:00
|
|
|
{
|
1994-06-08 15:41:58 +04:00
|
|
|
struct vop_reclaim_args /* {
|
|
|
|
struct vnode *a_vp;
|
1998-03-01 05:20:01 +03:00
|
|
|
struct proc *a_p;
|
1996-02-10 01:28:45 +03:00
|
|
|
} */ *ap = v;
|
1998-03-01 05:20:01 +03:00
|
|
|
struct vnode *vp = ap->a_vp;
|
Add code to UBCify LFS. This is still behind "#ifdef LFS_UBC" for now
(there are still some details to work out) but expect that to go
away soon. To support these basic changes (creation of lfs_putpages,
lfs_gop_write, mods to lfs_balloc) several other changes were made, to
wit:
* Create a writer daemon kernel thread whose purpose is to handle page
writes for the pagedaemon, but which also takes over some of the
functions of lfs_check(). This thread is started the first time an
LFS is mounted.
* Add a "flags" parameter to GOP_SIZE. Current values are
GOP_SIZE_READ, meaning that the call should return the size of the
in-core version of the file, and GOP_SIZE_WRITE, meaning that it
should return the on-disk size. One of GOP_SIZE_READ or
GOP_SIZE_WRITE must be specified.
* Instead of using malloc(...M_WAITOK) for everything, reserve enough
resources to get by and use malloc(...M_NOWAIT), using the reserves if
necessary. Use the pool subsystem for structures small enough that
this is feasible. This also obsoletes LFS_THROTTLE.
And a few that are not strictly necessary:
* Moves the LFS inode extensions off onto a separately allocated
structure; getting closer to LFS as an LKM. "Welcome to 1.6O."
* Unified GOP_ALLOC between FFS and LFS.
* Update LFS copyright headers to correct values.
* Actually cast to unsigned in lfs_shellsort, like the comment says.
* Keep track of which segments were empty before the previous
checkpoint; any segments that pass two checkpoints both dirty and
empty can be summarily cleaned. Do this. Right now lfs_segclean
still works, but this should be turned into an effectless
compatibility syscall.
2003-02-18 02:48:08 +03:00
|
|
|
struct inode *ip = VTOI(vp);
|
1994-06-08 15:41:58 +04:00
|
|
|
int 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
|
|
|
KASSERT(ip->i_ffs_nlink == ip->i_ffs_effnlink);
|
2003-01-08 18:40:54 +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
|
|
|
LFS_CLR_UINO(ip, IN_ALLMOD);
|
1998-03-01 05:20:01 +03:00
|
|
|
if ((error = ufs_reclaim(vp, ap->a_p)))
|
1994-06-08 15:41:58 +04: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
|
|
|
pool_put(&lfs_inoext_pool, ip->inode_ext.lfs);
|
|
|
|
ip->inode_ext.lfs = NULL;
|
1998-09-01 07:26:05 +04:00
|
|
|
pool_put(&lfs_inode_pool, vp->v_data);
|
1994-06-08 15:41:58 +04:00
|
|
|
vp->v_data = NULL;
|
|
|
|
return (0);
|
|
|
|
}
|
2001-12-18 10:51:16 +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
|
|
|
#ifndef LFS_UBC
|
2001-12-18 10:51:16 +03:00
|
|
|
int
|
|
|
|
lfs_getpages(void *v)
|
|
|
|
{
|
|
|
|
struct vop_getpages_args /* {
|
|
|
|
struct vnode *a_vp;
|
|
|
|
voff_t a_offset;
|
|
|
|
struct vm_page **a_m;
|
|
|
|
int *a_count;
|
|
|
|
int a_centeridx;
|
|
|
|
vm_prot_t a_access_type;
|
|
|
|
int a_advice;
|
|
|
|
int a_flags;
|
|
|
|
} */ *ap = v;
|
|
|
|
|
|
|
|
if ((ap->a_access_type & VM_PROT_WRITE) != 0) {
|
|
|
|
LFS_SET_UINO(VTOI(ap->a_vp), IN_MODIFIED);
|
|
|
|
}
|
|
|
|
return genfs_compat_getpages(v);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
lfs_putpages(void *v)
|
|
|
|
{
|
|
|
|
int error;
|
|
|
|
|
|
|
|
error = genfs_putpages(v);
|
|
|
|
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
|
|
|
|
|
|
|
#else /* LFS_UBC */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Make sure that for all pages in every block in the given range,
|
|
|
|
* either all are dirty or all are clean. If any of the pages
|
|
|
|
* we've seen so far are dirty, put the vnode on the paging chain,
|
|
|
|
* and mark it IN_PAGING.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
check_dirty(struct lfs *fs, struct vnode *vp,
|
|
|
|
off_t startoffset, off_t endoffset, off_t blkeof,
|
|
|
|
int flags)
|
|
|
|
{
|
|
|
|
int by_list;
|
|
|
|
struct vm_page *curpg, *pgs[MAXBSIZE / PAGE_SIZE], *pg;
|
|
|
|
struct lwp *l = curlwp ? curlwp : &lwp0;
|
|
|
|
off_t soff;
|
|
|
|
voff_t off;
|
|
|
|
int i, dirty, tdirty, nonexistent, any_dirty;
|
|
|
|
int pages_per_block = fs->lfs_bsize >> PAGE_SHIFT;
|
|
|
|
|
|
|
|
top:
|
|
|
|
by_list = (vp->v_uobj.uo_npages <=
|
|
|
|
((endoffset - startoffset) >> PAGE_SHIFT) *
|
|
|
|
UVM_PAGE_HASH_PENALTY);
|
|
|
|
any_dirty = 0;
|
|
|
|
|
|
|
|
if (by_list) {
|
|
|
|
curpg = TAILQ_FIRST(&vp->v_uobj.memq);
|
|
|
|
PHOLD(l);
|
|
|
|
} else {
|
|
|
|
soff = startoffset;
|
|
|
|
}
|
|
|
|
while (by_list || soff < MIN(blkeof, endoffset)) {
|
|
|
|
if (by_list) {
|
|
|
|
if (pages_per_block > 1) {
|
|
|
|
while (curpg && (curpg->offset & fs->lfs_bmask))
|
|
|
|
curpg = TAILQ_NEXT(curpg, listq);
|
|
|
|
}
|
|
|
|
if (curpg == NULL)
|
|
|
|
break;
|
|
|
|
soff = curpg->offset;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Mark all pages in extended range busy; find out if any
|
|
|
|
* of them are dirty.
|
|
|
|
*/
|
|
|
|
nonexistent = dirty = 0;
|
|
|
|
for (i = 0; i == 0 || i < pages_per_block; i++) {
|
|
|
|
if (by_list && pages_per_block <= 1) {
|
|
|
|
pgs[i] = pg = curpg;
|
|
|
|
} else {
|
|
|
|
off = soff + (i << PAGE_SHIFT);
|
|
|
|
pgs[i] = pg = uvm_pagelookup(&vp->v_uobj, off);
|
|
|
|
if (pg == NULL) {
|
|
|
|
++nonexistent;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
KASSERT(pg != NULL);
|
|
|
|
while (pg->flags & PG_BUSY) {
|
|
|
|
pg->flags |= PG_WANTED;
|
|
|
|
UVM_UNLOCK_AND_WAIT(pg, &vp->v_interlock, 0,
|
|
|
|
"lfsput", 0);
|
|
|
|
simple_lock(&vp->v_interlock);
|
|
|
|
if (by_list)
|
|
|
|
goto top;
|
|
|
|
}
|
|
|
|
pg->flags |= PG_BUSY;
|
|
|
|
UVM_PAGE_OWN(pg, "lfs_putpages");
|
|
|
|
|
|
|
|
pmap_page_protect(pg, VM_PROT_NONE);
|
|
|
|
tdirty = (pmap_clear_modify(pg) ||
|
|
|
|
(pg->flags & PG_CLEAN) == 0);
|
|
|
|
dirty += tdirty;
|
|
|
|
}
|
|
|
|
if (pages_per_block > 0 && nonexistent >= pages_per_block) {
|
|
|
|
if (by_list) {
|
|
|
|
curpg = TAILQ_NEXT(curpg, listq);
|
|
|
|
} else {
|
|
|
|
soff += fs->lfs_bsize;
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
any_dirty += dirty;
|
|
|
|
KASSERT(nonexistent == 0);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If any are dirty make all dirty; unbusy them,
|
|
|
|
* but if we were asked to clean, take them off
|
|
|
|
* of their queue so the pagedaemon doesn't bother
|
|
|
|
* us about them while they're on their way to disk.
|
|
|
|
*
|
|
|
|
* (XXXUBC the page is now on *no* page queue.)
|
|
|
|
*/
|
|
|
|
for (i = 0; i == 0 || i < pages_per_block; i++) {
|
|
|
|
pg = pgs[i];
|
|
|
|
KASSERT(!((pg->flags & PG_CLEAN) && (pg->flags & PG_DELWRI)));
|
|
|
|
if (dirty) {
|
|
|
|
pg->flags &= ~PG_CLEAN;
|
|
|
|
if (flags & PGO_FREE) {
|
|
|
|
/* XXXUBC need better way to update */
|
|
|
|
lfs_subsys_pages += MIN(1, pages_per_block);
|
|
|
|
uvm_lock_pageq();
|
|
|
|
UVM_PAGE_OWN(pg, NULL);
|
|
|
|
uvm_pagedequeue(pg);
|
|
|
|
/* Suspended write flag */
|
|
|
|
pg->flags |= PG_DELWRI;
|
|
|
|
uvm_unlock_pageq();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
UVM_PAGE_OWN(pg, NULL);
|
|
|
|
}
|
|
|
|
if (pg->flags & PG_WANTED)
|
|
|
|
wakeup(pg);
|
|
|
|
pg->flags &= ~(PG_WANTED|PG_BUSY);
|
|
|
|
/* UVM_PAGE_OWN(pg, NULL); */
|
|
|
|
}
|
|
|
|
|
|
|
|
if (by_list) {
|
|
|
|
curpg = TAILQ_NEXT(curpg, listq);
|
|
|
|
} else {
|
|
|
|
soff += MAX(PAGE_SIZE, fs->lfs_bsize);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (by_list) {
|
|
|
|
PRELE(l);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If any pages were dirty, mark this inode as "pageout requested",
|
|
|
|
* and put it on the paging queue.
|
|
|
|
* XXXUBC locking (check locking on dchainhd too)
|
|
|
|
*/
|
|
|
|
#ifdef notyet
|
|
|
|
if (any_dirty) {
|
|
|
|
if (!(ip->i_flags & IN_PAGING)) {
|
|
|
|
ip->i_flags |= IN_PAGING;
|
|
|
|
TAILQ_INSERT_TAIL(&fs->lfs_pchainhd, ip, i_lfs_pchain);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
return any_dirty;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* lfs_putpages functions like genfs_putpages except that
|
|
|
|
*
|
|
|
|
* (1) It needs to bounds-check the incoming requests to ensure that
|
|
|
|
* they are block-aligned; if they are not, expand the range and
|
|
|
|
* do the right thing in case, e.g., the requested range is clean
|
|
|
|
* but the expanded range is dirty.
|
|
|
|
* (2) It needs to explicitly send blocks to be written when it is done.
|
|
|
|
* VOP_PUTPAGES is not ever called with the seglock held, so
|
|
|
|
* we simply take the seglock and let lfs_segunlock wait for us.
|
|
|
|
* XXX Actually we can be called with the seglock held, if we have
|
|
|
|
* XXX to flush a vnode while lfs_markv is in operation. As of this
|
|
|
|
* XXX writing we panic in this case.
|
|
|
|
*
|
|
|
|
* Assumptions:
|
|
|
|
*
|
|
|
|
* (1) The caller does not hold any pages in this vnode busy. If it does,
|
|
|
|
* there is a danger that when we expand the page range and busy the
|
|
|
|
* pages we will deadlock.
|
|
|
|
* (2) We are called with vp->v_interlock held; we must return with it
|
|
|
|
* released.
|
|
|
|
* (3) We don't absolutely have to free pages right away, provided that
|
|
|
|
* the request does not have PGO_SYNCIO. When the pagedaemon gives
|
|
|
|
* us a request with PGO_FREE, we take the pages out of the paging
|
|
|
|
* queue and wake up the writer, which will handle freeing them for us.
|
|
|
|
*
|
|
|
|
* We ensure that for any filesystem block, all pages for that
|
|
|
|
* block are either resident or not, even if those pages are higher
|
|
|
|
* than EOF; that means that we will be getting requests to free
|
|
|
|
* "unused" pages above EOF all the time, and should ignore them.
|
|
|
|
*/
|
|
|
|
|
|
|
|
int
|
|
|
|
lfs_putpages(void *v)
|
|
|
|
{
|
|
|
|
int error;
|
|
|
|
struct vop_putpages_args /* {
|
|
|
|
struct vnode *a_vp;
|
|
|
|
voff_t a_offlo;
|
|
|
|
voff_t a_offhi;
|
|
|
|
int a_flags;
|
|
|
|
} */ *ap = v;
|
|
|
|
struct vnode *vp;
|
|
|
|
struct inode *ip;
|
|
|
|
struct lfs *fs;
|
|
|
|
struct segment *sp;
|
|
|
|
off_t origoffset, startoffset, endoffset, origendoffset, blkeof;
|
|
|
|
off_t max_endoffset;
|
|
|
|
int pages_per_block;
|
|
|
|
int s, sync, dirty, pagedaemon;
|
|
|
|
UVMHIST_FUNC("lfs_putpages"); UVMHIST_CALLED(ubchist);
|
|
|
|
|
|
|
|
vp = ap->a_vp;
|
|
|
|
ip = VTOI(vp);
|
|
|
|
fs = ip->i_lfs;
|
|
|
|
sync = (ap->a_flags & PGO_SYNCIO);
|
|
|
|
pagedaemon = (curproc == uvm.pagedaemon_proc);
|
|
|
|
|
|
|
|
/* Putpages does nothing for metadata. */
|
|
|
|
if (vp == fs->lfs_ivnode || vp->v_type != VREG) {
|
|
|
|
simple_unlock(&vp->v_interlock);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If there are no pages, don't do anything.
|
|
|
|
*/
|
|
|
|
if (vp->v_uobj.uo_npages == 0) {
|
|
|
|
s = splbio();
|
|
|
|
if (LIST_FIRST(&vp->v_dirtyblkhd) == NULL &&
|
|
|
|
(vp->v_flag & VONWORKLST)) {
|
|
|
|
vp->v_flag &= ~VONWORKLST;
|
|
|
|
LIST_REMOVE(vp, v_synclist);
|
|
|
|
}
|
|
|
|
splx(s);
|
|
|
|
simple_unlock(&vp->v_interlock);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
blkeof = blkroundup(fs, ip->i_ffs_size);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Ignore requests to free pages past EOF but in the same block
|
|
|
|
* as EOF, unless the request is synchronous. (XXX why sync?)
|
|
|
|
* XXXUBC Make these pages look "active" so the pagedaemon won't
|
|
|
|
* XXXUBC bother us with them again.
|
|
|
|
*/
|
|
|
|
if (!sync && ap->a_offlo >= ip->i_ffs_size && ap->a_offlo < blkeof) {
|
|
|
|
origoffset = ap->a_offlo;
|
|
|
|
ap->a_offlo = blkeof;
|
|
|
|
if (ap->a_offhi > 0 && ap->a_offhi <= ap->a_offlo) {
|
|
|
|
simple_unlock(&vp->v_interlock);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Extend page range to start and end at block boundaries.
|
|
|
|
* (For the purposes of VOP_PUTPAGES, fragments don't exist.)
|
|
|
|
*/
|
|
|
|
pages_per_block = fs->lfs_bsize >> PAGE_SHIFT;
|
|
|
|
origoffset = ap->a_offlo;
|
|
|
|
origendoffset = ap->a_offhi;
|
|
|
|
startoffset = origoffset & ~(fs->lfs_bmask);
|
|
|
|
max_endoffset = (trunc_page(LLONG_MAX) >> fs->lfs_bshift)
|
|
|
|
<< fs->lfs_bshift;
|
|
|
|
|
|
|
|
if (origendoffset == 0 || ap->a_flags & PGO_ALLPAGES) {
|
|
|
|
endoffset = max_endoffset;
|
|
|
|
origendoffset = endoffset;
|
|
|
|
} else {
|
|
|
|
origendoffset = round_page(ap->a_offhi);
|
|
|
|
endoffset = round_page(blkroundup(fs, origendoffset));
|
|
|
|
}
|
|
|
|
|
|
|
|
KASSERT(startoffset > 0 || endoffset >= startoffset);
|
|
|
|
if (startoffset == endoffset) {
|
|
|
|
/* Nothing to do, why were we called? */
|
|
|
|
simple_unlock(&vp->v_interlock);
|
|
|
|
#ifdef DEBUG
|
|
|
|
printf("lfs_putpages: startoffset = endoffset = %" PRId64 "\n",
|
|
|
|
startoffset);
|
|
|
|
#endif
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
ap->a_offlo = startoffset;
|
|
|
|
ap->a_offhi = endoffset;
|
|
|
|
|
|
|
|
if (!(ap->a_flags & PGO_CLEANIT))
|
|
|
|
return genfs_putpages(v);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Make sure that all pages in any given block are dirty, or
|
|
|
|
* none of them are. Find out if any of the pages we've been
|
|
|
|
* asked about are dirty. If none are dirty, send them on
|
|
|
|
* through genfs_putpages(), albeit with adjusted offsets.
|
|
|
|
* XXXUBC I am assuming here that they can't be dirtied in
|
|
|
|
* XXXUBC the meantime, but I bet that's wrong.
|
|
|
|
*/
|
|
|
|
dirty = check_dirty(fs, vp, startoffset, endoffset, blkeof, ap->a_flags);
|
|
|
|
if (!dirty)
|
|
|
|
return genfs_putpages(v);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Dirty and asked to clean.
|
|
|
|
*
|
|
|
|
* Pagedaemon can't actually write LFS pages; wake up
|
|
|
|
* the writer to take care of that. The writer will
|
|
|
|
* notice the pager inode queue and act on that.
|
|
|
|
*/
|
|
|
|
if (pagedaemon) {
|
|
|
|
++fs->lfs_pdflush;
|
|
|
|
wakeup(&lfs_writer_daemon);
|
|
|
|
return EWOULDBLOCK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If this is a file created in a recent dirop, we can't flush its
|
|
|
|
* inode until the dirop is complete. Drain dirops, then flush the
|
|
|
|
* filesystem (taking care of any other pending dirops while we're
|
|
|
|
* at it).
|
|
|
|
*/
|
|
|
|
if ((ap->a_flags & (PGO_CLEANIT|PGO_LOCKED)) == PGO_CLEANIT &&
|
|
|
|
(vp->v_flag & VDIROP)) {
|
|
|
|
int locked;
|
|
|
|
|
|
|
|
/* printf("putpages to clean VDIROP, flushing\n"); */
|
|
|
|
while (fs->lfs_dirops > 0) {
|
|
|
|
++fs->lfs_diropwait;
|
|
|
|
tsleep(&fs->lfs_writer, PRIBIO+1, "ppdirop", 0);
|
|
|
|
--fs->lfs_diropwait;
|
|
|
|
}
|
|
|
|
++fs->lfs_writer;
|
|
|
|
locked = VOP_ISLOCKED(vp) && /* XXX */
|
|
|
|
vp->v_lock.lk_lockholder == curproc->p_pid;
|
|
|
|
if (locked)
|
|
|
|
VOP_UNLOCK(vp, 0);
|
|
|
|
simple_unlock(&vp->v_interlock);
|
|
|
|
|
|
|
|
lfs_flush_fs(fs, sync ? SEGM_SYNC : 0);
|
|
|
|
|
|
|
|
simple_lock(&vp->v_interlock);
|
|
|
|
if (locked)
|
|
|
|
VOP_LOCK(vp, LK_EXCLUSIVE);
|
|
|
|
if (--fs->lfs_writer == 0)
|
|
|
|
wakeup(&fs->lfs_dirops);
|
|
|
|
|
|
|
|
/* XXX the flush should have taken care of this one too! */
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This is it. We are going to write some pages. From here on
|
|
|
|
* down it's all just mechanics.
|
|
|
|
*
|
|
|
|
* If there are more than one page per block, we don't want to get
|
|
|
|
* caught locking them backwards; so set PGO_BUSYFAIL to avoid
|
|
|
|
* deadlocks. Also, don't let genfs_putpages wait;
|
|
|
|
* lfs_segunlock will wait for us, if need be.
|
|
|
|
*/
|
|
|
|
ap->a_flags &= ~PGO_SYNCIO;
|
|
|
|
if (pages_per_block > 1)
|
|
|
|
ap->a_flags |= PGO_BUSYFAIL;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If we've already got the seglock, flush the node and return.
|
|
|
|
* The FIP has already been set up for us by lfs_writefile,
|
|
|
|
* and FIP cleanup and lfs_updatemeta will also be done there,
|
|
|
|
* unless genfs_putpages returns EDEADLK; then we must flush
|
|
|
|
* what we have, and correct FIP and segment header accounting.
|
|
|
|
*/
|
|
|
|
if (ap->a_flags & PGO_LOCKED) {
|
|
|
|
sp = fs->lfs_sp;
|
|
|
|
sp->vp = vp;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* XXXUBC
|
|
|
|
* There is some danger here that we might run out of
|
|
|
|
* buffers if we flush too much at once. If the number
|
|
|
|
* of dirty buffers is too great, we should cut the range
|
|
|
|
* down and write in chunks.
|
|
|
|
*/
|
|
|
|
while ((error = genfs_putpages(v)) == EDEADLK) {
|
|
|
|
#ifdef DEBUG_LFS
|
|
|
|
printf("lfs_putpages: genfs_putpages returned EDEADLK"
|
|
|
|
" ino %d off %x (seg %d)\n",
|
|
|
|
ip->i_number, fs->lfs_offset,
|
|
|
|
dtosn(fs, fs->lfs_offset));
|
|
|
|
#endif
|
|
|
|
/* Write gathered pages */
|
|
|
|
lfs_updatemeta(sp);
|
|
|
|
(void) lfs_writeseg(fs, sp);
|
|
|
|
|
|
|
|
/* Reinitialize brand new FIP and add us to it */
|
|
|
|
sp->vp = vp;
|
|
|
|
sp->fip->fi_version = ip->i_ffs_gen;
|
|
|
|
sp->fip->fi_ino = ip->i_number;
|
|
|
|
/* Add us to the new segment summary. */
|
|
|
|
++((SEGSUM *)(sp->segsum))->ss_nfinfo;
|
|
|
|
sp->sum_bytes_left -=
|
|
|
|
sizeof(struct finfo) - sizeof(int32_t);
|
|
|
|
|
|
|
|
/* Give the write a chance to complete */
|
|
|
|
simple_unlock(&vp->v_interlock);
|
|
|
|
preempt(NULL);
|
|
|
|
simple_lock(&vp->v_interlock);
|
|
|
|
}
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Take the seglock, because we are going to be writing pages.
|
|
|
|
*/
|
|
|
|
if ((error = lfs_seglock(fs, SEGM_PROT | (sync ? SEGM_SYNC : 0))) != 0)
|
|
|
|
return error;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* VOP_PUTPAGES should not be called while holding the seglock.
|
|
|
|
* XXX fix lfs_markv, or do this properly.
|
|
|
|
*/
|
|
|
|
KASSERT(fs->lfs_seglock == 1);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We assume we're being called with sp->fip pointing at blank space.
|
|
|
|
* Account for a new FIP in the segment header, and set sp->vp.
|
|
|
|
* (This should duplicate the setup at the top of lfs_writefile().)
|
|
|
|
*/
|
|
|
|
sp = fs->lfs_sp;
|
|
|
|
if (sp->seg_bytes_left < fs->lfs_bsize ||
|
|
|
|
sp->sum_bytes_left < sizeof(struct finfo))
|
|
|
|
(void) lfs_writeseg(fs, fs->lfs_sp);
|
|
|
|
|
|
|
|
sp->sum_bytes_left -= sizeof(struct finfo) - sizeof(int32_t);
|
|
|
|
++((SEGSUM *)(sp->segsum))->ss_nfinfo;
|
|
|
|
sp->vp = vp;
|
|
|
|
|
|
|
|
if (vp->v_flag & VDIROP)
|
|
|
|
((SEGSUM *)(sp->segsum))->ss_flags |= (SS_DIROP|SS_CONT);
|
|
|
|
|
|
|
|
sp->fip->fi_nblocks = 0;
|
|
|
|
sp->fip->fi_ino = ip->i_number;
|
|
|
|
sp->fip->fi_version = ip->i_ffs_gen;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Loop through genfs_putpages until all pages are gathered.
|
|
|
|
*/
|
|
|
|
/*
|
|
|
|
* There is some danger here that we might run out of
|
|
|
|
* buffers if we flush too much at once. If the number
|
|
|
|
* of dirty buffers is too great, then, cut the range down
|
|
|
|
* and write in chunks.
|
|
|
|
*
|
|
|
|
* XXXUBC this assumes a uniform dirtying of the pages
|
|
|
|
* XXXUBC across the address space
|
|
|
|
* XXXXXX do this
|
|
|
|
*/
|
|
|
|
while ((error = genfs_putpages(v)) == EDEADLK) {
|
|
|
|
#ifdef DEBUG_LFS
|
|
|
|
printf("lfs_putpages: genfs_putpages returned EDEADLK [2]"
|
|
|
|
" ino %d off %x (seg %d)\n",
|
|
|
|
ip->i_number, fs->lfs_offset,
|
|
|
|
dtosn(fs, fs->lfs_offset));
|
|
|
|
#endif
|
|
|
|
/* Write gathered pages */
|
|
|
|
lfs_updatemeta(sp);
|
|
|
|
(void) lfs_writeseg(fs, sp);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Reinitialize brand new FIP and add us to it.
|
|
|
|
* (This should duplicate the fixup in lfs_gatherpages().)
|
|
|
|
*/
|
|
|
|
sp->vp = vp;
|
|
|
|
sp->fip->fi_version = ip->i_ffs_gen;
|
|
|
|
sp->fip->fi_ino = ip->i_number;
|
|
|
|
/* Add us to the new segment summary. */
|
|
|
|
++((SEGSUM *)(sp->segsum))->ss_nfinfo;
|
|
|
|
sp->sum_bytes_left -=
|
|
|
|
sizeof(struct finfo) - sizeof(int32_t);
|
|
|
|
|
|
|
|
/* Give the write a chance to complete */
|
|
|
|
simple_unlock(&vp->v_interlock);
|
|
|
|
preempt(NULL);
|
|
|
|
simple_lock(&vp->v_interlock);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Blocks are now gathered into a segment waiting to be written.
|
|
|
|
* All that's left to do is update metadata, and write them.
|
|
|
|
*/
|
|
|
|
lfs_updatemeta(fs->lfs_sp);
|
|
|
|
fs->lfs_sp->vp = NULL;
|
|
|
|
lfs_writeseg(fs, fs->lfs_sp);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Clean up FIP.
|
|
|
|
* (This should duplicate cleanup at the end of lfs_writefile().)
|
|
|
|
*/
|
|
|
|
if (sp->fip->fi_nblocks != 0) {
|
|
|
|
sp->fip = (FINFO*)((caddr_t)sp->fip + sizeof(struct finfo) +
|
|
|
|
sizeof(int32_t) * (sp->fip->fi_nblocks - 1));
|
|
|
|
sp->start_lbp = &sp->fip->fi_blocks[0];
|
|
|
|
} else {
|
|
|
|
sp->sum_bytes_left += sizeof(FINFO) - sizeof(int32_t);
|
|
|
|
--((SEGSUM *)(sp->segsum))->ss_nfinfo;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* XXX - with the malloc/copy writeseg, the pages are freed by now
|
|
|
|
* even if we don't wait (e.g. if we hold a nested lock). This
|
|
|
|
* will not be true if we stop using malloc/copy.
|
|
|
|
*/
|
|
|
|
KASSERT(fs->lfs_sp->seg_flags & SEGM_PROT);
|
|
|
|
lfs_segunlock(fs);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Wait for v_numoutput to drop to zero. The seglock should
|
|
|
|
* take care of this, but there is a slight possibility that
|
|
|
|
* aiodoned might not have got around to our buffers yet.
|
|
|
|
*/
|
|
|
|
if (sync) {
|
|
|
|
int s;
|
|
|
|
|
|
|
|
s = splbio();
|
|
|
|
simple_lock(&global_v_numoutput_slock);
|
|
|
|
while(vp->v_numoutput > 0) {
|
|
|
|
#ifdef DEBUG
|
|
|
|
printf("ino %d sleeping on num %d\n",
|
|
|
|
ip->i_number, vp->v_numoutput);
|
|
|
|
#endif
|
|
|
|
vp->v_flag |= VBWAIT;
|
|
|
|
simple_unlock(&global_v_numoutput_slock);
|
|
|
|
tsleep(&vp->v_numoutput, PRIBIO + 1, "lfs_vn", 0);
|
|
|
|
simple_lock(&global_v_numoutput_slock);
|
|
|
|
}
|
|
|
|
simple_unlock(&global_v_numoutput_slock);
|
|
|
|
splx(s);
|
|
|
|
}
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Find out whether the vnode has any blocks or pages waiting to be written.
|
|
|
|
* We used to just check LIST_EMPTY(&vp->v_dirtyblkhd), but there is not
|
|
|
|
* presently as simple a mechanism for the page cache.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
lfs_checkifempty(struct vnode *vp)
|
|
|
|
{
|
|
|
|
struct vm_page *pg;
|
|
|
|
struct buf *bp;
|
|
|
|
int r, s;
|
|
|
|
|
|
|
|
if (vp->v_type != VREG || VTOI(vp)->i_number == LFS_IFILE_INUM)
|
|
|
|
return LIST_EMPTY(&vp->v_dirtyblkhd);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* For vnodes with pages it is a little more complex.
|
|
|
|
* Pages that have been written (i.e. are "clean" for our purposes)
|
|
|
|
* might be in seemingly dirty buffers, so we have to troll
|
|
|
|
* looking for indirect block buffers as well as pages.
|
|
|
|
*/
|
|
|
|
simple_lock(&vp->v_interlock);
|
|
|
|
s = splbio();
|
|
|
|
for (bp = LIST_FIRST(&vp->v_dirtyblkhd); bp;
|
|
|
|
bp = LIST_NEXT(bp, b_vnbufs)) {
|
|
|
|
if (bp->b_lblkno < 0) {
|
|
|
|
splx(s);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
splx(s);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Run through the page list to find dirty pages.
|
|
|
|
* Right now I just walk the memq.
|
|
|
|
*/
|
|
|
|
pg = TAILQ_FIRST(&vp->v_uobj.memq);
|
|
|
|
r = 1;
|
|
|
|
while(pg) {
|
|
|
|
if ((pg->flags & PG_CLEAN) == 0 || pmap_is_modified(pg)) {
|
|
|
|
r = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
pg = TAILQ_NEXT(pg, listq);
|
|
|
|
}
|
|
|
|
#if 0
|
|
|
|
if (r != !(vp->v_flag & VONWORKLST)) {
|
|
|
|
printf("nope, VONWORKLST isn't good enough!\n");
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
simple_unlock(&vp->v_interlock);
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Return the last logical file offset that should be written for this file
|
|
|
|
* if we're doing a write that ends at "size". If writing, we need to know
|
|
|
|
* about sizes on disk, i.e. fragments if there are any; if reading, we need
|
|
|
|
* to know about entire blocks.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
lfs_gop_size(struct vnode *vp, off_t size, off_t *eobp, int flags)
|
|
|
|
{
|
|
|
|
struct inode *ip = VTOI(vp);
|
|
|
|
struct lfs *fs = ip->i_lfs;
|
|
|
|
daddr_t olbn, nlbn;
|
|
|
|
|
|
|
|
KASSERT(flags & (GOP_SIZE_READ | GOP_SIZE_WRITE));
|
|
|
|
KASSERT((flags & (GOP_SIZE_READ | GOP_SIZE_WRITE))
|
|
|
|
!= (GOP_SIZE_READ | GOP_SIZE_WRITE));
|
|
|
|
|
|
|
|
olbn = lblkno(fs, ip->i_ffs_size);
|
|
|
|
nlbn = lblkno(fs, size);
|
|
|
|
if ((flags & GOP_SIZE_WRITE) && nlbn < NDADDR && olbn <= nlbn) {
|
|
|
|
*eobp = fragroundup(fs, size);
|
|
|
|
} else {
|
|
|
|
*eobp = blkroundup(fs, size);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
void lfs_dump_vop(void *);
|
|
|
|
|
|
|
|
void
|
|
|
|
lfs_dump_vop(void *v)
|
|
|
|
{
|
|
|
|
struct vop_putpages_args /* {
|
|
|
|
struct vnode *a_vp;
|
|
|
|
voff_t a_offlo;
|
|
|
|
voff_t a_offhi;
|
|
|
|
int a_flags;
|
|
|
|
} */ *ap = v;
|
|
|
|
|
|
|
|
vfs_vnode_print(ap->a_vp, 0, printf);
|
|
|
|
lfs_dump_dinode(&VTOI(ap->a_vp)->i_din.ffs_din);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
int
|
|
|
|
lfs_mmap(void *v)
|
|
|
|
{
|
|
|
|
struct vop_mmap_args /* {
|
|
|
|
const struct vnodeop_desc *a_desc;
|
|
|
|
struct vnode *a_vp;
|
|
|
|
int a_fflags;
|
|
|
|
struct ucred *a_cred;
|
|
|
|
struct proc *a_p;
|
|
|
|
} */ *ap = v;
|
|
|
|
|
|
|
|
if (VTOI(ap->a_vp)->i_number == LFS_IFILE_INUM)
|
|
|
|
return EOPNOTSUPP;
|
|
|
|
return ufs_mmap(v);
|
|
|
|
}
|
|
|
|
#endif /* LFS_UBC */
|