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

| DAOS API (v2.1 - dev)

Loading...
Searching...
No Matches
daos_obj.h
1
7#ifndef __DAOS_OBJ_H__
8#define __DAOS_OBJ_H__
9
10#define daos_obj_generate_oid daos_obj_generate_oid2
11
12#if defined(__cplusplus)
13extern "C" {
14#endif
15
16#include <daos_types.h>
17#include <daos_event.h>
18#include <daos_obj_class.h>
19#include <daos_prop.h>
20
21#define DAOS_OBJ_NIL ((daos_obj_id_t){0})
22
24#define OID_FMT_INTR_BITS 32
26#define OID_FMT_TYPE_BITS 8
28#define OID_FMT_CLASS_BITS 8
30#define OID_FMT_META_BITS 16
31
33#define OID_FMT_TYPE_SHIFT (64 - OID_FMT_TYPE_BITS)
35#define OID_FMT_CLASS_SHIFT (OID_FMT_TYPE_SHIFT - OID_FMT_CLASS_BITS)
37#define OID_FMT_META_SHIFT (OID_FMT_CLASS_SHIFT - OID_FMT_META_BITS)
38
40#define OID_FMT_TYPE_MAX ((1ULL << OID_FMT_TYPE_BITS) - 1)
42#define OID_FMT_CLASS_MAX ((1ULL << OID_FMT_CLASS_BITS) - 1)
44#define OID_FMT_META_MAX ((1ULL << OID_FMT_META_BITS) - 1)
45
47#define OID_FMT_TYPE_MASK (OID_FMT_TYPE_MAX << OID_FMT_TYPE_SHIFT)
49#define OID_FMT_CLASS_MASK (OID_FMT_CLASS_MAX << OID_FMT_CLASS_SHIFT)
51#define OID_FMT_META_MASK (OID_FMT_META_MAX << OID_FMT_META_SHIFT)
52
54enum daos_otype_t {
56 DAOS_OT_MULTI_HASHED = 0,
57
61 DAOS_OT_OIT = 1,
62
64 DAOS_OT_DKEY_UINT64 = 2,
65
67 DAOS_OT_AKEY_UINT64 = 3,
68
70 DAOS_OT_MULTI_UINT64 = 4,
71
73 DAOS_OT_DKEY_LEXICAL = 5,
74
76 DAOS_OT_AKEY_LEXICAL = 6,
77
79 DAOS_OT_MULTI_LEXICAL = 7,
80
82 DAOS_OT_KV_HASHED = 8,
83
85 DAOS_OT_KV_UINT64 = 9,
86
88 DAOS_OT_KV_LEXICAL = 10,
89
91 DAOS_OT_ARRAY = 11,
92
94 DAOS_OT_ARRAY_ATTR = 12,
95
97 DAOS_OT_ARRAY_BYTE = 13,
98
102 DAOS_OT_OIT_V2 = 14,
103
104 DAOS_OT_MAX = 14,
105
110
115};
116
117static inline bool
118daos_otype_t_is_valid(enum daos_otype_t type)
119{
120 return type <= DAOS_OT_MAX;
121}
122
123static inline bool
124daos_pa_domain_is_valid(uint32_t pa_domain)
125{
126 return pa_domain == DAOS_PROP_CO_REDUN_NODE || pa_domain == DAOS_PROP_CO_REDUN_RANK;
127}
128
129static inline enum daos_otype_t
130daos_obj_id2type(daos_obj_id_t oid)
131{
132 uint64_t type;
133
134 type = (oid.hi & OID_FMT_TYPE_MASK) >> OID_FMT_TYPE_SHIFT;
135
136 return (enum daos_otype_t)type;
137}
138
139static inline bool
140daos_is_dkey_lexical_type(enum daos_otype_t type)
141{
142 switch (type) {
143 case DAOS_OT_DKEY_LEXICAL:
144 case DAOS_OT_MULTI_LEXICAL:
145 case DAOS_OT_KV_LEXICAL:
146 return true;
147 default:
148 return false;
149
150 }
151}
152
153static inline bool
154daos_is_dkey_lexical(daos_obj_id_t oid)
155{
156 return daos_is_dkey_lexical_type(daos_obj_id2type(oid));
157}
158
159static inline bool
160daos_is_akey_lexical_type(enum daos_otype_t type)
161{
162 switch (type) {
163 case DAOS_OT_AKEY_LEXICAL:
164 case DAOS_OT_MULTI_LEXICAL:
165 return true;
166 default:
167 return false;
168
169 }
170}
171
172static inline bool
173daos_is_akey_lexical(daos_obj_id_t oid)
174{
175 return daos_is_akey_lexical_type(daos_obj_id2type(oid));
176}
177
178static inline bool
179daos_is_dkey_uint64_type(enum daos_otype_t type)
180{
181 switch (type) {
182 case DAOS_OT_ARRAY_BYTE:
183 case DAOS_OT_MULTI_UINT64:
184 case DAOS_OT_DKEY_UINT64:
185 case DAOS_OT_KV_UINT64:
186 case DAOS_OT_ARRAY:
187 case DAOS_OT_ARRAY_ATTR:
188 return true;
189 default:
190 return false;
191
192 }
193}
194
195static inline bool
196daos_is_dkey_uint64(daos_obj_id_t oid)
197{
198 return daos_is_dkey_uint64_type(daos_obj_id2type(oid));
199}
200
201static inline bool
202daos_is_akey_uint64_type(enum daos_otype_t type)
203{
204 switch (type) {
205 case DAOS_OT_MULTI_UINT64:
206 case DAOS_OT_AKEY_UINT64:
207 return true;
208 default:
209 return false;
210
211 }
212}
213
214static inline bool
215daos_is_akey_uint64(daos_obj_id_t oid)
216{
217 return daos_is_akey_uint64_type(daos_obj_id2type(oid));
218}
219
220static inline bool
221daos_is_array_type(enum daos_otype_t type)
222{
223 switch (type) {
224 case DAOS_OT_ARRAY_BYTE:
225 case DAOS_OT_ARRAY:
226 case DAOS_OT_ARRAY_ATTR:
227 return true;
228 default:
229 return false;
230
231 }
232}
233
234static inline bool
235daos_is_array(daos_obj_id_t oid)
236{
237 enum daos_otype_t type = daos_obj_id2type(oid);
238
239 return daos_is_array_type(type);
240}
241
242static inline bool
243daos_is_kv_type(enum daos_otype_t type)
244{
245 switch (type) {
246 case DAOS_OT_KV_HASHED:
247 case DAOS_OT_KV_UINT64:
248 case DAOS_OT_KV_LEXICAL:
249 return true;
250 default:
251 return false;
252
253 }
254}
255
256static inline bool
257daos_is_kv(daos_obj_id_t oid)
258{
259 enum daos_otype_t type = daos_obj_id2type(oid);
260
261 return daos_is_kv_type(type);
262}
263
265#define IO_FLAGS_COND_BITS 8
266
267enum {
268 /* Conditional Op: Punch key if it exists, fail otherwise */
269 DAOS_COND_PUNCH = (1 << 0),
270 /* Conditional Op: Insert dkey if it doesn't exist, fail otherwise */
271 DAOS_COND_DKEY_INSERT = (1 << 1),
272 /* Conditional Op: Update dkey if it exists, fail otherwise */
273 DAOS_COND_DKEY_UPDATE = (1 << 2),
274 /* Conditional Op: Fetch dkey if it exists, fail otherwise */
275 DAOS_COND_DKEY_FETCH = (1 << 3),
276 /* Conditional Op: Insert akey if it doesn't exist, fail otherwise */
277 DAOS_COND_AKEY_INSERT = (1 << 4),
278 /* Conditional Op: Update akey if it exists, fail otherwise */
279 DAOS_COND_AKEY_UPDATE = (1 << 5),
280 /* Conditional Op: Fetch akey if it exists, fail otherwise */
281 DAOS_COND_AKEY_FETCH = (1 << 6),
282 /* Indication of per akey conditional ops. If set, the global
283 * flag should not have any akey conditional ops specified. The
284 * per akey flags will be read from the iod_flags field.
285 */
286 DAOS_COND_PER_AKEY = (1 << 7),
288 DAOS_COND_MASK = ((1 << IO_FLAGS_COND_BITS) - 1),
289};
290
295 struct daos_obj_attr {
297 d_rank_t oa_rank;
299 struct daos_oclass_attr *oa_oa;
300};
301
303enum {
305 DAOS_OO_RO = (1 << 1),
307 DAOS_OO_RW = (1 << 2),
309 DAOS_OO_EXCL = (1 << 3),
311 DAOS_OO_IO_RAND = (1 << 4),
313 DAOS_OO_IO_SEQ = (1 << 5),
314};
315
331
337 typedef struct {
339 uint64_t rx_idx;
345 uint64_t rx_nr;
346} daos_recx_t;
347
349typedef enum {
351 DAOS_IOD_NONE = 0,
353 DAOS_IOD_SINGLE = 1,
355 DAOS_IOD_ARRAY = 2,
356} daos_iod_type_t;
357
363 typedef struct {
365 daos_key_t iod_name;
377 daos_iod_type_t iod_type;
379 daos_size_t iod_size;
383 uint64_t iod_flags;
388 uint32_t iod_nr;
394 daos_recx_t *iod_recxs;
395} daos_iod_t;
396
412#define DAOS_IOMF_DETAIL (0x1U)
417 typedef struct {
419 daos_iod_type_t iom_type;
423 uint32_t iom_nr;
430 uint32_t iom_nr_out;
432 uint32_t iom_flags;
434 daos_size_t iom_size;
439 daos_recx_t iom_recx_lo;
445 daos_recx_t iom_recx_hi;
449 daos_recx_t *iom_recxs;
450} daos_iom_t;
451
453enum {
455 DAOS_REC_ANY = 0,
456};
457
459enum {
461 DAOS_GET_MAX = (1 << 0),
463 DAOS_GET_MIN = (1 << 1),
465 DAOS_GET_DKEY = (1 << 2),
467 DAOS_GET_AKEY = (1 << 3),
469 DAOS_GET_RECX = (1 << 4),
470};
471
476 typedef struct {
478 daos_size_t kd_key_len;
483 uint32_t kd_val_type;
484} daos_key_desc_t;
485
486static enum daos_obj_redun
487daos_obj_id2ord(daos_obj_id_t oid)
488{
489 return (enum daos_obj_redun)((oid.hi & OID_FMT_CLASS_MASK) >> OID_FMT_CLASS_SHIFT);
490}
491
492static inline daos_oclass_id_t
493daos_obj_id2class(daos_obj_id_t oid)
494{
495 enum daos_obj_redun ord;
496 uint32_t nr_grps;
497
498 ord = daos_obj_id2ord(oid);
499 nr_grps = (oid.hi & OID_FMT_META_MASK) >> OID_FMT_META_SHIFT;
500
501 return (ord << OC_REDUN_SHIFT) | nr_grps;
502}
503
504static inline uint32_t
505daos_obj_id2grp_nr(daos_obj_id_t oid)
506{
507 return (oid.hi & OID_FMT_META_MASK) >> OID_FMT_META_SHIFT;
508}
509
510static inline bool
511daos_obj_id_is_nil(daos_obj_id_t oid)
512{
513 return oid.hi == 0 && oid.lo == 0;
514}
515
516#define DAOS_OCH_RDD_BITS 4
517#define DAOS_OCH_SHD_BITS 6
518#define DAOS_OCH_RDD_SHIFT 0
519#define DAOS_OCH_SHD_SHIFT DAOS_OCH_RDD_BITS
520#define DAOS_OCH_RDD_MAX_VAL ((1ULL << DAOS_OCH_RDD_BITS) - 1)
521#define DAOS_OCH_SHD_MAX_VAL ((1ULL << DAOS_OCH_SHD_BITS) - 1)
522#define DAOS_OCH_RDD_MASK (DAOS_OCH_RDD_MAX_VAL << DAOS_OCH_RDD_SHIFT)
523#define DAOS_OCH_SHD_MASK (DAOS_OCH_SHD_MAX_VAL << DAOS_OCH_SHD_SHIFT)
524
526enum {
528 DAOS_OCH_RDD_DEF = (1 << 0),
529 DAOS_OCH_RDD_NO = (1 << 1),
530 DAOS_OCH_RDD_RP = (1 << 2),
531 DAOS_OCH_RDD_EC = (1 << 3),
533 DAOS_OCH_SHD_DEF = (1 << 4),
536 DAOS_OCH_SHD_TINY = (1 << 5),
537 DAOS_OCH_SHD_REG = (1 << 6),
538 DAOS_OCH_SHD_HI = (1 << 7),
539 DAOS_OCH_SHD_EXT = (1 << 8),
540 DAOS_OCH_SHD_MAX = (1 << 9),
541};
542
569int
570daos_obj_generate_oid(daos_handle_t coh, daos_obj_id_t *oid,
571 enum daos_otype_t type, daos_oclass_id_t cid,
572 daos_oclass_hints_t hints, uint32_t args);
573
581static inline void
582daos_obj_oid_cycle(daos_obj_id_t *oid)
583{
585 oid->hi = (oid->hi + 999999937) & UINT_MAX;
586}
587
609int
610daos_obj_open(daos_handle_t coh, daos_obj_id_t oid, unsigned int mode,
611 daos_handle_t *oh, daos_event_t *ev);
612
625int
626daos_obj_close(daos_handle_t oh, daos_event_t *ev);
627
649int
650daos_obj_punch(daos_handle_t oh, daos_handle_t th, uint64_t flags,
651 daos_event_t *ev);
652
676int
677daos_obj_punch_dkeys(daos_handle_t oh, daos_handle_t th, uint64_t flags,
678 unsigned int nr, daos_key_t *dkeys, daos_event_t *ev);
679
704int
705daos_obj_punch_akeys(daos_handle_t oh, daos_handle_t th, uint64_t flags,
706 daos_key_t *dkey, unsigned int nr, daos_key_t *akeys,
707 daos_event_t *ev);
708
726int
727daos_obj_query(daos_handle_t oh, struct daos_obj_attr *oa, d_rank_list_t *ranks,
728 daos_event_t *ev);
729
730/*
731 * Object I/O API
732 */
733
792int
793daos_obj_fetch(daos_handle_t oh, daos_handle_t th, uint64_t flags,
794 daos_key_t *dkey, unsigned int nr, daos_iod_t *iods,
795 d_sg_list_t *sgls, daos_iom_t *ioms, daos_event_t *ev);
796
845int
846daos_obj_update(daos_handle_t oh, daos_handle_t th, uint64_t flags,
847 daos_key_t *dkey, unsigned int nr, daos_iod_t *iods,
848 d_sg_list_t *sgls, daos_event_t *ev);
849
895int
896daos_obj_list_dkey(daos_handle_t oh, daos_handle_t th, uint32_t *nr,
897 daos_key_desc_t *kds, d_sg_list_t *sgl,
898 daos_anchor_t *anchor, daos_event_t *ev);
899
946int
947daos_obj_list_akey(daos_handle_t oh, daos_handle_t th, daos_key_t *dkey,
948 uint32_t *nr, daos_key_desc_t *kds, d_sg_list_t *sgl,
949 daos_anchor_t *anchor, daos_event_t *ev);
950
999int
1000daos_obj_list_recx(daos_handle_t oh, daos_handle_t th, daos_key_t *dkey,
1001 daos_key_t *akey, daos_size_t *size, uint32_t *nr,
1002 daos_recx_t *recxs, daos_epoch_range_t *eprs,
1003 daos_anchor_t *anchor, bool incr_order,
1004 daos_event_t *ev);
1005
1049int
1050daos_obj_query_key(daos_handle_t oh, daos_handle_t th, uint64_t flags,
1051 daos_key_t *dkey, daos_key_t *akey, daos_recx_t *recx,
1052 daos_event_t *ev);
1053
1071int
1072daos_obj_query_max_epoch(daos_handle_t oh, daos_handle_t th, daos_epoch_t *epoch, daos_event_t *ev);
1073
1087int
1088daos_obj_verify(daos_handle_t coh, daos_obj_id_t oid, daos_epoch_t epoch);
1089
1113int
1114daos_obj_anchor_split(daos_handle_t oh, uint32_t *nr, daos_anchor_t *anchors);
1115
1131int
1132daos_obj_anchor_set(daos_handle_t oh, uint32_t index, daos_anchor_t *anchor);
1133
1149int
1150daos_obj_key2anchor(daos_handle_t oh, daos_handle_t th, daos_key_t *dkey, daos_key_t *akey,
1151 daos_anchor_t *anchor, daos_event_t *ev);
1152
1168int
1169daos_oit_open(daos_handle_t coh, daos_epoch_t epoch,
1170 daos_handle_t *oh, daos_event_t *ev);
1171
1184int
1185daos_oit_close(daos_handle_t oh, daos_event_t *ev);
1186
1206int
1207daos_oit_list(daos_handle_t oh, daos_obj_id_t *oids, uint32_t *oids_nr,
1208 daos_anchor_t *anchor, daos_event_t *ev);
1209
1210#define DAOS_OIT_MARKER_MAX_LEN (32)
1211
1232int
1233daos_oit_mark(daos_handle_t oh, daos_obj_id_t oid, d_iov_t *marker, daos_event_t *ev);
1234
1254int
1255daos_oit_list_unmarked(daos_handle_t oh, daos_obj_id_t *oids, uint32_t *oids_nr,
1256 daos_anchor_t *anchor, daos_event_t *ev);
1257
1271typedef int
1272(daos_oit_filter_cb)(daos_obj_id_t oid, d_iov_t *marker);
1273
1294int
1295daos_oit_list_filter(daos_handle_t oh, daos_obj_id_t *oids, uint32_t *oids_nr,
1296 daos_anchor_t *anchor, daos_oit_filter_cb filter, daos_event_t *ev);
1297
1298#if defined(__cplusplus)
1299}
1300#endif /* __cplusplus */
1301#endif /* __DAOS_OBJ_H__ */
daos_anchor_t
Definition daos_types.h:60
daos_epoch_range_t
Definition daos_types.h:119
daos_handle_t
Definition daos_types.h:75
daos_iod_t
Definition daos_obj.h:363
daos_iod_t::iod_flags
uint64_t iod_flags
Definition daos_obj.h:383
daos_iod_t::iod_name
daos_key_t iod_name
Definition daos_obj.h:365
daos_iod_t::iod_nr
uint32_t iod_nr
Definition daos_obj.h:388
daos_iod_t::iod_recxs
daos_recx_t * iod_recxs
Definition daos_obj.h:394
daos_iod_t::iod_size
daos_size_t iod_size
Definition daos_obj.h:379
daos_iod_t::iod_type
daos_iod_type_t iod_type
Definition daos_obj.h:377
daos_iom_t
Definition daos_obj.h:417
daos_iom_t::iom_flags
uint32_t iom_flags
Definition daos_obj.h:432
daos_iom_t::iom_size
daos_size_t iom_size
Definition daos_obj.h:434
daos_iom_t::iom_type
daos_iod_type_t iom_type
Definition daos_obj.h:419
daos_iom_t::iom_recx_hi
daos_recx_t iom_recx_hi
Definition daos_obj.h:445
daos_iom_t::iom_recx_lo
daos_recx_t iom_recx_lo
Definition daos_obj.h:439
daos_iom_t::iom_recxs
daos_recx_t * iom_recxs
Definition daos_obj.h:449
daos_iom_t::iom_nr
uint32_t iom_nr
Definition daos_obj.h:423
daos_iom_t::iom_nr_out
uint32_t iom_nr_out
Definition daos_obj.h:430
daos_key_desc_t
Definition daos_obj.h:476
daos_key_desc_t::kd_val_type
uint32_t kd_val_type
Definition daos_obj.h:483
daos_key_desc_t::kd_key_len
daos_size_t kd_key_len
Definition daos_obj.h:478
daos_obj_attr
Definition daos_obj.h:295
daos_obj_attr::oa_oa
struct daos_oclass_attr * oa_oa
Definition daos_obj.h:299
daos_obj_attr::oa_rank
d_rank_t oa_rank
Definition daos_obj.h:297
daos_obj_id_t
Definition daos_types.h:230
daos_obj_id_t::hi
uint64_t hi
Definition daos_types.h:234
daos_obj_id_t::lo
uint64_t lo
Definition daos_types.h:232
daos_oclass_attr
Definition daos_obj_class.h:445
daos_recx_t
Definition daos_obj.h:337
daos_recx_t::rx_nr
uint64_t rx_nr
Definition daos_obj.h:345
daos_recx_t::rx_idx
uint64_t rx_idx
Definition daos_obj.h:339