Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
daos.h
Go to the documentation of this file.
1/*
2 * (C) Copyright 2016-2018 Intel Corporation.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16/**
17 * \file
18 *
19 * This file is a reduced version of `daos_xxx.h` headers that provides (simplified) declarations for use in libdaos_mock.
20 */
21
22#ifndef __DAOS_H__
23#define __DAOS_H__
24extern "C" {
25
26
27//////////////////////////////////////////////////////////////////////////////// daos_types.h
28
29
30#include <stdint.h>
31#include <stdio.h>
32#include <string.h>
33#include <stdbool.h>
34#include <uuid/uuid.h>
35
36/** iovec for memory buffer */
37typedef struct {
38 void *iov_buf;
40 size_t iov_len;
41} d_iov_t;
42
43typedef struct {
44 char unused; // silence [-Wextern-c-compat]
46
47/** Scatter/gather list for memory buffers */
48typedef struct {
49 uint32_t sg_nr;
50 uint32_t sg_nr_out;
53
54static inline void d_iov_set(d_iov_t *iov, void *buf, size_t size)
55{
56 iov->iov_buf = buf;
57 iov->iov_len = iov->iov_buf_len = size;
58}
59
60typedef uint64_t daos_size_t;
61
62/** Generic handle for various DAOS components like container, object, etc. */
63typedef struct {
64 uint64_t cookie;
66
67#define DAOS_HDL_INVAL ((daos_handle_t){0})
68#define DAOS_TX_NONE DAOS_HDL_INVAL
69
70#define DAOS_PC_RO (1U << 0)
71#define DAOS_PC_RW (1U << 1)
72#define DAOS_PC_EX (1U << 2)
73
75
76/** Event and event queue */
77typedef struct daos_event {
79 struct {
80 uint64_t space[19];
82 uint64_t ev_debug;
84
85/** Wait for completion event forever */
86#define DAOS_EQ_WAIT -1
87/** Always return immediately */
88#define DAOS_EQ_NOWAIT 0
89
90
91//////////////////////////////////////////////////////////////////////////////// daos_event.h
92
93
95int daos_eq_destroy(daos_handle_t eqh, int flags);
96int daos_eq_poll(daos_handle_t eqh, int wait_running,
97 int64_t timeout, unsigned int nevents, daos_event_t **events);
100
101
102//////////////////////////////////////////////////////////////////////////////// daos_obj_class.h
103
104
105/** Predefined object classes */
106enum {
108
109 /** Replicated object class which is extremely scalable for fetch. */
111
112 /** Object classes with explicit layout */
113 OC_S1 = 200,
128
129 /** Class ID equal or higher than this is reserved */
130 OC_RESERVED = (1U << 10),
131};
132
133typedef uint16_t daos_oclass_id_t;
134typedef uint16_t daos_ofeat_t;
135
136int daos_oclass_name2id(const char *name);
138
139
140//////////////////////////////////////////////////////////////////////////////// daos_obj.h
141
142
143typedef struct {
144 uint64_t lo;
145 uint64_t hi;
147
148#define OID_FMT_VER 1
149
150#define OID_FMT_INTR_BITS 32
151#define OID_FMT_VER_BITS 4
152#define OID_FMT_FEAT_BITS 16
153#define OID_FMT_CLASS_BITS (OID_FMT_INTR_BITS - OID_FMT_VER_BITS - \
154 OID_FMT_FEAT_BITS)
155
156#define OID_FMT_VER_SHIFT (64 - OID_FMT_VER_BITS)
157#define OID_FMT_FEAT_SHIFT (OID_FMT_VER_SHIFT - OID_FMT_FEAT_BITS)
158#define OID_FMT_CLASS_SHIFT (OID_FMT_FEAT_SHIFT - OID_FMT_CLASS_BITS)
159
160enum {
164};
165
166enum {
169};
170
171/** Object open modes */
172enum {
173 DAOS_OO_RO = (1 << 1),
174 DAOS_OO_RW = (1 << 2),
175};
176
177typedef struct {
178 uint64_t rx_idx;
179 uint64_t rx_nr;
181
182/** Type of the value accessed in an IOD */
183typedef enum {
186
187typedef struct {
191 unsigned int iod_nr;
193} daos_iod_t;
194
195typedef struct {
196 char unused; // silence [-Wextern-c-compat]
197} daos_iom_t;
198
199enum {
200 /** Any record size, it is used by fetch */
202};
203
204static inline int daos_obj_generate_id(daos_obj_id_t *oid, daos_ofeat_t ofeats,
205 daos_oclass_id_t cid, uint32_t args)
206{
207 (void)args;
208 uint64_t hdr;
209
210 /* TODO: add check at here, it should return error if user specified
211 * bits reserved by DAOS
212 */
213 oid->hi &= (1ULL << OID_FMT_INTR_BITS) - 1;
214 /**
215 * | Upper bits contain
216 * | OID_FMT_VER_BITS (version) |
217 * | OID_FMT_FEAT_BITS (object features) |
218 * | OID_FMT_CLASS_BITS (object class) |
219 * | 96-bit for upper layer ... |
220 */
221 hdr = ((uint64_t)OID_FMT_VER << OID_FMT_VER_SHIFT);
222 hdr |= ((uint64_t)ofeats << OID_FMT_FEAT_SHIFT);
223 hdr |= ((uint64_t)cid << OID_FMT_CLASS_SHIFT);
224 oid->hi |= hdr;
225
226 return 0;
227}
228
229int daos_obj_open(daos_handle_t coh, daos_obj_id_t oid, unsigned int mode,
230 daos_handle_t *oh, daos_event_t *ev);
232int daos_obj_fetch(daos_handle_t oh, daos_handle_t th, uint64_t flags,
233 daos_key_t *dkey, unsigned int nr, daos_iod_t *iods,
234 d_sg_list_t *sgls, daos_iom_t *ioms, daos_event_t *ev);
235int daos_obj_update(daos_handle_t oh, daos_handle_t th, uint64_t flags,
236 daos_key_t *dkey, unsigned int nr, daos_iod_t *iods,
237 d_sg_list_t *sgls, daos_event_t *ev);
238
239
240//////////////////////////////////////////////////////////////////////////////// daos_prop.h
241
242
243/** daos properties, for pool or container */
244typedef struct {
245 char unused; // silence [-Wextern-c-compat]
247
248
249//////////////////////////////////////////////////////////////////////////////// daos_cont.h
250
251
252#define DAOS_COO_RO (1U << 0)
253#define DAOS_COO_RW (1U << 1)
254
255/** Container information */
256typedef struct {
257 char unused; // silence [-Wextern-c-compat]
259
260d_rank_list_t *daos_rank_list_parse(const char *str, const char *sep);
261
262int daos_cont_create(daos_handle_t poh, const uuid_t uuid, daos_prop_t *cont_prop,
263 daos_event_t *ev);
264int daos_cont_open(daos_handle_t poh, const uuid_t uuid, unsigned int flags,
267
268
269//////////////////////////////////////////////////////////////////////////////// daos_pool.h
270
271
272/** Storage pool */
273typedef struct {
274 char unused; // silence [-Wextern-c-compat]
276
277int daos_pool_connect(const uuid_t uuid, const char *grp,
278 const d_rank_list_t *svc, unsigned int flags,
281
282
283//////////////////////////////////////////////////////////////////////////////// daos_errno.h
284
285
286#define DER_ERR_GURT_BASE 1000
287#define DER_INVAL (DER_ERR_GURT_BASE + 3)
288const char *d_errstr(int rc);
289
290
291//////////////////////////////////////////////////////////////////////////////// daos.h
292
293
294int daos_init(void);
295int daos_fini(void);
296
297}
298#endif /* __DAOS_H__ */
typedef void(GLAPIENTRYP _GLUfuncptr)(void)
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
char name[80]
Definition TGX11.cxx:110
int daos_oclass_id2name(daos_oclass_id_t oc_id, char *name)
const char * d_errstr(int rc)
int daos_pool_disconnect(daos_handle_t poh, daos_event_t *ev)
d_iov_t daos_key_t
Definition daos.h:74
uint16_t daos_ofeat_t
Definition daos.h:134
int daos_oclass_name2id(const char *name)
int daos_obj_fetch(daos_handle_t oh, daos_handle_t th, uint64_t flags, daos_key_t *dkey, unsigned int nr, daos_iod_t *iods, d_sg_list_t *sgls, daos_iom_t *ioms, daos_event_t *ev)
static void d_iov_set(d_iov_t *iov, void *buf, size_t size)
Definition daos.h:54
@ DAOS_COND_DKEY_FETCH
Definition daos.h:167
@ DAOS_COND_AKEY_FETCH
Definition daos.h:168
int daos_obj_open(daos_handle_t coh, daos_obj_id_t oid, unsigned int mode, daos_handle_t *oh, daos_event_t *ev)
int daos_cont_create(daos_handle_t poh, const uuid_t uuid, daos_prop_t *cont_prop, daos_event_t *ev)
int daos_event_fini(daos_event_t *ev)
@ DAOS_OO_RW
Definition daos.h:174
@ DAOS_OO_RO
Definition daos.h:173
int daos_init(void)
int daos_obj_update(daos_handle_t oh, daos_handle_t th, uint64_t flags, daos_key_t *dkey, unsigned int nr, daos_iod_t *iods, d_sg_list_t *sgls, daos_event_t *ev)
int daos_cont_close(daos_handle_t coh, daos_event_t *ev)
uint16_t daos_oclass_id_t
Definition daos.h:133
#define OID_FMT_INTR_BITS
Definition daos.h:150
int daos_event_init(daos_event_t *ev, daos_handle_t eqh, daos_event_t *parent)
static int daos_obj_generate_id(daos_obj_id_t *oid, daos_ofeat_t ofeats, daos_oclass_id_t cid, uint32_t args)
Definition daos.h:204
struct daos_event daos_event_t
Event and event queue.
@ DAOS_OF_AKEY_UINT64
Definition daos.h:162
@ DAOS_OF_DKEY_UINT64
Definition daos.h:161
@ DAOS_OF_ARRAY_BYTE
Definition daos.h:163
int daos_eq_create(daos_handle_t *eqh)
int daos_cont_open(daos_handle_t poh, const uuid_t uuid, unsigned int flags, daos_handle_t *coh, daos_cont_info_t *info, daos_event_t *ev)
int daos_pool_connect(const uuid_t uuid, const char *grp, const d_rank_list_t *svc, unsigned int flags, daos_handle_t *poh, daos_pool_info_t *info, daos_event_t *ev)
d_rank_list_t * daos_rank_list_parse(const char *str, const char *sep)
@ DAOS_REC_ANY
Any record size, it is used by fetch.
Definition daos.h:201
int daos_obj_close(daos_handle_t oh, daos_event_t *ev)
daos_iod_type_t
Type of the value accessed in an IOD.
Definition daos.h:183
@ DAOS_IOD_SINGLE
Definition daos.h:184
#define OID_FMT_VER_SHIFT
Definition daos.h:156
int daos_eq_destroy(daos_handle_t eqh, int flags)
int daos_eq_poll(daos_handle_t eqh, int wait_running, int64_t timeout, unsigned int nevents, daos_event_t **events)
#define OID_FMT_CLASS_SHIFT
Definition daos.h:158
int daos_fini(void)
#define OID_FMT_FEAT_SHIFT
Definition daos.h:157
uint64_t daos_size_t
Definition daos.h:60
#define OID_FMT_VER
Definition daos.h:148
@ OC_S32
Definition daos.h:118
@ OC_S4
Definition daos.h:115
@ OC_S4K
Definition daos.h:125
@ OC_S128
Definition daos.h:120
@ OC_S512
Definition daos.h:122
@ OC_RESERVED
Class ID equal or higher than this is reserved.
Definition daos.h:130
@ OC_S256
Definition daos.h:121
@ OC_S2
Definition daos.h:114
@ OC_S2K
Definition daos.h:124
@ OC_SX
Definition daos.h:127
@ OC_S8
Definition daos.h:116
@ OC_UNKNOWN
Definition daos.h:107
@ OC_S16
Definition daos.h:117
@ OC_S1K
Definition daos.h:123
@ OC_S8K
Definition daos.h:126
@ OC_S1
Object classes with explicit layout.
Definition daos.h:113
@ OC_S64
Definition daos.h:119
@ OC_RP_XSF
Replicated object class which is extremely scalable for fetch.
Definition daos.h:110
iovec for memory buffer
Definition daos.h:37
size_t iov_buf_len
Definition daos.h:39
void * iov_buf
Definition daos.h:38
size_t iov_len
Definition daos.h:40
char unused
Definition daos.h:44
Scatter/gather list for memory buffers.
Definition daos.h:48
uint32_t sg_nr_out
Definition daos.h:50
d_iov_t * sg_iovs
Definition daos.h:51
uint32_t sg_nr
Definition daos.h:49
Container information.
Definition daos.h:256
Event and event queue.
Definition daos.h:77
int ev_error
Definition daos.h:78
uint64_t space[19]
Definition daos.h:80
struct daos_event::@190 ev_private
uint64_t ev_debug
Definition daos.h:82
Generic handle for various DAOS components like container, object, etc.
Definition daos.h:63
uint64_t cookie
Definition daos.h:64
daos_iod_type_t iod_type
Definition daos.h:189
unsigned int iod_nr
Definition daos.h:191
daos_key_t iod_name
Definition daos.h:188
daos_size_t iod_size
Definition daos.h:190
daos_recx_t * iod_recxs
Definition daos.h:192
char unused
Definition daos.h:196
uint64_t hi
Definition daos.h:145
uint64_t lo
Definition daos.h:144
Storage pool.
Definition daos.h:273
daos properties, for pool or container
Definition daos.h:244
char unused
Definition daos.h:245
uint64_t rx_nr
Definition daos.h:179
uint64_t rx_idx
Definition daos.h:178