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

| DAOS API (v2.1 - dev)

Loading...
Searching...
No Matches
daos_obj.h
1
6#ifndef __DAOS_OBJ_H__
7#define __DAOS_OBJ_H__
8
9#define daos_obj_generate_oid daos_obj_generate_oid2
10
11#if defined(__cplusplus)
12extern "C" {
13#endif
14
15#include <daos_types.h>
16#include <daos_event.h>
17#include <daos_obj_class.h>
18#include <daos_prop.h>
19
20#define DAOS_OBJ_NIL ((daos_obj_id_t){0})
21
23#define OID_FMT_INTR_BITS 32
25#define OID_FMT_TYPE_BITS 8
27#define OID_FMT_CLASS_BITS 8
29#define OID_FMT_META_BITS 16
30
32#define OID_FMT_TYPE_SHIFT (64 - OID_FMT_TYPE_BITS)
34#define OID_FMT_CLASS_SHIFT (OID_FMT_TYPE_SHIFT - OID_FMT_CLASS_BITS)
36#define OID_FMT_META_SHIFT (OID_FMT_CLASS_SHIFT - OID_FMT_META_BITS)
37
39#define OID_FMT_TYPE_MAX ((1ULL << OID_FMT_TYPE_BITS) - 1)
41#define OID_FMT_CLASS_MAX ((1ULL << OID_FMT_CLASS_BITS) - 1)
43#define OID_FMT_META_MAX ((1ULL << OID_FMT_META_BITS) - 1)
44
46#define OID_FMT_TYPE_MASK (OID_FMT_TYPE_MAX << OID_FMT_TYPE_SHIFT)
48#define OID_FMT_CLASS_MASK (OID_FMT_CLASS_MAX << OID_FMT_CLASS_SHIFT)
50#define OID_FMT_META_MASK (OID_FMT_META_MAX << OID_FMT_META_SHIFT)
51
53enum daos_otype_t {
55 DAOS_OT_MULTI_HASHED = 0,
56
60 DAOS_OT_OIT = 1,
61
63 DAOS_OT_DKEY_UINT64 = 2,
64
66 DAOS_OT_AKEY_UINT64 = 3,
67
69 DAOS_OT_MULTI_UINT64 = 4,
70
72 DAOS_OT_DKEY_LEXICAL = 5,
73
75 DAOS_OT_AKEY_LEXICAL = 6,
76
78 DAOS_OT_MULTI_LEXICAL = 7,
79
81 DAOS_OT_KV_HASHED = 8,
82
84 DAOS_OT_KV_UINT64 = 9,
85
87 DAOS_OT_KV_LEXICAL = 10,
88
90 DAOS_OT_ARRAY = 11,
91
93 DAOS_OT_ARRAY_ATTR = 12,
94
96 DAOS_OT_ARRAY_BYTE = 13,
97
101 DAOS_OT_OIT_V2 = 14,
102
103 DAOS_OT_MAX = 14,
104
109
114};
115
116static inline bool
117daos_otype_t_is_valid(enum daos_otype_t type)
118{
119 return type <= DAOS_OT_MAX;
120}
121
122static inline bool
123daos_pa_domain_is_valid(uint32_t pa_domain)
124{
125 return pa_domain == DAOS_PROP_CO_REDUN_NODE || pa_domain == DAOS_PROP_CO_REDUN_RANK;
126}
127
128static inline enum daos_otype_t
129daos_obj_id2type(daos_obj_id_t oid)
130{
131 uint64_t type;
132
133 type = (oid.hi & OID_FMT_TYPE_MASK) >> OID_FMT_TYPE_SHIFT;
134
135 return (enum daos_otype_t)type;
136}
137
138static inline bool
139daos_is_dkey_lexical_type(enum daos_otype_t type)
140{
141 switch (type) {
142 case DAOS_OT_DKEY_LEXICAL:
143 case DAOS_OT_MULTI_LEXICAL:
144 case DAOS_OT_KV_LEXICAL:
145 return true;
146 default:
147 return false;
148
149 }
150}
151
152static inline bool
153daos_is_dkey_lexical(daos_obj_id_t oid)
154{
155 return daos_is_dkey_lexical_type(daos_obj_id2type(oid));
156}
157
158static inline bool
159daos_is_akey_lexical_type(enum daos_otype_t type)
160{
161 switch (type) {
162 case DAOS_OT_AKEY_LEXICAL:
163 case DAOS_OT_MULTI_LEXICAL:
164 return true;
165 default:
166 return false;
167
168 }
169}
170
171static inline bool
172daos_is_akey_lexical(daos_obj_id_t oid)
173{
174 return daos_is_akey_lexical_type(daos_obj_id2type(oid));
175}
176
177static inline bool
178daos_is_dkey_uint64_type(enum daos_otype_t type)
179{
180 switch (type) {
181 case DAOS_OT_MULTI_UINT64:
182 case DAOS_OT_DKEY_UINT64:
183 case DAOS_OT_KV_UINT64:
184 case DAOS_OT_ARRAY:
185 case DAOS_OT_ARRAY_ATTR:
186 case DAOS_OT_ARRAY_BYTE:
187 return true;
188 default:
189 return false;
190
191 }
192}
193
194static inline bool
195daos_is_dkey_uint64(daos_obj_id_t oid)
196{
197 return daos_is_dkey_uint64_type(daos_obj_id2type(oid));
198}
199
200static inline bool
201daos_is_akey_uint64_type(enum daos_otype_t type)
202{
203 switch (type) {
204 case DAOS_OT_MULTI_UINT64:
205 case DAOS_OT_AKEY_UINT64:
206 return true;
207 default:
208 return false;
209
210 }
211}
212
213static inline bool
214daos_is_akey_uint64(daos_obj_id_t oid)
215{
216 return daos_is_akey_uint64_type(daos_obj_id2type(oid));
217}
218
219static inline bool
220daos_is_array_type(enum daos_otype_t type)
221{
222 switch (type) {
223 case DAOS_OT_ARRAY:
224 case DAOS_OT_ARRAY_ATTR:
225 case DAOS_OT_ARRAY_BYTE:
226 return true;
227 default:
228 return false;
229
230 }
231}
232
233static inline bool
234daos_is_array(daos_obj_id_t oid)
235{
236 enum daos_otype_t type = daos_obj_id2type(oid);
237
238 return daos_is_array_type(type);
239}
240
241static inline bool
242daos_is_kv_type(enum daos_otype_t type)
243{
244 switch (type) {
245 case DAOS_OT_KV_HASHED:
246 case DAOS_OT_KV_UINT64:
247 case DAOS_OT_KV_LEXICAL:
248 return true;
249 default:
250 return false;
251
252 }
253}
254
255static inline bool
256daos_is_kv(daos_obj_id_t oid)
257{
258 enum daos_otype_t type = daos_obj_id2type(oid);
259
260 return daos_is_kv_type(type);
261}
262
264#define IO_FLAGS_COND_BITS 8
265
266enum {
267 /* Conditional Op: Punch key if it exists, fail otherwise */
268 DAOS_COND_PUNCH = (1 << 0),
269 /* Conditional Op: Insert dkey if it doesn't exist, fail otherwise */
270 DAOS_COND_DKEY_INSERT = (1 << 1),
271 /* Conditional Op: Update dkey if it exists, fail otherwise */
272 DAOS_COND_DKEY_UPDATE = (1 << 2),
273 /* Conditional Op: Fetch dkey if it exists, fail otherwise */
274 DAOS_COND_DKEY_FETCH = (1 << 3),
275 /* Conditional Op: Insert akey if it doesn't exist, fail otherwise */
276 DAOS_COND_AKEY_INSERT = (1 << 4),
277 /* Conditional Op: Update akey if it exists, fail otherwise */
278 DAOS_COND_AKEY_UPDATE = (1 << 5),
279 /* Conditional Op: Fetch akey if it exists, fail otherwise */
280 DAOS_COND_AKEY_FETCH = (1 << 6),
281 /* Indication of per akey conditional ops. If set, the global
282 * flag should not have any akey conditional ops specified. The
283 * per akey flags will be read from the iod_flags field.
284 */
285 DAOS_COND_PER_AKEY = (1 << 7),
287 DAOS_COND_MASK = ((1 << IO_FLAGS_COND_BITS) - 1),
288};
289
294 struct daos_obj_attr {
296 d_rank_t oa_rank;
298 struct daos_oclass_attr *oa_oa;
299};
300
302enum {
304 DAOS_OO_RO = (1 << 1),
306 DAOS_OO_RW = (1 << 2),
308 DAOS_OO_EXCL = (1 << 3),
310 DAOS_OO_IO_RAND = (1 << 4),
312 DAOS_OO_IO_SEQ = (1 << 5),
313};
314
330
336 typedef struct {
338 uint64_t rx_idx;
344 uint64_t rx_nr;
345} daos_recx_t;
346
348typedef enum {
350 DAOS_IOD_NONE = 0,
352 DAOS_IOD_SINGLE = 1,
354 DAOS_IOD_ARRAY = 2,
355} daos_iod_type_t;
356
362 typedef struct {
364 daos_key_t iod_name;
376 daos_iod_type_t iod_type;
378 daos_size_t iod_size;
382 uint64_t iod_flags;
387 uint32_t iod_nr;
393 daos_recx_t *iod_recxs;
394} daos_iod_t;
395
411#define DAOS_IOMF_DETAIL (0x1U)
416 typedef struct {
418 daos_iod_type_t iom_type;
422 uint32_t iom_nr;
429 uint32_t iom_nr_out;
431 uint32_t iom_flags;
433 daos_size_t iom_size;
438 daos_recx_t iom_recx_lo;
444 daos_recx_t iom_recx_hi;
448 daos_recx_t *iom_recxs;
449} daos_iom_t;
450
452enum {
454 DAOS_REC_ANY = 0,
455};
456
458enum {
460 DAOS_GET_MAX = (1 << 0),
462 DAOS_GET_MIN = (1 << 1),
464 DAOS_GET_DKEY = (1 << 2),
466 DAOS_GET_AKEY = (1 << 3),
468 DAOS_GET_RECX = (1 << 4),
469};
470
475 typedef struct {
477 daos_size_t kd_key_len;
482 uint32_t kd_val_type;
483} daos_key_desc_t;
484
485static enum daos_obj_redun
486daos_obj_id2ord(daos_obj_id_t oid)
487{
488 return (enum daos_obj_redun)((oid.hi & OID_FMT_CLASS_MASK) >> OID_FMT_CLASS_SHIFT);
489}
490
491static inline daos_oclass_id_t
492daos_obj_id2class(daos_obj_id_t oid)
493{
494 enum daos_obj_redun ord;
495 uint32_t nr_grps;
496
497 ord = daos_obj_id2ord(oid);
498 nr_grps = (oid.hi & OID_FMT_META_MASK) >> OID_FMT_META_SHIFT;
499
500 return (ord << OC_REDUN_SHIFT) | nr_grps;
501}
502
503static inline bool
504daos_obj_id_is_nil(daos_obj_id_t oid)
505{
506 return oid.hi == 0 && oid.lo == 0;
507}
508
509#define DAOS_OCH_RDD_BITS 4
510#define DAOS_OCH_SHD_BITS 6
511#define DAOS_OCH_RDD_SHIFT 0
512#define DAOS_OCH_SHD_SHIFT DAOS_OCH_RDD_BITS
513#define DAOS_OCH_RDD_MAX_VAL ((1ULL << DAOS_OCH_RDD_BITS) - 1)
514#define DAOS_OCH_SHD_MAX_VAL ((1ULL << DAOS_OCH_SHD_BITS) - 1)
515#define DAOS_OCH_RDD_MASK (DAOS_OCH_RDD_MAX_VAL << DAOS_OCH_RDD_SHIFT)
516#define DAOS_OCH_SHD_MASK (DAOS_OCH_SHD_MAX_VAL << DAOS_OCH_SHD_SHIFT)
517
519enum {
521 DAOS_OCH_RDD_DEF = (1 << 0),
522 DAOS_OCH_RDD_NO = (1 << 1),
523 DAOS_OCH_RDD_RP = (1 << 2),
524 DAOS_OCH_RDD_EC = (1 << 3),
526 DAOS_OCH_SHD_DEF = (1 << 4),
529 DAOS_OCH_SHD_TINY = (1 << 5),
530 DAOS_OCH_SHD_REG = (1 << 6),
531 DAOS_OCH_SHD_HI = (1 << 7),
532 DAOS_OCH_SHD_EXT = (1 << 8),
533 DAOS_OCH_SHD_MAX = (1 << 9),
534};
535
562int
563daos_obj_generate_oid(daos_handle_t coh, daos_obj_id_t *oid,
564 enum daos_otype_t type, daos_oclass_id_t cid,
565 daos_oclass_hints_t hints, uint32_t args);
566
588int
589daos_obj_open(daos_handle_t coh, daos_obj_id_t oid, unsigned int mode,
590 daos_handle_t *oh, daos_event_t *ev);
591
604int
605daos_obj_close(daos_handle_t oh, daos_event_t *ev);
606
628int
629daos_obj_punch(daos_handle_t oh, daos_handle_t th, uint64_t flags,
630 daos_event_t *ev);
631
655int
656daos_obj_punch_dkeys(daos_handle_t oh, daos_handle_t th, uint64_t flags,
657 unsigned int nr, daos_key_t *dkeys, daos_event_t *ev);
658
683int
684daos_obj_punch_akeys(daos_handle_t oh, daos_handle_t th, uint64_t flags,
685 daos_key_t *dkey, unsigned int nr, daos_key_t *akeys,
686 daos_event_t *ev);
687
705int
706daos_obj_query(daos_handle_t oh, struct daos_obj_attr *oa, d_rank_list_t *ranks,
707 daos_event_t *ev);
708
709/*
710 * Object I/O API
711 */
712
771int
772daos_obj_fetch(daos_handle_t oh, daos_handle_t th, uint64_t flags,
773 daos_key_t *dkey, unsigned int nr, daos_iod_t *iods,
774 d_sg_list_t *sgls, daos_iom_t *ioms, daos_event_t *ev);
775
824int
825daos_obj_update(daos_handle_t oh, daos_handle_t th, uint64_t flags,
826 daos_key_t *dkey, unsigned int nr, daos_iod_t *iods,
827 d_sg_list_t *sgls, daos_event_t *ev);
828
874int
875daos_obj_list_dkey(daos_handle_t oh, daos_handle_t th, uint32_t *nr,
876 daos_key_desc_t *kds, d_sg_list_t *sgl,
877 daos_anchor_t *anchor, daos_event_t *ev);
878
925int
926daos_obj_list_akey(daos_handle_t oh, daos_handle_t th, daos_key_t *dkey,
927 uint32_t *nr, daos_key_desc_t *kds, d_sg_list_t *sgl,
928 daos_anchor_t *anchor, daos_event_t *ev);
929
978int
979daos_obj_list_recx(daos_handle_t oh, daos_handle_t th, daos_key_t *dkey,
980 daos_key_t *akey, daos_size_t *size, uint32_t *nr,
981 daos_recx_t *recxs, daos_epoch_range_t *eprs,
982 daos_anchor_t *anchor, bool incr_order,
983 daos_event_t *ev);
984
1028int
1029daos_obj_query_key(daos_handle_t oh, daos_handle_t th, uint64_t flags,
1030 daos_key_t *dkey, daos_key_t *akey, daos_recx_t *recx,
1031 daos_event_t *ev);
1032
1050int
1051daos_obj_query_max_epoch(daos_handle_t oh, daos_handle_t th, daos_epoch_t *epoch, daos_event_t *ev);
1052
1066int
1067daos_obj_verify(daos_handle_t coh, daos_obj_id_t oid, daos_epoch_t epoch);
1068
1092int
1093daos_obj_anchor_split(daos_handle_t oh, uint32_t *nr, daos_anchor_t *anchors);
1094
1110int
1111daos_obj_anchor_set(daos_handle_t oh, uint32_t index, daos_anchor_t *anchor);
1112
1128int
1129daos_obj_key2anchor(daos_handle_t oh, daos_handle_t th, daos_key_t *dkey, daos_key_t *akey,
1130 daos_anchor_t *anchor, daos_event_t *ev);
1131
1147int
1148daos_oit_open(daos_handle_t coh, daos_epoch_t epoch,
1149 daos_handle_t *oh, daos_event_t *ev);
1150
1163int
1164daos_oit_close(daos_handle_t oh, daos_event_t *ev);
1165
1185int
1186daos_oit_list(daos_handle_t oh, daos_obj_id_t *oids, uint32_t *oids_nr,
1187 daos_anchor_t *anchor, daos_event_t *ev);
1188
1189#define DAOS_OIT_MARKER_MAX_LEN (32)
1190
1211int
1212daos_oit_mark(daos_handle_t oh, daos_obj_id_t oid, d_iov_t *marker, daos_event_t *ev);
1213
1233int
1234daos_oit_list_unmarked(daos_handle_t oh, daos_obj_id_t *oids, uint32_t *oids_nr,
1235 daos_anchor_t *anchor, daos_event_t *ev);
1236
1250typedef int
1251(daos_oit_filter_cb)(daos_obj_id_t oid, d_iov_t *marker);
1252
1273int
1274daos_oit_list_filter(daos_handle_t oh, daos_obj_id_t *oids, uint32_t *oids_nr,
1275 daos_anchor_t *anchor, daos_oit_filter_cb filter, daos_event_t *ev);
1276
1277#if defined(__cplusplus)
1278}
1279#endif /* __cplusplus */
1280#endif /* __DAOS_OBJ_H__ */
daos_anchor_t
Definition daos_types.h:58
daos_epoch_range_t
Definition daos_types.h:117
daos_handle_t
Definition daos_types.h:73
daos_iod_t
Definition daos_obj.h:362
daos_iod_t::iod_flags
uint64_t iod_flags
Definition daos_obj.h:382
daos_iod_t::iod_name
daos_key_t iod_name
Definition daos_obj.h:364
daos_iod_t::iod_nr
uint32_t iod_nr
Definition daos_obj.h:387
daos_iod_t::iod_recxs
daos_recx_t * iod_recxs
Definition daos_obj.h:393
daos_iod_t::iod_size
daos_size_t iod_size
Definition daos_obj.h:378
daos_iod_t::iod_type
daos_iod_type_t iod_type
Definition daos_obj.h:376
daos_iom_t
Definition daos_obj.h:416
daos_iom_t::iom_flags
uint32_t iom_flags
Definition daos_obj.h:431
daos_iom_t::iom_size
daos_size_t iom_size
Definition daos_obj.h:433
daos_iom_t::iom_type
daos_iod_type_t iom_type
Definition daos_obj.h:418
daos_iom_t::iom_recx_hi
daos_recx_t iom_recx_hi
Definition daos_obj.h:444
daos_iom_t::iom_recx_lo
daos_recx_t iom_recx_lo
Definition daos_obj.h:438
daos_iom_t::iom_recxs
daos_recx_t * iom_recxs
Definition daos_obj.h:448
daos_iom_t::iom_nr
uint32_t iom_nr
Definition daos_obj.h:422
daos_iom_t::iom_nr_out
uint32_t iom_nr_out
Definition daos_obj.h:429
daos_key_desc_t
Definition daos_obj.h:475
daos_key_desc_t::kd_val_type
uint32_t kd_val_type
Definition daos_obj.h:482
daos_key_desc_t::kd_key_len
daos_size_t kd_key_len
Definition daos_obj.h:477
daos_obj_attr
Definition daos_obj.h:294
daos_obj_attr::oa_oa
struct daos_oclass_attr * oa_oa
Definition daos_obj.h:298
daos_obj_attr::oa_rank
d_rank_t oa_rank
Definition daos_obj.h:296
daos_obj_id_t
Definition daos_types.h:222
daos_obj_id_t::hi
uint64_t hi
Definition daos_types.h:226
daos_obj_id_t::lo
uint64_t lo
Definition daos_types.h:224
daos_oclass_attr
Definition daos_obj_class.h:400
daos_recx_t
Definition daos_obj.h:336
daos_recx_t::rx_nr
uint64_t rx_nr
Definition daos_obj.h:344
daos_recx_t::rx_idx
uint64_t rx_idx
Definition daos_obj.h:338