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

1.72    ! pooka       1: /*     $NetBSD: puffs_sys.h,v 1.71 2009/11/05 19:22:57 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.59      pooka     101: TAILQ_HEAD(puffs_wq, puffs_msgpark);
1.20      pooka     102: LIST_HEAD(puffs_node_hashlist, puffs_node);
1.1       pooka     103: struct puffs_mount {
1.28      pooka     104:        kmutex_t                        pmp_lock;
1.1       pooka     105:
1.31      pooka     106:        struct puffs_kargs              pmp_args;
1.10      pooka     107: #define pmp_flags pmp_args.pa_flags
                    108: #define pmp_vnopmask pmp_args.pa_vnopmask
1.1       pooka     109:
1.59      pooka     110:        struct puffs_wq                 pmp_msg_touser;
                    111:        int                             pmp_msg_touser_count;
                    112:        kcondvar_t                      pmp_msg_waiter_cv;
                    113:        size_t                          pmp_msg_maxsize;
1.1       pooka     114:
1.59      pooka     115:        struct puffs_wq                 pmp_msg_replywait;
1.1       pooka     116:
1.20      pooka     117:        struct puffs_node_hashlist      *pmp_pnodehash;
1.32      pooka     118:        int                             pmp_npnodehash;
1.1       pooka     119:
1.50      pooka     120:        LIST_HEAD(, puffs_newcookie)    pmp_newcookie;
                    121:
1.1       pooka     122:        struct mount                    *pmp_mp;
1.35      pooka     123:
1.1       pooka     124:        struct vnode                    *pmp_root;
1.70      pooka     125:        puffs_cookie_t                  pmp_root_cookie;
1.35      pooka     126:        enum vtype                      pmp_root_vtype;
                    127:        vsize_t                         pmp_root_vsize;
                    128:        dev_t                           pmp_root_rdev;
                    129:
1.60      pooka     130:        struct putter_instance          *pmp_pi;
1.1       pooka     131:
1.33      pooka     132:        unsigned int                    pmp_refcount;
                    133:        kcondvar_t                      pmp_refcount_cv;
1.28      pooka     134:
1.33      pooka     135:        kcondvar_t                      pmp_unmounting_cv;
1.14      pooka     136:        uint8_t                         pmp_unmounting;
1.33      pooka     137:
                    138:        uint8_t                         pmp_status;
1.22      pooka     139:        uint8_t                         pmp_suspend;
1.28      pooka     140:
1.59      pooka     141:        uint8_t                         *pmp_curput;
                    142:        size_t                          pmp_curres;
                    143:        void                            *pmp_curopaq;
                    144:
                    145:        uint64_t                        pmp_nextmsgid;
1.1       pooka     146: };
1.8       pooka     147:
1.1       pooka     148: #define PUFFSTAT_BEFOREINIT    0
                    149: #define PUFFSTAT_MOUNTING      1
                    150: #define PUFFSTAT_RUNNING       2
1.14      pooka     151: #define PUFFSTAT_DYING         3 /* Do you want your possessions identified? */
1.1       pooka     152:
1.27      pooka     153:
1.37      pooka     154: #define PNODE_NOREFS   0x01    /* no backend reference                 */
1.71      pooka     155: #define PNODE_DYING    0x02    /* NOREFS + inactive                    */
1.72    ! pooka     156: #define PNODE_FAF      0x04    /* issue all operations as FAF          */
1.38      pooka     157: #define PNODE_DOINACT  0x08    /* if inactive-on-demand, call inactive */
1.27      pooka     158:
                    159: #define PNODE_METACACHE_ATIME  0x10    /* cache atime metadata */
                    160: #define PNODE_METACACHE_CTIME  0x20    /* cache atime metadata */
                    161: #define PNODE_METACACHE_MTIME  0x40    /* cache atime metadata */
                    162: #define PNODE_METACACHE_SIZE   0x80    /* cache atime metadata */
                    163: #define PNODE_METACACHE_MASK   0xf0
                    164:
