[BACK]Return to puffs_sys.h CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / sys / fs / puffs

Annotation of src/sys/fs/puffs/puffs_sys.h, Revision 1.43

1.43    ! pooka       1: /*     $NetBSD: puffs_sys.h,v 1.42 2007/06/24 22:16:04 pooka Exp $     */
1.1       pooka       2:
                      3: /*
                      4:  * Copyright (c) 2005, 2006  Antti Kantee.  All Rights Reserved.
                      5:  *
                      6:  * Development of this software was supported by the
                      7:  * Google Summer of Code program and the Ulla Tuominen Foundation.
                      8:  * The Google SoC project was mentored by Bill Studenmund.
                      9:  *
                     10:  * Redistribution and use in source and binary forms, with or without
                     11:  * modification, are permitted provided that the following conditions
                     12:  * are met:
                     13:  * 1. Redistributions of source code must retain the above copyright
                     14:  *    notice, this list of conditions and the following disclaimer.
                     15:  * 2. Redistributions in binary form must reproduce the above copyright
                     16:  *    notice, this list of conditions and the following disclaimer in the
                     17:  *    documentation and/or other materials provided with the distribution.
                     18:  *
                     19:  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
                     20:  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
                     21:  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
                     22:  * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
                     23:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
                     24:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
                     25:  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                     26:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
                     27:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
                     28:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
                     29:  * SUCH DAMAGE.
                     30:  */
                     31:
                     32: #ifndef _PUFFS_SYS_H_
                     33: #define _PUFFS_SYS_H_
                     34:
                     35: #include <sys/param.h>
                     36: #include <sys/select.h>
                     37: #include <sys/kauth.h>
1.28      pooka      38: #include <sys/mutex.h>
1.1       pooka      39: #include <sys/queue.h>
1.4       pooka      40: #include <sys/pool.h>
1.1       pooka      41:
                     42: #include <fs/puffs/puffs_msgif.h>
                     43:
1.6       pooka      44: #include <miscfs/genfs/genfs_node.h>
                     45:
1.2       pooka      46: extern int (**puffs_vnodeop_p)(void *);
                     47: extern int (**puffs_specop_p)(void *);
1.3       pooka      48: extern int (**puffs_fifoop_p)(void *);
1.2       pooka      49:
                     50: extern const struct vnodeopv_desc puffs_vnodeop_opv_desc;
                     51: extern const struct vnodeopv_desc puffs_specop_opv_desc;
1.3       pooka      52: extern const struct vnodeopv_desc puffs_fifoop_opv_desc;
1.10      pooka      53: extern const struct vnodeopv_desc puffs_msgop_opv_desc;
1.2       pooka      54:
1.4       pooka      55: extern struct pool puffs_pnpool;
                     56:
1.17      pooka      57: #define PUFFS_NAMEPREFIX "puffs:"
                     58:
1.1       pooka      59: #define PUFFS_SIZEOPREQ_UIO_IN 1
                     60: #define PUFFS_SIZEOPREQ_UIO_OUT 2
                     61: #define PUFFS_SIZEOPREQ_BUF_IN 3
                     62: #define PUFFS_SIZEOPREQ_BUF_OUT 4
                     63:
                     64: #define PUFFS_SIZEOP_UIO(a)    \
                     65:        (((a)==PUFFS_SIZEOPREQ_UIO_IN)||(a)==PUFFS_SIZEOPREQ_UIO_OUT)
                     66: #define PUFFS_SIZEOP_BUF(a)    \
                     67:        (((a)==PUFFS_SIZEOPREQ_BUF_IN)||(a)==PUFFS_SIZEOPREQ_BUF_OUT)
                     68:
                     69: /* XXX: alignment-optimization */
                     70: struct puffs_sizepark {
                     71:        uint64_t        pkso_reqid;
                     72:        uint8_t         pkso_reqtype;
                     73:
                     74:        struct uio      *pkso_uio;
                     75:        void            *pkso_copybuf;
                     76:        size_t          pkso_bufsize;
                     77:
                     78:        TAILQ_ENTRY(puffs_sizepark) pkso_entries;
                     79: };
                     80:
