[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.70.20.1

1.70.20.1! snj         1: /*     $NetBSD: puffs_sys.h,v 1.70 2008/01/28 21:06:37 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.12      pooka      57: #ifdef DEBUG
1.24      pooka      58: #ifndef PUFFSDEBUG
                     59: #define PUFFSDEBUG
                     60: #endif
                     61: #endif
                     62:
                     63: #ifdef PUFFSDEBUG
1.12      pooka      64: extern int puffsdebug; /* puffs_subr.c */
                     65: #define DPRINTF(x) if (puffsdebug > 0) printf x
                     66: #define DPRINTF_VERBOSE(x) if (puffsdebug > 1) printf x
                     67: #else
1.1       pooka      68: #define DPRINTF(x)
1.10      pooka      69: #define DPRINTF_VERBOSE(x)
1.12      pooka      70: #endif
1.1       pooka      71:
                     72: #define MPTOPUFFSMP(mp) ((struct puffs_mount *)((mp)->mnt_data))
                     73: #define PMPTOMP(pmp) (pmp->pmp_mp)
                     74: #define VPTOPP(vp) ((struct puffs_node *)(vp)->v_data)
                     75: #define VPTOPNC(vp) (((struct puffs_node *)(vp)->v_data)->pn_cookie)
                     76: #define VPTOPUFFSMP(vp) ((struct puffs_mount*)((struct puffs_node*)vp->v_data))
                     77:
1.32      pooka      78: /* we don't pass the kernel overlay to userspace */
                     79: #define PUFFS_TOFHSIZE(s) ((s)==0 ? (s) : (s)+4)
                     80: #define PUFFS_FROMFHSIZE(s) ((s)==0 ? (s) : (s)-4)
                     81:
1.34      pooka      82: #define ALLOPS(pmp) (pmp->pmp_flags & PUFFS_KFLAG_ALLOPS)
1.10      pooka      83: #define EXISTSOP(pmp, op) \
1.34      pooka      84:  (ALLOPS(pmp) || ((pmp)->pmp_vnopmask[PUFFS_VN_##op]))
1.10      pooka      85:
1.42      pooka      86: #define PUFFS_USE_NAMECACHE(pmp)       \
                     87:     (((pmp)->pmp_flags & PUFFS_KFLAG_NOCACHE_NAME) == 0)
                     88: #define PUFFS_USE_PAGECACHE(pmp)       \
                     89:     (((pmp)->pmp_flags & PUFFS_KFLAG_NOCACHE_PAGE) == 0)
1.45      pooka      90: #define PUFFS_USE_FULLPNBUF(pmp)       \
                     91:     ((pmp)->pmp_flags & PUFFS_KFLAG_LOOKUP_FULLPNBUF)
1.16      pooka      92:
1.27      pooka      93: #define PUFFS_WCACHEINFO(pmp)  0
                     94:
1.50      pooka      95: struct puffs_newcookie {
1.70      pooka      96:        puffs_cookie_t  pnc_cookie;
1.50      pooka      97:
                     98:        LIST_ENTRY(puffs_newcookie) pnc_entries;
                     99: };
                    100:
1.70.20.1! snj       101: enum puffs_sopreqtype {
        !           102:        PUFFS_SOPREQ_EXIT,
        !           103:        PUFFS_SOPREQ_FLUSH,
        !           104: };
        !           105:
        !           106: struct puffs_sopreq {
        !           107:        union {
        !           108:                struct puffs_req preq;
        !           109:                struct puffs_flush pf;
        !           110:        } psopr_u;
        !           111:
        !           112:        enum puffs_sopreqtype psopr_sopreq;
        !           113:        TAILQ_ENTRY(puffs_sopreq) psopr_entries;
        !           114: };
        !           115: #define psopr_preq psopr_u.preq
        !           116: #define psopr_pf psopr_u.pf
        !           117:
1.59      pooka     118: TAILQ_HEAD(puffs_wq, puffs_msgpark);
1.20      pooka     119: LIST_HEAD(puffs_node_hashlist, puffs_node);
1.1       pooka     120: struct puffs_mount {
1.28      pooka     121:        kmutex_t                        pmp_lock;
1.1       pooka     122:
1.31      pooka     123:        struct puffs_kargs              pmp_args;
1.10      pooka     124: #define pmp_flags pmp_args.pa_flags
                    125: #define pmp_vnopmask pmp_args.pa_vnopmask
1.1       pooka     126:
1.59      pooka     127:        struct puffs_wq                 pmp_msg_touser;
                    128:        int                             pmp_msg_touser_count;
                    129:        kcondvar_t                      pmp_msg_waiter_cv;
                    130:        size_t                          pmp_msg_maxsize;
1.1       pooka     131:
1.59      pooka     132:        struct puffs_wq                 pmp_msg_replywait;
1.1       pooka     133:
1.20      pooka     134:        struct puffs_node_hashlist      *pmp_pnodehash;
1.32      pooka     135:        int                             pmp_npnodehash;
1.1       pooka     136:
1.50      pooka     137:        LIST_HEAD(, puffs_newcookie)    pmp_newcookie;
                    138:
1.1       pooka     139:        struct mount                    *pmp_mp;
1.35      pooka     140:
1.1       pooka     141:        struct vnode                    *pmp_root;
1.70      pooka     142:        puffs_cookie_t                  pmp_root_cookie;
1.35      pooka     143:        enum vtype                      pmp_root_vtype;
                    144:        vsize_t                         pmp_root_vsize;
                    145:        dev_t                           pmp_root_rdev;
                    146:
1.60      pooka     147:        struct putter_instance          *pmp_pi;
1.1       pooka     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:
1.59      pooka     158:        uint8_t                         *pmp_curput;
                    159:        size_t                          pmp_curres;
                    160:        void                            *pmp_curopaq;
                    161:
                    162:        uint64_t                        pmp_nextmsgid;
1.70.20.1! snj       163:
        !           164:        kmutex_t                        pmp_sopmtx;
        !           165:        kcondvar_t                      pmp_sopcv;
        !           166:        int                             pmp_sopthrcount;
        !           167:        TAILQ_HEAD(, puffs_sopreq)      pmp_sopreqs;
1.1       pooka     168: };
1.8       pooka     169:
1.1       pooka     170: #define PUFFSTAT_BEFOREINIT    0
                    171: #define PUFFSTAT_MOUNTING      1
                    172: #define PUFFSTAT_RUNNING       2
1.14      pooka     173: #define PUFFSTAT_DYING         3 /* Do you want your possessions identified? */
1.1       pooka     174:
1.27      pooka     175:
1.37      pooka     176: #define PNODE_NOREFS   0x01    /* no backend reference                 */
1.38      pooka     177: #define PNODE_SUSPEND  0x04    /* issue all operations as FAF          */
                    178: #define PNODE_DOINACT  0x08    /* if inactive-on-demand, call inactive */
1.27      pooka     179:
                    180: #define PNODE_METACACHE_ATIME  0x10    /* cache atime metadata */
                    181: #define PNODE_METACACHE_CTIME  0x20    /* cache atime metadata */
                    182: #define PNODE_METACACHE_MTIME  0x40    /* cache atime metadata */
                    183: #define PNODE_METACACHE_SIZE   0x80    /* cache atime metadata */
                    184: #define PNODE_METACACHE_MASK   0xf0
                    185:
1.1       pooka     186: struct puffs_node {
1.6       pooka     187:        struct genfs_node pn_gnode;     /* genfs glue                   */
                    188:
1.36      pooka     189:        kmutex_t        pn_mtx;
                    190:        int             pn_refcount;
                    191:
1.70      pooka     192:        puffs_cookie_t  pn_cookie;      /* userspace pnode cookie       */
1.1       pooka     193:        struct vnode    *pn_vp;         /* backpointer to vnode         */
                    194:        uint32_t        pn_stat;        /* node status                  */
                    195:
1.36      pooka     196:        struct selinfo  pn_sel;         /* for selecting on the node    */
                    197:        short           pn_revents;     /* available events             */
                    198:
1.27      pooka     199:        /* metacache */
                    200:        struct timespec pn_mc_atime;
                    201:        struct timespec pn_mc_ctime;
                    202:        struct timespec pn_mc_mtime;
                    203:        u_quad_t        pn_mc_size;
                    204:
1.47      pooka     205:        voff_t          pn_serversize;
                    206:
1.20      pooka     207:        LIST_ENTRY(puffs_node) pn_hashent;
1.1       pooka     208: };
                    209:
1.54      pooka     210: typedef void (*parkdone_fn)(struct puffs_mount *, struct puffs_req *, void *);
1.29      pooka     211:
1.59      pooka     212: struct puffs_msgpark;
1.28      pooka     213: void   puffs_msgif_init(void);
                    214: void   puffs_msgif_destroy(void);
1.59      pooka     215: int    puffs_msgmem_alloc(size_t, struct puffs_msgpark **, void **, int);
                    216: void   puffs_msgmem_release(struct puffs_msgpark *);
1.62      pooka     217:
1.70.20.1! snj       218: void   puffs_sop_thread(void *);
        !           219:
1.59      pooka     220: void   puffs_msg_setfaf(struct puffs_msgpark *);
1.62      pooka     221: void   puffs_msg_setdelta(struct puffs_msgpark *, size_t);
1.70      pooka     222: void   puffs_msg_setinfo(struct puffs_msgpark *, int, int, puffs_cookie_t);
1.62      pooka     223: void   puffs_msg_setcall(struct puffs_msgpark *, parkdone_fn, void *);
                    224:
                    225: void   puffs_msg_enqueue(struct puffs_mount *, struct puffs_msgpark *);
                    226: int    puffs_msg_wait(struct puffs_mount *, struct puffs_msgpark *);
                    227: int    puffs_msg_wait2(struct puffs_mount *, struct puffs_msgpark *,
                    228:                        struct puffs_node *, struct puffs_node *);
1.1       pooka     229:
1.66      pooka     230: void   puffs_msg_sendresp(struct puffs_mount *, struct puffs_req *, int);
                    231:
1.70      pooka     232: int    puffs_getvnode(struct mount *, puffs_cookie_t, enum vtype,
                    233:                       voff_t, dev_t, struct vnode **);
1.1       pooka     234: int    puffs_newnode(struct mount *, struct vnode *, struct vnode **,
1.70      pooka     235:                      puffs_cookie_t, struct componentname *,
                    236:                      enum vtype, dev_t);
1.1       pooka     237: void   puffs_putvnode(struct vnode *);
1.36      pooka     238:
                    239: void   puffs_releasenode(struct puffs_node *);
                    240: void   puffs_referencenode(struct puffs_node *);
                    241:
1.52      pooka     242: #define PUFFS_NOSUCHCOOKIE (-1)
1.70      pooka     243: int    puffs_cookie2vnode(struct puffs_mount *, puffs_cookie_t, int, int,
1.50      pooka     244:                           struct vnode **);
1.43      pooka     245: void   puffs_makecn(struct puffs_kcn *, struct puffs_kcred *,
1.67      pooka     246:                     const struct componentname *, int);
1.43      pooka     247: void   puffs_credcvt(struct puffs_kcred *, kauth_cred_t);
1.1       pooka     248:
1.54      pooka     249: void   puffs_parkdone_asyncbioread(struct puffs_mount *,
                    250:                                    struct puffs_req *, void *);
1.63      pooka     251: void   puffs_parkdone_asyncbiowrite(struct puffs_mount *,
                    252:                                     struct puffs_req *, void *);
1.54      pooka     253: void   puffs_parkdone_poll(struct puffs_mount *, struct puffs_req *, void *);
1.29      pooka     254:
1.33      pooka     255: void   puffs_mp_reference(struct puffs_mount *);
                    256: void   puffs_mp_release(struct puffs_mount *);
                    257:
1.53      pooka     258: void   puffs_gop_size(struct vnode *, off_t, off_t *, int);
                    259: void   puffs_gop_markupdate(struct vnode *, int);
                    260:
1.70      pooka     261: void   puffs_senderr(struct puffs_mount *, int, int, const char *,
                    262:                      puffs_cookie_t);
1.62      pooka     263:
1.64      pooka     264: void   puffs_updatenode(struct puffs_node *, int, voff_t);
1.6       pooka     265: #define PUFFS_UPDATEATIME      0x01
                    266: #define PUFFS_UPDATECTIME      0x02
                    267: #define PUFFS_UPDATEMTIME      0x04
                    268: #define PUFFS_UPDATESIZE       0x08
                    269:
1.60      pooka     270: void   puffs_userdead(struct puffs_mount *);
1.13      pooka     271:
1.1       pooka     272: extern int (**puffs_vnodeop_p)(void *);
                    273:
1.62      pooka     274: /* for putter */
1.59      pooka     275: int    puffs_msgif_getout(void *, size_t, int, uint8_t **, size_t *, void **);
                    276: void   puffs_msgif_releaseout(void *, void *, int);
1.61      pooka     277: int    puffs_msgif_dispatch(void *, struct putter_hdr *);
1.60      pooka     278: size_t puffs_msgif_waitcount(void *);
                    279: int    puffs_msgif_close(void *);
1.59      pooka     280:
1.54      pooka     281: static __inline int
                    282: checkerr(struct puffs_mount *pmp, int error, const char *str)
                    283: {
                    284:
                    285:        if (error < 0 || error > ELAST) {
1.62      pooka     286:                puffs_senderr(pmp, PUFFS_ERR_ERROR, error, str, NULL);
1.54      pooka     287:                error = EPROTO;
                    288:        }
                    289:
                    290:        return error;
                    291: }
                    292:
1.59      pooka     293: #define PUFFS_MSG_VARS(type, a)                                                \
                    294:        struct puffs_##type##msg_##a *a##_msg;                          \
                    295:        struct puffs_msgpark *park_##a = NULL
                    296:
                    297: #define PUFFS_MSG_ALLOC(type, a)                                       \
                    298:        puffs_msgmem_alloc(sizeof(struct puffs_##type##msg_##a),        \
1.69      pooka     299:            &park_##a, (void *)& a##_msg, 1)
1.59      pooka     300:
                    301: #define PUFFS_MSG_RELEASE(a)                                           \
                    302: do {                                                                   \
                    303:        if (park_##a) puffs_msgmem_release(park_##a);                   \
                    304: } while (/*CONSTCOND*/0)
                    305:
1.62      pooka     306: #define PUFFS_MSG_ENQUEUEWAIT(pmp, park, var)                          \
                    307: do {                                                                   \
                    308:        puffs_msg_enqueue(pmp, park);                                   \
                    309:        var = puffs_msg_wait(pmp, park);                                \
                    310: } while (/*CONSTCOND*/0)
                    311:
                    312: #define PUFFS_MSG_ENQUEUEWAIT2(pmp, park, vp1, vp2, var)               \
                    313: do {                                                                   \
                    314:        puffs_msg_enqueue(pmp, park);                                   \
                    315:        var = puffs_msg_wait2(pmp, park, vp1, vp2);                     \
                    316: } while (/*CONSTCOND*/0)
                    317:
1.1       pooka     318: #endif /* _PUFFS_SYS_H_ */

CVSweb <webmaster@jp.NetBSD.org>