Home | History | Annotate | Line # | Download | only in genfs
genfs_node.h revision 1.21
      1  1.21  dholland /* $NetBSD: genfs_node.h,v 1.21 2013/06/06 02:00:59 dholland Exp $ */
      2   1.1       chs 
      3   1.1       chs /*
      4   1.1       chs  * Copyright (c) 2001 Chuck Silvers.
      5   1.1       chs  * All rights reserved.
      6   1.1       chs  *
      7   1.1       chs  * Redistribution and use in source and binary forms, with or without
      8   1.1       chs  * modification, are permitted provided that the following conditions
      9   1.1       chs  * are met:
     10   1.1       chs  * 1. Redistributions of source code must retain the above copyright
     11   1.1       chs  *    notice, this list of conditions and the following disclaimer.
     12   1.1       chs  * 2. Redistributions in binary form must reproduce the above copyright
     13   1.1       chs  *    notice, this list of conditions and the following disclaimer in the
     14   1.1       chs  *    documentation and/or other materials provided with the distribution.
     15   1.1       chs  * 3. All advertising materials mentioning features or use of this software
     16   1.1       chs  *    must display the following acknowledgement:
     17   1.1       chs  *      This product includes software developed by Chuck Silvers.
     18   1.1       chs  * 4. The name of the author may not be used to endorse or promote products
     19   1.1       chs  *    derived from this software without specific prior written permission.
     20   1.1       chs  *
     21   1.1       chs  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     22   1.1       chs  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     23   1.1       chs  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     24   1.1       chs  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     25   1.1       chs  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     26   1.1       chs  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     27   1.1       chs  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     28   1.1       chs  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     29   1.1       chs  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     30   1.1       chs  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     31   1.1       chs  */
     32   1.1       chs 
     33   1.1       chs #ifndef	_MISCFS_GENFS_GENFS_NODE_H_
     34   1.1       chs #define	_MISCFS_GENFS_GENFS_NODE_H_
     35   1.2       chs 
     36  1.15        ad #include <sys/rwlock.h>
     37  1.15        ad 
     38   1.2       chs struct vm_page;
     39  1.11      elad struct kauth_cred;
     40  1.13    dogcow struct uio;
     41  1.21  dholland struct vnode;
     42   1.1       chs 
     43   1.1       chs struct genfs_ops {
     44   1.4  perseant 	void	(*gop_size)(struct vnode *, off_t, off_t *, int);
     45  1.11      elad 	int	(*gop_alloc)(struct vnode *, off_t, off_t, int,
     46  1.11      elad 	    struct kauth_cred *);
     47   1.1       chs 	int	(*gop_write)(struct vnode *, struct vm_page **, int, int);
     48   1.8      yamt 	void	(*gop_markupdate)(struct vnode *, int);
     49   1.1       chs };
     50   1.1       chs 
     51   1.4  perseant #define GOP_SIZE(vp, size, eobp, flags) \
     52   1.4  perseant 	(*VTOG(vp)->g_op->gop_size)((vp), (size), (eobp), (flags))
     53   1.1       chs #define GOP_ALLOC(vp, off, len, flags, cred) \
     54   1.1       chs 	(*VTOG(vp)->g_op->gop_alloc)((vp), (off), (len), (flags), (cred))
     55   1.1       chs #define GOP_WRITE(vp, pgs, npages, flags) \
     56   1.1       chs 	(*VTOG(vp)->g_op->gop_write)((vp), (pgs), (npages), (flags))
     57   1.1       chs 
     58   1.8      yamt /*
     59   1.8      yamt  * GOP_MARKUPDATE: mark vnode's timestamps for update.
     60   1.8      yamt  *
     61   1.8      yamt  * => called with v_interlock (and possibly other locks) held.
     62   1.8      yamt  * => used for accesses via mmap.
     63   1.8      yamt  */
     64   1.8      yamt 
     65   1.8      yamt #define GOP_MARKUPDATE(vp, flags) \
     66   1.8      yamt 	(VTOG(vp)->g_op->gop_markupdate) ? \
     67   1.8      yamt 	(*VTOG(vp)->g_op->gop_markupdate)((vp), (flags)) : \
     68   1.8      yamt 	(void)0;
     69   1.8      yamt 
     70   1.4  perseant /* Flags to GOP_SIZE */
     71   1.5      yamt #define	GOP_SIZE_MEM	0x4	/* in-memory size */
     72   1.4  perseant 
     73   1.8      yamt /* Flags to GOP_MARKUPDATE */
     74   1.8      yamt #define	GOP_UPDATE_ACCESSED	1
     75   1.8      yamt #define	GOP_UPDATE_MODIFIED	2
     76   1.8      yamt 
     77   1.1       chs struct genfs_node {
     78   1.6      yamt 	const struct genfs_ops	*g_op;		/* ops vector */
     79  1.15        ad 	krwlock_t		g_glock;	/* getpages lock */
     80   1.7      yamt 	int			g_dirtygen;
     81   1.1       chs };
     82   1.1       chs 
     83   1.1       chs #define VTOG(vp) ((struct genfs_node *)(vp)->v_data)
     84   1.1       chs 
     85   1.4  perseant void	genfs_size(struct vnode *, off_t, off_t *, int);
     86   1.6      yamt void	genfs_node_init(struct vnode *, const struct genfs_ops *);
     87  1.16        ad void	genfs_node_destroy(struct vnode *);
     88   1.1       chs int	genfs_gop_write(struct vnode *, struct vm_page **, int, int);
     89  1.17   reinoud int	genfs_gop_write_rwmap(struct vnode *, struct vm_page **, int, int);
     90   1.3       chs int	genfs_compat_gop_write(struct vnode *, struct vm_page **, int, int);
     91  1.12       chs void	genfs_directio(struct vnode *, struct uio *, int);
     92   1.1       chs 
     93  1.14      yamt void	genfs_node_wrlock(struct vnode *);
     94  1.14      yamt void	genfs_node_rdlock(struct vnode *);
     95  1.19  uebayasi int	genfs_node_rdtrylock(struct vnode *);
     96  1.14      yamt void	genfs_node_unlock(struct vnode *);
     97  1.20       chs int	genfs_node_wrlocked(struct vnode *);
     98  1.14      yamt 
     99   1.1       chs #endif	/* _MISCFS_GENFS_GENFS_NODE_H_ */
    100