1.12      pooka      81: #ifdef DEBUG
1.24      pooka      82: #ifndef PUFFSDEBUG
                     83: #define PUFFSDEBUG
                     84: #endif
                     85: #endif
                     86:
                     87: #ifdef PUFFSDEBUG
1.12      pooka      88: extern int puffsdebug; /* puffs_subr.c */
                     89: #define DPRINTF(x) if (puffsdebug > 0) printf x
                     90: #define DPRINTF_VERBOSE(x) if (puffsdebug > 1) printf x
                     91: #else
1.1       pooka      92: #define DPRINTF(x)
1.10      pooka      93: #define DPRINTF_VERBOSE(x)
1.12      pooka      94: #endif
1.1       pooka      95:
                     96: #define MPTOPUFFSMP(mp) ((struct puffs_mount *)((mp)->mnt_data))
                     97: #define PMPTOMP(pmp) (pmp->pmp_mp)
                     98: #define VPTOPP(vp) ((struct puffs_node *)(vp)->v_data)
                     99: #define VPTOPNC(vp) (((struct puffs_node *)(vp)->v_data)->pn_cookie)
                    100: #define VPTOPUFFSMP(vp) ((struct puffs_mount*)((struct puffs_node*)vp->v_data))
                    101: #define FPTOPMP(fp) (((struct puffs_instance *)fp->f_data)->pi_pmp)
                    102: #define FPTOPI(fp) ((struct puffs_instance *)fp->f_data)
                    103:
1.32      pooka     104: /* we don't pass the kernel overlay to userspace */
                    105: #define PUFFS_TOFHSIZE(s) ((s)==0 ? (s) : (s)+4)
                    106: #define PUFFS_FROMFHSIZE(s) ((s)==0 ? (s) : (s)-4)
                    107:
