DAOS API: src/include/daos_types.h Source File

| DAOS API (v2.1 - dev)

Loading...
Searching...
No Matches
daos_types.h
1
10
11#ifndef DAOS_TYPES_H
12#define DAOS_TYPES_H
13
14#if defined(__cplusplus)
15extern "C" {
16#endif
17
18#include <stdint.h>
19#include <stdio.h>
20#include <string.h>
21#include <stdbool.h>
22#include <ctype.h>
23#include <limits.h>
24
26#include <uuid/uuid.h>
28#include <cart/types.h>
29
30#include <daos_errno.h>
31
33#define DAOS_SYS_NAME_MAX 15
34
36#define DAOS_SYS_INFO_STRING_MAX 63
37
41
42typedef uint64_t daos_size_t;
43typedef uint64_t daos_off_t;
44
45#define crt_proc_daos_key_t crt_proc_d_iov_t
46#define crt_proc_daos_size_t crt_proc_uint64_t
47#define crt_proc_daos_epoch_t crt_proc_uint64_t
48
50#define DAOS_HKEY_MAX 32
51
52typedef enum {
53 DAOS_ANCHOR_TYPE_ZERO = 0,
54 DAOS_ANCHOR_TYPE_HKEY = 1,
55 DAOS_ANCHOR_TYPE_KEY = 2,
56 DAOS_ANCHOR_TYPE_EOF = 3,
57} daos_anchor_type_t;
58
59#define DAOS_ANCHOR_BUF_MAX 104
61 typedef struct {
62 uint16_t da_type;
63 uint16_t da_shard;
64 uint32_t da_flags;
65 uint64_t da_sub_anchors;
66 uint8_t da_buf[DAOS_ANCHOR_BUF_MAX];
67} daos_anchor_t;
68
69#define DAOS_ANCHOR_INIT { .da_type = DAOS_ANCHOR_TYPE_ZERO, \
70 .da_shard = 0, \
71 .da_flags = 0, \
72 .da_sub_anchors = 0, \
73 .da_buf = { 0 } }
74
76 typedef struct {
78 uint64_t cookie;
79} daos_handle_t;
80
81#define DAOS_HDL_INVAL ((daos_handle_t){0})
82#define DAOS_TX_NONE DAOS_HDL_INVAL
83
84static inline bool
85daos_handle_is_inval(daos_handle_t hdl)
86{
87 return hdl.cookie == 0;
88}
89
90static inline bool
91daos_handle_is_valid(daos_handle_t hdl)
92{
93 return !daos_handle_is_inval(hdl);
94}
95
105#define DAOS_PC_RO (1U << 0)
106#define DAOS_PC_RW (1U << 1)
107#define DAOS_PC_EX (1U << 2)
108
109#define DAOS_PC_NBITS 3
110#define DAOS_PC_MASK ((1U << DAOS_PC_NBITS) - 1)
111
115typedef uint64_t daos_epoch_t;
116
120 typedef struct {
122 daos_epoch_t epr_lo;
124 daos_epoch_t epr_hi;
125} daos_epoch_range_t;
126
128#define DAOS_EPOCH_MAX (~0ULL)
129
131 typedef struct {
133 uuid_t ci_uuid;
135 daos_epoch_t ci_lsnapshot;
137 uint32_t ci_nhandles;
139 uint32_t ci_nsnapshots;
141 uint64_t ci_md_otime;
143 uint64_t ci_md_mtime;
144 /* TODO: add more members, e.g., size, # objects, uid, gid... */
145} daos_cont_info_t;
146
147typedef d_iov_t daos_key_t;
148
149static inline bool
150daos_key_is_null(daos_key_t key)
151{
152 return key.iov_buf_len == 0 || key.iov_buf == NULL;
153}
154
158
159 typedef struct daos_event {
161 int ev_error;
163 struct {
164 uint64_t space[20];
165 } ev_private;
167 uint64_t ev_debug;
168} daos_event_t;
169
171#define DAOS_EQ_WAIT -1
173#define DAOS_EQ_NOWAIT 0
174
175typedef enum {
177 DAOS_EQR_COMPLETED = (1),
179 DAOS_EQR_WAITING = (1 << 1),
181 DAOS_EQR_ALL = (DAOS_EQR_COMPLETED | DAOS_EQR_WAITING),
182} daos_eq_query_t;
183
184typedef enum {
185 DAOS_EVS_READY,
186 DAOS_EVS_RUNNING,
187 DAOS_EVS_COMPLETED,
188 DAOS_EVS_ABORTED,
189} daos_ev_status_t;
190
195 struct d_tgt_list {
197 d_rank_t *tl_ranks;
199 int32_t *tl_tgts;
201 uint32_t tl_nr;
202};
203
204struct daos_eq;
205
212enum {
213 DAOS_HTYPE_EQ = 1,
214 DAOS_HTYPE_POOL = 3,
215 DAOS_HTYPE_CO = 5,
216 DAOS_HTYPE_OBJ = 7,
217 DAOS_HTYPE_ARRAY = 9,
218 DAOS_HTYPE_TX = 11,
219 DAOS_HTYPE_KV = 13,
220 /* Must enlarge D_HTYPE_BITS to add more types */
221};
222
231 typedef struct {
233 uint64_t lo;
235 uint64_t hi;
236} daos_obj_id_t;
237
238#define DAOS_UUID_STR_SIZE 37 /* 36 + 1 for '\0' */
239
240#define UUID_SST_UPPER 1
241#define UUID_SST_LOWER -1
242#define UUID_SST_NONE 0
243
244/*
245 * \param sensitive positive: expect uppercase character.
246 * negative: expect lowercase character.
247 * zero: no care uppercase or lowercase.
248 */
249static inline bool
250daos_is_valid_uuid_string(const char *uuid, int sensitive)
251{
252 const char *p;
253 int len = DAOS_UUID_STR_SIZE - 1; /* Not include the terminated '\0' */
254 int i;
255
256 if (strnlen(uuid, len) != len)
257 return false;
258
259 for (i = 0, p = uuid; i < len; i++, p++) {
260 if (i == 8 || i == 13 || i == 18 || i == 23) {
261 if (*p != '-')
262 return false;
263 } else {
264 if (sensitive >= UUID_SST_UPPER) {
265 if (!isxdigit(*p) || islower(*p))
266 return false;
267 } else if (sensitive <= UUID_SST_LOWER) {
268 if (!isxdigit(*p) || isupper(*p))
269 return false;
270 } else if (!isxdigit(*p)) {
271 return false;
272 }
273 }
274 }
275
276 return true;
277}
278
282 struct daos_rank_uri {
284 uint32_t dru_rank;
286 char *dru_uri;
287};
288
292 struct daos_sys_info {
294 char dsi_system_name[DAOS_SYS_INFO_STRING_MAX + 1];
296 char dsi_fabric_provider[DAOS_SYS_INFO_STRING_MAX + 1];
298 char dsi_agent_path[PATH_MAX];
300 uint32_t dsi_nr_ranks;
302 struct daos_rank_uri *dsi_ranks;
304 uint32_t dsi_nr_ms_ranks;
306 uint32_t *dsi_ms_ranks;
307};
308
310#define DAOS_ATTR_NAME_MAX 511
311
312#if defined(__cplusplus)
313}
314#endif
315
316#endif /* DAOS_TYPES_H */
d_tgt_list
Definition daos_types.h:195
d_tgt_list::tl_tgts
int32_t * tl_tgts
Definition daos_types.h:199
d_tgt_list::tl_nr
uint32_t tl_nr
Definition daos_types.h:201
d_tgt_list::tl_ranks
d_rank_t * tl_ranks
Definition daos_types.h:197
daos_anchor_t
Definition daos_types.h:61
daos_anchor_t::da_type
uint16_t da_type
Definition daos_types.h:62
daos_anchor_t::da_buf
uint8_t da_buf[DAOS_ANCHOR_BUF_MAX]
Definition daos_types.h:66
daos_anchor_t::da_flags
uint32_t da_flags
Definition daos_types.h:64
daos_anchor_t::da_shard
uint16_t da_shard
Definition daos_types.h:63
daos_anchor_t::da_sub_anchors
uint64_t da_sub_anchors
Definition daos_types.h:65
daos_cont_info_t
Definition daos_types.h:131
daos_cont_info_t::ci_md_otime
uint64_t ci_md_otime
Definition daos_types.h:141
daos_cont_info_t::ci_lsnapshot
daos_epoch_t ci_lsnapshot
Definition daos_types.h:135
daos_cont_info_t::ci_md_mtime
uint64_t ci_md_mtime
Definition daos_types.h:143
daos_cont_info_t::ci_nhandles
uint32_t ci_nhandles
Definition daos_types.h:137
daos_cont_info_t::ci_uuid
uuid_t ci_uuid
Definition daos_types.h:133
daos_cont_info_t::ci_nsnapshots
uint32_t ci_nsnapshots
Definition daos_types.h:139
daos_epoch_range_t
Definition daos_types.h:120
daos_epoch_range_t::epr_lo
daos_epoch_t epr_lo
Definition daos_types.h:122
daos_epoch_range_t::epr_hi
daos_epoch_t epr_hi
Definition daos_types.h:124
daos_event
Definition daos_types.h:159
daos_event::ev_error
int ev_error
Definition daos_types.h:161
daos_event::ev_debug
uint64_t ev_debug
Definition daos_types.h:167
daos_event::ev_private
struct daos_event::@277125326347062144130016000042162320351057142323 ev_private
daos_handle_t
Definition daos_types.h:76
daos_handle_t::cookie
uint64_t cookie
Definition daos_types.h:78
daos_obj_id_t
Definition daos_types.h:231
daos_obj_id_t::hi
uint64_t hi
Definition daos_types.h:235
daos_obj_id_t::lo
uint64_t lo
Definition daos_types.h:233
daos_rank_uri
Definition daos_types.h:282
daos_rank_uri::dru_uri
char * dru_uri
Definition daos_types.h:286
daos_rank_uri::dru_rank
uint32_t dru_rank
Definition daos_types.h:284
daos_sys_info
Definition daos_types.h:292
daos_sys_info::dsi_nr_ms_ranks
uint32_t dsi_nr_ms_ranks
Definition daos_types.h:304
daos_sys_info::dsi_ranks
struct daos_rank_uri * dsi_ranks
Definition daos_types.h:302
daos_sys_info::dsi_nr_ranks
uint32_t dsi_nr_ranks
Definition daos_types.h:300
daos_sys_info::dsi_system_name
char dsi_system_name[DAOS_SYS_INFO_STRING_MAX+1]
Definition daos_types.h:294
daos_sys_info::dsi_agent_path
char dsi_agent_path[PATH_MAX]
Definition daos_types.h:298
daos_sys_info::dsi_fabric_provider
char dsi_fabric_provider[DAOS_SYS_INFO_STRING_MAX+1]
Definition daos_types.h:296
daos_sys_info::dsi_ms_ranks
uint32_t * dsi_ms_ranks
Definition daos_types.h:306