vfs_default.c revision 176559
1139804Simp/*-
230489Sphk * Copyright (c) 1989, 1993
330489Sphk *	The Regents of the University of California.  All rights reserved.
430489Sphk *
530489Sphk * This code is derived from software contributed
630489Sphk * to Berkeley by John Heidemann of the UCLA Ficus project.
730489Sphk *
830489Sphk * Source: * @(#)i405_init.c 2.10 92/04/27 UCLA Ficus project
930489Sphk *
1030489Sphk * Redistribution and use in source and binary forms, with or without
1130489Sphk * modification, are permitted provided that the following conditions
1230489Sphk * are met:
1330489Sphk * 1. Redistributions of source code must retain the above copyright
1430489Sphk *    notice, this list of conditions and the following disclaimer.
1530489Sphk * 2. Redistributions in binary form must reproduce the above copyright
1630489Sphk *    notice, this list of conditions and the following disclaimer in the
1730489Sphk *    documentation and/or other materials provided with the distribution.
1830489Sphk * 4. Neither the name of the University nor the names of its contributors
1930489Sphk *    may be used to endorse or promote products derived from this software
2030489Sphk *    without specific prior written permission.
2130489Sphk *
2230489Sphk * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2330489Sphk * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2430489Sphk * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2530489Sphk * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2630489Sphk * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2730489Sphk * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2830489Sphk * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2930489Sphk * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
3030489Sphk * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3130489Sphk * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3230489Sphk * SUCH DAMAGE.
3330489Sphk */
3430489Sphk
35116182Sobrien#include <sys/cdefs.h>
36116182Sobrien__FBSDID("$FreeBSD: head/sys/kern/vfs_default.c 176559 2008-02-25 18:45:57Z attilio $");
37116182Sobrien
3830489Sphk#include <sys/param.h>
3930489Sphk#include <sys/systm.h>
4060041Sphk#include <sys/bio.h>
4144272Sbde#include <sys/buf.h>
4265770Sbp#include <sys/conf.h>
43147198Sssouhlal#include <sys/event.h>
4430489Sphk#include <sys/kernel.h>
45114216Skan#include <sys/limits.h>
4631561Sbde#include <sys/lock.h>
4730743Sphk#include <sys/malloc.h>
4851068Salfred#include <sys/mount.h>
4967365Sjhb#include <sys/mutex.h>
5030492Sphk#include <sys/unistd.h>
5130489Sphk#include <sys/vnode.h>
5230743Sphk#include <sys/poll.h>
5330489Sphk
5465770Sbp#include <vm/vm.h>
5565770Sbp#include <vm/vm_object.h>
5665770Sbp#include <vm/vm_extern.h>
5765770Sbp#include <vm/pmap.h>
5865770Sbp#include <vm/vm_map.h>
5965770Sbp#include <vm/vm_page.h>
6065770Sbp#include <vm/vm_pager.h>
6165770Sbp#include <vm/vnode_pager.h>
6265770Sbp
6392723Salfredstatic int	vop_nolookup(struct vop_lookup_args *);
6492723Salfredstatic int	vop_nostrategy(struct vop_strategy_args *);
6530489Sphk
6630489Sphk/*
6730489Sphk * This vnode table stores what we want to do if the filesystem doesn't
6830489Sphk * implement a particular VOP.
6930489Sphk *
7030489Sphk * If there is no specific entry here, we will return EOPNOTSUPP.
7130489Sphk *
7230489Sphk */
7330489Sphk
74138290Sphkstruct vop_vector default_vnodeops = {
75138290Sphk	.vop_default =		NULL,
76138339Sphk	.vop_bypass =		VOP_EOPNOTSUPP,
77138339Sphk
78138290Sphk	.vop_advlock =		VOP_EINVAL,
79138290Sphk	.vop_bmap =		vop_stdbmap,
80138290Sphk	.vop_close =		VOP_NULL,
81138290Sphk	.vop_fsync =		VOP_NULL,
82138290Sphk	.vop_getpages =		vop_stdgetpages,
83138290Sphk	.vop_getwritemount = 	vop_stdgetwritemount,
84143494Sjeff	.vop_inactive =		VOP_NULL,
85138290Sphk	.vop_ioctl =		VOP_ENOTTY,
86147198Sssouhlal	.vop_kqfilter =		vop_stdkqfilter,
87138290Sphk	.vop_islocked =		vop_stdislocked,
88138290Sphk	.vop_lease =		VOP_NULL,
89169671Skib	.vop_lock1 =		vop_stdlock,
90138290Sphk	.vop_lookup =		vop_nolookup,
91138290Sphk	.vop_open =		VOP_NULL,
92138290Sphk	.vop_pathconf =		VOP_EINVAL,
93138290Sphk	.vop_poll =		vop_nopoll,
94138290Sphk	.vop_putpages =		vop_stdputpages,
95138290Sphk	.vop_readlink =		VOP_EINVAL,
96138290Sphk	.vop_revoke =		VOP_PANIC,
97138290Sphk	.vop_strategy =		vop_nostrategy,
98138290Sphk	.vop_unlock =		vop_stdunlock,
99166774Spjd	.vop_vptofh =		vop_stdvptofh,
10030489Sphk};
10130489Sphk
10291690Seivind/*
10391690Seivind * Series of placeholder functions for various error returns for
10491690Seivind * VOPs.
10591690Seivind */
10691690Seivind
10730489Sphkint
10830492Sphkvop_eopnotsupp(struct vop_generic_args *ap)
10930489Sphk{
11030489Sphk	/*
11130492Sphk	printf("vop_notsupp[%s]\n", ap->a_desc->vdesc_name);
11230489Sphk	*/
11330489Sphk
11430489Sphk	return (EOPNOTSUPP);
11530489Sphk}
11630489Sphk
11730489Sphkint
11830492Sphkvop_ebadf(struct vop_generic_args *ap)
11930489Sphk{
12030489Sphk
12130492Sphk	return (EBADF);
12230492Sphk}
12330492Sphk
12430492Sphkint
12530492Sphkvop_enotty(struct vop_generic_args *ap)
12630492Sphk{
12730492Sphk
12830492Sphk	return (ENOTTY);
12930492Sphk}
13030492Sphk
13130492Sphkint
13230492Sphkvop_einval(struct vop_generic_args *ap)
13330492Sphk{
13430492Sphk
13530492Sphk	return (EINVAL);
13630492Sphk}
13730492Sphk
13830492Sphkint
13930492Sphkvop_null(struct vop_generic_args *ap)
14030492Sphk{
14130492Sphk
14230492Sphk	return (0);
14330492Sphk}
14430492Sphk
14591690Seivind/*
14691690Seivind * Helper function to panic on some bad VOPs in some filesystems.
14791690Seivind */
14841056Speterint
14941056Spetervop_panic(struct vop_generic_args *ap)
15041056Speter{
15141056Speter
15272594Sbde	panic("filesystem goof: vop_panic[%s]", ap->a_desc->vdesc_name);
15341056Speter}
15441056Speter
15591690Seivind/*
15691690Seivind * vop_std<something> and vop_no<something> are default functions for use by
15791690Seivind * filesystems that need the "default reasonable" implementation for a
15891690Seivind * particular operation.
15991690Seivind *
16091690Seivind * The documentation for the operations they implement exists (if it exists)
16191690Seivind * in the VOP_<SOMETHING>(9) manpage (all uppercase).
16291690Seivind */
16391690Seivind
16491690Seivind/*
16591690Seivind * Default vop for filesystems that do not support name lookup
16691690Seivind */
16772594Sbdestatic int
16872594Sbdevop_nolookup(ap)
16972594Sbde	struct vop_lookup_args /* {
17072594Sbde		struct vnode *a_dvp;
17172594Sbde		struct vnode **a_vpp;
17272594Sbde		struct componentname *a_cnp;
17372594Sbde	} */ *ap;
17472594Sbde{
17572594Sbde
17672594Sbde	*ap->a_vpp = NULL;
17772594Sbde	return (ENOTDIR);
17872594Sbde}
17972594Sbde
18046349Salc/*
18146349Salc *	vop_nostrategy:
18246349Salc *
18346349Salc *	Strategy routine for VFS devices that have none.
18446349Salc *
18558934Sphk *	BIO_ERROR and B_INVAL must be cleared prior to calling any strategy
18658345Sphk *	routine.  Typically this is done for a BIO_READ strategy call.
187112067Skan *	Typically B_INVAL is assumed to already be clear prior to a write
18858345Sphk *	and should not be cleared manually unless you just made the buffer
18958934Sphk *	invalid.  BIO_ERROR should be cleared either way.
19046349Salc */
19146349Salc
19230489Sphkstatic int
19330489Sphkvop_nostrategy (struct vop_strategy_args *ap)
19430489Sphk{
19530489Sphk	printf("No strategy for buffer at %p\n", ap->a_bp);
196111842Snjl	vprint("vnode", ap->a_vp);
19758934Sphk	ap->a_bp->b_ioflags |= BIO_ERROR;
19830489Sphk	ap->a_bp->b_error = EOPNOTSUPP;
19959249Sphk	bufdone(ap->a_bp);
20030489Sphk	return (EOPNOTSUPP);
20130489Sphk}
20230492Sphk
20391690Seivind/*
20491690Seivind * vop_stdpathconf:
205112067Skan *
20691690Seivind * Standard implementation of POSIX pathconf, to get information about limits
20791690Seivind * for a filesystem.
20891690Seivind * Override per filesystem for the case where the filesystem has smaller
20991690Seivind * limits.
21091690Seivind */
21130492Sphkint
21230492Sphkvop_stdpathconf(ap)
21330492Sphk	struct vop_pathconf_args /* {
21430492Sphk	struct vnode *a_vp;
21530492Sphk	int a_name;
21630492Sphk	int *a_retval;
21730492Sphk	} */ *ap;
21830492Sphk{
21930492Sphk
22030492Sphk	switch (ap->a_name) {
221149175Sphk		case _PC_NAME_MAX:
222149175Sphk			*ap->a_retval = NAME_MAX;
223149175Sphk			return (0);
224149175Sphk		case _PC_PATH_MAX:
225149175Sphk			*ap->a_retval = PATH_MAX;
226149175Sphk			return (0);
22730492Sphk		case _PC_LINK_MAX:
22830492Sphk			*ap->a_retval = LINK_MAX;
22930492Sphk			return (0);
23030492Sphk		case _PC_MAX_CANON:
23130492Sphk			*ap->a_retval = MAX_CANON;
23230492Sphk			return (0);
23330492Sphk		case _PC_MAX_INPUT:
23430492Sphk			*ap->a_retval = MAX_INPUT;
23530492Sphk			return (0);
23630492Sphk		case _PC_PIPE_BUF:
23730492Sphk			*ap->a_retval = PIPE_BUF;
23830492Sphk			return (0);
23930492Sphk		case _PC_CHOWN_RESTRICTED:
24030492Sphk			*ap->a_retval = 1;
24130492Sphk			return (0);
24230492Sphk		case _PC_VDISABLE:
24330492Sphk			*ap->a_retval = _POSIX_VDISABLE;
24430492Sphk			return (0);
24530492Sphk		default:
24630492Sphk			return (EINVAL);
24730492Sphk	}
24830492Sphk	/* NOTREACHED */
24930492Sphk}
25030513Sphk
25130513Sphk/*
25230513Sphk * Standard lock, unlock and islocked functions.
25330513Sphk */
25430513Sphkint
25530513Sphkvop_stdlock(ap)
256169671Skib	struct vop_lock1_args /* {
25730513Sphk		struct vnode *a_vp;
25830513Sphk		int a_flags;
259164248Skmacy		char *file;
260164248Skmacy		int line;
26130513Sphk	} */ *ap;
262112067Skan{
26366355Sbp	struct vnode *vp = ap->a_vp;
26430513Sphk
265176320Sattilio	return (_lockmgr_args(vp->v_vnlock, ap->a_flags, VI_MTX(vp),
266176320Sattilio	    LK_WMESG_DEFAULT, LK_PRIO_DEFAULT, LK_TIMO_DEFAULT, ap->a_file,
267175635Sattilio	    ap->a_line));
26830513Sphk}
26930513Sphk
27091690Seivind/* See above. */
27130513Sphkint
27230513Sphkvop_stdunlock(ap)
27330513Sphk	struct vop_unlock_args /* {
27430513Sphk		struct vnode *a_vp;
27530513Sphk		int a_flags;
27630513Sphk	} */ *ap;
27730513Sphk{
27866355Sbp	struct vnode *vp = ap->a_vp;
27930513Sphk
280175635Sattilio	return (lockmgr(vp->v_vnlock, ap->a_flags | LK_RELEASE, VI_MTX(vp)));
28130513Sphk}
28230513Sphk
28391690Seivind/* See above. */
28430513Sphkint
28530513Sphkvop_stdislocked(ap)
28630513Sphk	struct vop_islocked_args /* {
28730513Sphk		struct vnode *a_vp;
28830513Sphk	} */ *ap;
28930513Sphk{
29030513Sphk
291176559Sattilio	return (lockstatus(ap->a_vp->v_vnlock));
29230513Sphk}
29330513Sphk
29430743Sphk/*
29530743Sphk * Return true for select/poll.
29630743Sphk */
29730743Sphkint
29830743Sphkvop_nopoll(ap)
29930743Sphk	struct vop_poll_args /* {
30030743Sphk		struct vnode *a_vp;
30130743Sphk		int  a_events;
30230743Sphk		struct ucred *a_cred;
30383366Sjulian		struct thread *a_td;
30430743Sphk	} */ *ap;
30530743Sphk{
30630743Sphk	/*
30731727Swollman	 * Return true for read/write.  If the user asked for something
30831727Swollman	 * special, return POLLNVAL, so that clients have a way of
30931727Swollman	 * determining reliably whether or not the extended
31031727Swollman	 * functionality is present without hard-coding knowledge
31131727Swollman	 * of specific filesystem implementations.
312120514Sphk	 * Stay in sync with kern_conf.c::no_poll().
31330743Sphk	 */
31431727Swollman	if (ap->a_events & ~POLLSTANDARD)
31531727Swollman		return (POLLNVAL);
31631727Swollman
31730743Sphk	return (ap->a_events & (POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM));
31830743Sphk}
31930743Sphk
32031727Swollman/*
32131727Swollman * Implement poll for local filesystems that support it.
32231727Swollman */
32330743Sphkint
32431727Swollmanvop_stdpoll(ap)
32531727Swollman	struct vop_poll_args /* {
32631727Swollman		struct vnode *a_vp;
32731727Swollman		int  a_events;
32831727Swollman		struct ucred *a_cred;
32983366Sjulian		struct thread *a_td;
33031727Swollman	} */ *ap;
33131727Swollman{
33276578Sjlemon	if (ap->a_events & ~POLLSTANDARD)
33383366Sjulian		return (vn_pollrecord(ap->a_vp, ap->a_td, ap->a_events));
33476578Sjlemon	return (ap->a_events & (POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM));
33531727Swollman}
33631727Swollman
33730743Sphk/*
33862976Smckusick * Return our mount point, as we will take charge of the writes.
33962976Smckusick */
34062976Smckusickint
34162976Smckusickvop_stdgetwritemount(ap)
34262976Smckusick	struct vop_getwritemount_args /* {
34362976Smckusick		struct vnode *a_vp;
34462976Smckusick		struct mount **a_mpp;
34562976Smckusick	} */ *ap;
34662976Smckusick{
347157323Sjeff	struct mount *mp;
34862976Smckusick
349157323Sjeff	/*
350157323Sjeff	 * XXX Since this is called unlocked we may be recycled while
351157323Sjeff	 * attempting to ref the mount.  If this is the case or mountpoint
352157323Sjeff	 * will be set to NULL.  We only have to prevent this call from
353157323Sjeff	 * returning with a ref to an incorrect mountpoint.  It is not
354157323Sjeff	 * harmful to return with a ref to our previous mountpoint.
355157323Sjeff	 */
356157323Sjeff	mp = ap->a_vp->v_mount;
357162455Stegge	if (mp != NULL) {
358162455Stegge		vfs_ref(mp);
359162455Stegge		if (mp != ap->a_vp->v_mount) {
360162455Stegge			vfs_rel(mp);
361162455Stegge			mp = NULL;
362162455Stegge		}
363157323Sjeff	}
364157323Sjeff	*(ap->a_mpp) = mp;
36562976Smckusick	return (0);
36662976Smckusick}
36762976Smckusick
36891690Seivind/* XXX Needs good comment and VOP_BMAP(9) manpage */
36976131Sphkint
37076131Sphkvop_stdbmap(ap)
371112067Skan	struct vop_bmap_args /* {
37276131Sphk		struct vnode *a_vp;
37376131Sphk		daddr_t  a_bn;
374137726Sphk		struct bufobj **a_bop;
37576131Sphk		daddr_t *a_bnp;
37676131Sphk		int *a_runp;
37776131Sphk		int *a_runb;
37876131Sphk	} */ *ap;
37976131Sphk{
38076131Sphk
381137726Sphk	if (ap->a_bop != NULL)
382137726Sphk		*ap->a_bop = &ap->a_vp->v_bufobj;
38376131Sphk	if (ap->a_bnp != NULL)
38476131Sphk		*ap->a_bnp = ap->a_bn * btodb(ap->a_vp->v_mount->mnt_stat.f_iosize);
38576131Sphk	if (ap->a_runp != NULL)
38676131Sphk		*ap->a_runp = 0;
38776131Sphk	if (ap->a_runb != NULL)
38876131Sphk		*ap->a_runb = 0;
38976131Sphk	return (0);
39076131Sphk}
39176131Sphk
392110584Sjeffint
393110584Sjeffvop_stdfsync(ap)
394110584Sjeff	struct vop_fsync_args /* {
395110584Sjeff		struct vnode *a_vp;
396110584Sjeff		struct ucred *a_cred;
397110584Sjeff		int a_waitfor;
398110584Sjeff		struct thread *a_td;
399110584Sjeff	} */ *ap;
400110584Sjeff{
401110584Sjeff	struct vnode *vp = ap->a_vp;
402110584Sjeff	struct buf *bp;
403136751Sphk	struct bufobj *bo;
404110584Sjeff	struct buf *nbp;
405145732Sjeff	int error = 0;
406144584Sjeff	int maxretry = 1000;     /* large, arbitrarily chosen */
407110584Sjeff
408110584Sjeff	VI_LOCK(vp);
409110584Sjeffloop1:
410110584Sjeff	/*
411110584Sjeff	 * MARK/SCAN initialization to avoid infinite loops.
412110584Sjeff	 */
413136943Sphk        TAILQ_FOREACH(bp, &vp->v_bufobj.bo_dirty.bv_hd, b_bobufs) {
414110584Sjeff                bp->b_vflags &= ~BV_SCANNED;
415110584Sjeff		bp->b_error = 0;
416110584Sjeff	}
417110584Sjeff
418110584Sjeff	/*
419144584Sjeff	 * Flush all dirty buffers associated with a vnode.
420110584Sjeff	 */
421110584Sjeffloop2:
422136943Sphk	TAILQ_FOREACH_SAFE(bp, &vp->v_bufobj.bo_dirty.bv_hd, b_bobufs, nbp) {
423110584Sjeff		if ((bp->b_vflags & BV_SCANNED) != 0)
424110584Sjeff			continue;
425110584Sjeff		bp->b_vflags |= BV_SCANNED;
426111463Sjeff		if (BUF_LOCK(bp, LK_EXCLUSIVE | LK_NOWAIT, NULL))
427110584Sjeff			continue;
428110584Sjeff		VI_UNLOCK(vp);
429147388Sjeff		KASSERT(bp->b_bufobj == &vp->v_bufobj,
430147388Sjeff		    ("bp %p wrong b_bufobj %p should be %p",
431147388Sjeff		    bp, bp->b_bufobj, &vp->v_bufobj));
432110584Sjeff		if ((bp->b_flags & B_DELWRI) == 0)
433110588Sjeff			panic("fsync: not dirty");
434140734Sphk		if ((vp->v_object != NULL) && (bp->b_flags & B_CLUSTEROK)) {
435110584Sjeff			vfs_bio_awrite(bp);
436110584Sjeff		} else {
437110584Sjeff			bremfree(bp);
438110584Sjeff			bawrite(bp);
439110584Sjeff		}
440110584Sjeff		VI_LOCK(vp);
441110584Sjeff		goto loop2;
442110584Sjeff	}
443110584Sjeff
444110584Sjeff	/*
445110584Sjeff	 * If synchronous the caller expects us to completely resolve all
446110584Sjeff	 * dirty buffers in the system.  Wait for in-progress I/O to
447110584Sjeff	 * complete (which could include background bitmap writes), then
448110584Sjeff	 * retry if dirty blocks still exist.
449110584Sjeff	 */
450110584Sjeff	if (ap->a_waitfor == MNT_WAIT) {
451136751Sphk		bo = &vp->v_bufobj;
452136751Sphk		bufobj_wwait(bo, 0, 0);
453136751Sphk		if (bo->bo_dirty.bv_cnt > 0) {
454110584Sjeff			/*
455110584Sjeff			 * If we are unable to write any of these buffers
456110584Sjeff			 * then we fail now rather than trying endlessly
457110584Sjeff			 * to write them out.
458110584Sjeff			 */
459136751Sphk			TAILQ_FOREACH(bp, &bo->bo_dirty.bv_hd, b_bobufs)
460110584Sjeff				if ((error = bp->b_error) == 0)
461110584Sjeff					continue;
462145732Sjeff			if (error == 0 && --maxretry >= 0)
463110584Sjeff				goto loop1;
464110584Sjeff			error = EAGAIN;
465110584Sjeff		}
466110584Sjeff	}
467110584Sjeff	VI_UNLOCK(vp);
468144584Sjeff	if (error == EAGAIN)
469144584Sjeff		vprint("fsync: giving up on dirty", vp);
470112067Skan
471110584Sjeff	return (error);
472110584Sjeff}
473112067Skan
47491690Seivind/* XXX Needs good comment and more info in the manpage (VOP_GETPAGES(9)). */
47576167Sphkint
47676167Sphkvop_stdgetpages(ap)
47776167Sphk	struct vop_getpages_args /* {
47876167Sphk		struct vnode *a_vp;
47976167Sphk		vm_page_t *a_m;
48076167Sphk		int a_count;
48176167Sphk		int a_reqpage;
48276167Sphk		vm_ooffset_t a_offset;
48376167Sphk	} */ *ap;
48476167Sphk{
48576131Sphk
48676167Sphk	return vnode_pager_generic_getpages(ap->a_vp, ap->a_m,
48776167Sphk	    ap->a_count, ap->a_reqpage);
48876167Sphk}
48976167Sphk
490147198Sssouhlalint
491147198Sssouhlalvop_stdkqfilter(struct vop_kqfilter_args *ap)
492147198Sssouhlal{
493147198Sssouhlal	return vfs_kqfilter(ap);
494147198Sssouhlal}
495147198Sssouhlal
49691690Seivind/* XXX Needs good comment and more info in the manpage (VOP_PUTPAGES(9)). */
49776319Sphkint
49876167Sphkvop_stdputpages(ap)
49976167Sphk	struct vop_putpages_args /* {
50076167Sphk		struct vnode *a_vp;
50176167Sphk		vm_page_t *a_m;
50276167Sphk		int a_count;
50376167Sphk		int a_sync;
50476167Sphk		int *a_rtvals;
50576167Sphk		vm_ooffset_t a_offset;
50676167Sphk	} */ *ap;
50776167Sphk{
50876167Sphk
50976319Sphk	return vnode_pager_generic_putpages(ap->a_vp, ap->a_m, ap->a_count,
51076167Sphk	     ap->a_sync, ap->a_rtvals);
51176167Sphk}
51276167Sphk
513166774Spjdint
514166774Spjdvop_stdvptofh(struct vop_vptofh_args *ap)
515166774Spjd{
516166795Spjd	return (EOPNOTSUPP);
517166774Spjd}
518166774Spjd
519112067Skan/*
52051068Salfred * vfs default ops
52191690Seivind * used to fill the vfs function table to get reasonable default return values.
52251068Salfred */
52391690Seivindint
524144054Sjeffvfs_stdroot (mp, flags, vpp, td)
52551068Salfred	struct mount *mp;
526144054Sjeff	int flags;
52751068Salfred	struct vnode **vpp;
528132023Salfred	struct thread *td;
52951068Salfred{
530131734Salfred
53151068Salfred	return (EOPNOTSUPP);
53251068Salfred}
53351068Salfred
53491690Seivindint
53583366Sjulianvfs_stdstatfs (mp, sbp, td)
53651068Salfred	struct mount *mp;
53751068Salfred	struct statfs *sbp;
53883366Sjulian	struct thread *td;
53951068Salfred{
540131734Salfred
54151068Salfred	return (EOPNOTSUPP);
54251068Salfred}
54351068Salfred
54451068Salfredint
54583366Sjulianvfs_stdquotactl (mp, cmds, uid, arg, td)
54651068Salfred	struct mount *mp;
54751068Salfred	int cmds;
54851068Salfred	uid_t uid;
549153400Sdes	void *arg;
55083366Sjulian	struct thread *td;
55151068Salfred{
552131734Salfred
55351068Salfred	return (EOPNOTSUPP);
55451068Salfred}
55551068Salfred
556112067Skanint
557140048Sphkvfs_stdsync(mp, waitfor, td)
55851068Salfred	struct mount *mp;
55951068Salfred	int waitfor;
56083366Sjulian	struct thread *td;
56151068Salfred{
562154152Stegge	struct vnode *vp, *mvp;
563112119Skan	int error, lockreq, allerror = 0;
564112119Skan
565112119Skan	lockreq = LK_EXCLUSIVE | LK_INTERLOCK;
566112119Skan	if (waitfor != MNT_WAIT)
567112119Skan		lockreq |= LK_NOWAIT;
568112119Skan	/*
569112119Skan	 * Force stale buffer cache information to be flushed.
570112119Skan	 */
571122091Skan	MNT_ILOCK(mp);
572112119Skanloop:
573154152Stegge	MNT_VNODE_FOREACH(vp, mp, mvp) {
574112119Skan
575112119Skan		VI_LOCK(vp);
576136943Sphk		if (vp->v_bufobj.bo_dirty.bv_cnt == 0) {
577112119Skan			VI_UNLOCK(vp);
578112119Skan			continue;
579112119Skan		}
580122091Skan		MNT_IUNLOCK(mp);
581112119Skan
582112119Skan		if ((error = vget(vp, lockreq, td)) != 0) {
583122091Skan			MNT_ILOCK(mp);
584154152Stegge			if (error == ENOENT) {
585154152Stegge				MNT_VNODE_FOREACH_ABORT_ILOCKED(mp, mvp);
586112119Skan				goto loop;
587154152Stegge			}
588112119Skan			continue;
589112119Skan		}
590140048Sphk		error = VOP_FSYNC(vp, waitfor, td);
591112119Skan		if (error)
592112119Skan			allerror = error;
593112119Skan
594155032Sjeff		/* Do not turn this into vput.  td is not always curthread. */
595175294Sattilio		VOP_UNLOCK(vp, 0);
596121874Skan		vrele(vp);
597122091Skan		MNT_ILOCK(mp);
598112119Skan	}
599122091Skan	MNT_IUNLOCK(mp);
600112119Skan	return (allerror);
601112119Skan}
602112119Skan
603112119Skanint
604140048Sphkvfs_stdnosync (mp, waitfor, td)
605112119Skan	struct mount *mp;
606112119Skan	int waitfor;
607112119Skan	struct thread *td;
608112119Skan{
609131734Salfred
61051068Salfred	return (0);
61151068Salfred}
61251068Salfred
613112067Skanint
61492462Smckusickvfs_stdvget (mp, ino, flags, vpp)
61551068Salfred	struct mount *mp;
61651068Salfred	ino_t ino;
61792462Smckusick	int flags;
61851068Salfred	struct vnode **vpp;
61951068Salfred{
620131734Salfred
62151068Salfred	return (EOPNOTSUPP);
62251068Salfred}
62351068Salfred
624112067Skanint
62551138Salfredvfs_stdfhtovp (mp, fhp, vpp)
62651068Salfred	struct mount *mp;
62751068Salfred	struct fid *fhp;
62851138Salfred	struct vnode **vpp;
62951138Salfred{
630131734Salfred
63151138Salfred	return (EOPNOTSUPP);
63251138Salfred}
63351138Salfred
63451068Salfredint
635112067Skanvfs_stdinit (vfsp)
63651068Salfred	struct vfsconf *vfsp;
63751068Salfred{
638131734Salfred
63951068Salfred	return (0);
64051068Salfred}
64151068Salfred
64251068Salfredint
64351068Salfredvfs_stduninit (vfsp)
64451068Salfred	struct vfsconf *vfsp;
64551068Salfred{
646131734Salfred
64751068Salfred	return(0);
64851068Salfred}
64951068Salfred
65054803Srwatsonint
65183366Sjulianvfs_stdextattrctl(mp, cmd, filename_vp, attrnamespace, attrname, td)
65254803Srwatson	struct mount *mp;
65354803Srwatson	int cmd;
65474273Srwatson	struct vnode *filename_vp;
65574437Srwatson	int attrnamespace;
65656272Srwatson	const char *attrname;
65783366Sjulian	struct thread *td;
65854803Srwatson{
659131734Salfred
660101786Sphk	if (filename_vp != NULL)
661175294Sattilio		VOP_UNLOCK(filename_vp, 0);
662131734Salfred	return (EOPNOTSUPP);
66354803Srwatson}
66454803Srwatson
665131733Salfredint
666131733Salfredvfs_stdsysctl(mp, op, req)
667131733Salfred	struct mount *mp;
668131733Salfred	fsctlop_t op;
669131733Salfred	struct sysctl_req *req;
670131733Salfred{
671131733Salfred
672131733Salfred	return (EOPNOTSUPP);
673131733Salfred}
674131733Salfred
67551068Salfred/* end of vfs default ops */
676