1.34      pooka     108: #define ALLOPS(pmp) (pmp->pmp_flags & PUFFS_KFLAG_ALLOPS)
1.10      pooka     109: #define EXISTSOP(pmp, op) \
1.34      pooka     110:  (ALLOPS(pmp) || ((pmp)->pmp_vnopmask[PUFFS_VN_##op]))
1.10      pooka     111:
1.42      pooka     112: #define PUFFS_USE_NAMECACHE(pmp)       \
                    113:     (((pmp)->pmp_flags & PUFFS_KFLAG_NOCACHE_NAME) == 0)
                    114: #define PUFFS_USE_PAGECACHE(pmp)       \
                    115:     (((pmp)->pmp_flags & PUFFS_KFLAG_NOCACHE_PAGE) == 0)
1.16      pooka     116:
1.27      pooka     117: #define PUFFS_WCACHEINFO(pmp)  0
                    118:
1.1       pooka     119: TAILQ_HEAD(puffs_wq, puffs_park);
1.20      pooka     120: LIST_HEAD(puffs_node_hashlist, puffs_node);
1.1       pooka     121: struct puffs_mount {
1.28      pooka     122:        kmutex_t                        pmp_lock;
1.1       pooka     123:
1.31      pooka     124:        struct puffs_kargs              pmp_args;
1.10      pooka     125: #define pmp_flags pmp_args.pa_flags
                    126: #define pmp_vnopmask pmp_args.pa_vnopmask
1.1       pooka     127:
                    128:        struct puffs_wq                 pmp_req_touser;
1.33      pooka     129:        int                             pmp_req_touser_count;
1.28      pooka     130:        kcondvar_t                      pmp_req_waiter_cv;
1.1       pooka     131:        size_t                          pmp_req_maxsize;
                    132:
                    133:        struct puffs_wq                 pmp_req_replywait;
                    134:        TAILQ_HEAD(, puffs_sizepark)    pmp_req_sizepark;
                    135:
1.20      pooka     136:        struct puffs_node_hashlist      *pmp_pnodehash;
1.32      pooka     137:        int                             pmp_npnodehash;
1.1       pooka     138:
                    139:        struct mount                    *pmp_mp;
1.35      pooka     140:
1.1       pooka     141:        struct vnode                    *pmp_root;
1.35      pooka     142:        void                            *pmp_root_cookie;
                    143:        enum vtype                      pmp_root_vtype;
                    144:        vsize_t                         pmp_root_vsize;
                    145:        dev_t                           pmp_root_rdev;
                    146:
1.1       pooka     147:        struct selinfo                  *pmp_sel;       /* in puffs_instance */
                    148:
1.33      pooka     149:        unsigned int                    pmp_refcount;
                    150:        kcondvar_t                      pmp_refcount_cv;
1.28      pooka     151:
1.33      pooka     152:        kcondvar_t                      pmp_unmounting_cv;
1.14      pooka     153:        uint8_t                         pmp_unmounting;
1.33      pooka     154:
                    155:        uint8_t                         pmp_status;
1.22      pooka     156:        uint8_t                         pmp_suspend;
1.28      pooka     157:
                    158:        uint64_t                        pmp_nextreq;
1.1       pooka     159: };
1.8       pooka     160:
1.1       pooka     161: #define PUFFSTAT_BEFOREINIT    0
                    162: #define PUFFSTAT_MOUNTING      1
                    163: #define PUFFSTAT_RUNNING       2
1.14      pooka     164: #define PUFFSTAT_DYING         3 /* Do you want your possessions identified? */
1.1       pooka     165:
1.27      pooka     166:
1.37      pooka     167: #define PNODE_NOREFS   0x01    /* no backend reference                 */
1.38      pooka     168: #define PNODE_DYING    0x02    /* NOREF + inactive                     */
                    169: #define PNODE_SUSPEND  0x04    /* issue all operations as FAF          */
                    170: #define PNODE_DOINACT  0x08    /* if inactive-on-demand, call inactive */
1.27      pooka     171:
                    172: #define PNODE_METACACHE_ATIME  0x10    /* cache atime metadata */
                    173: #define PNODE_METACACHE_CTIME  0x20    /* cache atime metadata */
                    174: #define PNODE_METACACHE_MTIME  0x40    /* cache atime metadata */
                    175: #define PNODE_METACACHE_SIZE   0x80    /* cache atime metadata */
                    176: #define PNODE_METACACHE_MASK   0xf0
                    177:
1.1       pooka     178: struct puffs_node {
1.6       pooka     179:        struct genfs_node pn_gnode;     /* genfs glue                   */
                    180:
1.36      pooka     181:        kmutex_t        pn_mtx;
                    182:        int             pn_refcount;
                    183:
1.1       pooka     184:        void            *pn_cookie;     /* userspace pnode cookie       */
                    185:        struct vnode    *pn_vp;         /* backpointer to vnode         */
                    186:        uint32_t        pn_stat;        /* node status                  */
                    187:
1.36      pooka     188:        struct selinfo  pn_sel;         /* for selecting on the node    */
                    189:        short           pn_revents;     /* available events             */
                    190:
1.27      pooka     191:        /* metacache */
                    192:        struct timespec pn_mc_atime;
                    193:        struct timespec pn_mc_ctime;
                    194:        struct timespec pn_mc_mtime;
                    195:        u_quad_t        pn_mc_size;
                    196:
1.20      pooka     197:        LIST_ENTRY(puffs_node) pn_hashent;
1.1       pooka     198: };
                    199:
1.29      pooka     200: typedef void (*parkdone_fn)(struct puffs_req *, void *);
                    201:
1.28      pooka     202: void   puffs_transport_init(void);
                    203: void   puffs_transport_destroy(void);
                    204:
                    205: void   puffs_msgif_init(void);
                    206: void   puffs_msgif_destroy(void);
1.30      pooka     207: void   *puffs_park_alloc(int);
                    208: void   puffs_park_release(void *, int);
1.28      pooka     209:
1.1       pooka     210: int    puffs_vfstouser(struct puffs_mount *, int, void *, size_t);
1.22      pooka     211: void   puffs_suspendtouser(struct puffs_mount *, int);
1.29      pooka     212: int    puffs_vntouser(struct puffs_mount *, int, void *, size_t, size_t,
1.34      pooka     213:                       struct vnode *, struct vnode *);
1.29      pooka     214: int    puffs_vntouser_req(struct puffs_mount *, int, void *, size_t, size_t,
1.34      pooka     215:                           uint64_t, struct vnode *, struct vnode *);
1.29      pooka     216: void   puffs_vntouser_call(struct puffs_mount *, int, void *, size_t, size_t,
1.34      pooka     217:                            parkdone_fn, void *, struct vnode *, struct vnode*);
                    218: void   puffs_vntouser_faf(struct puffs_mount *, int, void *, size_t,
                    219:                           struct vnode *);
1.27      pooka     220: void   puffs_cacheop(struct puffs_mount *, struct puffs_park *,
                    221:                      struct puffs_cacheinfo *, size_t, void *);
                    222: struct puffs_park *puffs_cacheop_alloc(void);
1.1       pooka     223:
1.6       pooka     224: int    puffs_getvnode(struct mount *, void *, enum vtype, voff_t, dev_t,
1.2       pooka     225:                       struct vnode **);
1.1       pooka     226: int    puffs_newnode(struct mount *, struct vnode *, struct vnode **,
1.2       pooka     227:                      void *, struct componentname *, enum vtype, dev_t);
1.1       pooka     228: void   puffs_putvnode(struct vnode *);
1.36      pooka     229:
                    230: void   puffs_releasenode(struct puffs_node *);
                    231: void   puffs_referencenode(struct puffs_node *);
                    232:
1.41      pooka     233: int    puffs_pnode2vnode(struct puffs_mount *, void *, int, struct vnode **);
1.43    ! pooka     234: void   puffs_makecn(struct puffs_kcn *, struct puffs_kcred *,
        !           235:                     const struct componentname *);
        !           236: void   puffs_credcvt(struct puffs_kcred *, kauth_cred_t);
1.1       pooka     237: pid_t  puffs_lwp2pid(struct lwp *);
                    238:
1.29      pooka     239: void   puffs_parkdone_asyncbioread(struct puffs_req *, void *);
1.36      pooka     240: void   puffs_parkdone_poll(struct puffs_req *, void *);
1.29      pooka     241:
1.33      pooka     242: void   puffs_mp_reference(struct puffs_mount *);
                    243: void   puffs_mp_release(struct puffs_mount *);
                    244:
1.6       pooka     245: void   puffs_updatenode(struct vnode *, int);
                    246: #define PUFFS_UPDATEATIME      0x01
                    247: #define PUFFS_UPDATECTIME      0x02
                    248: #define PUFFS_UPDATEMTIME      0x04
                    249: #define PUFFS_UPDATESIZE       0x08
1.9       pooka     250: void   puffs_updatevpsize(struct vnode *);
1.6       pooka     251:
1.1       pooka     252: int    puffs_setpmp(pid_t, int, struct puffs_mount *);
                    253: void   puffs_nukebypmp(struct puffs_mount *);
                    254:
1.28      pooka     255: uint64_t       puffs_getreqid(struct puffs_mount *);
                    256: void           puffs_userdead(struct puffs_mount *);
1.1       pooka     257:
1.13      pooka     258: /* get/put called by ioctl handler */
                    259: int    puffs_getop(struct puffs_mount *, struct puffs_reqh_get *, int);
                    260: int    puffs_putop(struct puffs_mount *, struct puffs_reqh_put *);
                    261:
1.1       pooka     262: extern int (**puffs_vnodeop_p)(void *);
                    263:
                    264: MALLOC_DECLARE(M_PUFFS);
                    265:
                    266: #endif /* _PUFFS_SYS_H_ */

CVSweb <webmaster@jp.NetBSD.org>