Home | History | Annotate | Line # | Download | only in lfs
lfs_vnops.c revision 1.25.2.5
      1  1.25.2.5        he /*	$NetBSD: lfs_vnops.c,v 1.25.2.5 2000/01/15 17:52:33 he Exp $	*/
      2       1.2       cgd 
      3      1.22  perseant /*-
      4      1.22  perseant  * Copyright (c) 1999 The NetBSD Foundation, Inc.
      5      1.22  perseant  * All rights reserved.
      6      1.22  perseant  *
      7      1.22  perseant  * This code is derived from software contributed to The NetBSD Foundation
      8      1.22  perseant  * by Konrad E. Schroder <perseant (at) hhhh.org>.
      9      1.22  perseant  *
     10      1.22  perseant  * Redistribution and use in source and binary forms, with or without
     11      1.22  perseant  * modification, are permitted provided that the following conditions
     12      1.22  perseant  * are met:
     13      1.22  perseant  * 1. Redistributions of source code must retain the above copyright
     14      1.22  perseant  *    notice, this list of conditions and the following disclaimer.
     15      1.22  perseant  * 2. Redistributions in binary form must reproduce the above copyright
     16      1.22  perseant  *    notice, this list of conditions and the following disclaimer in the
     17      1.22  perseant  *    documentation and/or other materials provided with the distribution.
     18      1.22  perseant  * 3. All advertising materials mentioning features or use of this software
     19      1.22  perseant  *    must display the following acknowledgement:
     20      1.22  perseant  *      This product includes software developed by the NetBSD
     21      1.22  perseant  *      Foundation, Inc. and its contributors.
     22      1.22  perseant  * 4. Neither the name of The NetBSD Foundation nor the names of its
     23      1.22  perseant  *    contributors may be used to endorse or promote products derived
     24      1.22  perseant  *    from this software without specific prior written permission.
     25      1.22  perseant  *
     26      1.22  perseant  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     27      1.22  perseant  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     28      1.22  perseant  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     29      1.22  perseant  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     30      1.22  perseant  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     31      1.22  perseant  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     32      1.22  perseant  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     33      1.22  perseant  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     34      1.22  perseant  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     35      1.22  perseant  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     36      1.22  perseant  * POSSIBILITY OF SUCH DAMAGE.
     37      1.22  perseant  */
     38       1.1   mycroft /*
     39      1.15      fvdl  * Copyright (c) 1986, 1989, 1991, 1993, 1995
     40       1.1   mycroft  *	The Regents of the University of California.  All rights reserved.
     41       1.1   mycroft  *
     42       1.1   mycroft  * Redistribution and use in source and binary forms, with or without
     43       1.1   mycroft  * modification, are permitted provided that the following conditions
     44       1.1   mycroft  * are met:
     45       1.1   mycroft  * 1. Redistributions of source code must retain the above copyright
     46       1.1   mycroft  *    notice, this list of conditions and the following disclaimer.
     47       1.1   mycroft  * 2. Redistributions in binary form must reproduce the above copyright
     48       1.1   mycroft  *    notice, this list of conditions and the following disclaimer in the
     49       1.1   mycroft  *    documentation and/or other materials provided with the distribution.
     50       1.1   mycroft  * 3. All advertising materials mentioning features or use of this software
     51       1.1   mycroft  *    must display the following acknowledgement:
     52       1.1   mycroft  *	This product includes software developed by the University of
     53       1.1   mycroft  *	California, Berkeley and its contributors.
     54       1.1   mycroft  * 4. Neither the name of the University nor the names of its contributors
     55       1.1   mycroft  *    may be used to endorse or promote products derived from this software
     56       1.1   mycroft  *    without specific prior written permission.
     57       1.1   mycroft  *
     58       1.1   mycroft  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     59       1.1   mycroft  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     60       1.1   mycroft  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     61       1.1   mycroft  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     62       1.1   mycroft  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     63       1.1   mycroft  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     64       1.1   mycroft  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     65       1.1   mycroft  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     66       1.1   mycroft  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     67       1.1   mycroft  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     68       1.1   mycroft  * SUCH DAMAGE.
     69       1.1   mycroft  *
     70      1.15      fvdl  *	@(#)lfs_vnops.c	8.13 (Berkeley) 6/10/95
     71       1.1   mycroft  */
     72      1.17  sommerfe 
     73       1.1   mycroft #include <sys/param.h>
     74       1.1   mycroft #include <sys/systm.h>
     75       1.1   mycroft #include <sys/namei.h>
     76       1.1   mycroft #include <sys/resourcevar.h>
     77       1.1   mycroft #include <sys/kernel.h>
     78       1.1   mycroft #include <sys/file.h>
     79       1.1   mycroft #include <sys/stat.h>
     80       1.1   mycroft #include <sys/buf.h>
     81       1.1   mycroft #include <sys/proc.h>
     82       1.1   mycroft #include <sys/conf.h>
     83       1.1   mycroft #include <sys/mount.h>
     84       1.1   mycroft #include <sys/vnode.h>
     85       1.1   mycroft #include <sys/malloc.h>
     86      1.19   thorpej #include <sys/pool.h>
     87      1.10  christos #include <sys/signalvar.h>
     88       1.1   mycroft 
     89       1.1   mycroft #include <vm/vm.h>
     90       1.1   mycroft 
     91      1.12   mycroft #include <miscfs/fifofs/fifo.h>
     92      1.12   mycroft #include <miscfs/genfs/genfs.h>
     93       1.1   mycroft #include <miscfs/specfs/specdev.h>
     94       1.1   mycroft 
     95       1.1   mycroft #include <ufs/ufs/quota.h>
     96       1.1   mycroft #include <ufs/ufs/inode.h>
     97       1.1   mycroft #include <ufs/ufs/dir.h>
     98       1.1   mycroft #include <ufs/ufs/ufsmount.h>
     99       1.1   mycroft #include <ufs/ufs/ufs_extern.h>
    100       1.1   mycroft 
    101       1.1   mycroft #include <ufs/lfs/lfs.h>
    102       1.1   mycroft #include <ufs/lfs/lfs_extern.h>
    103       1.1   mycroft 
    104       1.1   mycroft /* Global vfs data structures for lfs. */
    105      1.10  christos int (**lfs_vnodeop_p) __P((void *));
    106       1.1   mycroft struct vnodeopv_entry_desc lfs_vnodeop_entries[] = {
    107       1.1   mycroft 	{ &vop_default_desc, vn_default_error },
    108       1.1   mycroft 	{ &vop_lookup_desc, ufs_lookup },		/* lookup */
    109      1.22  perseant 	{ &vop_create_desc, lfs_create },		/* create */
    110      1.22  perseant 	{ &vop_whiteout_desc, lfs_whiteout },		/* whiteout */
    111      1.22  perseant 	{ &vop_mknod_desc, lfs_mknod },			/* mknod */
    112       1.1   mycroft 	{ &vop_open_desc, ufs_open },			/* open */
    113       1.1   mycroft 	{ &vop_close_desc, lfs_close },			/* close */
    114       1.1   mycroft 	{ &vop_access_desc, ufs_access },		/* access */
    115       1.1   mycroft 	{ &vop_getattr_desc, lfs_getattr },		/* getattr */
    116       1.1   mycroft 	{ &vop_setattr_desc, ufs_setattr },		/* setattr */
    117       1.1   mycroft 	{ &vop_read_desc, lfs_read },			/* read */
    118       1.1   mycroft 	{ &vop_write_desc, lfs_write },			/* write */
    119       1.4   mycroft 	{ &vop_lease_desc, ufs_lease_check },		/* lease */
    120       1.1   mycroft 	{ &vop_ioctl_desc, ufs_ioctl },			/* ioctl */
    121      1.13   mycroft 	{ &vop_poll_desc, ufs_poll },			/* poll */
    122      1.15      fvdl 	{ &vop_revoke_desc, ufs_revoke },		/* revoke */
    123       1.1   mycroft 	{ &vop_mmap_desc, ufs_mmap },			/* mmap */
    124       1.1   mycroft 	{ &vop_fsync_desc, lfs_fsync },			/* fsync */
    125       1.1   mycroft 	{ &vop_seek_desc, ufs_seek },			/* seek */
    126      1.22  perseant 	{ &vop_remove_desc, lfs_remove },		/* remove */
    127      1.22  perseant 	{ &vop_link_desc, lfs_link },			/* link */
    128      1.22  perseant 	{ &vop_rename_desc, lfs_rename },		/* rename */
    129      1.22  perseant 	{ &vop_mkdir_desc, lfs_mkdir },			/* mkdir */
    130      1.22  perseant 	{ &vop_rmdir_desc, lfs_rmdir },			/* rmdir */
    131      1.22  perseant 	{ &vop_symlink_desc, lfs_symlink },		/* symlink */
    132       1.1   mycroft 	{ &vop_readdir_desc, ufs_readdir },		/* readdir */
    133       1.1   mycroft 	{ &vop_readlink_desc, ufs_readlink },		/* readlink */
    134       1.1   mycroft 	{ &vop_abortop_desc, ufs_abortop },		/* abortop */
    135      1.15      fvdl 	{ &vop_inactive_desc, ufs_inactive },		/* inactive */
    136       1.1   mycroft 	{ &vop_reclaim_desc, lfs_reclaim },		/* reclaim */
    137       1.1   mycroft 	{ &vop_lock_desc, ufs_lock },			/* lock */
    138       1.1   mycroft 	{ &vop_unlock_desc, ufs_unlock },		/* unlock */
    139       1.1   mycroft 	{ &vop_bmap_desc, ufs_bmap },			/* bmap */
    140       1.1   mycroft 	{ &vop_strategy_desc, ufs_strategy },		/* strategy */
    141       1.1   mycroft 	{ &vop_print_desc, ufs_print },			/* print */
    142       1.1   mycroft 	{ &vop_islocked_desc, ufs_islocked },		/* islocked */
    143       1.1   mycroft 	{ &vop_pathconf_desc, ufs_pathconf },		/* pathconf */
    144       1.1   mycroft 	{ &vop_advlock_desc, ufs_advlock },		/* advlock */
    145       1.1   mycroft 	{ &vop_blkatoff_desc, lfs_blkatoff },		/* blkatoff */
    146       1.1   mycroft 	{ &vop_valloc_desc, lfs_valloc },		/* valloc */
    147       1.1   mycroft 	{ &vop_vfree_desc, lfs_vfree },			/* vfree */
    148       1.1   mycroft 	{ &vop_truncate_desc, lfs_truncate },		/* truncate */
    149       1.1   mycroft 	{ &vop_update_desc, lfs_update },		/* update */
    150       1.1   mycroft 	{ &vop_bwrite_desc, lfs_bwrite },		/* bwrite */
    151      1.10  christos 	{ (struct vnodeop_desc*)NULL, (int(*) __P((void *)))NULL }
    152       1.1   mycroft };
    153       1.1   mycroft struct vnodeopv_desc lfs_vnodeop_opv_desc =
    154       1.1   mycroft 	{ &lfs_vnodeop_p, lfs_vnodeop_entries };
    155       1.1   mycroft 
    156      1.10  christos int (**lfs_specop_p) __P((void *));
    157       1.1   mycroft struct vnodeopv_entry_desc lfs_specop_entries[] = {
    158       1.1   mycroft 	{ &vop_default_desc, vn_default_error },
    159       1.1   mycroft 	{ &vop_lookup_desc, spec_lookup },		/* lookup */
    160       1.1   mycroft 	{ &vop_create_desc, spec_create },		/* create */
    161       1.1   mycroft 	{ &vop_mknod_desc, spec_mknod },		/* mknod */
    162       1.1   mycroft 	{ &vop_open_desc, spec_open },			/* open */
    163       1.1   mycroft 	{ &vop_close_desc, ufsspec_close },		/* close */
    164       1.1   mycroft 	{ &vop_access_desc, ufs_access },		/* access */
    165       1.1   mycroft 	{ &vop_getattr_desc, lfs_getattr },		/* getattr */
    166       1.1   mycroft 	{ &vop_setattr_desc, ufs_setattr },		/* setattr */
    167       1.1   mycroft 	{ &vop_read_desc, ufsspec_read },		/* read */
    168       1.1   mycroft 	{ &vop_write_desc, ufsspec_write },		/* write */
    169       1.4   mycroft 	{ &vop_lease_desc, spec_lease_check },		/* lease */
    170       1.1   mycroft 	{ &vop_ioctl_desc, spec_ioctl },		/* ioctl */
    171      1.13   mycroft 	{ &vop_poll_desc, spec_poll },			/* poll */
    172      1.15      fvdl 	{ &vop_revoke_desc, spec_revoke },		/* revoke */
    173       1.1   mycroft 	{ &vop_mmap_desc, spec_mmap },			/* mmap */
    174       1.1   mycroft 	{ &vop_fsync_desc, spec_fsync },		/* fsync */
    175       1.1   mycroft 	{ &vop_seek_desc, spec_seek },			/* seek */
    176       1.1   mycroft 	{ &vop_remove_desc, spec_remove },		/* remove */
    177       1.1   mycroft 	{ &vop_link_desc, spec_link },			/* link */
    178       1.1   mycroft 	{ &vop_rename_desc, spec_rename },		/* rename */
    179       1.1   mycroft 	{ &vop_mkdir_desc, spec_mkdir },		/* mkdir */
    180       1.1   mycroft 	{ &vop_rmdir_desc, spec_rmdir },		/* rmdir */
    181       1.1   mycroft 	{ &vop_symlink_desc, spec_symlink },		/* symlink */
    182       1.1   mycroft 	{ &vop_readdir_desc, spec_readdir },		/* readdir */
    183       1.1   mycroft 	{ &vop_readlink_desc, spec_readlink },		/* readlink */
    184       1.1   mycroft 	{ &vop_abortop_desc, spec_abortop },		/* abortop */
    185      1.15      fvdl 	{ &vop_inactive_desc, ufs_inactive },		/* inactive */
    186       1.1   mycroft 	{ &vop_reclaim_desc, lfs_reclaim },		/* reclaim */
    187       1.1   mycroft 	{ &vop_lock_desc, ufs_lock },			/* lock */
    188       1.1   mycroft 	{ &vop_unlock_desc, ufs_unlock },		/* unlock */
    189       1.1   mycroft 	{ &vop_bmap_desc, spec_bmap },			/* bmap */
    190       1.1   mycroft 	{ &vop_strategy_desc, spec_strategy },		/* strategy */
    191       1.1   mycroft 	{ &vop_print_desc, ufs_print },			/* print */
    192       1.1   mycroft 	{ &vop_islocked_desc, ufs_islocked },		/* islocked */
    193       1.1   mycroft 	{ &vop_pathconf_desc, spec_pathconf },		/* pathconf */
    194       1.1   mycroft 	{ &vop_advlock_desc, spec_advlock },		/* advlock */
    195       1.1   mycroft 	{ &vop_blkatoff_desc, spec_blkatoff },		/* blkatoff */
    196       1.1   mycroft 	{ &vop_valloc_desc, spec_valloc },		/* valloc */
    197       1.1   mycroft 	{ &vop_vfree_desc, lfs_vfree },			/* vfree */
    198       1.1   mycroft 	{ &vop_truncate_desc, spec_truncate },		/* truncate */
    199       1.1   mycroft 	{ &vop_update_desc, lfs_update },		/* update */
    200  1.25.2.5        he 	{ &vop_bwrite_desc, vn_bwrite },		/* bwrite */
    201      1.10  christos 	{ (struct vnodeop_desc*)NULL, (int(*) __P((void *)))NULL }
    202       1.1   mycroft };
    203       1.1   mycroft struct vnodeopv_desc lfs_specop_opv_desc =
    204       1.1   mycroft 	{ &lfs_specop_p, lfs_specop_entries };
    205       1.1   mycroft 
    206      1.10  christos int (**lfs_fifoop_p) __P((void *));
    207       1.1   mycroft struct vnodeopv_entry_desc lfs_fifoop_entries[] = {
    208       1.1   mycroft 	{ &vop_default_desc, vn_default_error },
    209       1.1   mycroft 	{ &vop_lookup_desc, fifo_lookup },		/* lookup */
    210       1.1   mycroft 	{ &vop_create_desc, fifo_create },		/* create */
    211       1.1   mycroft 	{ &vop_mknod_desc, fifo_mknod },		/* mknod */
    212       1.1   mycroft 	{ &vop_open_desc, fifo_open },			/* open */
    213       1.1   mycroft 	{ &vop_close_desc, ufsfifo_close },		/* close */
    214       1.1   mycroft 	{ &vop_access_desc, ufs_access },		/* access */
    215       1.1   mycroft 	{ &vop_getattr_desc, lfs_getattr },		/* getattr */
    216       1.1   mycroft 	{ &vop_setattr_desc, ufs_setattr },		/* setattr */
    217       1.1   mycroft 	{ &vop_read_desc, ufsfifo_read },		/* read */
    218       1.1   mycroft 	{ &vop_write_desc, ufsfifo_write },		/* write */
    219       1.4   mycroft 	{ &vop_lease_desc, fifo_lease_check },		/* lease */
    220       1.1   mycroft 	{ &vop_ioctl_desc, fifo_ioctl },		/* ioctl */
    221      1.13   mycroft 	{ &vop_poll_desc, fifo_poll },			/* poll */
    222      1.15      fvdl 	{ &vop_revoke_desc, fifo_revoke },		/* revoke */
    223       1.1   mycroft 	{ &vop_mmap_desc, fifo_mmap },			/* mmap */
    224       1.1   mycroft 	{ &vop_fsync_desc, fifo_fsync },		/* fsync */
    225       1.1   mycroft 	{ &vop_seek_desc, fifo_seek },			/* seek */
    226       1.1   mycroft 	{ &vop_remove_desc, fifo_remove },		/* remove */
    227       1.1   mycroft 	{ &vop_link_desc, fifo_link },			/* link */
    228       1.1   mycroft 	{ &vop_rename_desc, fifo_rename },		/* rename */
    229       1.1   mycroft 	{ &vop_mkdir_desc, fifo_mkdir },		/* mkdir */
    230       1.1   mycroft 	{ &vop_rmdir_desc, fifo_rmdir },		/* rmdir */
    231       1.1   mycroft 	{ &vop_symlink_desc, fifo_symlink },		/* symlink */
    232       1.1   mycroft 	{ &vop_readdir_desc, fifo_readdir },		/* readdir */
    233       1.1   mycroft 	{ &vop_readlink_desc, fifo_readlink },		/* readlink */
    234       1.1   mycroft 	{ &vop_abortop_desc, fifo_abortop },		/* abortop */
    235      1.15      fvdl 	{ &vop_inactive_desc, ufs_inactive },		/* inactive */
    236       1.1   mycroft 	{ &vop_reclaim_desc, lfs_reclaim },		/* reclaim */
    237       1.1   mycroft 	{ &vop_lock_desc, ufs_lock },			/* lock */
    238       1.1   mycroft 	{ &vop_unlock_desc, ufs_unlock },		/* unlock */
    239       1.1   mycroft 	{ &vop_bmap_desc, fifo_bmap },			/* bmap */
    240       1.1   mycroft 	{ &vop_strategy_desc, fifo_strategy },		/* strategy */
    241       1.1   mycroft 	{ &vop_print_desc, ufs_print },			/* print */
    242       1.1   mycroft 	{ &vop_islocked_desc, ufs_islocked },		/* islocked */
    243       1.1   mycroft 	{ &vop_pathconf_desc, fifo_pathconf },		/* pathconf */
    244       1.1   mycroft 	{ &vop_advlock_desc, fifo_advlock },		/* advlock */
    245       1.1   mycroft 	{ &vop_blkatoff_desc, fifo_blkatoff },		/* blkatoff */
    246       1.1   mycroft 	{ &vop_valloc_desc, fifo_valloc },		/* valloc */
    247       1.1   mycroft 	{ &vop_vfree_desc, lfs_vfree },			/* vfree */
    248       1.1   mycroft 	{ &vop_truncate_desc, fifo_truncate },		/* truncate */
    249       1.1   mycroft 	{ &vop_update_desc, lfs_update },		/* update */
    250       1.1   mycroft 	{ &vop_bwrite_desc, lfs_bwrite },		/* bwrite */
    251      1.10  christos 	{ (struct vnodeop_desc*)NULL, (int(*) __P((void *)))NULL }
    252       1.1   mycroft };
    253       1.1   mycroft struct vnodeopv_desc lfs_fifoop_opv_desc =
    254       1.1   mycroft 	{ &lfs_fifoop_p, lfs_fifoop_entries };
    255       1.1   mycroft 
    256       1.1   mycroft #define	LFS_READWRITE
    257       1.1   mycroft #include <ufs/ufs/ufs_readwrite.c>
    258       1.1   mycroft #undef	LFS_READWRITE
    259       1.1   mycroft 
    260       1.1   mycroft /*
    261       1.1   mycroft  * Synch an open file.
    262       1.1   mycroft  */
    263       1.1   mycroft /* ARGSUSED */
    264      1.10  christos int
    265      1.10  christos lfs_fsync(v)
    266      1.10  christos 	void *v;
    267      1.10  christos {
    268       1.1   mycroft 	struct vop_fsync_args /* {
    269       1.1   mycroft 		struct vnode *a_vp;
    270       1.1   mycroft 		struct ucred *a_cred;
    271      1.22  perseant 		int a_flags;
    272       1.1   mycroft 		struct proc *a_p;
    273      1.10  christos 	} */ *ap = v;
    274      1.22  perseant 
    275      1.21   mycroft 	return (VOP_UPDATE(ap->a_vp, NULL, NULL,
    276      1.22  perseant 			   (ap->a_flags & FSYNC_WAIT) != 0 ? LFS_SYNC : 0)); /* XXX */
    277       1.1   mycroft }
    278       1.1   mycroft 
    279       1.1   mycroft /*
    280       1.1   mycroft  * These macros are used to bracket UFS directory ops, so that we can
    281       1.1   mycroft  * identify all the pages touched during directory ops which need to
    282       1.1   mycroft  * be ordered and flushed atomically, so that they may be recovered.
    283       1.1   mycroft  */
    284      1.22  perseant /*
    285      1.22  perseant  * XXX KS - Because we have to mark nodes VDIROP in order to prevent
    286      1.22  perseant  * the cache from reclaiming them while a dirop is in progress, we must
    287      1.22  perseant  * also manage the number of nodes so marked (otherwise we can run out).
    288      1.22  perseant  * We do this by setting lfs_dirvcount to the number of marked vnodes; it
    289      1.22  perseant  * is decremented during segment write, when VDIROP is taken off.
    290      1.22  perseant  */
    291      1.24  perseant #define	SET_DIROP(fs) lfs_set_dirop(fs)
    292      1.24  perseant static int lfs_set_dirop __P((struct lfs *));
    293  1.25.2.3        he extern int lfs_dirvcount;
    294      1.24  perseant 
    295      1.24  perseant static int lfs_set_dirop(fs)
    296      1.24  perseant 	struct lfs *fs;
    297      1.24  perseant {
    298      1.24  perseant 	int error;
    299      1.24  perseant 
    300  1.25.2.3        he 	while (fs->lfs_writer || lfs_dirvcount>LFS_MAXDIROP) {
    301      1.24  perseant 		if(fs->lfs_writer)
    302      1.24  perseant 			tsleep(&fs->lfs_dirops, PRIBIO + 1, "lfs_dirop", 0);
    303  1.25.2.4        he 		if(lfs_dirvcount > LFS_MAXDIROP && fs->lfs_dirops==0) {
    304  1.25.2.4        he                 	++fs->lfs_writer;
    305  1.25.2.4        he                 	lfs_flush(fs, 0);
    306  1.25.2.4        he                 	if(--fs->lfs_writer==0)
    307  1.25.2.4        he                         	wakeup(&fs->lfs_dirops);
    308  1.25.2.4        he 		}
    309  1.25.2.4        he 
    310  1.25.2.3        he 		if(lfs_dirvcount > LFS_MAXDIROP) {
    311      1.24  perseant #ifdef DEBUG_LFS
    312  1.25.2.4        he 			printf("lfs_set_dirop: sleeping with dirops=%d, dirvcount=%d\n",fs->lfs_dirops,lfs_dirvcount);
    313      1.24  perseant #endif
    314  1.25.2.3        he 			if((error=tsleep(&lfs_dirvcount, PCATCH|PUSER, "lfs_maxdirop", 0))!=0)
    315      1.24  perseant 				return error;
    316      1.24  perseant 		}
    317      1.24  perseant 	}
    318      1.24  perseant 	++fs->lfs_dirops;
    319      1.24  perseant 	fs->lfs_doifile = 1;
    320      1.24  perseant 
    321      1.24  perseant 	return 0;
    322       1.1   mycroft }
    323       1.1   mycroft 
    324  1.25.2.1  perseant #define	SET_ENDOP(fs,vp,str) {						\
    325       1.1   mycroft 	--(fs)->lfs_dirops;						\
    326      1.22  perseant 	if (!(fs)->lfs_dirops) {					\
    327       1.1   mycroft 		wakeup(&(fs)->lfs_writer);				\
    328  1.25.2.1  perseant 		lfs_check((vp),LFS_UNUSED_LBN,0);			\
    329      1.22  perseant 	}								\
    330       1.1   mycroft }
    331       1.1   mycroft 
    332      1.22  perseant #define	MARK_VNODE(dvp)  do {                                           \
    333      1.22  perseant         if(!((dvp)->v_flag & VDIROP)) {					\
    334      1.22  perseant                 lfs_vref(dvp);						\
    335  1.25.2.3        he 		++lfs_dirvcount;					\
    336      1.22  perseant 	}								\
    337      1.22  perseant         (dvp)->v_flag |= VDIROP;					\
    338      1.22  perseant } while(0)
    339      1.15      fvdl 
    340      1.24  perseant #define MAYBE_INACTIVE(fs,vp) do {                                      \
    341      1.24  perseant         if((vp) && ((vp)->v_flag & VDIROP) && (vp)->v_usecount == 1     \
    342      1.24  perseant            && VTOI(vp) && VTOI(vp)->i_ffs_nlink == 0)                   \
    343      1.24  perseant         {                                                               \
    344      1.24  perseant 		if (VOP_LOCK((vp), LK_EXCLUSIVE) == 0) { 		\
    345      1.24  perseant                         VOP_INACTIVE((vp),curproc);                     \
    346      1.24  perseant 		}                                                       \
    347      1.24  perseant         }                                                               \
    348      1.24  perseant } while(0)
    349      1.24  perseant 
    350       1.1   mycroft int
    351      1.10  christos lfs_symlink(v)
    352      1.10  christos 	void *v;
    353      1.10  christos {
    354       1.1   mycroft 	struct vop_symlink_args /* {
    355       1.1   mycroft 		struct vnode *a_dvp;
    356       1.1   mycroft 		struct vnode **a_vpp;
    357       1.1   mycroft 		struct componentname *a_cnp;
    358       1.1   mycroft 		struct vattr *a_vap;
    359       1.1   mycroft 		char *a_target;
    360      1.10  christos 	} */ *ap = v;
    361       1.1   mycroft 	int ret;
    362       1.1   mycroft 
    363      1.24  perseant 	if((ret=SET_DIROP(VTOI(ap->a_dvp)->i_lfs))!=0)
    364      1.24  perseant 		return ret;
    365       1.1   mycroft 	MARK_VNODE(ap->a_dvp);
    366       1.1   mycroft 	ret = ufs_symlink(ap);
    367      1.24  perseant 	MAYBE_INACTIVE(VTOI(ap->a_dvp)->i_lfs,*(ap->a_vpp)); /* XXX KS */
    368  1.25.2.1  perseant 	SET_ENDOP(VTOI(ap->a_dvp)->i_lfs,ap->a_dvp,"symilnk");
    369       1.1   mycroft 	return (ret);
    370       1.1   mycroft }
    371       1.1   mycroft 
    372       1.1   mycroft int
    373      1.10  christos lfs_mknod(v)
    374      1.10  christos 	void *v;
    375      1.10  christos {
    376      1.22  perseant 	struct vop_mknod_args	/* {
    377       1.1   mycroft 		struct vnode *a_dvp;
    378       1.1   mycroft 		struct vnode **a_vpp;
    379       1.1   mycroft 		struct componentname *a_cnp;
    380       1.1   mycroft 		struct vattr *a_vap;
    381      1.22  perseant 		} */ *ap = v;
    382  1.25.2.5        he         struct vattr *vap = ap->a_vap;
    383  1.25.2.5        he         struct vnode **vpp = ap->a_vpp;
    384  1.25.2.5        he         struct inode *ip;
    385  1.25.2.5        he         int error;
    386       1.1   mycroft 
    387  1.25.2.5        he 	if((error=SET_DIROP(VTOI(ap->a_dvp)->i_lfs))!=0)
    388  1.25.2.5        he 		return error;
    389       1.1   mycroft 	MARK_VNODE(ap->a_dvp);
    390  1.25.2.5        he 	error = ufs_makeinode(MAKEIMODE(vap->va_type, vap->va_mode),
    391  1.25.2.5        he             ap->a_dvp, vpp, ap->a_cnp);
    392  1.25.2.5        he 
    393  1.25.2.5        he 	/* Either way we're done with the dirop at this point */
    394  1.25.2.1  perseant 	SET_ENDOP(VTOI(ap->a_dvp)->i_lfs,ap->a_dvp,"mknod");
    395  1.25.2.5        he 
    396  1.25.2.5        he         if (error)
    397  1.25.2.5        he 		return (error);
    398  1.25.2.5        he 
    399  1.25.2.5        he         ip = VTOI(*vpp);
    400  1.25.2.5        he         ip->i_flag |= IN_ACCESS | IN_CHANGE | IN_UPDATE;
    401  1.25.2.5        he         if (vap->va_rdev != VNOVAL) {
    402  1.25.2.5        he                 /*
    403  1.25.2.5        he                  * Want to be able to use this to make badblock
    404  1.25.2.5        he                  * inodes, so don't truncate the dev number.
    405  1.25.2.5        he                  */
    406  1.25.2.5        he #if 0
    407  1.25.2.5        he                 ip->i_ffs_rdev = ufs_rw32(vap->va_rdev,
    408  1.25.2.5        he                     UFS_MPNEEDSWAP((*vpp)->v_mount));
    409  1.25.2.5        he #else
    410  1.25.2.5        he                 ip->i_ffs_rdev = vap->va_rdev;
    411  1.25.2.5        he #endif
    412  1.25.2.5        he         }
    413  1.25.2.5        he 	/*
    414  1.25.2.5        he 	 * Call fsync to write the vnode so that we don't have to deal with
    415  1.25.2.5        he 	 * flushing it when it's marked VDIROP|VXLOCK.
    416  1.25.2.5        he 	 *
    417  1.25.2.5        he 	 * XXX KS - If we can't flush we also can't call vgone(), so must
    418  1.25.2.5        he 	 * return.  But, that leaves this vnode in limbo, also not good.
    419  1.25.2.5        he 	 * Can this ever happen (barring hardware failure)?
    420  1.25.2.5        he 	 */
    421  1.25.2.5        he 	if ((error = VOP_FSYNC(*vpp, NOCRED, FSYNC_WAIT, curproc)) != 0)
    422  1.25.2.5        he 		return (error);
    423  1.25.2.5        he         /*
    424  1.25.2.5        he          * Remove inode so that it will be reloaded by VFS_VGET and
    425  1.25.2.5        he          * checked to see if it is an alias of an existing entry in
    426  1.25.2.5        he          * the inode cache.
    427  1.25.2.5        he          */
    428  1.25.2.5        he 	/* Used to be vput, but that causes us to call VOP_INACTIVE twice. */
    429  1.25.2.5        he 	VOP_UNLOCK(*vpp,0);
    430  1.25.2.5        he 	lfs_vunref(*vpp);
    431  1.25.2.5        he         (*vpp)->v_type = VNON;
    432  1.25.2.5        he         vgone(*vpp);
    433  1.25.2.5        he         *vpp = 0;
    434  1.25.2.5        he         return (0);
    435       1.1   mycroft }
    436       1.1   mycroft 
    437       1.1   mycroft int
    438      1.10  christos lfs_create(v)
    439      1.10  christos 	void *v;
    440      1.10  christos {
    441      1.22  perseant 	struct vop_create_args	/* {
    442       1.1   mycroft 		struct vnode *a_dvp;
    443       1.1   mycroft 		struct vnode **a_vpp;
    444       1.1   mycroft 		struct componentname *a_cnp;
    445       1.1   mycroft 		struct vattr *a_vap;
    446      1.10  christos 	} */ *ap = v;
    447       1.1   mycroft 	int ret;
    448       1.1   mycroft 
    449      1.24  perseant 	if((ret=SET_DIROP(VTOI(ap->a_dvp)->i_lfs))!=0)
    450      1.24  perseant 		return ret;
    451       1.1   mycroft 	MARK_VNODE(ap->a_dvp);
    452       1.1   mycroft 	ret = ufs_create(ap);
    453      1.24  perseant 	MAYBE_INACTIVE(VTOI(ap->a_dvp)->i_lfs,*(ap->a_vpp)); /* XXX KS */
    454  1.25.2.1  perseant 	SET_ENDOP(VTOI(ap->a_dvp)->i_lfs,ap->a_dvp,"create");
    455       1.1   mycroft 	return (ret);
    456       1.1   mycroft }
    457       1.1   mycroft 
    458       1.1   mycroft int
    459      1.22  perseant lfs_whiteout(v)
    460      1.22  perseant 	void *v;
    461      1.22  perseant {
    462      1.22  perseant 	struct vop_whiteout_args /* {
    463      1.22  perseant 		struct vnode *a_dvp;
    464      1.22  perseant 		struct componentname *a_cnp;
    465      1.22  perseant 		int a_flags;
    466      1.22  perseant 	} */ *ap = v;
    467      1.22  perseant 	int ret;
    468      1.22  perseant 
    469      1.24  perseant 	if((ret=SET_DIROP(VTOI(ap->a_dvp)->i_lfs))!=0)
    470      1.24  perseant 		return ret;
    471      1.22  perseant 	MARK_VNODE(ap->a_dvp);
    472      1.22  perseant 	ret = ufs_whiteout(ap);
    473  1.25.2.1  perseant 	SET_ENDOP(VTOI(ap->a_dvp)->i_lfs,ap->a_dvp,"whiteout");
    474      1.22  perseant 	return (ret);
    475      1.22  perseant }
    476      1.22  perseant 
    477      1.22  perseant int
    478      1.10  christos lfs_mkdir(v)
    479      1.10  christos 	void *v;
    480      1.10  christos {
    481      1.22  perseant 	struct vop_mkdir_args	/* {
    482       1.1   mycroft 		struct vnode *a_dvp;
    483       1.1   mycroft 		struct vnode **a_vpp;
    484       1.1   mycroft 		struct componentname *a_cnp;
    485       1.1   mycroft 		struct vattr *a_vap;
    486      1.10  christos 	} */ *ap = v;
    487       1.1   mycroft 	int ret;
    488       1.1   mycroft 
    489      1.24  perseant 	if((ret=SET_DIROP(VTOI(ap->a_dvp)->i_lfs))!=0)
    490      1.24  perseant 		return ret;
    491       1.1   mycroft 	MARK_VNODE(ap->a_dvp);
    492       1.1   mycroft 	ret = ufs_mkdir(ap);
    493      1.24  perseant 	MAYBE_INACTIVE(VTOI(ap->a_dvp)->i_lfs,*(ap->a_vpp)); /* XXX KS */
    494  1.25.2.1  perseant 	SET_ENDOP(VTOI(ap->a_dvp)->i_lfs,ap->a_dvp,"mkdir");
    495       1.1   mycroft 	return (ret);
    496       1.1   mycroft }
    497       1.1   mycroft 
    498       1.1   mycroft int
    499      1.10  christos lfs_remove(v)
    500      1.10  christos 	void *v;
    501      1.10  christos {
    502      1.22  perseant 	struct vop_remove_args	/* {
    503       1.1   mycroft 		struct vnode *a_dvp;
    504       1.1   mycroft 		struct vnode *a_vp;
    505       1.1   mycroft 		struct componentname *a_cnp;
    506      1.10  christos 	} */ *ap = v;
    507       1.1   mycroft 	int ret;
    508      1.24  perseant 	if((ret=SET_DIROP(VTOI(ap->a_dvp)->i_lfs))!=0)
    509      1.24  perseant 		return ret;
    510       1.1   mycroft 	MARK_VNODE(ap->a_dvp);
    511       1.1   mycroft 	MARK_VNODE(ap->a_vp);
    512       1.1   mycroft 	ret = ufs_remove(ap);
    513      1.24  perseant 	MAYBE_INACTIVE(VTOI(ap->a_dvp)->i_lfs,ap->a_vp);
    514  1.25.2.1  perseant 	SET_ENDOP(VTOI(ap->a_dvp)->i_lfs,ap->a_dvp,"remove");
    515       1.1   mycroft 	return (ret);
    516       1.1   mycroft }
    517       1.1   mycroft 
    518       1.1   mycroft int
    519      1.10  christos lfs_rmdir(v)
    520      1.10  christos 	void *v;
    521      1.10  christos {
    522      1.22  perseant 	struct vop_rmdir_args	/* {
    523       1.1   mycroft 		struct vnodeop_desc *a_desc;
    524       1.1   mycroft 		struct vnode *a_dvp;
    525       1.1   mycroft 		struct vnode *a_vp;
    526       1.1   mycroft 		struct componentname *a_cnp;
    527      1.10  christos 	} */ *ap = v;
    528       1.1   mycroft 	int ret;
    529       1.1   mycroft 
    530      1.24  perseant 	if((ret=SET_DIROP(VTOI(ap->a_dvp)->i_lfs))!=0)
    531      1.24  perseant 		return ret;
    532       1.1   mycroft 	MARK_VNODE(ap->a_dvp);
    533       1.1   mycroft 	MARK_VNODE(ap->a_vp);
    534       1.1   mycroft 	ret = ufs_rmdir(ap);
    535      1.24  perseant 	MAYBE_INACTIVE(VTOI(ap->a_dvp)->i_lfs,ap->a_vp);
    536  1.25.2.1  perseant 	SET_ENDOP(VTOI(ap->a_dvp)->i_lfs,ap->a_dvp,"rmdir");
    537       1.1   mycroft 	return (ret);
    538       1.1   mycroft }
    539       1.1   mycroft 
    540       1.1   mycroft int
    541      1.10  christos lfs_link(v)
    542      1.10  christos 	void *v;
    543      1.10  christos {
    544      1.22  perseant 	struct vop_link_args	/* {
    545       1.9   mycroft 		struct vnode *a_dvp;
    546       1.1   mycroft 		struct vnode *a_vp;
    547       1.1   mycroft 		struct componentname *a_cnp;
    548      1.10  christos 	} */ *ap = v;
    549       1.1   mycroft 	int ret;
    550       1.1   mycroft 
    551      1.24  perseant 	if((ret=SET_DIROP(VTOI(ap->a_dvp)->i_lfs))!=0)
    552      1.24  perseant 		return ret;
    553       1.9   mycroft 	MARK_VNODE(ap->a_dvp);
    554       1.1   mycroft 	ret = ufs_link(ap);
    555  1.25.2.1  perseant 	SET_ENDOP(VTOI(ap->a_dvp)->i_lfs,ap->a_dvp,"link");
    556       1.1   mycroft 	return (ret);
    557       1.1   mycroft }
    558      1.22  perseant 
    559       1.1   mycroft int
    560      1.10  christos lfs_rename(v)
    561      1.10  christos 	void *v;
    562      1.10  christos {
    563      1.22  perseant 	struct vop_rename_args	/* {
    564       1.1   mycroft 		struct vnode *a_fdvp;
    565       1.1   mycroft 		struct vnode *a_fvp;
    566       1.1   mycroft 		struct componentname *a_fcnp;
    567       1.1   mycroft 		struct vnode *a_tdvp;
    568       1.1   mycroft 		struct vnode *a_tvp;
    569       1.1   mycroft 		struct componentname *a_tcnp;
    570      1.10  christos 	} */ *ap = v;
    571  1.25.2.2       cgd 	struct vnode *tvp, *fvp, *tdvp, *fdvp;
    572  1.25.2.2       cgd 	int error;
    573  1.25.2.2       cgd 	struct lfs *fs;
    574  1.25.2.2       cgd 
    575  1.25.2.2       cgd 	fs = VTOI(ap->a_fdvp)->i_lfs;
    576  1.25.2.2       cgd 	tvp = ap->a_tvp;
    577  1.25.2.2       cgd 	tdvp = ap->a_tdvp;
    578  1.25.2.2       cgd 	fvp = ap->a_fvp;
    579  1.25.2.2       cgd 	fdvp = ap->a_fdvp;
    580  1.25.2.2       cgd 
    581  1.25.2.2       cgd 	/*
    582  1.25.2.2       cgd 	 * Check for cross-device rename.
    583  1.25.2.2       cgd 	 * If it is, we don't want to set dirops, just error out.
    584  1.25.2.2       cgd 	 * (In particular note that MARK_VNODE(tdvp) will DTWT on
    585  1.25.2.2       cgd 	 * a cross-device rename.)
    586  1.25.2.2       cgd 	 *
    587  1.25.2.2       cgd 	 * Copied from ufs_rename.
    588  1.25.2.2       cgd 	 */
    589  1.25.2.2       cgd 	if ((fvp->v_mount != tdvp->v_mount) ||
    590  1.25.2.2       cgd 	    (tvp && (fvp->v_mount != tvp->v_mount))) {
    591  1.25.2.2       cgd 		error = EXDEV;
    592  1.25.2.2       cgd 		VOP_ABORTOP(tdvp, ap->a_tcnp); /* XXX, why not in NFS? */
    593  1.25.2.2       cgd 		if (tdvp == tvp)
    594  1.25.2.2       cgd 			vrele(tdvp);
    595  1.25.2.2       cgd 		else
    596  1.25.2.2       cgd 			vput(tdvp);
    597  1.25.2.2       cgd 		if (tvp)
    598  1.25.2.2       cgd 			vput(tvp);
    599  1.25.2.2       cgd 		VOP_ABORTOP(fdvp, ap->a_fcnp); /* XXX, why not in NFS? */
    600  1.25.2.2       cgd 		vrele(fdvp);
    601  1.25.2.2       cgd 		vrele(fvp);
    602  1.25.2.2       cgd 		return (error);
    603  1.25.2.2       cgd 	}
    604  1.25.2.2       cgd 	if((error=SET_DIROP(fs))!=0)
    605  1.25.2.2       cgd 		return (error);
    606  1.25.2.2       cgd 	MARK_VNODE(fdvp);
    607  1.25.2.2       cgd 	MARK_VNODE(tdvp);
    608  1.25.2.2       cgd 	error = ufs_rename(ap);
    609  1.25.2.2       cgd 	MAYBE_INACTIVE(fs,fvp);
    610  1.25.2.2       cgd 	MAYBE_INACTIVE(fs,tvp);
    611  1.25.2.2       cgd 	SET_ENDOP(fs,fdvp,"rename");
    612  1.25.2.2       cgd 	return (error);
    613       1.1   mycroft }
    614      1.22  perseant 
    615       1.1   mycroft /* XXX hack to avoid calling ITIMES in getattr */
    616       1.1   mycroft int
    617      1.10  christos lfs_getattr(v)
    618      1.10  christos 	void *v;
    619      1.10  christos {
    620       1.1   mycroft 	struct vop_getattr_args /* {
    621       1.1   mycroft 		struct vnode *a_vp;
    622       1.1   mycroft 		struct vattr *a_vap;
    623       1.1   mycroft 		struct ucred *a_cred;
    624       1.1   mycroft 		struct proc *a_p;
    625      1.10  christos 	} */ *ap = v;
    626       1.1   mycroft 	register struct vnode *vp = ap->a_vp;
    627       1.1   mycroft 	register struct inode *ip = VTOI(vp);
    628       1.1   mycroft 	register struct vattr *vap = ap->a_vap;
    629       1.1   mycroft 	/*
    630       1.1   mycroft 	 * Copy from inode table
    631       1.1   mycroft 	 */
    632       1.1   mycroft 	vap->va_fsid = ip->i_dev;
    633       1.1   mycroft 	vap->va_fileid = ip->i_number;
    634      1.14    bouyer 	vap->va_mode = ip->i_ffs_mode & ~IFMT;
    635      1.14    bouyer 	vap->va_nlink = ip->i_ffs_nlink;
    636      1.14    bouyer 	vap->va_uid = ip->i_ffs_uid;
    637      1.14    bouyer 	vap->va_gid = ip->i_ffs_gid;
    638      1.14    bouyer 	vap->va_rdev = (dev_t)ip->i_ffs_rdev;
    639      1.14    bouyer 	vap->va_size = ip->i_ffs_size;
    640      1.14    bouyer 	vap->va_atime.tv_sec = ip->i_ffs_atime;
    641      1.14    bouyer 	vap->va_atime.tv_nsec = ip->i_ffs_atimensec;
    642      1.14    bouyer 	vap->va_mtime.tv_sec = ip->i_ffs_mtime;
    643      1.14    bouyer 	vap->va_mtime.tv_nsec = ip->i_ffs_mtimensec;
    644      1.14    bouyer 	vap->va_ctime.tv_sec = ip->i_ffs_ctime;
    645      1.14    bouyer 	vap->va_ctime.tv_nsec = ip->i_ffs_ctimensec;
    646      1.14    bouyer 	vap->va_flags = ip->i_ffs_flags;
    647      1.14    bouyer 	vap->va_gen = ip->i_ffs_gen;
    648       1.1   mycroft 	/* this doesn't belong here */
    649       1.1   mycroft 	if (vp->v_type == VBLK)
    650       1.1   mycroft 		vap->va_blocksize = BLKDEV_IOSIZE;
    651       1.1   mycroft 	else if (vp->v_type == VCHR)
    652       1.1   mycroft 		vap->va_blocksize = MAXBSIZE;
    653       1.1   mycroft 	else
    654       1.1   mycroft 		vap->va_blocksize = vp->v_mount->mnt_stat.f_iosize;
    655      1.20       cgd 	vap->va_bytes = dbtob((u_quad_t)ip->i_ffs_blocks);
    656       1.1   mycroft 	vap->va_type = vp->v_type;
    657       1.1   mycroft 	vap->va_filerev = ip->i_modrev;
    658       1.1   mycroft 	return (0);
    659       1.1   mycroft }
    660      1.22  perseant 
    661       1.1   mycroft /*
    662       1.1   mycroft  * Close called
    663       1.1   mycroft  *
    664       1.1   mycroft  * XXX -- we were using ufs_close, but since it updates the
    665       1.1   mycroft  * times on the inode, we might need to bump the uinodes
    666       1.1   mycroft  * count.
    667       1.1   mycroft  */
    668       1.1   mycroft /* ARGSUSED */
    669       1.1   mycroft int
    670      1.10  christos lfs_close(v)
    671      1.10  christos 	void *v;
    672      1.10  christos {
    673       1.1   mycroft 	struct vop_close_args /* {
    674       1.1   mycroft 		struct vnode *a_vp;
    675       1.1   mycroft 		int  a_fflag;
    676       1.1   mycroft 		struct ucred *a_cred;
    677       1.1   mycroft 		struct proc *a_p;
    678      1.10  christos 	} */ *ap = v;
    679       1.1   mycroft 	register struct vnode *vp = ap->a_vp;
    680       1.1   mycroft 	register struct inode *ip = VTOI(vp);
    681       1.1   mycroft 	int mod;
    682      1.12   mycroft 	struct timespec ts;
    683       1.1   mycroft 
    684      1.15      fvdl 	simple_lock(&vp->v_interlock);
    685      1.15      fvdl 	if (vp->v_usecount > 1) {
    686       1.1   mycroft 		mod = ip->i_flag & IN_MODIFIED;
    687      1.12   mycroft 		TIMEVAL_TO_TIMESPEC(&time, &ts);
    688      1.22  perseant 		LFS_ITIMES(ip, &ts, &ts, &ts);
    689       1.1   mycroft 		if (!mod && ip->i_flag & IN_MODIFIED)
    690       1.1   mycroft 			ip->i_lfs->lfs_uinodes++;
    691       1.1   mycroft 	}
    692      1.15      fvdl 	simple_unlock(&vp->v_interlock);
    693       1.1   mycroft 	return (0);
    694       1.1   mycroft }
    695       1.1   mycroft 
    696       1.1   mycroft /*
    697      1.15      fvdl  * Reclaim an inode so that it can be used for other purposes.
    698       1.1   mycroft  */
    699       1.1   mycroft int lfs_no_inactive = 0;
    700       1.1   mycroft 
    701       1.1   mycroft int
    702      1.10  christos lfs_reclaim(v)
    703      1.10  christos 	void *v;
    704      1.10  christos {
    705       1.1   mycroft 	struct vop_reclaim_args /* {
    706       1.1   mycroft 		struct vnode *a_vp;
    707      1.15      fvdl 		struct proc *a_p;
    708      1.10  christos 	} */ *ap = v;
    709      1.15      fvdl 	struct vnode *vp = ap->a_vp;
    710       1.1   mycroft 	int error;
    711       1.1   mycroft 
    712      1.15      fvdl 	if ((error = ufs_reclaim(vp, ap->a_p)))
    713       1.1   mycroft 		return (error);
    714      1.19   thorpej 	pool_put(&lfs_inode_pool, vp->v_data);
    715       1.1   mycroft 	vp->v_data = NULL;
    716       1.1   mycroft 	return (0);
    717       1.1   mycroft }
    718