| 1 | /* |
|---|
| 2 | * (C) 2011 Clemson University and The University of Chicago |
|---|
| 3 | * |
|---|
| 4 | * See COPYING in top-level directory. |
|---|
| 5 | */ |
|---|
| 6 | #ifndef AIOCOMMON_H |
|---|
| 7 | #define AIOCOMMON_H |
|---|
| 8 | |
|---|
| 9 | #include <unistd.h> |
|---|
| 10 | #include <pthread.h> |
|---|
| 11 | #include "pvfs2-types.h" |
|---|
| 12 | #include "usrint.h" |
|---|
| 13 | #include "posix-ops.h" |
|---|
| 14 | #include "openfile-util.h" |
|---|
| 15 | #include "iocommon.h" |
|---|
| 16 | #include "aio.h" |
|---|
| 17 | #include "quicklist.h" |
|---|
| 18 | #include "gossip.h" |
|---|
| 19 | #include "pvfs2-aio.h" |
|---|
| 20 | |
|---|
| 21 | #define PVFS_AIO_MAX_RUNNING 10 |
|---|
| 22 | #define PVFS_AIO_LISTIO_MAX 10 |
|---|
| 23 | |
|---|
| 24 | #define PVFS_AIO_DEFAULT_TIMEOUT_MS 10 |
|---|
| 25 | |
|---|
| 26 | enum |
|---|
| 27 | { |
|---|
| 28 | PVFS_AIO_PROGRESS_IDLE, |
|---|
| 29 | PVFS_AIO_PROGRESS_RUNNING, |
|---|
| 30 | }; |
|---|
| 31 | |
|---|
| 32 | typedef enum |
|---|
| 33 | { |
|---|
| 34 | PVFS_AIO_IO_OP = 1, |
|---|
| 35 | PVFS_AIO_IOV_OP, |
|---|
| 36 | PVFS_AIO_OPEN_OP, |
|---|
| 37 | PVFS_AIO_RENAME_OP, |
|---|
| 38 | PVFS_AIO_STAT_OP, |
|---|
| 39 | PVFS_AIO_STAT64_OP, |
|---|
| 40 | } PVFS_aio_op_code; |
|---|
| 41 | |
|---|
| 42 | |
|---|
| 43 | /* the following structures contain operation dependent data for aio calls */ |
|---|
| 44 | struct PINT_aio_io_cb |
|---|
| 45 | { |
|---|
| 46 | struct iovec *vector; /* in */ |
|---|
| 47 | int count; /* in (readv writev )*/ |
|---|
| 48 | pvfs_descriptor *pd; /* in */ |
|---|
| 49 | enum PVFS_io_type which; /* in */ |
|---|
| 50 | off64_t offset; /* in */ |
|---|
| 51 | int advance_fp; /* in */ |
|---|
| 52 | void *sys_buf; |
|---|
| 53 | PVFS_Request mem_req; |
|---|
| 54 | PVFS_Request file_req; |
|---|
| 55 | PVFS_sysresp_io io_resp; |
|---|
| 56 | ssize_t *bcnt; /* out */ |
|---|
| 57 | }; |
|---|
| 58 | |
|---|
| 59 | struct PINT_aio_open_cb |
|---|
| 60 | { |
|---|
| 61 | char *path; /* in */ |
|---|
| 62 | char *directory; /* in */ |
|---|
| 63 | char *filename; /* in */ |
|---|
| 64 | int flags; /* in */ |
|---|
| 65 | PVFS_hint file_creation_param; /* in */ |
|---|
| 66 | int mode; /* in */ |
|---|
| 67 | pvfs_descriptor *pdir; /* in */ |
|---|
| 68 | int *fd; /* in/out */ |
|---|
| 69 | pvfs_descriptor *pd; /* out */ |
|---|
| 70 | }; |
|---|
| 71 | |
|---|
| 72 | struct PINT_aio_rename_cb |
|---|
| 73 | { |
|---|
| 74 | PVFS_object_ref *oldpdir; /* in */ |
|---|
| 75 | char *olddir; /* in */ |
|---|
| 76 | char *oldname; /* in */ |
|---|
| 77 | PVFS_object_ref *newpdir; /* in */ |
|---|
| 78 | char *newdir; /* in */ |
|---|
| 79 | char *newname; /* in */ |
|---|
| 80 | }; |
|---|
| 81 | |
|---|
| 82 | struct PINT_aio_stat_cb |
|---|
| 83 | { |
|---|
| 84 | pvfs_descriptor *pd; /* in */ |
|---|
| 85 | uint32_t mask; /* in */ |
|---|
| 86 | PVFS_sysresp_getattr getattr_resp; |
|---|
| 87 | void *buf; /* out */ |
|---|
| 88 | }; |
|---|
| 89 | |
|---|
| 90 | /* a pvfs async control block, used for keeping track of async |
|---|
| 91 | * operations outstanding in the filesystem |
|---|
| 92 | */ |
|---|
| 93 | struct pvfs_aiocb |
|---|
| 94 | { |
|---|
| 95 | PVFS_sys_op_id op_id; |
|---|
| 96 | PVFS_hint hints; |
|---|
| 97 | |
|---|
| 98 | PVFS_aio_op_code op_code; |
|---|
| 99 | PVFS_error error_code; |
|---|
| 100 | struct qlist_head link; |
|---|
| 101 | |
|---|
| 102 | int (*call_back_fn)(void *c_dat, int status); |
|---|
| 103 | void *call_back_dat; |
|---|
| 104 | |
|---|
| 105 | union |
|---|
| 106 | { |
|---|
| 107 | struct PINT_aio_io_cb io; |
|---|
| 108 | struct PINT_aio_open_cb open; |
|---|
| 109 | struct PINT_aio_rename_cb rename; |
|---|
| 110 | struct PINT_aio_stat_cb stat; |
|---|
| 111 | } u; |
|---|
| 112 | }; |
|---|
| 113 | |
|---|
| 114 | int aiocommon_init(void); |
|---|
| 115 | |
|---|
| 116 | void aiocommon_submit_op(struct pvfs_aiocb *p_cb); |
|---|
| 117 | |
|---|
| 118 | /* |
|---|
| 119 | * Local variables: |
|---|
| 120 | * c-indent-level: 4 |
|---|
| 121 | * c-basic-offset: 4 |
|---|
| 122 | * End: |
|---|
| 123 | * |
|---|
| 124 | * vim: ts=8 sts=4 sw=4 expandtab |
|---|
| 125 | */ |
|---|
| 126 | |
|---|
| 127 | #endif |
|---|