2003-01-25 00:55:02 +03:00
|
|
|
/* $NetBSD: advnops.c,v 1.3 2003/01/24 21:55:17 fvdl Exp $ */
|
1994-06-29 10:29:24 +04:00
|
|
|
|
1994-05-11 22:49:06 +04:00
|
|
|
/*
|
|
|
|
* Copyright (c) 1994 Christian E. Hopps
|
1996-04-05 09:06:07 +04:00
|
|
|
* Copyright (c) 1996 Matthias Scheler
|
1994-05-11 22:49:06 +04:00
|
|
|
* 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 Christian E. Hopps.
|
|
|
|
* 4. The name of the author may not be used to endorse or promote products
|
|
|
|
* derived from this software without specific prior written permission
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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-06-08 08:27:50 +04:00
|
|
|
|
2001-11-13 01:54:03 +03:00
|
|
|
#include <sys/cdefs.h>
|
2003-01-25 00:55:02 +03:00
|
|
|
__KERNEL_RCSID(0, "$NetBSD: advnops.c,v 1.3 2003/01/24 21:55:17 fvdl Exp $");
|
2001-11-13 01:54:03 +03:00
|
|
|
|
2001-05-30 15:40:35 +04:00
|
|
|
#if defined(_KERNEL_OPT)
|
1998-06-08 08:27:50 +04:00
|
|
|
#include "opt_quota.h"
|
1998-06-09 11:46:31 +04:00
|
|
|
#endif
|
1998-06-08 08:27:50 +04:00
|
|
|
|
1994-05-11 22:49:06 +04:00
|
|
|
#include <sys/param.h>
|
1994-10-29 10:58:24 +03:00
|
|
|
#include <sys/systm.h>
|
1994-05-11 22:49:06 +04:00
|
|
|
#include <sys/vnode.h>
|
|
|
|
#include <sys/mount.h>
|
|
|
|
#include <sys/time.h>
|
|
|
|
#include <sys/queue.h>
|
|
|
|
#include <sys/namei.h>
|
|
|
|
#include <sys/buf.h>
|
|
|
|
#include <sys/dirent.h>
|
1994-06-18 00:06:05 +04:00
|
|
|
#include <sys/malloc.h>
|
1998-09-01 07:33:26 +04:00
|
|
|
#include <sys/pool.h>
|
1994-05-11 22:49:06 +04:00
|
|
|
#include <sys/stat.h>
|
1994-06-18 00:06:05 +04:00
|
|
|
#include <sys/unistd.h>
|
1996-02-09 22:06:38 +03:00
|
|
|
#include <sys/proc.h>
|
1996-09-02 03:47:48 +04:00
|
|
|
|
|
|
|
#include <miscfs/genfs/genfs.h>
|
1994-05-11 22:49:06 +04:00
|
|
|
#include <miscfs/specfs/specdev.h>
|
2002-12-23 20:15:20 +03:00
|
|
|
#include <fs/adosfs/adosfs.h>
|
1994-05-11 22:49:06 +04:00
|
|
|
|
|
|
|
extern struct vnodeops adosfs_vnodeops;
|
|
|
|
|
1996-09-02 03:47:48 +04:00
|
|
|
#define adosfs_open genfs_nullop
|
1996-02-09 22:06:38 +03:00
|
|
|
int adosfs_getattr __P((void *));
|
|
|
|
int adosfs_read __P((void *));
|
|
|
|
int adosfs_write __P((void *));
|
1999-08-04 00:19:16 +04:00
|
|
|
#define adosfs_fcntl genfs_fcntl
|
1998-08-10 12:11:10 +04:00
|
|
|
#define adosfs_ioctl genfs_enoioctl
|
1996-09-07 16:40:22 +04:00
|
|
|
#define adosfs_poll genfs_poll
|
1996-02-09 22:06:38 +03:00
|
|
|
int adosfs_strategy __P((void *));
|
1996-02-10 03:44:18 +03:00
|
|
|
int adosfs_link __P((void *));
|
|
|
|
int adosfs_symlink __P((void *));
|
1996-09-02 03:47:48 +04:00
|
|
|
#define adosfs_abortop genfs_abortop
|
1996-02-09 22:06:38 +03:00
|
|
|
int adosfs_bmap __P((void *));
|
|
|
|
int adosfs_print __P((void *));
|
|
|
|
int adosfs_readdir __P((void *));
|
|
|
|
int adosfs_access __P((void *));
|
|
|
|
int adosfs_readlink __P((void *));
|
|
|
|
int adosfs_inactive __P((void *));
|
|
|
|
int adosfs_reclaim __P((void *));
|
|
|
|
int adosfs_pathconf __P((void *));
|
|
|
|
|
1996-09-02 03:47:48 +04:00
|
|
|
#define adosfs_close genfs_nullop
|
|
|
|
#define adosfs_fsync genfs_nullop
|
1998-06-26 02:20:39 +04:00
|
|
|
#define adosfs_lease_check genfs_lease_check
|
1997-04-12 01:52:00 +04:00
|
|
|
#define adosfs_seek genfs_seek
|
1996-09-02 03:47:48 +04:00
|
|
|
#define adosfs_vfree genfs_nullop
|
|
|
|
|
1998-08-13 14:06:31 +04:00
|
|
|
#define adosfs_advlock genfs_einval
|
1996-09-02 03:47:48 +04:00
|
|
|
#define adosfs_blkatoff genfs_eopnotsupp
|
|
|
|
#define adosfs_bwrite genfs_eopnotsupp
|
|
|
|
#define adosfs_create genfs_eopnotsupp
|
|
|
|
#define adosfs_mkdir genfs_eopnotsupp
|
|
|
|
#define adosfs_mknod genfs_eopnotsupp
|
1998-03-01 05:20:01 +03:00
|
|
|
#define adosfs_revoke genfs_revoke
|
2001-05-28 06:50:51 +04:00
|
|
|
#define adosfs_mmap genfs_mmap
|
1996-09-02 03:47:48 +04:00
|
|
|
#define adosfs_remove genfs_eopnotsupp
|
|
|
|
#define adosfs_rename genfs_eopnotsupp
|
|
|
|
#define adosfs_rmdir genfs_eopnotsupp
|
|
|
|
#define adosfs_setattr genfs_eopnotsupp
|
|
|
|
#define adosfs_truncate genfs_eopnotsupp
|
|
|
|
#define adosfs_update genfs_nullop
|
|
|
|
#define adosfs_valloc genfs_eopnotsupp
|
1996-02-09 22:06:38 +03:00
|
|
|
|
2001-01-22 15:17:35 +03:00
|
|
|
const struct vnodeopv_entry_desc adosfs_vnodeop_entries[] = {
|
1996-09-02 03:47:48 +04:00
|
|
|
{ &vop_default_desc, vn_default_error },
|
|
|
|
{ &vop_lookup_desc, adosfs_lookup }, /* lookup */
|
|
|
|
{ &vop_create_desc, adosfs_create }, /* create */
|
|
|
|
{ &vop_mknod_desc, adosfs_mknod }, /* mknod */
|
|
|
|
{ &vop_open_desc, adosfs_open }, /* open */
|
|
|
|
{ &vop_close_desc, adosfs_close }, /* close */
|
|
|
|
{ &vop_access_desc, adosfs_access }, /* access */
|
|
|
|
{ &vop_getattr_desc, adosfs_getattr }, /* getattr */
|
|
|
|
{ &vop_setattr_desc, adosfs_setattr }, /* setattr */
|
|
|
|
{ &vop_read_desc, adosfs_read }, /* read */
|
|
|
|
{ &vop_write_desc, adosfs_write }, /* write */
|
|
|
|
{ &vop_lease_desc, adosfs_lease_check }, /* lease */
|
1999-08-04 00:19:16 +04:00
|
|
|
{ &vop_fcntl_desc, adosfs_fcntl }, /* fcntl */
|
1996-09-02 03:47:48 +04:00
|
|
|
{ &vop_ioctl_desc, adosfs_ioctl }, /* ioctl */
|
1996-09-07 16:40:22 +04:00
|
|
|
{ &vop_poll_desc, adosfs_poll }, /* poll */
|
2002-10-23 13:10:23 +04:00
|
|
|
{ &vop_kqfilter_desc, genfs_kqfilter }, /* kqfilter */
|
1999-08-19 07:42:23 +04:00
|
|
|
{ &vop_revoke_desc, adosfs_revoke }, /* revoke */
|
1996-09-02 03:47:48 +04:00
|
|
|
{ &vop_mmap_desc, adosfs_mmap }, /* mmap */
|
|
|
|
{ &vop_fsync_desc, adosfs_fsync }, /* fsync */
|
|
|
|
{ &vop_seek_desc, adosfs_seek }, /* seek */
|
|
|
|
{ &vop_remove_desc, adosfs_remove }, /* remove */
|
|
|
|
{ &vop_link_desc, adosfs_link }, /* link */
|
|
|
|
{ &vop_rename_desc, adosfs_rename }, /* rename */
|
|
|
|
{ &vop_mkdir_desc, adosfs_mkdir }, /* mkdir */
|
|
|
|
{ &vop_rmdir_desc, adosfs_rmdir }, /* rmdir */
|
|
|
|
{ &vop_symlink_desc, adosfs_symlink }, /* symlink */
|
|
|
|
{ &vop_readdir_desc, adosfs_readdir }, /* readdir */
|
|
|
|
{ &vop_readlink_desc, adosfs_readlink }, /* readlink */
|
|
|
|
{ &vop_abortop_desc, adosfs_abortop }, /* abortop */
|
|
|
|
{ &vop_inactive_desc, adosfs_inactive }, /* inactive */
|
|
|
|
{ &vop_reclaim_desc, adosfs_reclaim }, /* reclaim */
|
1999-07-08 05:05:58 +04:00
|
|
|
{ &vop_lock_desc, genfs_lock }, /* lock */
|
|
|
|
{ &vop_unlock_desc, genfs_unlock }, /* unlock */
|
1996-09-02 03:47:48 +04:00
|
|
|
{ &vop_bmap_desc, adosfs_bmap }, /* bmap */
|
|
|
|
{ &vop_strategy_desc, adosfs_strategy }, /* strategy */
|
|
|
|
{ &vop_print_desc, adosfs_print }, /* print */
|
1999-07-08 05:05:58 +04:00
|
|
|
{ &vop_islocked_desc, genfs_islocked }, /* islocked */
|
1996-09-02 03:47:48 +04:00
|
|
|
{ &vop_pathconf_desc, adosfs_pathconf }, /* pathconf */
|
|
|
|
{ &vop_advlock_desc, adosfs_advlock }, /* advlock */
|
|
|
|
{ &vop_blkatoff_desc, adosfs_blkatoff }, /* blkatoff */
|
|
|
|
{ &vop_valloc_desc, adosfs_valloc }, /* valloc */
|
|
|
|
{ &vop_vfree_desc, adosfs_vfree }, /* vfree */
|
|
|
|
{ &vop_truncate_desc, adosfs_truncate }, /* truncate */
|
|
|
|
{ &vop_update_desc, adosfs_update }, /* update */
|
|
|
|
{ &vop_bwrite_desc, adosfs_bwrite }, /* bwrite */
|
2000-11-27 11:39:39 +03:00
|
|
|
{ &vop_getpages_desc, genfs_getpages }, /* getpages */
|
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
|
|
|
{ &vop_putpages_desc, genfs_putpages }, /* putpages */
|
2000-11-27 11:39:39 +03:00
|
|
|
{ NULL, NULL }
|
1996-02-09 22:06:38 +03:00
|
|
|
};
|
|
|
|
|
2001-01-22 15:17:35 +03:00
|
|
|
const struct vnodeopv_desc adosfs_vnodeop_opv_desc =
|
1996-02-09 22:06:38 +03:00
|
|
|
{ &adosfs_vnodeop_p, adosfs_vnodeop_entries };
|
|
|
|
|
1994-05-11 22:49:06 +04:00
|
|
|
int
|
1996-02-09 22:06:38 +03:00
|
|
|
adosfs_getattr(v)
|
|
|
|
void *v;
|
|
|
|
{
|
1994-06-18 00:06:05 +04:00
|
|
|
struct vop_getattr_args /* {
|
|
|
|
struct vnode *a_vp;
|
|
|
|
struct vattr *a_vap;
|
|
|
|
struct ucred *a_cred;
|
|
|
|
struct proc *a_p;
|
1996-02-09 22:06:38 +03:00
|
|
|
} */ *sp = v;
|
1994-05-11 22:49:06 +04:00
|
|
|
struct vattr *vap;
|
1995-01-18 12:17:32 +03:00
|
|
|
struct adosfsmount *amp;
|
1994-05-11 22:49:06 +04:00
|
|
|
struct anode *ap;
|
1994-05-13 08:53:48 +04:00
|
|
|
u_long fblks;
|
1994-05-11 22:49:06 +04:00
|
|
|
|
|
|
|
#ifdef ADOSFS_DIAGNOSTIC
|
1994-06-18 00:06:05 +04:00
|
|
|
advopprint(sp);
|
1994-05-11 22:49:06 +04:00
|
|
|
#endif
|
1994-06-18 00:06:05 +04:00
|
|
|
vap = sp->a_vap;
|
|
|
|
ap = VTOA(sp->a_vp);
|
1994-05-11 22:49:06 +04:00
|
|
|
amp = ap->amp;
|
|
|
|
vattr_null(vap);
|
1994-12-28 11:51:56 +03:00
|
|
|
vap->va_uid = ap->uid;
|
|
|
|
vap->va_gid = ap->gid;
|
1994-06-18 00:06:05 +04:00
|
|
|
vap->va_fsid = sp->a_vp->v_mount->mnt_stat.f_fsid.val[0];
|
1996-02-01 03:04:52 +03:00
|
|
|
vap->va_atime.tv_sec = vap->va_mtime.tv_sec = vap->va_ctime.tv_sec =
|
1994-12-28 11:51:56 +03:00
|
|
|
ap->mtime.days * 24 * 60 * 60 + ap->mtime.mins * 60 +
|
|
|
|
ap->mtime.ticks / 50 + (8 * 365 + 2) * 24 * 60 * 60;
|
1996-02-01 03:04:52 +03:00
|
|
|
vap->va_atime.tv_nsec = vap->va_mtime.tv_nsec = vap->va_ctime.tv_nsec = 0;
|
1994-05-11 22:49:06 +04:00
|
|
|
vap->va_gen = 0;
|
|
|
|
vap->va_flags = 0;
|
1994-05-13 08:53:48 +04:00
|
|
|
vap->va_rdev = NODEV;
|
|
|
|
vap->va_fileid = ap->block;
|
1994-06-18 00:06:05 +04:00
|
|
|
vap->va_type = sp->a_vp->v_type;
|
1997-05-08 20:19:43 +04:00
|
|
|
vap->va_mode = adunixprot(ap->adprot) & amp->mask;
|
1994-06-18 00:06:05 +04:00
|
|
|
if (sp->a_vp->v_type == VDIR) {
|
1994-05-16 09:03:56 +04:00
|
|
|
vap->va_nlink = 1; /* XXX bogus, oh well */
|
1994-05-11 22:49:06 +04:00
|
|
|
vap->va_bytes = amp->bsize;
|
|
|
|
vap->va_size = amp->bsize;
|
1994-05-13 08:53:48 +04:00
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* XXX actually we can track this if we were to walk the list
|
|
|
|
* of links if it exists.
|
1996-04-05 09:06:07 +04:00
|
|
|
* XXX for now, just set nlink to 2 if this is a hard link
|
|
|
|
* to a file, or a file with a hard link.
|
1994-05-13 08:53:48 +04:00
|
|
|
*/
|
1996-04-05 09:06:07 +04:00
|
|
|
vap->va_nlink = 1 + (ap->linkto != 0);
|
1994-05-13 08:53:48 +04:00
|
|
|
/*
|
|
|
|
* round up to nearest blocks add number of file list
|
|
|
|
* blocks needed and mutiply by number of bytes per block.
|
|
|
|
*/
|
1996-04-05 09:06:07 +04:00
|
|
|
fblks = howmany(ap->fsize, amp->dbsize);
|
1994-05-13 08:53:48 +04:00
|
|
|
fblks += howmany(fblks, ANODENDATBLKENT(ap));
|
1996-04-05 09:06:07 +04:00
|
|
|
vap->va_bytes = fblks * amp->dbsize;
|
1994-05-13 08:53:48 +04:00
|
|
|
vap->va_size = ap->fsize;
|
1995-04-17 16:22:08 +04:00
|
|
|
|
1996-04-05 09:06:07 +04:00
|
|
|
vap->va_blocksize = amp->dbsize;
|
1994-05-11 22:49:06 +04:00
|
|
|
}
|
|
|
|
#ifdef ADOSFS_DIAGNOSTIC
|
1996-10-13 06:52:06 +04:00
|
|
|
printf(" 0)");
|
1994-05-11 22:49:06 +04:00
|
|
|
#endif
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* are things locked??? they need to be to avoid this being
|
|
|
|
* deleted or changed (data block pointer blocks moving about.)
|
|
|
|
*/
|
|
|
|
int
|
1996-02-09 22:06:38 +03:00
|
|
|
adosfs_read(v)
|
|
|
|
void *v;
|
|
|
|
{
|
1994-06-18 00:06:05 +04:00
|
|
|
struct vop_read_args /* {
|
|
|
|
struct vnode *a_vp;
|
|
|
|
struct uio *a_uio;
|
|
|
|
int a_ioflag;
|
|
|
|
struct ucred *a_cred;
|
1996-02-09 22:06:38 +03:00
|
|
|
} */ *sp = v;
|
2000-11-27 11:39:39 +03:00
|
|
|
struct vnode *vp = sp->a_vp;
|
1995-01-18 12:17:32 +03:00
|
|
|
struct adosfsmount *amp;
|
1994-06-18 00:06:05 +04:00
|
|
|
struct anode *ap;
|
|
|
|
struct uio *uio;
|
1994-05-11 22:49:06 +04:00
|
|
|
struct buf *bp;
|
1996-02-09 22:06:38 +03:00
|
|
|
daddr_t lbn;
|
1994-05-11 22:49:06 +04:00
|
|
|
int size, diff, error;
|
|
|
|
long n, on;
|
|
|
|
|
|
|
|
#ifdef ADOSFS_DIAGNOSTIC
|
1994-06-18 00:06:05 +04:00
|
|
|
advopprint(sp);
|
1994-05-11 22:49:06 +04:00
|
|
|
#endif
|
|
|
|
error = 0;
|
1994-06-18 00:06:05 +04:00
|
|
|
uio = sp->a_uio;
|
|
|
|
ap = VTOA(sp->a_vp);
|
1994-05-11 22:49:06 +04:00
|
|
|
amp = ap->amp;
|
|
|
|
/*
|
|
|
|
* Return EOF for character devices, EIO for others
|
|
|
|
*/
|
1994-06-18 00:06:05 +04:00
|
|
|
if (sp->a_vp->v_type != VREG) {
|
1994-05-11 22:49:06 +04:00
|
|
|
error = EIO;
|
|
|
|
goto reterr;
|
|
|
|
}
|
|
|
|
if (uio->uio_resid == 0)
|
|
|
|
goto reterr;
|
|
|
|
if (uio->uio_offset < 0) {
|
|
|
|
error = EINVAL;
|
|
|
|
goto reterr;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* to expensive to let general algorithm figure out that
|
|
|
|
* we are beyond the file. Do it now.
|
|
|
|
*/
|
|
|
|
if (uio->uio_offset >= ap->fsize)
|
|
|
|
goto reterr;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* taken from ufs_read()
|
|
|
|
*/
|
2000-11-27 11:39:39 +03:00
|
|
|
|
2001-04-12 08:12:04 +04:00
|
|
|
if (vp->v_type == VREG && IS_FFS(amp)) {
|
2000-11-27 11:39:39 +03:00
|
|
|
error = 0;
|
|
|
|
while (uio->uio_resid > 0) {
|
|
|
|
void *win;
|
2001-02-27 07:37:44 +03:00
|
|
|
vsize_t bytelen = MIN(ap->fsize - uio->uio_offset,
|
2000-11-27 11:39:39 +03:00
|
|
|
uio->uio_resid);
|
|
|
|
|
|
|
|
if (bytelen == 0) {
|
|
|
|
break;
|
|
|
|
}
|
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
|
|
|
win = ubc_alloc(&vp->v_uobj, uio->uio_offset,
|
2000-11-27 11:39:39 +03:00
|
|
|
&bytelen, UBC_READ);
|
|
|
|
error = uiomove(win, bytelen, uio);
|
|
|
|
ubc_release(win, 0);
|
|
|
|
if (error) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
1994-05-11 22:49:06 +04:00
|
|
|
do {
|
1996-04-05 09:06:07 +04:00
|
|
|
size = amp->dbsize;
|
1994-05-11 22:49:06 +04:00
|
|
|
lbn = uio->uio_offset / size;
|
|
|
|
on = uio->uio_offset % size;
|
2001-02-27 07:37:44 +03:00
|
|
|
n = MIN(size - on, uio->uio_resid);
|
1994-05-11 22:49:06 +04:00
|
|
|
diff = ap->fsize - uio->uio_offset;
|
|
|
|
/*
|
|
|
|
* check for EOF
|
|
|
|
*/
|
|
|
|
if (diff <= 0)
|
|
|
|
return(0);
|
|
|
|
if (diff < n)
|
|
|
|
n = diff;
|
|
|
|
/*
|
|
|
|
* read ahead could possibly be worth something
|
|
|
|
* but not much as ados makes little attempt to
|
|
|
|
* make things contigous
|
|
|
|
*/
|
2003-01-09 21:34:41 +03:00
|
|
|
error = bread(sp->a_vp, lbn, amp->bsize, NOCRED, &bp);
|
1999-02-10 16:14:08 +03:00
|
|
|
if (error) {
|
|
|
|
brelse(bp);
|
|
|
|
goto reterr;
|
|
|
|
}
|
1996-04-05 09:06:07 +04:00
|
|
|
if (!IS_FFS(amp)) {
|
|
|
|
if (bp->b_resid > 0)
|
|
|
|
error = EIO; /* OFS needs the complete block */
|
|
|
|
else if (adoswordn(bp, 0) != BPT_DATA) {
|
|
|
|
#ifdef DIAGNOSTIC
|
1996-10-13 06:52:06 +04:00
|
|
|
printf("adosfs: bad primary type blk %ld\n",
|
1999-06-03 02:04:30 +04:00
|
|
|
bp->b_blkno / (amp->bsize / DEV_BSIZE));
|
1996-04-05 09:06:07 +04:00
|
|
|
#endif
|
2001-04-12 08:12:04 +04:00
|
|
|
error = EINVAL;
|
|
|
|
} else if (adoscksum(bp, ap->nwords)) {
|
1996-04-05 09:06:07 +04:00
|
|
|
#ifdef DIAGNOSTIC
|
1996-10-13 06:52:06 +04:00
|
|
|
printf("adosfs: blk %ld failed cksum.\n",
|
1999-06-03 02:04:30 +04:00
|
|
|
bp->b_blkno / (amp->bsize / DEV_BSIZE));
|
1996-04-05 09:06:07 +04:00
|
|
|
#endif
|
2001-04-12 08:12:04 +04:00
|
|
|
error = EINVAL;
|
1996-04-05 09:06:07 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1994-05-11 22:49:06 +04:00
|
|
|
if (error) {
|
|
|
|
brelse(bp);
|
|
|
|
goto reterr;
|
|
|
|
}
|
|
|
|
#ifdef ADOSFS_DIAGNOSTIC
|
1996-10-13 06:52:06 +04:00
|
|
|
printf(" %d+%d-%d+%d", lbn, on, lbn, n);
|
1994-05-11 22:49:06 +04:00
|
|
|
#endif
|
2001-02-27 07:37:44 +03:00
|
|
|
n = MIN(n, size - bp->b_resid);
|
2000-05-19 22:54:22 +04:00
|
|
|
error = uiomove(bp->b_data + on +
|
1996-04-05 09:06:07 +04:00
|
|
|
amp->bsize - amp->dbsize, (int)n, uio);
|
1994-05-11 22:49:06 +04:00
|
|
|
brelse(bp);
|
|
|
|
} while (error == 0 && uio->uio_resid > 0 && n != 0);
|
2000-11-27 11:39:39 +03:00
|
|
|
|
|
|
|
out:
|
1994-05-11 22:49:06 +04:00
|
|
|
reterr:
|
|
|
|
#ifdef ADOSFS_DIAGNOSTIC
|
1996-10-13 06:52:06 +04:00
|
|
|
printf(" %d)", error);
|
1994-05-11 22:49:06 +04:00
|
|
|
#endif
|
|
|
|
return(error);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1996-02-09 22:06:38 +03:00
|
|
|
adosfs_write(v)
|
|
|
|
void *v;
|
|
|
|
{
|
|
|
|
#ifdef ADOSFS_DIAGNOSTIC
|
1994-06-18 00:06:05 +04:00
|
|
|
struct vop_write_args /* {
|
|
|
|
struct vnode *a_vp;
|
|
|
|
struct uio *a_uio;
|
|
|
|
int a_ioflag;
|
|
|
|
struct ucred *a_cred;
|
1996-02-09 22:06:38 +03:00
|
|
|
} */ *sp = v;
|
1994-06-18 00:06:05 +04:00
|
|
|
advopprint(sp);
|
1996-10-13 06:52:06 +04:00
|
|
|
printf(" EOPNOTSUPP)");
|
1994-05-11 22:49:06 +04:00
|
|
|
#endif
|
|
|
|
return(EOPNOTSUPP);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Just call the device strategy routine
|
|
|
|
*/
|
|
|
|
int
|
1996-02-09 22:06:38 +03:00
|
|
|
adosfs_strategy(v)
|
|
|
|
void *v;
|
|
|
|
{
|
1994-06-18 00:06:05 +04:00
|
|
|
struct vop_strategy_args /* {
|
|
|
|
struct buf *a_bp;
|
1996-02-09 22:06:38 +03:00
|
|
|
} */ *sp = v;
|
1994-06-18 00:06:05 +04:00
|
|
|
struct buf *bp;
|
1994-05-11 22:49:06 +04:00
|
|
|
struct anode *ap;
|
|
|
|
struct vnode *vp;
|
|
|
|
int error;
|
|
|
|
|
|
|
|
#ifdef ADOSFS_DIAGNOSTIC
|
1994-06-18 00:06:05 +04:00
|
|
|
advopprint(sp);
|
1994-05-11 22:49:06 +04:00
|
|
|
#endif
|
|
|
|
error = 0;
|
1994-06-18 00:06:05 +04:00
|
|
|
bp = sp->a_bp;
|
1994-05-11 22:49:06 +04:00
|
|
|
if (bp->b_vp == NULL) {
|
|
|
|
bp->b_flags |= B_ERROR;
|
|
|
|
biodone(bp);
|
|
|
|
error = EIO;
|
|
|
|
goto reterr;
|
|
|
|
}
|
|
|
|
vp = bp->b_vp;
|
|
|
|
ap = VTOA(vp);
|
1994-06-18 00:06:05 +04:00
|
|
|
if (bp->b_blkno == bp->b_lblkno) {
|
1996-02-09 22:06:38 +03:00
|
|
|
error = VOP_BMAP(vp, bp->b_lblkno, NULL, &bp->b_blkno, NULL);
|
|
|
|
if (error) {
|
1994-05-11 22:49:06 +04:00
|
|
|
bp->b_flags |= B_ERROR;
|
|
|
|
biodone(bp);
|
|
|
|
goto reterr;
|
|
|
|
}
|
1994-06-18 00:06:05 +04:00
|
|
|
}
|
|
|
|
if ((long)bp->b_blkno == -1) {
|
|
|
|
biodone(bp);
|
|
|
|
error = 0;
|
|
|
|
goto reterr;
|
|
|
|
}
|
1994-05-11 22:49:06 +04:00
|
|
|
vp = ap->amp->devvp;
|
|
|
|
bp->b_dev = vp->v_rdev;
|
1994-06-18 00:06:05 +04:00
|
|
|
VOCALL(vp->v_op, VOFFSET(vop_strategy), sp);
|
1994-05-11 22:49:06 +04:00
|
|
|
reterr:
|
|
|
|
#ifdef ADOSFS_DIAGNOSTIC
|
1996-10-13 06:52:06 +04:00
|
|
|
printf(" %d)", error);
|
1994-05-11 22:49:06 +04:00
|
|
|
#endif
|
|
|
|
return(error);
|
|
|
|
}
|
|
|
|
|
1996-02-09 17:45:36 +03:00
|
|
|
int
|
1996-02-09 22:06:38 +03:00
|
|
|
adosfs_link(v)
|
|
|
|
void *v;
|
|
|
|
{
|
1996-02-09 17:45:36 +03:00
|
|
|
struct vop_link_args /* {
|
|
|
|
struct vnode *a_dvp;
|
|
|
|
struct vnode *a_vp;
|
|
|
|
struct componentname *a_cnp;
|
1996-02-09 22:06:38 +03:00
|
|
|
} */ *ap = v;
|
1996-02-09 17:45:36 +03:00
|
|
|
|
|
|
|
VOP_ABORTOP(ap->a_dvp, ap->a_cnp);
|
|
|
|
vput(ap->a_dvp);
|
|
|
|
return (EROFS);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1996-02-09 22:06:38 +03:00
|
|
|
adosfs_symlink(v)
|
|
|
|
void *v;
|
|
|
|
{
|
1996-02-09 17:45:36 +03: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-09 22:06:38 +03:00
|
|
|
} */ *ap = v;
|
1996-02-09 17:45:36 +03:00
|
|
|
|
|
|
|
VOP_ABORTOP(ap->a_dvp, ap->a_cnp);
|
|
|
|
vput(ap->a_dvp);
|
|
|
|
return (EROFS);
|
|
|
|
}
|
|
|
|
|
1994-05-11 22:49:06 +04:00
|
|
|
/*
|
|
|
|
* Wait until the vnode has finished changing state.
|
|
|
|
*/
|
|
|
|
int
|
1996-02-09 22:06:38 +03:00
|
|
|
adosfs_bmap(v)
|
|
|
|
void *v;
|
|
|
|
{
|
1994-06-18 00:06:05 +04:00
|
|
|
struct vop_bmap_args /* {
|
|
|
|
struct vnode *a_vp;
|
|
|
|
daddr_t a_bn;
|
|
|
|
struct vnode **a_vpp;
|
|
|
|
daddr_t *a_bnp;
|
|
|
|
int *a_runp;
|
1996-02-09 22:06:38 +03:00
|
|
|
} */ *sp = v;
|
1994-05-11 22:49:06 +04:00
|
|
|
struct anode *ap;
|
|
|
|
struct buf *flbp;
|
1994-07-11 09:07:38 +04:00
|
|
|
long nb, flblk, flblkoff, fcnt;
|
1994-06-18 00:06:05 +04:00
|
|
|
daddr_t *bnp;
|
|
|
|
daddr_t bn;
|
1994-05-11 22:49:06 +04:00
|
|
|
int error;
|
|
|
|
|
|
|
|
#ifdef ADOSFS_DIAGNOSTIC
|
1994-06-18 00:06:05 +04:00
|
|
|
advopprint(sp);
|
1994-05-11 22:49:06 +04:00
|
|
|
#endif
|
1996-04-05 09:06:07 +04:00
|
|
|
ap = VTOA(sp->a_vp);
|
2003-01-09 21:34:41 +03:00
|
|
|
bn = sp->a_bn;
|
1994-06-18 00:06:05 +04:00
|
|
|
bnp = sp->a_bnp;
|
2001-04-12 08:12:04 +04:00
|
|
|
if (sp->a_runp) {
|
|
|
|
*sp->a_runp = 0;
|
|
|
|
}
|
1994-05-11 22:49:06 +04:00
|
|
|
error = 0;
|
|
|
|
|
1994-06-18 00:06:05 +04:00
|
|
|
if (sp->a_vpp != NULL)
|
|
|
|
*sp->a_vpp = ap->amp->devvp;
|
|
|
|
if (bnp == NULL)
|
|
|
|
goto reterr;
|
1994-05-11 22:49:06 +04:00
|
|
|
if (bn < 0) {
|
|
|
|
error = EFBIG;
|
|
|
|
goto reterr;
|
|
|
|
}
|
1994-06-18 00:06:05 +04:00
|
|
|
if (sp->a_vp->v_type != VREG) {
|
1994-05-11 22:49:06 +04:00
|
|
|
error = EINVAL;
|
|
|
|
goto reterr;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* walk the chain of file list blocks until we find
|
|
|
|
* the one that will yield the block pointer we need.
|
|
|
|
*/
|
|
|
|
if (ap->type == AFILE)
|
|
|
|
nb = ap->block; /* pointer to ourself */
|
|
|
|
else if (ap->type == ALFILE)
|
|
|
|
nb = ap->linkto; /* pointer to real file */
|
|
|
|
else {
|
|
|
|
error = EINVAL;
|
|
|
|
goto reterr;
|
|
|
|
}
|
|
|
|
|
|
|
|
flblk = bn / ANODENDATBLKENT(ap);
|
|
|
|
flbp = NULL;
|
1994-07-11 09:07:38 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* check last indirect block cache
|
|
|
|
*/
|
1994-12-28 11:51:56 +03:00
|
|
|
if (flblk < ap->lastlindblk)
|
1994-07-11 09:07:38 +04:00
|
|
|
fcnt = 0;
|
|
|
|
else {
|
|
|
|
flblk -= ap->lastlindblk;
|
|
|
|
fcnt = ap->lastlindblk;
|
|
|
|
nb = ap->lastindblk;
|
|
|
|
}
|
1994-05-11 22:49:06 +04:00
|
|
|
while (flblk >= 0) {
|
|
|
|
if (flbp)
|
|
|
|
brelse(flbp);
|
|
|
|
if (nb == 0) {
|
|
|
|
#ifdef DIAGNOSTIC
|
1996-10-13 06:52:06 +04:00
|
|
|
printf("adosfs: bad file list chain.\n");
|
1994-05-11 22:49:06 +04:00
|
|
|
#endif
|
|
|
|
error = EINVAL;
|
|
|
|
goto reterr;
|
|
|
|
}
|
1999-06-03 02:04:30 +04:00
|
|
|
error = bread(ap->amp->devvp, nb * ap->amp->bsize / DEV_BSIZE,
|
1996-04-05 09:06:07 +04:00
|
|
|
ap->amp->bsize, NOCRED, &flbp);
|
1999-02-10 16:14:08 +03:00
|
|
|
if (error) {
|
|
|
|
brelse(flbp);
|
1994-05-11 22:49:06 +04:00
|
|
|
goto reterr;
|
1999-02-10 16:14:08 +03:00
|
|
|
}
|
1994-05-11 22:49:06 +04:00
|
|
|
if (adoscksum(flbp, ap->nwords)) {
|
|
|
|
#ifdef DIAGNOSTIC
|
1996-10-13 06:52:06 +04:00
|
|
|
printf("adosfs: blk %ld failed cksum.\n", nb);
|
1994-05-11 22:49:06 +04:00
|
|
|
#endif
|
|
|
|
brelse(flbp);
|
|
|
|
error = EINVAL;
|
|
|
|
goto reterr;
|
|
|
|
}
|
1994-07-11 09:07:38 +04:00
|
|
|
/*
|
|
|
|
* update last indirect block cache
|
|
|
|
*/
|
|
|
|
ap->lastlindblk = fcnt++;
|
|
|
|
ap->lastindblk = nb;
|
|
|
|
|
1994-05-11 22:49:06 +04:00
|
|
|
nb = adoswordn(flbp, ap->nwords - 2);
|
|
|
|
flblk--;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* calculate offset of block number in table. The table starts
|
|
|
|
* at nwords - 51 and goes to offset 6 or less if indicated by the
|
|
|
|
* valid table entries stored at offset ADBI_NBLKTABENT.
|
|
|
|
*/
|
|
|
|
flblkoff = bn % ANODENDATBLKENT(ap);
|
|
|
|
if (flblkoff < adoswordn(flbp, 2 /* ADBI_NBLKTABENT */)) {
|
|
|
|
flblkoff = (ap->nwords - 51) - flblkoff;
|
1999-06-03 02:04:30 +04:00
|
|
|
*bnp = adoswordn(flbp, flblkoff) * ap->amp->bsize / DEV_BSIZE;
|
1994-05-11 22:49:06 +04:00
|
|
|
} else {
|
|
|
|
#ifdef DIAGNOSTIC
|
1996-10-13 06:52:06 +04:00
|
|
|
printf("flblk offset %ld too large in lblk %ld blk %d\n",
|
2003-01-09 21:34:41 +03:00
|
|
|
flblkoff, (long)bn, flbp->b_blkno);
|
1994-05-11 22:49:06 +04:00
|
|
|
#endif
|
|
|
|
error = EINVAL;
|
|
|
|
}
|
|
|
|
brelse(flbp);
|
|
|
|
reterr:
|
|
|
|
#ifdef ADOSFS_DIAGNOSTIC
|
|
|
|
if (error == 0 && bnp)
|
2003-01-25 00:55:02 +03:00
|
|
|
printf(" %lld => %lld", (long long)bn, (long long)*bnp);
|
2003-01-09 21:34:41 +03:00
|
|
|
printf(" %d)\n", error);
|
1994-05-11 22:49:06 +04:00
|
|
|
#endif
|
|
|
|
return(error);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Print out the contents of a adosfs vnode.
|
|
|
|
*/
|
|
|
|
/* ARGSUSED */
|
|
|
|
int
|
1996-02-09 22:06:38 +03:00
|
|
|
adosfs_print(v)
|
|
|
|
void *v;
|
|
|
|
{
|
|
|
|
#if 0
|
1994-06-18 00:06:05 +04:00
|
|
|
struct vop_print_args /* {
|
|
|
|
struct vnode *a_vp;
|
1996-02-09 22:06:38 +03:00
|
|
|
} */ *sp = v;
|
|
|
|
#endif
|
1994-05-11 22:49:06 +04:00
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
struct adirent {
|
|
|
|
u_long fileno;
|
|
|
|
u_short reclen;
|
1994-06-18 00:06:05 +04:00
|
|
|
char type;
|
|
|
|
char namlen;
|
1994-05-11 22:49:06 +04:00
|
|
|
char name[32]; /* maxlen of 30 plus 2 NUL's */
|
|
|
|
};
|
|
|
|
|
|
|
|
int
|
1996-02-09 22:06:38 +03:00
|
|
|
adosfs_readdir(v)
|
|
|
|
void *v;
|
|
|
|
{
|
1994-06-18 00:06:05 +04:00
|
|
|
struct vop_readdir_args /* {
|
|
|
|
struct vnode *a_vp;
|
|
|
|
struct uio *a_uio;
|
|
|
|
struct ucred *a_cred;
|
|
|
|
int *a_eofflag;
|
1998-03-01 05:20:01 +03:00
|
|
|
off_t **a_cookies;
|
|
|
|
int *a_ncookies;
|
1996-02-09 22:06:38 +03:00
|
|
|
} */ *sp = v;
|
1994-05-11 22:49:06 +04:00
|
|
|
int error, useri, chainc, hashi, scanned, uavail;
|
|
|
|
struct adirent ad, *adp;
|
|
|
|
struct anode *pap, *ap;
|
1995-01-18 12:17:32 +03:00
|
|
|
struct adosfsmount *amp;
|
1994-06-18 00:06:05 +04:00
|
|
|
struct vnode *vp;
|
|
|
|
struct uio *uio;
|
1996-02-09 22:06:38 +03:00
|
|
|
u_long nextbn;
|
1998-03-01 05:20:01 +03:00
|
|
|
off_t uoff, *cookies = NULL;
|
|
|
|
int ncookies = 0;
|
1994-05-11 22:49:06 +04:00
|
|
|
|
|
|
|
#ifdef ADOSFS_DIAGNOSTIC
|
1994-06-18 00:06:05 +04:00
|
|
|
advopprint(sp);
|
1994-05-11 22:49:06 +04:00
|
|
|
#endif
|
1994-06-18 00:06:05 +04:00
|
|
|
if (sp->a_vp->v_type != VDIR) {
|
1994-05-11 22:49:06 +04:00
|
|
|
error = ENOTDIR;
|
|
|
|
goto reterr;
|
|
|
|
}
|
1998-03-01 05:20:01 +03:00
|
|
|
|
1994-06-18 00:06:05 +04:00
|
|
|
uio = sp->a_uio;
|
1994-05-11 22:49:06 +04:00
|
|
|
uoff = uio->uio_offset;
|
|
|
|
if (uoff < 0) {
|
|
|
|
error = EINVAL;
|
|
|
|
goto reterr;
|
|
|
|
}
|
|
|
|
|
1994-06-18 00:06:05 +04:00
|
|
|
pap = VTOA(sp->a_vp);
|
1994-05-11 22:49:06 +04:00
|
|
|
amp = pap->amp;
|
|
|
|
adp = &ad;
|
|
|
|
error = nextbn = hashi = chainc = scanned = 0;
|
|
|
|
uavail = uio->uio_resid / sizeof(ad);
|
|
|
|
useri = uoff / sizeof(ad);
|
|
|
|
|
1994-05-13 08:53:48 +04:00
|
|
|
/*
|
|
|
|
* if no slots available or offset requested is not on a slot boundry
|
|
|
|
*/
|
|
|
|
if (uavail < 1 || uoff % sizeof(ad)) {
|
|
|
|
error = EINVAL;
|
|
|
|
goto reterr;
|
|
|
|
}
|
|
|
|
|
1998-03-01 05:20:01 +03:00
|
|
|
if (sp->a_ncookies) {
|
|
|
|
ncookies = 0;
|
2000-08-03 04:54:23 +04:00
|
|
|
cookies = malloc(sizeof (off_t) * uavail, M_TEMP, M_WAITOK);
|
1998-03-01 05:20:01 +03:00
|
|
|
*sp->a_cookies = cookies;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (uavail) {
|
1994-05-11 22:49:06 +04:00
|
|
|
if (hashi == pap->ntabent) {
|
1994-06-18 00:06:05 +04:00
|
|
|
*sp->a_eofflag = 1;
|
1994-05-11 22:49:06 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (pap->tab[hashi] == 0) {
|
|
|
|
hashi++;
|
|
|
|
continue;
|
|
|
|
}
|
1994-05-13 08:53:48 +04:00
|
|
|
if (nextbn == 0)
|
1994-05-11 22:49:06 +04:00
|
|
|
nextbn = pap->tab[hashi];
|
|
|
|
|
|
|
|
/*
|
|
|
|
* first determine if we can skip this chain
|
|
|
|
*/
|
|
|
|
if (chainc == 0) {
|
|
|
|
int skip;
|
|
|
|
|
|
|
|
skip = useri - scanned;
|
|
|
|
if (pap->tabi[hashi] > 0 && pap->tabi[hashi] <= skip) {
|
|
|
|
scanned += pap->tabi[hashi];
|
|
|
|
hashi++;
|
1994-05-13 08:53:48 +04:00
|
|
|
nextbn = 0;
|
1994-05-11 22:49:06 +04:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* now [continue to] walk the chain
|
|
|
|
*/
|
|
|
|
ap = NULL;
|
|
|
|
do {
|
1996-02-09 22:06:38 +03:00
|
|
|
error = VFS_VGET(amp->mp, (ino_t)nextbn, &vp);
|
|
|
|
if (error)
|
1994-05-11 22:49:06 +04:00
|
|
|
goto reterr;
|
1994-06-18 00:06:05 +04:00
|
|
|
ap = VTOA(vp);
|
1994-05-11 22:49:06 +04:00
|
|
|
scanned++;
|
|
|
|
chainc++;
|
|
|
|
nextbn = ap->hashf;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* check for end of chain.
|
|
|
|
*/
|
|
|
|
if (nextbn == 0) {
|
|
|
|
pap->tabi[hashi] = chainc;
|
|
|
|
hashi++;
|
1994-05-13 08:53:48 +04:00
|
|
|
chainc = 0;
|
1994-05-11 22:49:06 +04:00
|
|
|
} else if (pap->tabi[hashi] <= 0 &&
|
|
|
|
-chainc < pap->tabi[hashi])
|
|
|
|
pap->tabi[hashi] = -chainc;
|
|
|
|
|
1994-05-13 08:53:48 +04:00
|
|
|
if (useri >= scanned) {
|
1994-06-18 00:06:05 +04:00
|
|
|
vput(vp);
|
1994-05-11 22:49:06 +04:00
|
|
|
ap = NULL;
|
|
|
|
}
|
|
|
|
} while (ap == NULL && nextbn != 0);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* we left the loop but without a result so do main over.
|
|
|
|
*/
|
|
|
|
if (ap == NULL)
|
|
|
|
continue;
|
|
|
|
/*
|
|
|
|
* Fill in dirent record
|
|
|
|
*/
|
1998-08-10 00:15:38 +04:00
|
|
|
memset(adp, 0, sizeof(struct adirent));
|
1994-05-11 22:49:06 +04:00
|
|
|
adp->fileno = ap->block;
|
1994-06-18 00:06:05 +04:00
|
|
|
/*
|
|
|
|
* this deserves an function in kern/vfs_subr.c
|
|
|
|
*/
|
|
|
|
switch (ATOV(ap)->v_type) {
|
|
|
|
case VREG:
|
|
|
|
adp->type = DT_REG;
|
|
|
|
break;
|
|
|
|
case VDIR:
|
|
|
|
adp->type = DT_DIR;
|
|
|
|
break;
|
|
|
|
case VLNK:
|
|
|
|
adp->type = DT_LNK;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
adp->type = DT_UNKNOWN;
|
|
|
|
break;
|
|
|
|
}
|
1994-05-11 22:49:06 +04:00
|
|
|
adp->reclen = sizeof(struct adirent);
|
|
|
|
adp->namlen = strlen(ap->name);
|
1998-08-10 00:15:38 +04:00
|
|
|
memcpy(adp->name, ap->name, adp->namlen);
|
1994-06-18 00:06:05 +04:00
|
|
|
vput(vp);
|
1994-05-11 22:49:06 +04:00
|
|
|
|
1996-02-09 22:06:38 +03:00
|
|
|
error = uiomove((caddr_t) adp, sizeof(struct adirent), uio);
|
1994-05-11 22:49:06 +04:00
|
|
|
if (error)
|
|
|
|
break;
|
1998-03-01 05:20:01 +03:00
|
|
|
if (sp->a_ncookies) {
|
|
|
|
*cookies++ = uoff;
|
|
|
|
ncookies++;
|
1994-05-11 22:49:06 +04:00
|
|
|
}
|
|
|
|
uoff += sizeof(struct adirent);
|
|
|
|
useri++;
|
|
|
|
uavail--;
|
|
|
|
}
|
1994-05-13 08:53:48 +04:00
|
|
|
#if doesnt_uiomove_handle_this
|
1994-05-11 22:49:06 +04:00
|
|
|
uio->uio_offset = uoff;
|
1994-05-13 08:53:48 +04:00
|
|
|
#endif
|
1994-05-11 22:49:06 +04:00
|
|
|
reterr:
|
|
|
|
#ifdef ADOSFS_DIAGNOSTIC
|
1996-10-13 06:52:06 +04:00
|
|
|
printf(" %d)", error);
|
1994-05-11 22:49:06 +04:00
|
|
|
#endif
|
1998-03-01 05:20:01 +03:00
|
|
|
if (sp->a_ncookies) {
|
|
|
|
if (error) {
|
2000-08-03 04:54:23 +04:00
|
|
|
free(*sp->a_cookies, M_TEMP);
|
1998-03-01 05:20:01 +03:00
|
|
|
*sp->a_ncookies = 0;
|
|
|
|
*sp->a_cookies = NULL;
|
|
|
|
} else
|
|
|
|
*sp->a_ncookies = ncookies;
|
|
|
|
}
|
1994-05-11 22:49:06 +04:00
|
|
|
return(error);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int
|
1996-02-09 22:06:38 +03:00
|
|
|
adosfs_access(v)
|
|
|
|
void *v;
|
|
|
|
{
|
1994-06-18 00:06:05 +04:00
|
|
|
struct vop_access_args /* {
|
|
|
|
struct vnode *a_vp;
|
|
|
|
int a_mode;
|
|
|
|
struct ucred *a_cred;
|
|
|
|
struct proc *a_p;
|
1996-02-09 22:06:38 +03:00
|
|
|
} */ *sp = v;
|
1994-05-11 22:49:06 +04:00
|
|
|
struct anode *ap;
|
1998-03-01 05:20:01 +03:00
|
|
|
struct vnode *vp = sp->a_vp;
|
1994-12-30 01:06:15 +03:00
|
|
|
int error;
|
1994-05-11 22:49:06 +04:00
|
|
|
|
|
|
|
#ifdef ADOSFS_DIAGNOSTIC
|
1994-06-18 00:06:05 +04:00
|
|
|
advopprint(sp);
|
1994-05-11 22:49:06 +04:00
|
|
|
#endif
|
|
|
|
|
1998-03-01 05:20:01 +03:00
|
|
|
ap = VTOA(vp);
|
1994-05-11 22:49:06 +04:00
|
|
|
#ifdef DIAGNOSTIC
|
1998-03-01 05:20:01 +03:00
|
|
|
if (!VOP_ISLOCKED(vp)) {
|
1994-06-18 00:06:05 +04:00
|
|
|
vprint("adosfs_access: not locked", sp->a_vp);
|
1994-05-11 22:49:06 +04:00
|
|
|
panic("adosfs_access: not locked");
|
|
|
|
}
|
|
|
|
#endif
|
1998-03-01 05:20:01 +03:00
|
|
|
/*
|
|
|
|
* Disallow write attempts unless the file is a socket,
|
|
|
|
* fifo, or a block or character device resident on the
|
|
|
|
* file system.
|
|
|
|
*/
|
|
|
|
if (sp->a_mode & VWRITE) {
|
|
|
|
switch (vp->v_type) {
|
|
|
|
case VDIR:
|
|
|
|
case VLNK:
|
|
|
|
case VREG:
|
|
|
|
return (EROFS);
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
1994-05-11 22:49:06 +04:00
|
|
|
#ifdef QUOTA
|
|
|
|
#endif
|
1997-05-14 23:00:17 +04:00
|
|
|
error = vaccess(sp->a_vp->v_type, adunixprot(ap->adprot) & ap->amp->mask,
|
1997-05-08 20:19:43 +04:00
|
|
|
ap->uid, ap->gid, sp->a_mode, sp->a_cred);
|
1994-05-11 22:49:06 +04:00
|
|
|
#ifdef ADOSFS_DIAGNOSTIC
|
1996-10-13 06:52:06 +04:00
|
|
|
printf(" %d)", error);
|
1994-05-11 22:49:06 +04:00
|
|
|
#endif
|
|
|
|
return(error);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1996-02-09 22:06:38 +03:00
|
|
|
adosfs_readlink(v)
|
|
|
|
void *v;
|
|
|
|
{
|
1994-06-18 00:06:05 +04:00
|
|
|
struct vop_readlink_args /* {
|
|
|
|
struct vnode *a_vp;
|
|
|
|
struct uio *a_uio;
|
|
|
|
struct ucred *a_cred;
|
1996-02-09 22:06:38 +03:00
|
|
|
} */ *sp = v;
|
1994-06-18 00:06:05 +04:00
|
|
|
struct anode *ap;
|
|
|
|
int error;
|
|
|
|
|
1994-05-11 22:49:06 +04:00
|
|
|
#ifdef ADOSFS_DIAGNOSTIC
|
1994-06-18 00:06:05 +04:00
|
|
|
advopprint(sp);
|
1994-05-11 22:49:06 +04:00
|
|
|
#endif
|
1994-06-18 00:06:05 +04:00
|
|
|
ap = VTOA(sp->a_vp);
|
1998-08-19 17:12:40 +04:00
|
|
|
error = uiomove(ap->slinkto, strlen(ap->slinkto), sp->a_uio);
|
1994-05-11 22:49:06 +04:00
|
|
|
#ifdef ADOSFS_DIAGNOSTIC
|
1996-10-13 06:52:06 +04:00
|
|
|
printf(" %d)", error);
|
1994-05-11 22:49:06 +04:00
|
|
|
#endif
|
1998-08-19 17:12:40 +04:00
|
|
|
return (error);
|
1994-05-11 22:49:06 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*ARGSUSED*/
|
|
|
|
int
|
1996-02-09 22:06:38 +03:00
|
|
|
adosfs_inactive(v)
|
|
|
|
void *v;
|
|
|
|
{
|
1994-06-18 00:06:05 +04:00
|
|
|
struct vop_inactive_args /* {
|
|
|
|
struct vnode *a_vp;
|
1998-03-01 05:20:01 +03:00
|
|
|
struct proc *a_p;
|
1996-02-09 22:06:38 +03:00
|
|
|
} */ *sp = v;
|
1998-03-01 05:20:01 +03:00
|
|
|
struct vnode *vp = sp->a_vp;
|
|
|
|
struct proc *p = sp->a_p;
|
1994-05-11 22:49:06 +04:00
|
|
|
#ifdef ADOSFS_DIAGNOSTIC
|
1994-06-18 00:06:05 +04:00
|
|
|
advopprint(sp);
|
1994-05-11 22:49:06 +04:00
|
|
|
#endif
|
1998-03-01 05:20:01 +03:00
|
|
|
VOP_UNLOCK(vp, 0);
|
|
|
|
/* XXX this needs to check if file was deleted */
|
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
|
|
|
vrecycle(vp, NULL, p);
|
1994-05-11 22:49:06 +04:00
|
|
|
|
|
|
|
#ifdef ADOSFS_DIAGNOSTIC
|
1996-10-13 06:52:06 +04:00
|
|
|
printf(" 0)");
|
1994-05-11 22:49:06 +04:00
|
|
|
#endif
|
|
|
|
return(0);
|
|
|
|
}
|
1996-02-09 22:06:38 +03:00
|
|
|
|
1994-06-18 00:06:05 +04:00
|
|
|
/*
|
|
|
|
* the kernel wants its vnode back.
|
|
|
|
* no lock needed we are being called from vclean()
|
|
|
|
*/
|
1994-05-11 22:49:06 +04:00
|
|
|
int
|
1996-02-09 22:06:38 +03:00
|
|
|
adosfs_reclaim(v)
|
|
|
|
void *v;
|
|
|
|
{
|
1994-06-18 00:06:05 +04:00
|
|
|
struct vop_reclaim_args /* {
|
|
|
|
struct vnode *a_vp;
|
1996-02-09 22:06:38 +03:00
|
|
|
} */ *sp = v;
|
1994-05-11 22:49:06 +04:00
|
|
|
struct vnode *vp;
|
|
|
|
struct anode *ap;
|
|
|
|
|
|
|
|
#ifdef ADOSFS_DIAGNOSTIC
|
1996-10-13 06:52:06 +04:00
|
|
|
printf("(reclaim 0)");
|
1994-05-11 22:49:06 +04:00
|
|
|
#endif
|
1994-06-18 00:06:05 +04:00
|
|
|
vp = sp->a_vp;
|
1994-05-11 22:49:06 +04:00
|
|
|
ap = VTOA(vp);
|
1994-06-18 00:06:05 +04:00
|
|
|
LIST_REMOVE(ap, link);
|
|
|
|
cache_purge(vp);
|
|
|
|
if (vp->v_type == VDIR && ap->tab)
|
|
|
|
free(ap->tab, M_ANODE);
|
|
|
|
else if (vp->v_type == VLNK && ap->slinkto)
|
|
|
|
free(ap->slinkto, M_ANODE);
|
1998-09-01 07:33:26 +04:00
|
|
|
pool_put(&adosfs_node_pool, ap);
|
1994-06-18 00:06:05 +04:00
|
|
|
vp->v_data = NULL;
|
|
|
|
return(0);
|
1994-05-11 22:49:06 +04:00
|
|
|
}
|
|
|
|
|
1994-06-18 00:06:05 +04:00
|
|
|
/*
|
|
|
|
* POSIX pathconf info, grabbed from kern/u fs, probably need to
|
|
|
|
* investigate exactly what each return type means as they are probably
|
|
|
|
* not valid currently
|
|
|
|
*/
|
1996-02-09 22:06:38 +03:00
|
|
|
int
|
|
|
|
adosfs_pathconf(v)
|
|
|
|
void *v;
|
|
|
|
{
|
1994-06-18 00:06:05 +04:00
|
|
|
struct vop_pathconf_args /* {
|
|
|
|
struct vnode *a_vp;
|
|
|
|
int a_name;
|
1994-10-20 07:22:35 +03:00
|
|
|
register_t *a_retval;
|
1996-02-09 22:06:38 +03:00
|
|
|
} */ *sp = v;
|
1994-05-11 22:49:06 +04:00
|
|
|
|
1994-06-18 00:06:05 +04:00
|
|
|
switch (sp->a_name) {
|
|
|
|
case _PC_LINK_MAX:
|
|
|
|
*sp->a_retval = LINK_MAX;
|
|
|
|
return (0);
|
|
|
|
case _PC_PIPE_BUF:
|
|
|
|
*sp->a_retval = PIPE_BUF;
|
|
|
|
return (0);
|
|
|
|
case _PC_CHOWN_RESTRICTED:
|
|
|
|
*sp->a_retval = 1;
|
|
|
|
return (0);
|
|
|
|
case _PC_VDISABLE:
|
|
|
|
*sp->a_retval = _POSIX_VDISABLE;
|
|
|
|
return (0);
|
1998-08-03 18:19:57 +04:00
|
|
|
case _PC_SYNC_IO:
|
|
|
|
*sp->a_retval = 1;
|
|
|
|
return (0);
|
1999-03-22 22:21:07 +03:00
|
|
|
case _PC_FILESIZEBITS:
|
|
|
|
*sp->a_retval = 32;
|
|
|
|
return (0);
|
1994-06-18 00:06:05 +04:00
|
|
|
default:
|
|
|
|
return (EINVAL);
|
|
|
|
}
|
|
|
|
/* NOTREACHED */
|
1994-05-11 22:49:06 +04:00
|
|
|
}
|