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

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

CVSweb <webmaster@jp.NetBSD.org>