DAOS API (v2.0)
Loading...
Searching...
No Matches
daos_obj.h
1
6#ifndef __DAOS_OBJ_H__
7#define __DAOS_OBJ_H__
8
9#if defined(__cplusplus)
10extern "C" {
11#endif
12
13#include <daos_types.h>
14#include <daos_event.h>
15#include <daos_obj_class.h>
16
17#define DAOS_OBJ_NIL ((daos_obj_id_t){0})
18
20#define OID_FMT_INTR_BITS 32
22#define OID_FMT_TYPE_BITS 8
24#define OID_FMT_CLASS_BITS 8
26#define OID_FMT_META_BITS 16
27
29#define OID_FMT_TYPE_SHIFT (64 - OID_FMT_TYPE_BITS)
31#define OID_FMT_CLASS_SHIFT (OID_FMT_TYPE_SHIFT - OID_FMT_CLASS_BITS)
33#define OID_FMT_META_SHIFT (OID_FMT_CLASS_SHIFT - OID_FMT_META_BITS)
34
36#define OID_FMT_TYPE_MAX ((1ULL << OID_FMT_TYPE_BITS) - 1)
38#define OID_FMT_CLASS_MAX ((1ULL << OID_FMT_CLASS_BITS) - 1)
40#define OID_FMT_META_MAX ((1ULL << OID_FMT_META_BITS) - 1)
41
43#define OID_FMT_TYPE_MASK (OID_FMT_TYPE_MAX << OID_FMT_TYPE_SHIFT)
45#define OID_FMT_CLASS_MASK (OID_FMT_CLASS_MAX << OID_FMT_CLASS_SHIFT)
47#define OID_FMT_META_MASK (OID_FMT_META_MAX << OID_FMT_META_SHIFT)
48
50enum daos_otype_t {
52 DAOS_OT_MULTI_HASHED = 0,
53
57 DAOS_OT_OIT = 1,
58
60 DAOS_OT_DKEY_UINT64 = 2,
61
63 DAOS_OT_AKEY_UINT64 = 3,
64
66 DAOS_OT_MULTI_UINT64 = 4,
67
69 DAOS_OT_DKEY_LEXICAL = 5,
70
72 DAOS_OT_AKEY_LEXICAL = 6,
73
75 DAOS_OT_MULTI_LEXICAL = 7,
76
78 DAOS_OT_KV_HASHED = 8,
79
81 DAOS_OT_KV_UINT64 = 9,
82
84 DAOS_OT_KV_LEXICAL = 10,
85
87 DAOS_OT_ARRAY = 11,
88
90 DAOS_OT_ARRAY_ATTR = 12,
91
93 DAOS_OT_ARRAY_BYTE = 13,
94
95 DAOS_OT_MAX = 13,
105};
106
107static inline bool
108daos_otype_t_is_valid(enum daos_otype_t type)
109{
110 return type <= DAOS_OT_MAX;
111}
112
113static inline enum daos_otype_t
114daos_obj_id2type(daos_obj_id_t oid)
115{
116 uint64_t type;
117
118 type = (oid.hi & OID_FMT_TYPE_MASK) >> OID_FMT_TYPE_SHIFT;
119
120 return (enum daos_otype_t)type;
121}
122
123static inline bool
124daos_is_dkey_lexical_type(enum daos_otype_t type)
125{
126 switch (type) {
127 case DAOS_OT_DKEY_LEXICAL:
128 case DAOS_OT_MULTI_LEXICAL:
129 case DAOS_OT_KV_LEXICAL:
130 return true;
131 default:
132 return false;
133
134 }
135}
136
137static inline bool
138daos_is_dkey_lexical(daos_obj_id_t oid)
139{
140 return daos_is_dkey_lexical_type(daos_obj_id2type(oid));
141}
142
143static inline bool
144daos_is_akey_lexical_type(enum daos_otype_t type)
145{
146 switch (type) {
147 case DAOS_OT_AKEY_LEXICAL:
148 case DAOS_OT_MULTI_LEXICAL:
149 return true;
150 default:
151 return false;
152
153 }
154}
155
156static inline bool
157daos_is_akey_lexical(daos_obj_id_t oid)
158{
159 return daos_is_akey_lexical_type(daos_obj_id2type(oid));
160}
161
162static inline bool
163daos_is_dkey_uint64_type(enum daos_otype_t type)
164{
165 switch (type) {
166 case DAOS_OT_MULTI_UINT64:
167 case DAOS_OT_DKEY_UINT64:
168 case DAOS_OT_KV_UINT64:
169 case DAOS_OT_ARRAY:
170 case DAOS_OT_ARRAY_ATTR:
171 case DAOS_OT_ARRAY_BYTE:
172 return true;
173 default:
174 return false;
175
176 }
177}
178
179static inline bool
180daos_is_dkey_uint64(daos_obj_id_t oid)
181{
182 return daos_is_dkey_uint64_type(daos_obj_id2type(oid));
183}
184
185static inline bool
186daos_is_akey_uint64_type(enum daos_otype_t type)
187{
188 switch (type) {
189 case DAOS_OT_MULTI_UINT64:
190 case DAOS_OT_AKEY_UINT64:
191 return true;
192 default:
193 return false;
194
195 }
196}
197
198static inline bool
199daos_is_akey_uint64(daos_obj_id_t oid)
200{
201 return daos_is_akey_uint64_type(daos_obj_id2type(oid));
202}
203
204static inline bool
205daos_is_array_type(enum daos_otype_t type)
206{
207 switch (type) {
208 case DAOS_OT_ARRAY:
209 case DAOS_OT_ARRAY_ATTR:
210 case DAOS_OT_ARRAY_BYTE:
211 return true;
212 default:
213 return false;
214
215 }
216}
217
218static inline bool
219daos_is_array(daos_obj_id_t oid)
220{
221 enum daos_otype_t type = daos_obj_id2type(oid);
222
223 return daos_is_array_type(type);
224}
225
226static inline bool
227daos_is_kv_type(enum daos_otype_t type)
228{
229 switch (type) {
230 case DAOS_OT_KV_HASHED:
231 case DAOS_OT_KV_UINT64:
232 case DAOS_OT_KV_LEXICAL:
233 return true;
234 default:
235 return false;
236
237 }
238}
239
240static inline bool
241daos_is_kv(daos_obj_id_t oid)
242{
243 enum daos_otype_t type = daos_obj_id2type(oid);
244
245 return daos_is_kv_type(type);
246}
247
249#define IO_FLAGS_COND_BITS 8
250
251enum {
252 /* Conditional Op: Punch key if it exists, fail otherwise */
253 DAOS_COND_PUNCH = (1 << 0),
254 /* Conditional Op: Insert dkey if it doesn't exist, fail otherwise */
255 DAOS_COND_DKEY_INSERT = (1 << 1),
256 /* Conditional Op: Update dkey if it exists, fail otherwise */
257 DAOS_COND_DKEY_UPDATE = (1 << 2),
258 /* Conditional Op: Fetch dkey if it exists, fail otherwise */
259 DAOS_COND_DKEY_FETCH = (1 << 3),
260 /* Conditional Op: Insert akey if it doesn't exist, fail otherwise */
261 DAOS_COND_AKEY_INSERT = (1 << 4),
262 /* Conditional Op: Update akey if it exists, fail otherwise */
263 DAOS_COND_AKEY_UPDATE = (1 << 5),
264 /* Conditional Op: Fetch akey if it exists, fail otherwise */
265 DAOS_COND_AKEY_FETCH = (1 << 6),
266 /* Indication of per akey conditional ops. If set, the global
267 * flag should not have any akey conditional ops specified. The
268 * per akey flags will be read from the iod_flags field.
269 */
270 DAOS_COND_PER_AKEY = (1 << 7),
272 DAOS_COND_MASK = ((1 << IO_FLAGS_COND_BITS) - 1),
273};
274
281 d_rank_t oa_rank;
284};
285
287enum {
289 DAOS_OO_RO = (1 << 1),
291 DAOS_OO_RW = (1 << 2),
293 DAOS_OO_EXCL = (1 << 3),
295 DAOS_OO_IO_RAND = (1 << 4),
297 DAOS_OO_IO_SEQ = (1 << 5),
298};
299
302 uint32_t ol_nr;
303 uint32_t ol_nr_out;
306};
307
329typedef struct {
331 uint64_t rx_idx;
337 uint64_t rx_nr;
339
341typedef enum {
343 DAOS_IOD_NONE = 0,
345 DAOS_IOD_SINGLE = 1,
347 DAOS_IOD_ARRAY = 2,
348} daos_iod_type_t;
349
355typedef struct {
357 daos_key_t iod_name;
358 /*
359 * Type of the value in an iod can be either a single type that is
360 * always overwritten when updated, or it can be an array of EQUAL sized
361 * records where the record is updated atomically. Note that an akey can
362 * only support one type of value which is set on the first update. If
363 * user attempts to mix types in the same akey, the behavior is
364 * undefined, even after the object, key, or value is punched. If
365 * \a iod_type == DAOS_IOD_SINGLE, then iod_nr has to be 1, and
366 * \a iod_size would be the size of the single atomic value. The idx is
367 * ignored and the rx_nr is also required to be 1.
368 */
369 daos_iod_type_t iod_type;
371 daos_size_t iod_size;
375 uint64_t iod_flags;
376 /*
377 * Number of entries in the \a iod_recxs for arrays,
378 * should be 1 if single value.
379 */
380 uint32_t iod_nr;
381 /*
382 * Array of extents, where each extent defines the index of the first
383 * record in the extent and the number of records to access. If the
384 * type of the iod is single, this is ignored.
385 */
386 daos_recx_t *iod_recxs;
387} daos_iod_t;
388
404#define DAOS_IOMF_DETAIL (0x1U)
409typedef struct {
411 daos_iod_type_t iom_type;
415 uint32_t iom_nr;
422 uint32_t iom_nr_out;
423 uint32_t iom_flags;
425 daos_size_t iom_size;
441} daos_iom_t;
442
444enum {
446 DAOS_REC_ANY = 0,
447};
448
450enum {
452 DAOS_GET_MAX = (1 << 0),
454 DAOS_GET_MIN = (1 << 1),
456 DAOS_GET_DKEY = (1 << 2),
458 DAOS_GET_AKEY = (1 << 3),
460 DAOS_GET_RECX = (1 << 4),
461};
462
467typedef struct {
469 daos_size_t kd_key_len;
474 uint32_t kd_val_type;
476
477static inline daos_oclass_id_t
478daos_obj_id2class(daos_obj_id_t oid)
479{
480 enum daos_obj_redun ord;
481 uint32_t nr_grps;
482
483 ord = (enum daos_obj_redun)((oid.hi & OID_FMT_CLASS_MASK) >> OID_FMT_CLASS_SHIFT);
484 nr_grps = (oid.hi & OID_FMT_META_MASK) >> OID_FMT_META_SHIFT;
485
486 return (ord << OC_REDUN_SHIFT) | nr_grps;
487}
488
489static inline bool
490daos_obj_id_is_nil(daos_obj_id_t oid)
491{
492 return oid.hi == 0 && oid.lo == 0;
493}
494
495#define DAOS_OCH_RDD_BITS 4
496#define DAOS_OCH_SHD_BITS 6
497#define DAOS_OCH_RDD_SHIFT 0
498#define DAOS_OCH_SHD_SHIFT DAOS_OCH_RDD_BITS
499#define DAOS_OCH_RDD_MAX_VAL ((1ULL << DAOS_OCH_RDD_BITS) - 1)
500#define DAOS_OCH_SHD_MAX_VAL ((1ULL << DAOS_OCH_SHD_BITS) - 1)
501#define DAOS_OCH_RDD_MASK (DAOS_OCH_RDD_MAX_VAL << DAOS_OCH_RDD_SHIFT)
502#define DAOS_OCH_SHD_MASK (DAOS_OCH_SHD_MAX_VAL << DAOS_OCH_SHD_SHIFT)
503
505enum {
507 DAOS_OCH_RDD_DEF = (1 << 0),
508 DAOS_OCH_RDD_NO = (1 << 1),
509 DAOS_OCH_RDD_RP = (1 << 2),
510 DAOS_OCH_RDD_EC = (1 << 3),
512 DAOS_OCH_SHD_DEF = (1 << 4),
515 DAOS_OCH_SHD_TINY = (1 << 5),
516 DAOS_OCH_SHD_REG = (1 << 6),
517 DAOS_OCH_SHD_HI = (1 << 7),
518 DAOS_OCH_SHD_EXT = (1 << 8),
519 DAOS_OCH_SHD_MAX = (1 << 9),
520};
521
548int
549daos_obj_generate_oid(daos_handle_t coh, daos_obj_id_t *oid,
550 enum daos_otype_t type, daos_oclass_id_t cid,
551 daos_oclass_hints_t hints, uint32_t args);
552
574int
575daos_obj_open(daos_handle_t coh, daos_obj_id_t oid, unsigned int mode,
576 daos_handle_t *oh, daos_event_t *ev);
577
590int
591daos_obj_close(daos_handle_t oh, daos_event_t *ev);
592
614int
615daos_obj_punch(daos_handle_t oh, daos_handle_t th, uint64_t flags,
616 daos_event_t *ev);
617
641int
642daos_obj_punch_dkeys(daos_handle_t oh, daos_handle_t th, uint64_t flags,
643 unsigned int nr, daos_key_t *dkeys, daos_event_t *ev);
644
669int
670daos_obj_punch_akeys(daos_handle_t oh, daos_handle_t th, uint64_t flags,
671 daos_key_t *dkey, unsigned int nr, daos_key_t *akeys,
672 daos_event_t *ev);
673
691int
692daos_obj_query(daos_handle_t oh, struct daos_obj_attr *oa, d_rank_list_t *ranks,
693 daos_event_t *ev);
694
695/*
696 * Object I/O API
697 */
698
757int
758daos_obj_fetch(daos_handle_t oh, daos_handle_t th, uint64_t flags,
759 daos_key_t *dkey, unsigned int nr, daos_iod_t *iods,
760 d_sg_list_t *sgls, daos_iom_t *ioms, daos_event_t *ev);
761
810int
811daos_obj_update(daos_handle_t oh, daos_handle_t th, uint64_t flags,
812 daos_key_t *dkey, unsigned int nr, daos_iod_t *iods,
813 d_sg_list_t *sgls, daos_event_t *ev);
814
860int
861daos_obj_list_dkey(daos_handle_t oh, daos_handle_t th, uint32_t *nr,
862 daos_key_desc_t *kds, d_sg_list_t *sgl,
863 daos_anchor_t *anchor, daos_event_t *ev);
864
911int
912daos_obj_list_akey(daos_handle_t oh, daos_handle_t th, daos_key_t *dkey,
913 uint32_t *nr, daos_key_desc_t *kds, d_sg_list_t *sgl,
914 daos_anchor_t *anchor, daos_event_t *ev);
915
964int
965daos_obj_list_recx(daos_handle_t oh, daos_handle_t th, daos_key_t *dkey,
966 daos_key_t *akey, daos_size_t *size, uint32_t *nr,
967 daos_recx_t *recxs, daos_epoch_range_t *eprs,
968 daos_anchor_t *anchor, bool incr_order,
969 daos_event_t *ev);
970
1014int
1015daos_obj_query_key(daos_handle_t oh, daos_handle_t th, uint64_t flags,
1016 daos_key_t *dkey, daos_key_t *akey, daos_recx_t *recx,
1017 daos_event_t *ev);
1018
1032int
1033daos_obj_verify(daos_handle_t coh, daos_obj_id_t oid, daos_epoch_t epoch);
1034
1058int
1059daos_obj_anchor_split(daos_handle_t oh, uint32_t *nr, daos_anchor_t *anchors);
1060
1076int
1077daos_obj_anchor_set(daos_handle_t oh, uint32_t index, daos_anchor_t *anchor);
1078
1094int
1095daos_oit_open(daos_handle_t coh, daos_epoch_t epoch,
1096 daos_handle_t *oh, daos_event_t *ev);
1097
1110int
1111daos_oit_close(daos_handle_t oh, daos_event_t *ev);
1112
1132int
1133daos_oit_list(daos_handle_t oh, daos_obj_id_t *oids, uint32_t *oids_nr,
1134 daos_anchor_t *anchor, daos_event_t *ev);
1135
1140typedef uint16_t daos_ofeat_t;
1141int
1142daos_obj_generate_oid1(daos_handle_t coh, daos_obj_id_t *oid,
1143 daos_ofeat_t type, daos_oclass_id_t cid,
1144 daos_oclass_hints_t hints, uint32_t args);
1145int
1146daos_obj_generate_oid2(daos_handle_t coh, daos_obj_id_t *oid,
1147 enum daos_otype_t type, daos_oclass_id_t cid,
1148 daos_oclass_hints_t hints, uint32_t args);
1149
1153#define DAOS_OF_DKEY_UINT64 ((daos_ofeat_t)(1 << 0))
1155#define DAOS_OF_DKEY_LEXICAL ((daos_ofeat_t)(1 << 1))
1159#define DAOS_OF_AKEY_UINT64 ((daos_ofeat_t)(1 << 2))
1161#define DAOS_OF_AKEY_LEXICAL ((daos_ofeat_t)(1 << 3))
1163#define DAOS_OF_KV_FLAT ((daos_ofeat_t)(1 << 4))
1165#define DAOS_OF_ARRAY ((daos_ofeat_t)(1 << 5))
1167#define DAOS_OF_ARRAY_MD ((daos_ofeat_t)(1 << 6))
1169#define DAOS_OF_ARRAY_BYTE ((daos_ofeat_t)(1 << 7))
1176#define DAOS_OF_ECHO ((daos_ofeat_t)(1 << 15))
1178#define DAOS_OF_MASK ((daos_ofeat_t)((1 << 16) - 1))
1179
1180#if defined(__cplusplus)
1181}
1182#define daos_obj_generate_oid daos_obj_generate_oid_cpp
1183static inline int
1184daos_obj_generate_oid_cpp(daos_handle_t coh, daos_obj_id_t *oid,
1185 enum daos_otype_t type, daos_oclass_id_t cid,
1186 daos_oclass_hints_t hints, uint32_t args)
1187{
1188 return daos_obj_generate_oid2(coh, oid, type, cid, hints, args);
1189}
1190static inline int
1191daos_obj_generate_oid_cpp(daos_handle_t coh, daos_obj_id_t *oid,
1192 daos_ofeat_t feat, daos_oclass_id_t cid,
1193 daos_oclass_hints_t hints, uint32_t args)
1194{
1195 return daos_obj_generate_oid1(coh, oid, feat, cid, hints, args);
1196}
1197#else
1202#define daos_obj_generate_oid(coh, oid, type, ...) \
1203 ({ \
1204 int _ret; \
1205 if (__builtin_types_compatible_p(__typeof__(type), \
1206 daos_ofeat_t)) { \
1207 _ret = daos_obj_generate_oid((coh), (oid), \
1208 (type), \
1209 __VA_ARGS__); \
1210 } else { \
1211 _ret = daos_obj_generate_oid2((coh), (oid), \
1212 (type), \
1213 __VA_ARGS__); \
1214 } \
1215 _ret; \
1216 })
1217#endif /* __cplusplus */
1218#endif /* __DAOS_OBJ_H__ */
uint64_t iod_flags
Definition daos_obj.h:375
daos_key_t iod_name
Definition daos_obj.h:357
daos_size_t iod_size
Definition daos_obj.h:371
daos_size_t iom_size
Definition daos_obj.h:425
daos_iod_type_t iom_type
Definition daos_obj.h:411
daos_recx_t iom_recx_hi
Definition daos_obj.h:436
daos_recx_t iom_recx_lo
Definition daos_obj.h:430
daos_recx_t * iom_recxs
Definition daos_obj.h:440
uint32_t iom_nr
Definition daos_obj.h:415
uint32_t iom_nr_out
Definition daos_obj.h:422
uint32_t kd_val_type
Definition daos_obj.h:474
daos_size_t kd_key_len
Definition daos_obj.h:469
struct daos_oclass_attr * oa_oa
Definition daos_obj.h:283
d_rank_t oa_rank
Definition daos_obj.h:281
uint32_t ol_nr
Definition daos_obj.h:302
daos_obj_id_t * ol_oids
Definition daos_obj.h:305
uint64_t rx_nr
Definition daos_obj.h:337
uint64_t rx_idx
Definition daos_obj.h:331