1.1       pooka     165: struct puffs_node {
1.6       pooka     166:        struct genfs_node pn_gnode;     /* genfs glue                   */
                    167:
1.36      pooka     168:        kmutex_t        pn_mtx;
                    169:        int             pn_refcount;
                    170:
1.70      pooka     171:        puffs_cookie_t  pn_cookie;      /* userspace pnode cookie       */
1.1       pooka     172:        struct vnode    *pn_vp;         /* backpointer to vnode         */
                    173:        uint32_t        pn_stat;        /* node status                  */
                    174:
1.36      pooka     175:        struct selinfo  pn_sel;         /* for selecting on the node    */
                    176:        short           pn_revents;     /* available events             */
                    177:
1.27      pooka     178:        /* metacache */
                    179:        struct timespec pn_mc_atime;
                    180:        struct timespec pn_mc_ctime;
                    181:        struct timespec pn_mc_mtime;
                    182:        u_quad_t        pn_mc_size;
                    183:
1.47      pooka     184:        voff_t          pn_serversize;
                    185:
1.20      pooka     186:        LIST_ENTRY(puffs_node) pn_hashent;
1.1       pooka     187: };
                    188:
1.54      pooka     189: typedef void (*parkdone_fn)(struct puffs_mount *, struct puffs_req *, void *);
1.29      pooka     190:
1.59      pooka     191: struct puffs_msgpark;
1.28      pooka     192: void   puffs_msgif_init(void);
                    193: void   puffs_msgif_destroy(void);
1.59      pooka     194: int    puffs_msgmem_alloc(size_t, struct puffs_msgpark **, void **, int);
                    195: void   puffs_msgmem_release(struct puffs_msgpark *);
1.62      pooka     196:
1.59      pooka     197: void   puffs_msg_setfaf(struct puffs_msgpark *);
1.62      pooka     198: void   puffs_msg_setdelta(struct puffs_msgpark *, size_t);
1.70      pooka     199: void   puffs_msg_setinfo(struct puffs_msgpark *, int, int, puffs_cookie_t);
1.62      pooka     200: void   puffs_msg_setcall(struct puffs_msgpark *, parkdone_fn, void *);
                    201:
                    202: void   puffs_msg_enqueue(struct puffs_mount *, struct puffs_msgpark *);
                    203: int    puffs_msg_wait(struct puffs_mount *, struct puffs_msgpark *);
                    204: int    puffs_msg_wait2(struct puffs_mount *, struct puffs_msgpark *,
                    205:                        struct puffs_node *, struct puffs_node *);
1.1       pooka     206:
1.66      pooka     207: void   puffs_msg_sendresp(struct puffs_mount *, struct puffs_req *, int);
                    208:
1.70      pooka     209: int    puffs_getvnode(struct mount *, puffs_cookie_t, enum vtype,
                    210:                       voff_t, dev_t, struct vnode **);
1.1       pooka     211: int    puffs_newnode(struct mount *, struct vnode *, struct vnode **,
1.70      pooka     212:                      puffs_cookie_t, struct componentname *,
                    213:                      enum vtype, dev_t);
1.1       pooka     214: void   puffs_putvnode(struct vnode *);
1.36      pooka     215:
                    216: void   puffs_releasenode(struct puffs_node *);
                    217: void   puffs_referencenode(struct puffs_node *);
                    218:
1.52      pooka     219: #define PUFFS_NOSUCHCOOKIE (-1)
1.70      pooka     220: int    puffs_cookie2vnode(struct puffs_mount *, puffs_cookie_t, int, int,
1.50      pooka     221:                           struct vnode **);
1.43      pooka     222: void   puffs_makecn(struct puffs_kcn *, struct puffs_kcred *,
1.67      pooka     223:                     const struct componentname *, int);
1.43      pooka     224: void   puffs_credcvt(struct puffs_kcred *, kauth_cred_t);
1.1       pooka     225:
1.54      pooka     226: void   puffs_parkdone_asyncbioread(struct puffs_mount *,
                    227:                                    struct puffs_req *, void *);
