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
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
297 d_rank_t oa_rank;
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
337typedef struct {
339 uint64_t rx_idx;
345 uint64_t rx_nr;
347
349typedef enum {
351 DAOS_IOD_NONE = 0,
353 DAOS_IOD_SINGLE = 1,
355 DAOS_IOD_ARRAY = 2,
356} daos_iod_type_t;
357
363typedef 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;
395} daos_iod_t;
396
412#define DAOS_IOMF_DETAIL (0x1U)
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
476typedef struct {
478 daos_size_t kd_key_len;
480 uint32_t kd_val_type;
482
483static enum daos_obj_redun
484daos_obj_id2ord(daos_obj_id_t oid)
485{
486 return (enum daos_obj_redun)((oid.hi & OID_FMT_CLASS_MASK) >> OID_FMT_CLASS_SHIFT);
487}
488
489static inline daos_oclass_id_t
490daos_obj_id2class(daos_obj_id_t oid)
491{
492 enum daos_obj_redun ord;
493 uint32_t nr_grps;
494
495 ord = daos_obj_id2ord(oid);
496 nr_grps = (oid.hi & OID_FMT_META_MASK) >> OID_FMT_META_SHIFT;
497
498 return (ord << OC_REDUN_SHIFT) | nr_grps;
499}
500
501static inline uint32_t
502daos_obj_id2grp_nr(daos_obj_id_t oid)
503{
504 return (oid.hi & OID_FMT_META_MASK) >> OID_FMT_META_SHIFT;
505}
506
507static inline bool
508daos_obj_id_is_nil(daos_obj_id_t oid)
509{
510 return oid.hi == 0 && oid.lo == 0;
511}
512
513#define DAOS_OCH_RDD_BITS 4
514#define DAOS_OCH_SHD_BITS 6
515#define DAOS_OCH_RDD_SHIFT 0
516#define DAOS_OCH_SHD_SHIFT DAOS_OCH_RDD_BITS
517#define DAOS_OCH_RDD_MAX_VAL ((1ULL << DAOS_OCH_RDD_BITS) - 1)
518#define DAOS_OCH_SHD_MAX_VAL ((1ULL << DAOS_OCH_SHD_BITS) - 1)
519#define DAOS_OCH_RDD_MASK (DAOS_OCH_RDD_MAX_VAL << DAOS_OCH_RDD_SHIFT)
520#define DAOS_OCH_SHD_MASK (DAOS_OCH_SHD_MAX_VAL << DAOS_OCH_SHD_SHIFT)
521
523enum {
525 DAOS_OCH_RDD_DEF = (1 << 0),
526 DAOS_OCH_RDD_NO = (1 << 1),
527 DAOS_OCH_RDD_RP = (1 << 2),
528 DAOS_OCH_RDD_EC = (1 << 3),
530 DAOS_OCH_SHD_DEF = (1 << 4),
533 DAOS_OCH_SHD_TINY = (1 << 5),
534 DAOS_OCH_SHD_REG = (1 << 6),
535 DAOS_OCH_SHD_HI = (1 << 7),
536 DAOS_OCH_SHD_EXT = (1 << 8),
537 DAOS_OCH_SHD_MAX = (1 << 9),
538};
539
566int
567daos_obj_generate_oid(daos_handle_t coh, daos_obj_id_t *oid,
568 enum daos_otype_t type, daos_oclass_id_t cid,
569 daos_oclass_hints_t hints, uint32_t args);
570
578static inline void
579daos_obj_oid_cycle(daos_obj_id_t *oid)
580{
582 oid->hi = (oid->hi + 999999937) & UINT_MAX;
583}
584
606int
607daos_obj_open(daos_handle_t coh, daos_obj_id_t oid, unsigned int mode,
608 daos_handle_t *oh, daos_event_t *ev);
609
622int
623daos_obj_close(daos_handle_t oh, daos_event_t *ev);
624
646int
647daos_obj_punch(daos_handle_t oh, daos_handle_t th, uint64_t flags,
648 daos_event_t *ev);
649
673int
674daos_obj_punch_dkeys(daos_handle_t oh, daos_handle_t th, uint64_t flags,
675 unsigned int nr, daos_key_t *dkeys, daos_event_t *ev);
676
701int
702daos_obj_punch_akeys(daos_handle_t oh, daos_handle_t th, uint64_t flags,
703 daos_key_t *dkey, unsigned int nr, daos_key_t *akeys,
704 daos_event_t *ev);
705
723int
724daos_obj_query(daos_handle_t oh, struct daos_obj_attr *oa, d_rank_list_t *ranks,
725 daos_event_t *ev);
726
727/*
728 * Object I/O API
729 */
730
789int
790daos_obj_fetch(daos_handle_t oh, daos_handle_t th, uint64_t flags,
791 daos_key_t *dkey, unsigned int nr, daos_iod_t *iods,
792 d_sg_list_t *sgls, daos_iom_t *ioms, daos_event_t *ev);
793
842int
843daos_obj_update(daos_handle_t oh, daos_handle_t th, uint64_t flags,
844 daos_key_t *dkey, unsigned int nr, daos_iod_t *iods,
845 d_sg_list_t *sgls, daos_event_t *ev);
846
892int
893daos_obj_list_dkey(daos_handle_t oh, daos_handle_t th, uint32_t *nr,
894 daos_key_desc_t *kds, d_sg_list_t *sgl,
895 daos_anchor_t *anchor, daos_event_t *ev);
896
943int
944daos_obj_list_akey(daos_handle_t oh, daos_handle_t th, daos_key_t *dkey,
945 uint32_t *nr, daos_key_desc_t *kds, d_sg_list_t *sgl,
946 daos_anchor_t *anchor, daos_event_t *ev);
947
996int
997daos_obj_list_recx(daos_handle_t oh, daos_handle_t th, daos_key_t *dkey,
998 daos_key_t *akey, daos_size_t *size, uint32_t *nr,
999 daos_recx_t *recxs, daos_epoch_range_t *eprs,
1000 daos_anchor_t *anchor, bool incr_order,
1001 daos_event_t *ev);
1002
1046int
1047daos_obj_query_key(daos_handle_t oh, daos_handle_t th, uint64_t flags,
1048 daos_key_t *dkey, daos_key_t *akey, daos_recx_t *recx,
1049 daos_event_t *ev);
1050
1068int
1069daos_obj_query_max_epoch(daos_handle_t oh, daos_handle_t th, daos_epoch_t *epoch, daos_event_t *ev);
1070
1084int
1085daos_obj_verify(daos_handle_t coh, daos_obj_id_t oid, daos_epoch_t epoch);
1086
1110int
1111daos_obj_anchor_split(daos_handle_t oh, uint32_t *nr, daos_anchor_t *anchors);
1112
1128int
1129daos_obj_anchor_set(daos_handle_t oh, uint32_t index, daos_anchor_t *anchor);
1130
1146int
1147daos_obj_key2anchor(daos_handle_t oh, daos_handle_t th, daos_key_t *dkey, daos_key_t *akey,
1148 daos_anchor_t *anchor, daos_event_t *ev);
1149
1165int
1166daos_oit_open(daos_handle_t coh, daos_epoch_t epoch,
1167 daos_handle_t *oh, daos_event_t *ev);
1168
1181int
1182daos_oit_close(daos_handle_t oh, daos_event_t *ev);
1183
1203int
1204daos_oit_list(daos_handle_t oh, daos_obj_id_t *oids, uint32_t *oids_nr,
1205 daos_anchor_t *anchor, daos_event_t *ev);
1206
1207#define DAOS_OIT_MARKER_MAX_LEN (32)
1208
1229int
1230daos_oit_mark(daos_handle_t oh, daos_obj_id_t oid, d_iov_t *marker, daos_event_t *ev);
1231
1251int
1252daos_oit_list_unmarked(daos_handle_t oh, daos_obj_id_t *oids, uint32_t *oids_nr,
1253 daos_anchor_t *anchor, daos_event_t *ev);
1254
1268typedef int
1269(daos_oit_filter_cb)(daos_obj_id_t oid, d_iov_t *marker);
1270
1291int
1292daos_oit_list_filter(daos_handle_t oh, daos_obj_id_t *oids, uint32_t *oids_nr,
1293 daos_anchor_t *anchor, daos_oit_filter_cb filter, daos_event_t *ev);
1294
1295#if defined(__cplusplus)
1296}
1297#endif /* __cplusplus */
1298#endif /* __DAOS_OBJ_H__ */
uint64_t iod_flags
Definition daos_obj.h:383
daos_key_t iod_name
Definition daos_obj.h:365
uint32_t iod_nr
Definition daos_obj.h:388
daos_recx_t * iod_recxs
Definition daos_obj.h:394
daos_size_t iod_size
Definition daos_obj.h:379
daos_iod_type_t iod_type
Definition daos_obj.h:377
uint32_t iom_flags
Definition daos_obj.h:432
daos_size_t iom_size
Definition daos_obj.h:434
daos_iod_type_t iom_type
Definition daos_obj.h:419
daos_recx_t iom_recx_hi
Definition daos_obj.h:445
daos_recx_t iom_recx_lo
Definition daos_obj.h:439
daos_recx_t * iom_recxs
Definition daos_obj.h:449
uint32_t iom_nr
Definition daos_obj.h:423
uint32_t iom_nr_out
Definition daos_obj.h:430
uint32_t kd_val_type
Definition daos_obj.h:480
daos_size_t kd_key_len
Definition daos_obj.h:478
struct daos_oclass_attr * oa_oa
Definition daos_obj.h:299
d_rank_t oa_rank
Definition daos_obj.h:297
uint64_t hi
Definition daos_types.h:234
uint64_t lo
Definition daos_types.h:232
uint64_t rx_nr
Definition daos_obj.h:345
uint64_t rx_idx
Definition daos_obj.h:339