diff options
Diffstat (limited to 'sys/fs/fuse/fuse_ipc.h')
-rw-r--r-- | sys/fs/fuse/fuse_ipc.h | 341 |
1 files changed, 161 insertions, 180 deletions
diff --git a/sys/fs/fuse/fuse_ipc.h b/sys/fs/fuse/fuse_ipc.h index 0ecbe5bf8d5a..4c3dd35384cf 100644 --- a/sys/fs/fuse/fuse_ipc.h +++ b/sys/fs/fuse/fuse_ipc.h @@ -64,10 +64,10 @@ #include <sys/refcount.h> struct fuse_iov { - void *base; - size_t len; - size_t allocated_size; - int credit; + void *base; + size_t len; + size_t allocated_size; + int credit; }; void fiov_init(struct fuse_iov *fiov, size_t size); @@ -75,23 +75,22 @@ void fiov_teardown(struct fuse_iov *fiov); void fiov_refresh(struct fuse_iov *fiov); void fiov_adjust(struct fuse_iov *fiov, size_t size); -#define FUSE_DIMALLOC(fiov, spc1, spc2, amnt) \ -do { \ - fiov_adjust(fiov, (sizeof(*(spc1)) + (amnt))); \ - (spc1) = (fiov)->base; \ - (spc2) = (char *)(fiov)->base + (sizeof(*(spc1))); \ +#define FUSE_DIMALLOC(fiov, spc1, spc2, amnt) do { \ + fiov_adjust(fiov, (sizeof(*(spc1)) + (amnt))); \ + (spc1) = (fiov)->base; \ + (spc2) = (char *)(fiov)->base + (sizeof(*(spc1))); \ } while (0) #define FU_AT_LEAST(siz) max((siz), 160) -#define FUSE_ASSERT_AW_DONE(ftick) \ - KASSERT((ftick)->tk_aw_link.tqe_next == NULL && \ - (ftick)->tk_aw_link.tqe_prev == NULL, \ - ("FUSE: ticket still on answer delivery list %p", (ftick))) \ +#define FUSE_ASSERT_AW_DONE(ftick) \ + KASSERT((ftick)->tk_aw_link.tqe_next == NULL && \ + (ftick)->tk_aw_link.tqe_prev == NULL, \ + ("FUSE: ticket still on answer delivery list %p", (ftick))) -#define FUSE_ASSERT_MS_DONE(ftick) \ - KASSERT((ftick)->tk_ms_link.stqe_next == NULL, \ - ("FUSE: ticket still on message list %p", (ftick))) +#define FUSE_ASSERT_MS_DONE(ftick) \ + KASSERT((ftick)->tk_ms_link.stqe_next == NULL, \ + ("FUSE: ticket still on message list %p", (ftick))) struct fuse_ticket; struct fuse_data; @@ -99,66 +98,62 @@ struct fuse_data; typedef int fuse_handler_t(struct fuse_ticket *ftick, struct uio *uio); struct fuse_ticket { - /* fields giving the identity of the ticket */ - uint64_t tk_unique; - struct fuse_data *tk_data; - int tk_flag; - u_int tk_refcount; - - /* fields for initiating an upgoing message */ - struct fuse_iov tk_ms_fiov; - void *tk_ms_bufdata; - size_t tk_ms_bufsize; - enum { FT_M_FIOV, FT_M_BUF } tk_ms_type; - STAILQ_ENTRY(fuse_ticket) tk_ms_link; - - /* fields for handling answers coming from userspace */ - struct fuse_iov tk_aw_fiov; - void *tk_aw_bufdata; - size_t tk_aw_bufsize; - enum { FT_A_FIOV, FT_A_BUF } tk_aw_type; - - struct fuse_out_header tk_aw_ohead; - int tk_aw_errno; - struct mtx tk_aw_mtx; - fuse_handler_t *tk_aw_handler; - TAILQ_ENTRY(fuse_ticket) tk_aw_link; + /* fields giving the identity of the ticket */ + uint64_t tk_unique; + struct fuse_data *tk_data; + int tk_flag; + u_int tk_refcount; + + /* fields for initiating an upgoing message */ + struct fuse_iov tk_ms_fiov; + void *tk_ms_bufdata; + size_t tk_ms_bufsize; + enum { FT_M_FIOV, FT_M_BUF } tk_ms_type; + STAILQ_ENTRY(fuse_ticket) tk_ms_link; + + /* fields for handling answers coming from userspace */ + struct fuse_iov tk_aw_fiov; + void *tk_aw_bufdata; + size_t tk_aw_bufsize; + enum { FT_A_FIOV, FT_A_BUF } tk_aw_type; + + struct fuse_out_header tk_aw_ohead; + int tk_aw_errno; + struct mtx tk_aw_mtx; + fuse_handler_t *tk_aw_handler; + TAILQ_ENTRY(fuse_ticket) tk_aw_link; }; #define FT_ANSW 0x01 /* request of ticket has already been answered */ #define FT_DIRTY 0x04 /* ticket has been used */ -static __inline__ -struct fuse_iov * +static inline struct fuse_iov * fticket_resp(struct fuse_ticket *ftick) { - return (&ftick->tk_aw_fiov); + return (&ftick->tk_aw_fiov); } -static __inline__ -int +static inline bool fticket_answered(struct fuse_ticket *ftick) { - DEBUGX(FUSE_DEBUG_IPC, "-> ftick=%p\n", ftick); - mtx_assert(&ftick->tk_aw_mtx, MA_OWNED); - return (ftick->tk_flag & FT_ANSW); + DEBUGX(FUSE_DEBUG_IPC, "-> ftick=%p\n", ftick); + mtx_assert(&ftick->tk_aw_mtx, MA_OWNED); + return (ftick->tk_flag & FT_ANSW); } -static __inline__ -void +static inline void fticket_set_answered(struct fuse_ticket *ftick) { - DEBUGX(FUSE_DEBUG_IPC, "-> ftick=%p\n", ftick); - mtx_assert(&ftick->tk_aw_mtx, MA_OWNED); - ftick->tk_flag |= FT_ANSW; + DEBUGX(FUSE_DEBUG_IPC, "-> ftick=%p\n", ftick); + mtx_assert(&ftick->tk_aw_mtx, MA_OWNED); + ftick->tk_flag |= FT_ANSW; } -static __inline__ -enum fuse_opcode +static inline enum fuse_opcode fticket_opcode(struct fuse_ticket *ftick) { - DEBUGX(FUSE_DEBUG_IPC, "-> ftick=%p\n", ftick); - return (((struct fuse_in_header *)(ftick->tk_ms_fiov.base))->opcode); + DEBUGX(FUSE_DEBUG_IPC, "-> ftick=%p\n", ftick); + return (((struct fuse_in_header *)(ftick->tk_ms_fiov.base))->opcode); } int fticket_pull(struct fuse_ticket *ftick, struct uio *uio); @@ -169,35 +164,35 @@ enum mountpri { FM_NOMOUNTED, FM_PRIMARY, FM_SECONDARY }; * The data representing a FUSE session. */ struct fuse_data { - struct cdev *fdev; - struct mount *mp; - struct vnode *vroot; - struct ucred *daemoncred; - int dataflags; - int ref; + struct cdev *fdev; + struct mount *mp; + struct vnode *vroot; + struct ucred *daemoncred; + int dataflags; + int ref; - struct mtx ms_mtx; - STAILQ_HEAD(, fuse_ticket) ms_head; + struct mtx ms_mtx; + STAILQ_HEAD(, fuse_ticket) ms_head; - struct mtx aw_mtx; - TAILQ_HEAD(, fuse_ticket) aw_head; + struct mtx aw_mtx; + TAILQ_HEAD(, fuse_ticket) aw_head; - u_long ticketer; + u_long ticketer; - struct sx rename_lock; + struct sx rename_lock; - uint32_t fuse_libabi_major; - uint32_t fuse_libabi_minor; + uint32_t fuse_libabi_major; + uint32_t fuse_libabi_minor; - uint32_t max_write; - uint32_t max_read; - uint32_t subtype; - char volname[MAXPATHLEN]; + uint32_t max_write; + uint32_t max_read; + uint32_t subtype; + char volname[MAXPATHLEN]; - struct selinfo ks_rsel; + struct selinfo ks_rsel; - int daemon_timeout; - uint64_t notimpl; + int daemon_timeout; + uint64_t notimpl; }; #define FSESS_DEAD 0x0001 /* session is to be closed */ @@ -226,127 +221,120 @@ extern int fuse_mmap_enable; extern int fuse_sync_resize; extern int fuse_fix_broken_io; -static __inline__ -struct fuse_data * +static inline struct fuse_data * fuse_get_mpdata(struct mount *mp) { - return mp->mnt_data; + return mp->mnt_data; } -static __inline int +static inline bool fsess_isimpl(struct mount *mp, int opcode) { - struct fuse_data *data = fuse_get_mpdata(mp); + struct fuse_data *data = fuse_get_mpdata(mp); - return (data->notimpl & (1ULL << opcode)) == 0; + return ((data->notimpl & (1ULL << opcode)) == 0); } -static __inline void +static inline void fsess_set_notimpl(struct mount *mp, int opcode) { - struct fuse_data *data = fuse_get_mpdata(mp); + struct fuse_data *data = fuse_get_mpdata(mp); - data->notimpl |= (1ULL << opcode); + data->notimpl |= (1ULL << opcode); } -static __inline int +static inline bool fsess_opt_datacache(struct mount *mp) { - struct fuse_data *data = fuse_get_mpdata(mp); + struct fuse_data *data = fuse_get_mpdata(mp); - return (fuse_data_cache_mode != FUSE_CACHE_UC && - (data->dataflags & FSESS_NO_DATACACHE) == 0); + return (fuse_data_cache_mode != FUSE_CACHE_UC && + (data->dataflags & FSESS_NO_DATACACHE) == 0); } -static __inline int +static inline bool fsess_opt_mmap(struct mount *mp) { - struct fuse_data *data = fuse_get_mpdata(mp); + struct fuse_data *data = fuse_get_mpdata(mp); - if (!fuse_mmap_enable || fuse_data_cache_mode == FUSE_CACHE_UC) - return 0; - return ((data->dataflags & (FSESS_NO_DATACACHE | FSESS_NO_MMAP)) == 0); + if (!fuse_mmap_enable || fuse_data_cache_mode == FUSE_CACHE_UC) + return (false); + return ((data->dataflags & (FSESS_NO_DATACACHE | FSESS_NO_MMAP)) == 0); } -static __inline int +static inline bool fsess_opt_brokenio(struct mount *mp) { - struct fuse_data *data = fuse_get_mpdata(mp); + struct fuse_data *data = fuse_get_mpdata(mp); - return (fuse_fix_broken_io || (data->dataflags & FSESS_BROKENIO)); + return (fuse_fix_broken_io || (data->dataflags & FSESS_BROKENIO)); } -static __inline__ -void +static inline void fuse_ms_push(struct fuse_ticket *ftick) { - DEBUGX(FUSE_DEBUG_IPC, "ftick=%p refcount=%d\n", - ftick, ftick->tk_refcount + 1); - mtx_assert(&ftick->tk_data->ms_mtx, MA_OWNED); - refcount_acquire(&ftick->tk_refcount); - STAILQ_INSERT_TAIL(&ftick->tk_data->ms_head, ftick, tk_ms_link); + DEBUGX(FUSE_DEBUG_IPC, "ftick=%p refcount=%d\n", ftick, + ftick->tk_refcount + 1); + mtx_assert(&ftick->tk_data->ms_mtx, MA_OWNED); + refcount_acquire(&ftick->tk_refcount); + STAILQ_INSERT_TAIL(&ftick->tk_data->ms_head, ftick, tk_ms_link); } -static __inline__ -struct fuse_ticket * +static inline struct fuse_ticket * fuse_ms_pop(struct fuse_data *data) { - struct fuse_ticket *ftick = NULL; + struct fuse_ticket *ftick = NULL; - mtx_assert(&data->ms_mtx, MA_OWNED); + mtx_assert(&data->ms_mtx, MA_OWNED); - if ((ftick = STAILQ_FIRST(&data->ms_head))) { - STAILQ_REMOVE_HEAD(&data->ms_head, tk_ms_link); + if ((ftick = STAILQ_FIRST(&data->ms_head))) { + STAILQ_REMOVE_HEAD(&data->ms_head, tk_ms_link); #ifdef INVARIANTS - ftick->tk_ms_link.stqe_next = NULL; + ftick->tk_ms_link.stqe_next = NULL; #endif - } - DEBUGX(FUSE_DEBUG_IPC, "ftick=%p refcount=%d\n", - ftick, ftick ? ftick->tk_refcount : -1); + } + DEBUGX(FUSE_DEBUG_IPC, "ftick=%p refcount=%d\n", ftick, + ftick ? ftick->tk_refcount : -1); - return ftick; + return (ftick); } -static __inline__ -void +static inline void fuse_aw_push(struct fuse_ticket *ftick) { - DEBUGX(FUSE_DEBUG_IPC, "ftick=%p refcount=%d\n", - ftick, ftick->tk_refcount + 1); - mtx_assert(&ftick->tk_data->aw_mtx, MA_OWNED); - refcount_acquire(&ftick->tk_refcount); - TAILQ_INSERT_TAIL(&ftick->tk_data->aw_head, ftick, tk_aw_link); + DEBUGX(FUSE_DEBUG_IPC, "ftick=%p refcount=%d\n", ftick, + ftick->tk_refcount + 1); + mtx_assert(&ftick->tk_data->aw_mtx, MA_OWNED); + refcount_acquire(&ftick->tk_refcount); + TAILQ_INSERT_TAIL(&ftick->tk_data->aw_head, ftick, tk_aw_link); } -static __inline__ -void +static inline void fuse_aw_remove(struct fuse_ticket *ftick) { - DEBUGX(FUSE_DEBUG_IPC, "ftick=%p refcount=%d\n", - ftick, ftick->tk_refcount); - mtx_assert(&ftick->tk_data->aw_mtx, MA_OWNED); - TAILQ_REMOVE(&ftick->tk_data->aw_head, ftick, tk_aw_link); + DEBUGX(FUSE_DEBUG_IPC, "ftick=%p refcount=%d\n", + ftick, ftick->tk_refcount); + mtx_assert(&ftick->tk_data->aw_mtx, MA_OWNED); + TAILQ_REMOVE(&ftick->tk_data->aw_head, ftick, tk_aw_link); #ifdef INVARIANTS - ftick->tk_aw_link.tqe_next = NULL; - ftick->tk_aw_link.tqe_prev = NULL; + ftick->tk_aw_link.tqe_next = NULL; + ftick->tk_aw_link.tqe_prev = NULL; #endif } -static __inline__ -struct fuse_ticket * +static inline struct fuse_ticket * fuse_aw_pop(struct fuse_data *data) { - struct fuse_ticket *ftick = NULL; + struct fuse_ticket *ftick; - mtx_assert(&data->aw_mtx, MA_OWNED); + mtx_assert(&data->aw_mtx, MA_OWNED); - if ((ftick = TAILQ_FIRST(&data->aw_head))) { - fuse_aw_remove(ftick); - } - DEBUGX(FUSE_DEBUG_IPC, "ftick=%p refcount=%d\n", - ftick, ftick ? ftick->tk_refcount : -1); + if ((ftick = TAILQ_FIRST(&data->aw_head)) != NULL) + fuse_aw_remove(ftick); + DEBUGX(FUSE_DEBUG_IPC, "ftick=%p refcount=%d\n", ftick, + ftick ? ftick->tk_refcount : -1); - return ftick; + return (ftick); } struct fuse_ticket *fuse_ticket_fetch(struct fuse_data *data); @@ -354,78 +342,71 @@ int fuse_ticket_drop(struct fuse_ticket *ftick); void fuse_insert_callback(struct fuse_ticket *ftick, fuse_handler_t *handler); void fuse_insert_message(struct fuse_ticket *ftick); -static __inline__ -int +static inline bool fuse_libabi_geq(struct fuse_data *data, uint32_t abi_maj, uint32_t abi_min) { - return (data->fuse_libabi_major > abi_maj || - (data->fuse_libabi_major == abi_maj && data->fuse_libabi_minor >= abi_min)); + return (data->fuse_libabi_major > abi_maj || + (data->fuse_libabi_major == abi_maj && + data->fuse_libabi_minor >= abi_min)); } struct fuse_data *fdata_alloc(struct cdev *dev, struct ucred *cred); void fdata_trydestroy(struct fuse_data *data); void fdata_set_dead(struct fuse_data *data); -static __inline__ -int +static inline bool fdata_get_dead(struct fuse_data *data) { - return (data->dataflags & FSESS_DEAD); + return (data->dataflags & FSESS_DEAD); } struct fuse_dispatcher { - - struct fuse_ticket *tick; - struct fuse_in_header *finh; - - void *indata; - size_t iosize; - uint64_t nodeid; - int answ_stat; - void *answ; + struct fuse_ticket *tick; + struct fuse_in_header *finh; + + void *indata; + size_t iosize; + uint64_t nodeid; + int answ_stat; + void *answ; }; -static __inline__ -void +static inline void fdisp_init(struct fuse_dispatcher *fdisp, size_t iosize) { - DEBUGX(FUSE_DEBUG_IPC, "-> fdisp=%p, iosize=%zx\n", fdisp, iosize); - fdisp->iosize = iosize; - fdisp->tick = NULL; + DEBUGX(FUSE_DEBUG_IPC, "-> fdisp=%p, iosize=%zx\n", fdisp, iosize); + fdisp->iosize = iosize; + fdisp->tick = NULL; } -static __inline__ -void +static inline void fdisp_destroy(struct fuse_dispatcher *fdisp) { - DEBUGX(FUSE_DEBUG_IPC, "-> fdisp=%p, ftick=%p\n", fdisp, fdisp->tick); - fuse_ticket_drop(fdisp->tick); + DEBUGX(FUSE_DEBUG_IPC, "-> fdisp=%p, ftick=%p\n", fdisp, fdisp->tick); + fuse_ticket_drop(fdisp->tick); #ifdef INVARIANTS - fdisp->tick = NULL; + fdisp->tick = NULL; #endif } void fdisp_make(struct fuse_dispatcher *fdip, enum fuse_opcode op, - struct mount *mp, uint64_t nid, struct thread *td, - struct ucred *cred); + struct mount *mp, uint64_t nid, struct thread *td, struct ucred *cred); void fdisp_make_pid(struct fuse_dispatcher *fdip, enum fuse_opcode op, - struct mount *mp, uint64_t nid, pid_t pid, - struct ucred *cred); + struct mount *mp, uint64_t nid, pid_t pid, struct ucred *cred); void fdisp_make_vp(struct fuse_dispatcher *fdip, enum fuse_opcode op, - struct vnode *vp, struct thread *td, struct ucred *cred); + struct vnode *vp, struct thread *td, struct ucred *cred); -int fdisp_wait_answ(struct fuse_dispatcher *fdip); +int fdisp_wait_answ(struct fuse_dispatcher *fdip); -static __inline__ -int +static inline int fdisp_simple_putget_vp(struct fuse_dispatcher *fdip, enum fuse_opcode op, - struct vnode *vp, struct thread *td, struct ucred *cred) + struct vnode *vp, struct thread *td, struct ucred *cred) { - DEBUGX(FUSE_DEBUG_IPC, "-> fdip=%p, opcode=%d, vp=%p\n", fdip, op, vp); - fdisp_make_vp(fdip, op, vp, td, cred); - return fdisp_wait_answ(fdip); + DEBUGX(FUSE_DEBUG_IPC, "-> fdip=%p, opcode=%d, vp=%p\n", fdip, op, vp); + fdisp_make_vp(fdip, op, vp, td, cred); + return (fdisp_wait_answ(fdip)); } #endif /* _FUSE_IPC_H_ */ |