1.63      pooka     228: void   puffs_parkdone_asyncbiowrite(struct puffs_mount *,
                    229:                                     struct puffs_req *, void *);
1.54      pooka     230: void   puffs_parkdone_poll(struct puffs_mount *, struct puffs_req *, void *);
1.29      pooka     231:
1.33      pooka     232: void   puffs_mp_reference(struct puffs_mount *);
                    233: void   puffs_mp_release(struct puffs_mount *);
                    234:
1.53      pooka     235: void   puffs_gop_size(struct vnode *, off_t, off_t *, int);
                    236: void   puffs_gop_markupdate(struct vnode *, int);
                    237:
1.70      pooka     238: void   puffs_senderr(struct puffs_mount *, int, int, const char *,
                    239:                      puffs_cookie_t);
1.62      pooka     240:
1.64      pooka     241: void   puffs_updatenode(struct puffs_node *, int, voff_t);
1.6       pooka     242: #define PUFFS_UPDATEATIME      0x01
                    243: #define PUFFS_UPDATECTIME      0x02
                    244: #define PUFFS_UPDATEMTIME      0x04
                    245: #define PUFFS_UPDATESIZE       0x08
                    246:
1.60      pooka     247: void   puffs_userdead(struct puffs_mount *);
1.13      pooka     248:
1.1       pooka     249: extern int (**puffs_vnodeop_p)(void *);
                    250:
1.62      pooka     251: /* for putter */
1.59      pooka     252: int    puffs_msgif_getout(void *, size_t, int, uint8_t **, size_t *, void **);
                    253: void   puffs_msgif_releaseout(void *, void *, int);
1.61      pooka     254: int    puffs_msgif_dispatch(void *, struct putter_hdr *);
1.60      pooka     255: size_t puffs_msgif_waitcount(void *);
                    256: int    puffs_msgif_close(void *);
1.59      pooka     257:
1.54      pooka     258: static __inline int
                    259: checkerr(struct puffs_mount *pmp, int error, const char *str)
                    260: {
                    261:
                    262:        if (error < 0 || error > ELAST) {
1.62      pooka     263:                puffs_senderr(pmp, PUFFS_ERR_ERROR, error, str, NULL);
1.54      pooka     264:                error = EPROTO;
                    265:        }
                    266:
                    267:        return error;
                    268: }
                    269:
1.59      pooka     270: #define PUFFS_MSG_VARS(type, a)                                                \
                    271:        struct puffs_##type##msg_##a *a##_msg;                          \
                    272:        struct puffs_msgpark *park_##a = NULL
                    273:
                    274: #define PUFFS_MSG_ALLOC(type, a)                                       \
                    275:        puffs_msgmem_alloc(sizeof(struct puffs_##type##msg_##a),        \
1.69      pooka     276:            &park_##a, (void *)& a##_msg, 1)
1.59      pooka     277:
                    278: #define PUFFS_MSG_RELEASE(a)                                           \
                    279: do {                                                                   \
                    280:        if (park_##a) puffs_msgmem_release(park_##a);                   \
                    281: } while (/*CONSTCOND*/0)
                    282:
1.62      pooka     283: #define PUFFS_MSG_ENQUEUEWAIT(pmp, park, var)                          \
                    284: do {                                                                   \
                    285:        puffs_msg_enqueue(pmp, park);                                   \
                    286:        var = puffs_msg_wait(pmp, park);                                \
                    287: } while (/*CONSTCOND*/0)
                    288:
                    289: #define PUFFS_MSG_ENQUEUEWAIT2(pmp, park, vp1, vp2, var)               \
                    290: do {                                                                   \
                    291:        puffs_msg_enqueue(pmp, park);                                   \
                    292:        var = puffs_msg_wait2(pmp, park, vp1, vp2);                     \
                    293: } while (/*CONSTCOND*/0)
                    294:
1.1       pooka     295: #endif /* _PUFFS_SYS_H_ */

CVSweb <webmaster@jp.NetBSD.org>