Home | History | Annotate | Line # | Download | only in ffs
ffs_vnops.c revision 1.86.4.11
      1  1.86.4.11        ad /*	$NetBSD: ffs_vnops.c,v 1.86.4.11 2007/08/30 09:55:15 ad Exp $	*/
      2        1.3       cgd 
      3        1.1   mycroft /*
      4        1.1   mycroft  * Copyright (c) 1982, 1986, 1989, 1993
      5        1.1   mycroft  *	The Regents of the University of California.  All rights reserved.
      6        1.1   mycroft  *
      7        1.1   mycroft  * Redistribution and use in source and binary forms, with or without
      8        1.1   mycroft  * modification, are permitted provided that the following conditions
      9        1.1   mycroft  * are met:
     10        1.1   mycroft  * 1. Redistributions of source code must retain the above copyright
     11        1.1   mycroft  *    notice, this list of conditions and the following disclaimer.
     12        1.1   mycroft  * 2. Redistributions in binary form must reproduce the above copyright
     13        1.1   mycroft  *    notice, this list of conditions and the following disclaimer in the
     14        1.1   mycroft  *    documentation and/or other materials provided with the distribution.
     15       1.60       agc  * 3. Neither the name of the University nor the names of its contributors
     16        1.1   mycroft  *    may be used to endorse or promote products derived from this software
     17        1.1   mycroft  *    without specific prior written permission.
     18        1.1   mycroft  *
     19        1.1   mycroft  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     20        1.1   mycroft  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     21        1.1   mycroft  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     22        1.1   mycroft  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     23        1.1   mycroft  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     24        1.1   mycroft  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     25        1.1   mycroft  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     26        1.1   mycroft  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     27        1.1   mycroft  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     28        1.1   mycroft  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     29        1.1   mycroft  * SUCH DAMAGE.
     30        1.1   mycroft  *
     31       1.12      fvdl  *	@(#)ffs_vnops.c	8.15 (Berkeley) 5/14/95
     32        1.1   mycroft  */
     33       1.44     lukem 
     34       1.44     lukem #include <sys/cdefs.h>
     35  1.86.4.11        ad __KERNEL_RCSID(0, "$NetBSD: ffs_vnops.c,v 1.86.4.11 2007/08/30 09:55:15 ad Exp $");
     36       1.11       mrg 
     37        1.1   mycroft #include <sys/param.h>
     38        1.1   mycroft #include <sys/systm.h>
     39        1.1   mycroft #include <sys/resourcevar.h>
     40        1.1   mycroft #include <sys/kernel.h>
     41        1.1   mycroft #include <sys/file.h>
     42        1.1   mycroft #include <sys/stat.h>
     43        1.1   mycroft #include <sys/buf.h>
     44       1.50  jdolecek #include <sys/event.h>
     45        1.1   mycroft #include <sys/proc.h>
     46        1.1   mycroft #include <sys/mount.h>
     47        1.1   mycroft #include <sys/vnode.h>
     48       1.16   thorpej #include <sys/pool.h>
     49        1.6  christos #include <sys/signalvar.h>
     50       1.80      elad #include <sys/kauth.h>
     51       1.84   hannken #include <sys/fstrans.h>
     52        1.1   mycroft 
     53        1.8   mycroft #include <miscfs/fifofs/fifo.h>
     54        1.8   mycroft #include <miscfs/genfs/genfs.h>
     55        1.1   mycroft #include <miscfs/specfs/specdev.h>
     56        1.1   mycroft 
     57        1.1   mycroft #include <ufs/ufs/inode.h>
     58        1.1   mycroft #include <ufs/ufs/dir.h>
     59        1.1   mycroft #include <ufs/ufs/ufs_extern.h>
     60        1.2   mycroft #include <ufs/ufs/ufsmount.h>
     61        1.1   mycroft 
     62        1.1   mycroft #include <ufs/ffs/fs.h>
     63        1.1   mycroft #include <ufs/ffs/ffs_extern.h>
     64        1.1   mycroft 
     65       1.49       chs #include <uvm/uvm.h>
     66       1.49       chs 
     67       1.74   xtraeme static int ffs_full_fsync(void *);
     68       1.33      fvdl 
     69        1.1   mycroft /* Global vfs data structures for ufs. */
     70       1.74   xtraeme int (**ffs_vnodeop_p)(void *);
     71       1.37  jdolecek const struct vnodeopv_entry_desc ffs_vnodeop_entries[] = {
     72        1.1   mycroft 	{ &vop_default_desc, vn_default_error },
     73        1.1   mycroft 	{ &vop_lookup_desc, ufs_lookup },		/* lookup */
     74        1.1   mycroft 	{ &vop_create_desc, ufs_create },		/* create */
     75        1.5   mycroft 	{ &vop_whiteout_desc, ufs_whiteout },		/* whiteout */
     76        1.1   mycroft 	{ &vop_mknod_desc, ufs_mknod },			/* mknod */
     77        1.1   mycroft 	{ &vop_open_desc, ufs_open },			/* open */
     78        1.1   mycroft 	{ &vop_close_desc, ufs_close },			/* close */
     79        1.1   mycroft 	{ &vop_access_desc, ufs_access },		/* access */
     80        1.1   mycroft 	{ &vop_getattr_desc, ufs_getattr },		/* getattr */
     81        1.1   mycroft 	{ &vop_setattr_desc, ufs_setattr },		/* setattr */
     82        1.1   mycroft 	{ &vop_read_desc, ffs_read },			/* read */
     83        1.1   mycroft 	{ &vop_write_desc, ffs_write },			/* write */
     84        1.4   mycroft 	{ &vop_lease_desc, ufs_lease_check },		/* lease */
     85        1.1   mycroft 	{ &vop_ioctl_desc, ufs_ioctl },			/* ioctl */
     86       1.19  wrstuden 	{ &vop_fcntl_desc, ufs_fcntl },			/* fcntl */
     87        1.9   mycroft 	{ &vop_poll_desc, ufs_poll },			/* poll */
     88       1.50  jdolecek 	{ &vop_kqfilter_desc, genfs_kqfilter },		/* kqfilter */
     89       1.12      fvdl 	{ &vop_revoke_desc, ufs_revoke },		/* revoke */
     90        1.1   mycroft 	{ &vop_mmap_desc, ufs_mmap },			/* mmap */
     91        1.1   mycroft 	{ &vop_fsync_desc, ffs_fsync },			/* fsync */
     92        1.1   mycroft 	{ &vop_seek_desc, ufs_seek },			/* seek */
     93        1.1   mycroft 	{ &vop_remove_desc, ufs_remove },		/* remove */
     94        1.1   mycroft 	{ &vop_link_desc, ufs_link },			/* link */
     95        1.1   mycroft 	{ &vop_rename_desc, ufs_rename },		/* rename */
     96        1.1   mycroft 	{ &vop_mkdir_desc, ufs_mkdir },			/* mkdir */
     97        1.1   mycroft 	{ &vop_rmdir_desc, ufs_rmdir },			/* rmdir */
     98        1.1   mycroft 	{ &vop_symlink_desc, ufs_symlink },		/* symlink */
     99        1.1   mycroft 	{ &vop_readdir_desc, ufs_readdir },		/* readdir */
    100        1.1   mycroft 	{ &vop_readlink_desc, ufs_readlink },		/* readlink */
    101        1.1   mycroft 	{ &vop_abortop_desc, ufs_abortop },		/* abortop */
    102        1.1   mycroft 	{ &vop_inactive_desc, ufs_inactive },		/* inactive */
    103        1.1   mycroft 	{ &vop_reclaim_desc, ffs_reclaim },		/* reclaim */
    104   1.86.4.9        ad 	{ &vop_lock_desc, ffs_lock },			/* lock */
    105   1.86.4.9        ad 	{ &vop_unlock_desc, ffs_unlock },		/* unlock */
    106        1.1   mycroft 	{ &vop_bmap_desc, ufs_bmap },			/* bmap */
    107        1.1   mycroft 	{ &vop_strategy_desc, ufs_strategy },		/* strategy */
    108        1.1   mycroft 	{ &vop_print_desc, ufs_print },			/* print */
    109   1.86.4.9        ad 	{ &vop_islocked_desc, ffs_islocked },		/* islocked */
    110        1.1   mycroft 	{ &vop_pathconf_desc, ufs_pathconf },		/* pathconf */
    111        1.1   mycroft 	{ &vop_advlock_desc, ufs_advlock },		/* advlock */
    112        1.8   mycroft 	{ &vop_bwrite_desc, vn_bwrite },		/* bwrite */
    113   1.86.4.6        ad 	{ &vop_getpages_desc, genfs_getpages },		/* getpages */
    114       1.75      yamt 	{ &vop_putpages_desc, genfs_putpages },		/* putpages */
    115       1.73   thorpej 	{ &vop_openextattr_desc, ffs_openextattr },	/* openextattr */
    116       1.73   thorpej 	{ &vop_closeextattr_desc, ffs_closeextattr },	/* closeextattr */
    117       1.73   thorpej 	{ &vop_getextattr_desc, ffs_getextattr },	/* getextattr */
    118       1.73   thorpej 	{ &vop_setextattr_desc, ffs_setextattr },	/* setextattr */
    119       1.73   thorpej 	{ &vop_listextattr_desc, ffs_listextattr },	/* listextattr */
    120       1.73   thorpej 	{ &vop_deleteextattr_desc, ffs_deleteextattr },	/* deleteextattr */
    121       1.35       chs 	{ NULL, NULL }
    122        1.1   mycroft };
    123       1.37  jdolecek const struct vnodeopv_desc ffs_vnodeop_opv_desc =
    124        1.1   mycroft 	{ &ffs_vnodeop_p, ffs_vnodeop_entries };
    125        1.1   mycroft 
    126       1.74   xtraeme int (**ffs_specop_p)(void *);
    127       1.37  jdolecek const struct vnodeopv_entry_desc ffs_specop_entries[] = {
    128        1.1   mycroft 	{ &vop_default_desc, vn_default_error },
    129        1.1   mycroft 	{ &vop_lookup_desc, spec_lookup },		/* lookup */
    130        1.1   mycroft 	{ &vop_create_desc, spec_create },		/* create */
    131        1.1   mycroft 	{ &vop_mknod_desc, spec_mknod },		/* mknod */
    132        1.1   mycroft 	{ &vop_open_desc, spec_open },			/* open */
    133        1.1   mycroft 	{ &vop_close_desc, ufsspec_close },		/* close */
    134        1.1   mycroft 	{ &vop_access_desc, ufs_access },		/* access */
    135        1.1   mycroft 	{ &vop_getattr_desc, ufs_getattr },		/* getattr */
    136        1.1   mycroft 	{ &vop_setattr_desc, ufs_setattr },		/* setattr */
    137        1.1   mycroft 	{ &vop_read_desc, ufsspec_read },		/* read */
    138        1.1   mycroft 	{ &vop_write_desc, ufsspec_write },		/* write */
    139        1.4   mycroft 	{ &vop_lease_desc, spec_lease_check },		/* lease */
    140        1.1   mycroft 	{ &vop_ioctl_desc, spec_ioctl },		/* ioctl */
    141       1.19  wrstuden 	{ &vop_fcntl_desc, ufs_fcntl },			/* fcntl */
    142        1.9   mycroft 	{ &vop_poll_desc, spec_poll },			/* poll */
    143       1.50  jdolecek 	{ &vop_kqfilter_desc, spec_kqfilter },		/* kqfilter */
    144       1.12      fvdl 	{ &vop_revoke_desc, spec_revoke },		/* revoke */
    145        1.1   mycroft 	{ &vop_mmap_desc, spec_mmap },			/* mmap */
    146        1.1   mycroft 	{ &vop_fsync_desc, ffs_fsync },			/* fsync */
    147        1.1   mycroft 	{ &vop_seek_desc, spec_seek },			/* seek */
    148        1.1   mycroft 	{ &vop_remove_desc, spec_remove },		/* remove */
    149        1.1   mycroft 	{ &vop_link_desc, spec_link },			/* link */
    150        1.1   mycroft 	{ &vop_rename_desc, spec_rename },		/* rename */
    151        1.1   mycroft 	{ &vop_mkdir_desc, spec_mkdir },		/* mkdir */
    152        1.1   mycroft 	{ &vop_rmdir_desc, spec_rmdir },		/* rmdir */
    153        1.1   mycroft 	{ &vop_symlink_desc, spec_symlink },		/* symlink */
    154        1.1   mycroft 	{ &vop_readdir_desc, spec_readdir },		/* readdir */
    155        1.1   mycroft 	{ &vop_readlink_desc, spec_readlink },		/* readlink */
    156        1.1   mycroft 	{ &vop_abortop_desc, spec_abortop },		/* abortop */
    157        1.1   mycroft 	{ &vop_inactive_desc, ufs_inactive },		/* inactive */
    158        1.1   mycroft 	{ &vop_reclaim_desc, ffs_reclaim },		/* reclaim */
    159   1.86.4.9        ad 	{ &vop_lock_desc, ffs_lock },			/* lock */
    160   1.86.4.9        ad 	{ &vop_unlock_desc, ffs_unlock },		/* unlock */
    161        1.1   mycroft 	{ &vop_bmap_desc, spec_bmap },			/* bmap */
    162        1.1   mycroft 	{ &vop_strategy_desc, spec_strategy },		/* strategy */
    163        1.1   mycroft 	{ &vop_print_desc, ufs_print },			/* print */
    164   1.86.4.9        ad 	{ &vop_islocked_desc, ffs_islocked },		/* islocked */
    165        1.1   mycroft 	{ &vop_pathconf_desc, spec_pathconf },		/* pathconf */
    166        1.1   mycroft 	{ &vop_advlock_desc, spec_advlock },		/* advlock */
    167        1.8   mycroft 	{ &vop_bwrite_desc, vn_bwrite },		/* bwrite */
    168       1.38       chs 	{ &vop_getpages_desc, spec_getpages },		/* getpages */
    169       1.38       chs 	{ &vop_putpages_desc, spec_putpages },		/* putpages */
    170       1.73   thorpej 	{ &vop_openextattr_desc, ffs_openextattr },	/* openextattr */
    171       1.73   thorpej 	{ &vop_closeextattr_desc, ffs_closeextattr },	/* closeextattr */
    172       1.73   thorpej 	{ &vop_getextattr_desc, ffs_getextattr },	/* getextattr */
    173       1.73   thorpej 	{ &vop_setextattr_desc, ffs_setextattr },	/* setextattr */
    174       1.73   thorpej 	{ &vop_listextattr_desc, ffs_listextattr },	/* listextattr */
    175       1.73   thorpej 	{ &vop_deleteextattr_desc, ffs_deleteextattr },	/* deleteextattr */
    176       1.35       chs 	{ NULL, NULL }
    177        1.1   mycroft };
    178       1.37  jdolecek const struct vnodeopv_desc ffs_specop_opv_desc =
    179        1.1   mycroft 	{ &ffs_specop_p, ffs_specop_entries };
    180        1.1   mycroft 
    181       1.74   xtraeme int (**ffs_fifoop_p)(void *);
    182       1.37  jdolecek const struct vnodeopv_entry_desc ffs_fifoop_entries[] = {
    183        1.1   mycroft 	{ &vop_default_desc, vn_default_error },
    184        1.1   mycroft 	{ &vop_lookup_desc, fifo_lookup },		/* lookup */
    185        1.1   mycroft 	{ &vop_create_desc, fifo_create },		/* create */
    186        1.1   mycroft 	{ &vop_mknod_desc, fifo_mknod },		/* mknod */
    187        1.1   mycroft 	{ &vop_open_desc, fifo_open },			/* open */
    188        1.1   mycroft 	{ &vop_close_desc, ufsfifo_close },		/* close */
    189        1.1   mycroft 	{ &vop_access_desc, ufs_access },		/* access */
    190        1.1   mycroft 	{ &vop_getattr_desc, ufs_getattr },		/* getattr */
    191        1.1   mycroft 	{ &vop_setattr_desc, ufs_setattr },		/* setattr */
    192        1.1   mycroft 	{ &vop_read_desc, ufsfifo_read },		/* read */
    193        1.1   mycroft 	{ &vop_write_desc, ufsfifo_write },		/* write */
    194        1.4   mycroft 	{ &vop_lease_desc, fifo_lease_check },		/* lease */
    195        1.1   mycroft 	{ &vop_ioctl_desc, fifo_ioctl },		/* ioctl */
    196       1.19  wrstuden 	{ &vop_fcntl_desc, ufs_fcntl },			/* fcntl */
    197        1.9   mycroft 	{ &vop_poll_desc, fifo_poll },			/* poll */
    198       1.50  jdolecek 	{ &vop_kqfilter_desc, fifo_kqfilter },		/* kqfilter */
    199       1.12      fvdl 	{ &vop_revoke_desc, fifo_revoke },		/* revoke */
    200        1.1   mycroft 	{ &vop_mmap_desc, fifo_mmap },			/* mmap */
    201        1.1   mycroft 	{ &vop_fsync_desc, ffs_fsync },			/* fsync */
    202        1.1   mycroft 	{ &vop_seek_desc, fifo_seek },			/* seek */
    203        1.1   mycroft 	{ &vop_remove_desc, fifo_remove },		/* remove */
    204        1.1   mycroft 	{ &vop_link_desc, fifo_link },			/* link */
    205        1.1   mycroft 	{ &vop_rename_desc, fifo_rename },		/* rename */
    206        1.1   mycroft 	{ &vop_mkdir_desc, fifo_mkdir },		/* mkdir */
    207        1.1   mycroft 	{ &vop_rmdir_desc, fifo_rmdir },		/* rmdir */
    208        1.1   mycroft 	{ &vop_symlink_desc, fifo_symlink },		/* symlink */
    209        1.1   mycroft 	{ &vop_readdir_desc, fifo_readdir },		/* readdir */
    210        1.1   mycroft 	{ &vop_readlink_desc, fifo_readlink },		/* readlink */
    211        1.1   mycroft 	{ &vop_abortop_desc, fifo_abortop },		/* abortop */
    212        1.1   mycroft 	{ &vop_inactive_desc, ufs_inactive },		/* inactive */
    213        1.1   mycroft 	{ &vop_reclaim_desc, ffs_reclaim },		/* reclaim */
    214   1.86.4.9        ad 	{ &vop_lock_desc, ffs_lock },			/* lock */
    215   1.86.4.9        ad 	{ &vop_unlock_desc, ffs_unlock },		/* unlock */
    216        1.1   mycroft 	{ &vop_bmap_desc, fifo_bmap },			/* bmap */
    217        1.1   mycroft 	{ &vop_strategy_desc, fifo_strategy },		/* strategy */
    218        1.1   mycroft 	{ &vop_print_desc, ufs_print },			/* print */
    219   1.86.4.9        ad 	{ &vop_islocked_desc, ffs_islocked },		/* islocked */
    220        1.1   mycroft 	{ &vop_pathconf_desc, fifo_pathconf },		/* pathconf */
    221        1.1   mycroft 	{ &vop_advlock_desc, fifo_advlock },		/* advlock */
    222        1.8   mycroft 	{ &vop_bwrite_desc, vn_bwrite },		/* bwrite */
    223       1.40  sommerfe 	{ &vop_putpages_desc, fifo_putpages }, 		/* putpages */
    224       1.73   thorpej 	{ &vop_openextattr_desc, ffs_openextattr },	/* openextattr */
    225       1.73   thorpej 	{ &vop_closeextattr_desc, ffs_closeextattr },	/* closeextattr */
    226       1.73   thorpej 	{ &vop_getextattr_desc, ffs_getextattr },	/* getextattr */
    227       1.73   thorpej 	{ &vop_setextattr_desc, ffs_setextattr },	/* setextattr */
    228       1.73   thorpej 	{ &vop_listextattr_desc, ffs_listextattr },	/* listextattr */
    229       1.73   thorpej 	{ &vop_deleteextattr_desc, ffs_deleteextattr },	/* deleteextattr */
    230       1.35       chs 	{ NULL, NULL }
    231        1.1   mycroft };
    232       1.37  jdolecek const struct vnodeopv_desc ffs_fifoop_opv_desc =
    233        1.1   mycroft 	{ &ffs_fifoop_p, ffs_fifoop_entries };
    234        1.1   mycroft 
    235        1.1   mycroft #include <ufs/ufs/ufs_readwrite.c>
    236       1.20      fvdl 
    237       1.33      fvdl int
    238       1.70   thorpej ffs_fsync(void *v)
    239       1.33      fvdl {
    240       1.33      fvdl 	struct vop_fsync_args /* {
    241       1.33      fvdl 		struct vnode *a_vp;
    242       1.80      elad 		kauth_cred_t a_cred;
    243       1.33      fvdl 		int a_flags;
    244       1.46       chs 		off_t a_offlo;
    245       1.46       chs 		off_t a_offhi;
    246       1.77  christos 		struct lwp *a_l;
    247       1.33      fvdl 	} */ *ap = v;
    248       1.35       chs 	struct buf *bp;
    249   1.86.4.3        ad 	int num, error, i;
    250       1.33      fvdl 	struct indir ia[NIADDR + 1];
    251       1.33      fvdl 	int bsize;
    252       1.45    simonb 	daddr_t blk_high;
    253       1.33      fvdl 	struct vnode *vp;
    254       1.33      fvdl 
    255       1.84   hannken 	vp = ap->a_vp;
    256       1.84   hannken 
    257   1.86.4.5        ad 	fstrans_start(vp->v_mount, FSTRANS_LAZY);
    258       1.33      fvdl 	/*
    259       1.33      fvdl 	 * XXX no easy way to sync a range in a file with softdep.
    260       1.33      fvdl 	 */
    261       1.84   hannken 	if ((ap->a_offlo == 0 && ap->a_offhi == 0) || DOINGSOFTDEP(vp) ||
    262       1.84   hannken 	    (vp->v_type != VREG)) {
    263       1.84   hannken 		error = ffs_full_fsync(v);
    264       1.84   hannken 		goto out;
    265       1.84   hannken 	}
    266       1.33      fvdl 
    267       1.84   hannken 	bsize = vp->v_mount->mnt_stat.f_iosize;
    268       1.33      fvdl 	blk_high = ap->a_offhi / bsize;
    269       1.33      fvdl 	if (ap->a_offhi % bsize != 0)
    270       1.33      fvdl 		blk_high++;
    271       1.33      fvdl 
    272       1.33      fvdl 	/*
    273       1.35       chs 	 * First, flush all pages in range.
    274       1.33      fvdl 	 */
    275       1.35       chs 
    276   1.86.4.1        ad 	mutex_enter(&vp->v_interlock);
    277       1.64       dbj 	error = VOP_PUTPAGES(vp, trunc_page(ap->a_offlo),
    278       1.64       dbj 	    round_page(ap->a_offhi), PGO_CLEANIT |
    279       1.64       dbj 	    ((ap->a_flags & FSYNC_WAIT) ? PGO_SYNCIO : 0));
    280       1.64       dbj 	if (error) {
    281       1.84   hannken 		goto out;
    282       1.39       chs 	}
    283       1.33      fvdl 
    284       1.33      fvdl 	/*
    285       1.35       chs 	 * Then, flush indirect blocks.
    286       1.33      fvdl 	 */
    287       1.35       chs 
    288       1.61    kleink 	if (blk_high >= NDADDR) {
    289       1.33      fvdl 		error = ufs_getlbns(vp, blk_high, ia, &num);
    290   1.86.4.3        ad 		if (error)
    291       1.84   hannken 			goto out;
    292   1.86.4.3        ad 
    293  1.86.4.10        ad 		mutex_enter(&bufcache_lock);
    294       1.33      fvdl 		for (i = 0; i < num; i++) {
    295   1.86.4.3        ad 			if ((bp = incore(vp, ia[i].in_lbn)) == NULL)
    296   1.86.4.3        ad 				continue;
    297  1.86.4.10        ad 			if ((bp->b_cflags & BC_BUSY) != 0 ||
    298  1.86.4.10        ad 			    (bp->b_oflags & BO_DELWRI) == 0)
    299   1.86.4.3        ad 				continue;
    300  1.86.4.10        ad 			bp->b_cflags |= BC_BUSY | BC_VFLUSH;
    301  1.86.4.10        ad 			mutex_exit(&bufcache_lock);
    302   1.86.4.3        ad 			bawrite(bp);
    303  1.86.4.10        ad 			mutex_enter(&bufcache_lock);
    304       1.33      fvdl 		}
    305  1.86.4.10        ad 		mutex_exit(&bufcache_lock);
    306       1.33      fvdl 	}
    307       1.33      fvdl 
    308       1.33      fvdl 	if (ap->a_flags & FSYNC_WAIT) {
    309   1.86.4.7        ad 		mutex_enter(&vp->v_interlock);
    310   1.86.4.2        ad 		while (vp->v_numoutput > 0)
    311   1.86.4.7        ad 			cv_wait(&vp->v_cv, &vp->v_interlock);
    312   1.86.4.7        ad 		mutex_exit(&vp->v_interlock);
    313       1.33      fvdl 	}
    314       1.33      fvdl 
    315       1.76      yamt 	error = ffs_update(vp, NULL, NULL,
    316       1.66   thorpej 	    ((ap->a_flags & (FSYNC_WAIT | FSYNC_DATAONLY)) == FSYNC_WAIT)
    317       1.67  wrstuden 	    ? UPDATE_WAIT : 0);
    318       1.67  wrstuden 
    319       1.67  wrstuden 	if (error == 0 && ap->a_flags & FSYNC_CACHE) {
    320       1.67  wrstuden 		int l = 0;
    321       1.67  wrstuden 		VOP_IOCTL(VTOI(vp)->i_devvp, DIOCCACHESYNC, &l, FWRITE,
    322       1.81        ad 			ap->a_l->l_cred, ap->a_l);
    323       1.67  wrstuden 	}
    324       1.67  wrstuden 
    325       1.84   hannken out:
    326       1.84   hannken 	fstrans_done(vp->v_mount);
    327       1.67  wrstuden 	return error;
    328       1.33      fvdl }
    329       1.33      fvdl 
    330       1.20      fvdl /*
    331       1.20      fvdl  * Synch an open file.
    332       1.20      fvdl  */
    333       1.20      fvdl /* ARGSUSED */
    334       1.33      fvdl static int
    335       1.70   thorpej ffs_full_fsync(void *v)
    336       1.20      fvdl {
    337       1.29   mycroft 	struct vop_fsync_args /* {
    338       1.20      fvdl 		struct vnode *a_vp;
    339       1.80      elad 		kauth_cred_t a_cred;
    340       1.20      fvdl 		int a_flags;
    341       1.46       chs 		off_t a_offlo;
    342       1.46       chs 		off_t a_offhi;
    343       1.77  christos 		struct lwp *a_l;
    344       1.20      fvdl 	} */ *ap = v;
    345       1.20      fvdl 	struct vnode *vp = ap->a_vp;
    346       1.20      fvdl 	struct buf *bp, *nbp;
    347   1.86.4.3        ad 	int error, passes, skipmeta, inodedeps_only, waitfor;
    348       1.24      fvdl 
    349       1.20      fvdl 	if (vp->v_type == VBLK &&
    350       1.20      fvdl 	    vp->v_specmountpoint != NULL &&
    351       1.20      fvdl 	    (vp->v_specmountpoint->mnt_flag & MNT_SOFTDEP))
    352       1.20      fvdl 		softdep_fsync_mountdev(vp);
    353       1.21  perseant 
    354   1.86.4.8        ad 	mutex_enter(&vp->v_interlock);
    355   1.86.4.8        ad 
    356       1.47      fvdl 	inodedeps_only = DOINGSOFTDEP(vp) && (ap->a_flags & FSYNC_RECLAIM)
    357   1.86.4.9        ad 	    && UVM_OBJ_IS_CLEAN(&vp->v_uobj) && LIST_EMPTY(&vp->v_dirtyblkhd);
    358       1.47      fvdl 
    359       1.35       chs 	/*
    360       1.35       chs 	 * Flush all dirty data associated with a vnode.
    361       1.20      fvdl 	 */
    362       1.35       chs 
    363       1.72      yamt 	if (vp->v_type == VREG || vp->v_type == VBLK) {
    364       1.46       chs 		error = VOP_PUTPAGES(vp, 0, 0, PGO_ALLPAGES | PGO_CLEANIT |
    365       1.84   hannken 		    ((ap->a_flags & FSYNC_WAIT) ? PGO_SYNCIO : 0) |
    366       1.85   hannken 		    (fstrans_getstate(vp->v_mount) == FSTRANS_SUSPENDING ?
    367       1.84   hannken 			PGO_FREE : 0));
    368       1.39       chs 		if (error) {
    369       1.39       chs 			return error;
    370       1.39       chs 		}
    371  1.86.4.10        ad 	} else
    372  1.86.4.10        ad 		mutex_exit(&vp->v_interlock);
    373       1.35       chs 
    374       1.20      fvdl 	passes = NIADDR + 1;
    375       1.20      fvdl 	skipmeta = 0;
    376       1.61    kleink 	if (ap->a_flags & FSYNC_WAIT)
    377       1.20      fvdl 		skipmeta = 1;
    378       1.35       chs 
    379       1.20      fvdl loop:
    380  1.86.4.11        ad 	mutex_enter(&bufcache_lock);
    381   1.86.4.3        ad 	LIST_FOREACH(bp, &vp->v_dirtyblkhd, b_vnbufs) {
    382  1.86.4.10        ad 		bp->b_cflags &= ~BC_SCANNED;
    383   1.86.4.3        ad 	}
    384       1.29   mycroft 	for (bp = LIST_FIRST(&vp->v_dirtyblkhd); bp; bp = nbp) {
    385       1.29   mycroft 		nbp = LIST_NEXT(bp, b_vnbufs);
    386  1.86.4.10        ad 		if (bp->b_cflags & (BC_BUSY | BC_SCANNED))
    387       1.20      fvdl 			continue;
    388  1.86.4.10        ad 		if ((bp->b_oflags & BO_DELWRI) == 0)
    389       1.20      fvdl 			panic("ffs_fsync: not dirty");
    390  1.86.4.10        ad 		if (skipmeta && bp->b_lblkno < 0)
    391       1.20      fvdl 			continue;
    392  1.86.4.10        ad 		bp->b_cflags |= BC_BUSY | BC_VFLUSH | BC_SCANNED;
    393  1.86.4.10        ad 		mutex_exit(&bufcache_lock);
    394       1.20      fvdl 		/*
    395       1.20      fvdl 		 * On our final pass through, do all I/O synchronously
    396       1.20      fvdl 		 * so that we can find out if our flush is failing
    397       1.20      fvdl 		 * because of write errors.
    398       1.20      fvdl 		 */
    399       1.20      fvdl 		if (passes > 0 || !(ap->a_flags & FSYNC_WAIT))
    400       1.20      fvdl 			(void) bawrite(bp);
    401       1.20      fvdl 		else if ((error = bwrite(bp)) != 0)
    402       1.20      fvdl 			return (error);
    403       1.20      fvdl 		/*
    404  1.86.4.10        ad 		 * Since we unlocked during the I/O, we need
    405       1.20      fvdl 		 * to start from a known point.
    406       1.20      fvdl 		 */
    407  1.86.4.10        ad 		mutex_enter(&bufcache_lock);
    408       1.29   mycroft 		nbp = LIST_FIRST(&vp->v_dirtyblkhd);
    409       1.20      fvdl 	}
    410  1.86.4.11        ad 	mutex_exit(&bufcache_lock);
    411       1.61    kleink 	if (skipmeta) {
    412       1.20      fvdl 		skipmeta = 0;
    413       1.20      fvdl 		goto loop;
    414       1.20      fvdl 	}
    415  1.86.4.10        ad 
    416       1.20      fvdl 	if (ap->a_flags & FSYNC_WAIT) {
    417  1.86.4.11        ad 		mutex_enter(&vp->v_interlock);
    418       1.20      fvdl 		while (vp->v_numoutput) {
    419   1.86.4.7        ad 			cv_wait(&vp->v_cv, &vp->v_interlock);
    420       1.20      fvdl 		}
    421   1.86.4.7        ad 		mutex_exit(&vp->v_interlock);
    422       1.20      fvdl 
    423       1.69     perry 		/*
    424       1.20      fvdl 		 * Ensure that any filesystem metadata associated
    425       1.20      fvdl 		 * with the vnode has been written.
    426       1.20      fvdl 		 */
    427       1.31   mycroft 		if ((error = softdep_sync_metadata(ap)) != 0)
    428       1.20      fvdl 			return (error);
    429       1.29   mycroft 
    430       1.29   mycroft 		if (!LIST_EMPTY(&vp->v_dirtyblkhd)) {
    431       1.29   mycroft 			/*
    432       1.29   mycroft 			* Block devices associated with filesystems may
    433       1.29   mycroft 			* have new I/O requests posted for them even if
    434       1.29   mycroft 			* the vnode is locked, so no amount of trying will
    435       1.29   mycroft 			* get them clean. Thus we give block devices a
    436       1.29   mycroft 			* good effort, then just give up. For all other file
    437       1.29   mycroft 			* types, go around and try again until it is clean.
    438       1.29   mycroft 			*/
    439       1.29   mycroft 			if (passes > 0) {
    440       1.29   mycroft 				passes--;
    441       1.29   mycroft 				goto loop;
    442       1.29   mycroft 			}
    443       1.20      fvdl #ifdef DIAGNOSTIC
    444       1.29   mycroft 			if (vp->v_type != VBLK)
    445       1.29   mycroft 				vprint("ffs_fsync: dirty", vp);
    446       1.20      fvdl #endif
    447       1.29   mycroft 		}
    448  1.86.4.11        ad 	}
    449       1.47      fvdl 
    450       1.47      fvdl 	if (inodedeps_only)
    451       1.47      fvdl 		waitfor = 0;
    452       1.47      fvdl 	else
    453       1.47      fvdl 		waitfor = (ap->a_flags & FSYNC_WAIT) ? UPDATE_WAIT : 0;
    454       1.76      yamt 	error = ffs_update(vp, NULL, NULL, waitfor);
    455       1.67  wrstuden 
    456       1.68  wrstuden 	if (error == 0 && ap->a_flags & FSYNC_CACHE) {
    457       1.67  wrstuden 		int i = 0;
    458       1.67  wrstuden 		VOP_IOCTL(VTOI(vp)->i_devvp, DIOCCACHESYNC, &i, FWRITE,
    459       1.81        ad 			ap->a_l->l_cred, ap->a_l);
    460       1.67  wrstuden 	}
    461       1.67  wrstuden 
    462       1.67  wrstuden 	return error;
    463       1.20      fvdl }
    464        1.1   mycroft 
    465        1.1   mycroft /*
    466        1.1   mycroft  * Reclaim an inode so that it can be used for other purposes.
    467        1.1   mycroft  */
    468        1.1   mycroft int
    469       1.70   thorpej ffs_reclaim(void *v)
    470        1.6  christos {
    471        1.1   mycroft 	struct vop_reclaim_args /* {
    472        1.1   mycroft 		struct vnode *a_vp;
    473       1.77  christos 		struct lwp *a_l;
    474        1.6  christos 	} */ *ap = v;
    475       1.26  augustss 	struct vnode *vp = ap->a_vp;
    476       1.56      fvdl 	struct inode *ip = VTOI(vp);
    477       1.84   hannken 	struct mount *mp = vp->v_mount;
    478       1.56      fvdl 	struct ufsmount *ump = ip->i_ump;
    479   1.86.4.4        ad 	void *data;
    480        1.1   mycroft 	int error;
    481        1.1   mycroft 
    482   1.86.4.5        ad 	fstrans_start(mp, FSTRANS_LAZY);
    483       1.84   hannken 	if ((error = ufs_reclaim(vp, ap->a_l)) != 0) {
    484       1.84   hannken 		fstrans_done(mp);
    485        1.1   mycroft 		return (error);
    486       1.84   hannken 	}
    487       1.57      fvdl 	if (ip->i_din.ffs1_din != NULL) {
    488       1.57      fvdl 		if (ump->um_fstype == UFS1)
    489       1.57      fvdl 			pool_put(&ffs_dinode1_pool, ip->i_din.ffs1_din);
    490       1.57      fvdl 		else
    491       1.57      fvdl 			pool_put(&ffs_dinode2_pool, ip->i_din.ffs2_din);
    492       1.57      fvdl 	}
    493       1.16   thorpej 	/*
    494   1.86.4.4        ad 	 * To interlock with ffs_sync().
    495       1.16   thorpej 	 */
    496       1.86        ad 	genfs_node_destroy(vp);
    497   1.86.4.4        ad 	mutex_enter(&vp->v_interlock);
    498   1.86.4.4        ad 	data = vp->v_data;
    499        1.1   mycroft 	vp->v_data = NULL;
    500   1.86.4.4        ad 	mutex_exit(&vp->v_interlock);
    501   1.86.4.4        ad 
    502   1.86.4.4        ad 	/*
    503   1.86.4.4        ad 	 * XXX MFS ends up here, too, to free an inode.  Should we create
    504   1.86.4.4        ad 	 * XXX a separate pool for MFS inodes?
    505   1.86.4.4        ad 	 */
    506   1.86.4.4        ad 	pool_put(&ffs_inode_pool, data);
    507       1.84   hannken 	fstrans_done(mp);
    508        1.1   mycroft 	return (0);
    509       1.35       chs }
    510       1.35       chs 
    511   1.86.4.6        ad #if 0
    512       1.39       chs int
    513       1.39       chs ffs_getpages(void *v)
    514       1.39       chs {
    515       1.39       chs 	struct vop_getpages_args /* {
    516       1.39       chs 		struct vnode *a_vp;
    517       1.39       chs 		voff_t a_offset;
    518       1.39       chs 		struct vm_page **a_m;
    519       1.39       chs 		int *a_count;
    520       1.39       chs 		int a_centeridx;
    521       1.39       chs 		vm_prot_t a_access_type;
    522       1.39       chs 		int a_advice;
    523       1.39       chs 		int a_flags;
    524       1.39       chs 	} */ *ap = v;
    525       1.39       chs 	struct vnode *vp = ap->a_vp;
    526       1.39       chs 	struct inode *ip = VTOI(vp);
    527       1.39       chs 	struct fs *fs = ip->i_fs;
    528       1.39       chs 
    529       1.39       chs 	/*
    530       1.39       chs 	 * don't allow a softdep write to create pages for only part of a block.
    531       1.39       chs 	 * the dependency tracking requires that all pages be in memory for
    532       1.39       chs 	 * a block involved in a dependency.
    533       1.39       chs 	 */
    534       1.39       chs 
    535       1.39       chs 	if (ap->a_flags & PGO_OVERWRITE &&
    536       1.39       chs 	    (blkoff(fs, ap->a_offset) != 0 ||
    537       1.39       chs 	     blkoff(fs, *ap->a_count << PAGE_SHIFT) != 0) &&
    538       1.39       chs 	    DOINGSOFTDEP(ap->a_vp)) {
    539       1.39       chs 		if ((ap->a_flags & PGO_LOCKED) == 0) {
    540   1.86.4.1        ad 			mutex_exit(&vp->v_interlock);
    541       1.39       chs 		}
    542       1.39       chs 		return EINVAL;
    543       1.39       chs 	}
    544       1.39       chs 	return genfs_getpages(v);
    545       1.49       chs }
    546   1.86.4.6        ad #endif
    547       1.49       chs 
    548       1.35       chs /*
    549       1.35       chs  * Return the last logical file offset that should be written for this file
    550       1.35       chs  * if we're doing a write that ends at "size".
    551       1.35       chs  */
    552       1.39       chs 
    553       1.39       chs void
    554       1.83  christos ffs_gop_size(struct vnode *vp, off_t size, off_t *eobp, int flags)
    555       1.35       chs {
    556       1.39       chs 	struct inode *ip = VTOI(vp);
    557       1.35       chs 	struct fs *fs = ip->i_fs;
    558       1.52      fvdl 	daddr_t olbn, nlbn;
    559       1.55  perseant 
    560       1.56      fvdl 	olbn = lblkno(fs, ip->i_size);
    561       1.39       chs 	nlbn = lblkno(fs, size);
    562       1.35       chs 	if (nlbn < NDADDR && olbn <= nlbn) {
    563       1.39       chs 		*eobp = fragroundup(fs, size);
    564       1.35       chs 	} else {
    565       1.39       chs 		*eobp = blkroundup(fs, size);
    566       1.35       chs 	}
    567        1.1   mycroft }
    568       1.73   thorpej 
    569       1.73   thorpej int
    570       1.73   thorpej ffs_openextattr(void *v)
    571       1.73   thorpej {
    572       1.73   thorpej 	struct vop_openextattr_args /* {
    573       1.73   thorpej 		struct vnode *a_vp;
    574       1.80      elad 		kauth_cred_t a_cred;
    575       1.73   thorpej 		struct proc *a_p;
    576       1.73   thorpej 	} */ *ap = v;
    577       1.73   thorpej 	struct inode *ip = VTOI(ap->a_vp);
    578       1.73   thorpej 	struct fs *fs = ip->i_fs;
    579       1.73   thorpej 
    580       1.73   thorpej 	/* Not supported for UFS1 file systems. */
    581       1.73   thorpej 	if (fs->fs_magic == FS_UFS1_MAGIC)
    582       1.73   thorpej 		return (EOPNOTSUPP);
    583       1.73   thorpej 
    584       1.73   thorpej 	/* XXX Not implemented for UFS2 file systems. */
    585       1.73   thorpej 	return (EOPNOTSUPP);
    586       1.73   thorpej }
    587       1.73   thorpej 
    588       1.73   thorpej int
    589       1.73   thorpej ffs_closeextattr(void *v)
    590       1.73   thorpej {
    591       1.73   thorpej 	struct vop_closeextattr_args /* {
    592       1.73   thorpej 		struct vnode *a_vp;
    593       1.73   thorpej 		int a_commit;
    594       1.80      elad 		kauth_cred_t a_cred;
    595       1.73   thorpej 		struct proc *a_p;
    596       1.73   thorpej 	} */ *ap = v;
    597       1.73   thorpej 	struct inode *ip = VTOI(ap->a_vp);
    598       1.73   thorpej 	struct fs *fs = ip->i_fs;
    599       1.73   thorpej 
    600       1.73   thorpej 	/* Not supported for UFS1 file systems. */
    601       1.73   thorpej 	if (fs->fs_magic == FS_UFS1_MAGIC)
    602       1.73   thorpej 		return (EOPNOTSUPP);
    603       1.73   thorpej 
    604       1.73   thorpej 	/* XXX Not implemented for UFS2 file systems. */
    605       1.73   thorpej 	return (EOPNOTSUPP);
    606       1.73   thorpej }
    607       1.73   thorpej 
    608       1.73   thorpej int
    609       1.73   thorpej ffs_getextattr(void *v)
    610       1.73   thorpej {
    611       1.73   thorpej 	struct vop_getextattr_args /* {
    612       1.73   thorpej 		struct vnode *a_vp;
    613       1.73   thorpej 		int a_attrnamespace;
    614       1.73   thorpej 		const char *a_name;
    615       1.73   thorpej 		struct uio *a_uio;
    616       1.73   thorpej 		size_t *a_size;
    617       1.80      elad 		kauth_cred_t a_cred;
    618       1.73   thorpej 		struct proc *a_p;
    619       1.73   thorpej 	} */ *ap = v;
    620       1.84   hannken 	struct vnode *vp = ap->a_vp;
    621       1.84   hannken 	struct inode *ip = VTOI(vp);
    622       1.73   thorpej 	struct fs *fs = ip->i_fs;
    623       1.73   thorpej 
    624       1.73   thorpej 	if (fs->fs_magic == FS_UFS1_MAGIC) {
    625       1.73   thorpej #ifdef UFS_EXTATTR
    626       1.84   hannken 		int error;
    627       1.84   hannken 
    628   1.86.4.5        ad 		fstrans_start(vp->v_mount, FSTRANS_SHARED);
    629       1.84   hannken 		error = ufs_getextattr(ap);
    630       1.84   hannken 		fstrans_done(vp->v_mount);
    631       1.84   hannken 		return error;
    632       1.73   thorpej #else
    633       1.73   thorpej 		return (EOPNOTSUPP);
    634       1.73   thorpej #endif
    635       1.73   thorpej 	}
    636       1.73   thorpej 
    637       1.73   thorpej 	/* XXX Not implemented for UFS2 file systems. */
    638       1.73   thorpej 	return (EOPNOTSUPP);
    639       1.73   thorpej }
    640       1.73   thorpej 
    641       1.73   thorpej int
    642       1.73   thorpej ffs_setextattr(void *v)
    643       1.73   thorpej {
    644       1.73   thorpej 	struct vop_setextattr_args /* {
    645       1.73   thorpej 		struct vnode *a_vp;
    646       1.73   thorpej 		int a_attrnamespace;
    647       1.73   thorpej 		const char *a_name;
    648       1.73   thorpej 		struct uio *a_uio;
    649       1.80      elad 		kauth_cred_t a_cred;
    650       1.73   thorpej 		struct proc *a_p;
    651       1.73   thorpej 	} */ *ap = v;
    652       1.84   hannken 	struct vnode *vp = ap->a_vp;
    653       1.84   hannken 	struct inode *ip = VTOI(vp);
    654       1.73   thorpej 	struct fs *fs = ip->i_fs;
    655       1.73   thorpej 
    656       1.73   thorpej 	if (fs->fs_magic == FS_UFS1_MAGIC) {
    657       1.73   thorpej #ifdef UFS_EXTATTR
    658       1.84   hannken 		int error;
    659       1.84   hannken 
    660   1.86.4.5        ad 		fstrans_start(vp->v_mount, FSTRANS_SHARED);
    661       1.84   hannken 		error = ufs_setextattr(ap);
    662       1.84   hannken 		fstrans_done(vp->v_mount);
    663       1.84   hannken 		return error;
    664       1.73   thorpej #else
    665       1.73   thorpej 		return (EOPNOTSUPP);
    666       1.73   thorpej #endif
    667       1.73   thorpej 	}
    668       1.73   thorpej 
    669       1.73   thorpej 	/* XXX Not implemented for UFS2 file systems. */
    670       1.73   thorpej 	return (EOPNOTSUPP);
    671       1.73   thorpej }
    672       1.73   thorpej 
    673       1.73   thorpej int
    674       1.73   thorpej ffs_listextattr(void *v)
    675       1.73   thorpej {
    676       1.73   thorpej 	struct vop_listextattr_args /* {
    677       1.73   thorpej 		struct vnode *a_vp;
    678       1.73   thorpej 		int a_attrnamespace;
    679       1.73   thorpej 		struct uio *a_uio;
    680       1.73   thorpej 		size_t *a_size;
    681       1.80      elad 		kauth_cred_t a_cred;
    682       1.73   thorpej 		struct proc *a_p;
    683       1.73   thorpej 	} */ *ap = v;
    684       1.73   thorpej 	struct inode *ip = VTOI(ap->a_vp);
    685       1.73   thorpej 	struct fs *fs = ip->i_fs;
    686       1.73   thorpej 
    687       1.73   thorpej 	/* Not supported for UFS1 file systems. */
    688       1.73   thorpej 	if (fs->fs_magic == FS_UFS1_MAGIC)
    689       1.73   thorpej 		return (EOPNOTSUPP);
    690       1.73   thorpej 
    691       1.73   thorpej 	/* XXX Not implemented for UFS2 file systems. */
    692       1.73   thorpej 	return (EOPNOTSUPP);
    693       1.73   thorpej }
    694       1.73   thorpej 
    695       1.73   thorpej int
    696       1.73   thorpej ffs_deleteextattr(void *v)
    697       1.73   thorpej {
    698       1.73   thorpej 	struct vop_deleteextattr_args /* {
    699       1.73   thorpej 		struct vnode *a_vp;
    700       1.73   thorpej 		int a_attrnamespace;
    701       1.80      elad 		kauth_cred_t a_cred;
    702       1.73   thorpej 		struct proc *a_p;
    703       1.73   thorpej 	} */ *ap = v;
    704       1.84   hannken 	struct vnode *vp = ap->a_vp;
    705       1.84   hannken 	struct inode *ip = VTOI(vp);
    706       1.73   thorpej 	struct fs *fs = ip->i_fs;
    707       1.73   thorpej 
    708       1.73   thorpej 	if (fs->fs_magic == FS_UFS1_MAGIC) {
    709       1.73   thorpej #ifdef UFS_EXTATTR
    710       1.84   hannken 		int error;
    711       1.84   hannken 
    712   1.86.4.5        ad 		fstrans_start(vp->v_mount, FSTRANS_SHARED);
    713       1.84   hannken 		error = ufs_deleteextattr(ap);
    714       1.84   hannken 		fstrans_done(vp->v_mount);
    715       1.84   hannken 		return error;
    716       1.73   thorpej #else
    717       1.73   thorpej 		return (EOPNOTSUPP);
    718       1.73   thorpej #endif
    719       1.73   thorpej 	}
    720       1.73   thorpej 
    721       1.73   thorpej 	/* XXX Not implemented for UFS2 file systems. */
    722       1.73   thorpej 	return (EOPNOTSUPP);
    723       1.73   thorpej }
    724   1.86.4.9        ad 
    725   1.86.4.9        ad /*
    726   1.86.4.9        ad  * Lock the node.
    727   1.86.4.9        ad  */
    728   1.86.4.9        ad int
    729   1.86.4.9        ad ffs_lock(void *v)
    730   1.86.4.9        ad {
    731   1.86.4.9        ad 	struct vop_lock_args /* {
    732   1.86.4.9        ad 		struct vnode *a_vp;
    733   1.86.4.9        ad 		int a_flags;
    734   1.86.4.9        ad 	} */ *ap = v;
    735   1.86.4.9        ad 	struct vnode *vp = ap->a_vp;
    736   1.86.4.9        ad 	struct mount *mp = vp->v_mount;
    737   1.86.4.9        ad 
    738   1.86.4.9        ad 	/*
    739   1.86.4.9        ad 	 * Fake lock during file system suspension.
    740   1.86.4.9        ad 	 */
    741   1.86.4.9        ad 	if ((vp->v_type == VREG || vp->v_type == VDIR) &&
    742   1.86.4.9        ad 	    fstrans_is_owner(mp) &&
    743   1.86.4.9        ad 	    fstrans_getstate(mp) == FSTRANS_SUSPENDING) {
    744   1.86.4.9        ad 		if ((ap->a_flags & LK_INTERLOCK) != 0)
    745   1.86.4.9        ad 			mutex_exit(&vp->v_interlock);
    746   1.86.4.9        ad 		return 0;
    747   1.86.4.9        ad 	}
    748   1.86.4.9        ad 	return (lockmgr(vp->v_vnlock, ap->a_flags, &vp->v_interlock));
    749   1.86.4.9        ad }
    750   1.86.4.9        ad 
    751   1.86.4.9        ad /*
    752   1.86.4.9        ad  * Unlock the node.
    753   1.86.4.9        ad  */
    754   1.86.4.9        ad int
    755   1.86.4.9        ad ffs_unlock(void *v)
    756   1.86.4.9        ad {
    757   1.86.4.9        ad 	struct vop_unlock_args /* {
    758   1.86.4.9        ad 		struct vnode *a_vp;
    759   1.86.4.9        ad 		int a_flags;
    760   1.86.4.9        ad 	} */ *ap = v;
    761   1.86.4.9        ad 	struct vnode *vp = ap->a_vp;
    762   1.86.4.9        ad 	struct mount *mp = vp->v_mount;
    763   1.86.4.9        ad 
    764   1.86.4.9        ad 	/*
    765   1.86.4.9        ad 	 * Fake unlock during file system suspension.
    766   1.86.4.9        ad 	 */
    767   1.86.4.9        ad 	if ((vp->v_type == VREG || vp->v_type == VDIR) &&
    768   1.86.4.9        ad 	    fstrans_is_owner(mp) &&
    769   1.86.4.9        ad 	    fstrans_getstate(mp) == FSTRANS_SUSPENDING) {
    770   1.86.4.9        ad 		if ((ap->a_flags & LK_INTERLOCK) != 0)
    771   1.86.4.9        ad 			mutex_exit(&vp->v_interlock);
    772   1.86.4.9        ad 		return 0;
    773   1.86.4.9        ad 	}
    774   1.86.4.9        ad 	return (lockmgr(vp->v_vnlock, ap->a_flags | LK_RELEASE,
    775   1.86.4.9        ad 	    &vp->v_interlock));
    776   1.86.4.9        ad }
    777   1.86.4.9        ad 
    778   1.86.4.9        ad /*
    779   1.86.4.9        ad  * Return whether or not the node is locked.
    780   1.86.4.9        ad  */
    781   1.86.4.9        ad int
    782   1.86.4.9        ad ffs_islocked(void *v)
    783   1.86.4.9        ad {
    784   1.86.4.9        ad 	struct vop_islocked_args /* {
    785   1.86.4.9        ad 		struct vnode *a_vp;
    786   1.86.4.9        ad 	} */ *ap = v;
    787   1.86.4.9        ad 	struct vnode *vp = ap->a_vp;
    788   1.86.4.9        ad 
    789   1.86.4.9        ad 	return (lockstatus(vp->v_vnlock));
    790   1.86.4.9        ad }
    791