Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:10:31

0001 /*
0002  * (C) Copyright 2016-2018 Intel Corporation.
0003  *
0004  * Licensed under the Apache License, Version 2.0 (the "License");
0005  * you may not use this file except in compliance with the License.
0006  * You may obtain a copy of the License at
0007  *
0008  *    http://www.apache.org/licenses/LICENSE-2.0
0009  *
0010  * Unless required by applicable law or agreed to in writing, software
0011  * distributed under the License is distributed on an "AS IS" BASIS,
0012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0013  * See the License for the specific language governing permissions and
0014  * limitations under the License.
0015  */
0016 /**
0017  * \file
0018  *
0019  * This file is a reduced version of `daos_xxx.h` headers that provides (simplified) declarations for use in
0020  * libdaos_mock.
0021  */
0022 
0023 #ifndef __DAOS_H__
0024 #define __DAOS_H__
0025 extern "C" {
0026 
0027 //////////////////////////////////////////////////////////////////////////////// daos_types.h
0028 
0029 #include <stdint.h>
0030 #include <stdio.h>
0031 #include <string.h>
0032 #include <stdbool.h>
0033 #include <uuid/uuid.h>
0034 #include <ctype.h>
0035 
0036 /** iovec for memory buffer */
0037 typedef struct {
0038     void        *iov_buf;
0039     size_t      iov_buf_len;
0040     size_t      iov_len;
0041 } d_iov_t;
0042 
0043 /** Scatter/gather list for memory buffers */
0044 typedef struct {
0045     uint32_t    sg_nr;
0046     uint32_t    sg_nr_out;
0047     d_iov_t     *sg_iovs;
0048 } d_sg_list_t;
0049 
0050 static inline void d_iov_set(d_iov_t *iov, void *buf, size_t size)
0051 {
0052     iov->iov_buf = buf;
0053     iov->iov_len = iov->iov_buf_len = size;
0054 }
0055 
0056 typedef uint64_t    daos_size_t;
0057 
0058 /** Generic handle for various DAOS components like container, object, etc. */
0059 typedef struct {
0060     uint64_t    cookie;
0061 } daos_handle_t;
0062 
0063 typedef enum {
0064    DAOS_EQR_COMPLETED = (1),
0065    DAOS_EQR_WAITING = (1 << 1),
0066    DAOS_EQR_ALL = (DAOS_EQR_COMPLETED | DAOS_EQR_WAITING),
0067 } daos_eq_query_t;
0068 
0069 #define DAOS_HDL_INVAL  ((daos_handle_t){0})
0070 #define DAOS_TX_NONE    DAOS_HDL_INVAL
0071 
0072 #define DAOS_PC_RO  (1U << 0)
0073 #define DAOS_PC_RW  (1U << 1)
0074 #define DAOS_PC_EX  (1U << 2)
0075 
0076 typedef d_iov_t daos_key_t;
0077 
0078 /** Event and event queue */
0079 typedef struct daos_event {
0080     int         ev_error;
0081     struct {
0082         uint64_t    space[19];
0083     }           ev_private;
0084     uint64_t        ev_debug;
0085 } daos_event_t;
0086 
0087 /** Wait for completion event forever */
0088 #define DAOS_EQ_WAIT            -1
0089 /** Always return immediately */
0090 #define DAOS_EQ_NOWAIT          0
0091 
0092 
0093 //////////////////////////////////////////////////////////////////////////////// daos_event.h
0094 
0095 int daos_eq_create(daos_handle_t *eqh);
0096 int daos_eq_destroy(daos_handle_t eqh, int flags);
0097 int daos_eq_poll(daos_handle_t eqh, int wait_running, int64_t timeout, unsigned int nevents, daos_event_t **events);
0098 
0099 int daos_event_test(daos_event_t *ev, int64_t timeout, bool *flag);
0100 int daos_event_parent_barrier(daos_event_t *ev);
0101 int daos_event_init(daos_event_t *ev, daos_handle_t eqh, daos_event_t *parent);
0102 int daos_event_fini(daos_event_t *ev);
0103 
0104 //////////////////////////////////////////////////////////////////////////////// daos_obj_class.h
0105 
0106 
0107 /** Predefined object classes */
0108 enum {
0109     OC_UNKNOWN  = 0,
0110 
0111     /** Replicated object class which is extremely scalable for fetch. */
0112     OC_RP_XSF   = 80,
0113 
0114     /** Object classes with explicit layout */
0115     OC_S1       = 200,
0116     OC_S2,
0117     OC_S4,
0118     OC_S8,
0119     OC_S16,
0120     OC_S32,
0121     OC_S64,
0122     OC_S128,
0123     OC_S256,
0124     OC_S512,
0125     OC_S1K,
0126     OC_S2K,
0127     OC_S4K,
0128     OC_S8K,
0129     OC_SX,
0130 
0131     /** Class ID equal or higher than this is reserved */
0132     OC_RESERVED     = (1U << 10),
0133 };
0134 
0135 typedef uint16_t daos_oclass_id_t;
0136 typedef uint16_t daos_oclass_hints_t;
0137 
0138 int daos_oclass_name2id(const char *name);
0139 int daos_oclass_id2name(daos_oclass_id_t oc_id, char *name);
0140 
0141 
0142 //////////////////////////////////////////////////////////////////////////////// daos_obj.h
0143 
0144 
0145 typedef struct {
0146     uint64_t    lo;
0147     uint64_t    hi;
0148 } daos_obj_id_t;
0149 
0150 #define DAOS_OBJ_NIL ((daos_obj_id_t){0})
0151 
0152 #define OID_FMT_INTR_BITS 32 // 32 bits for DAOS internal use
0153 #define OID_FMT_TYPE_BITS 8
0154 #define OID_FMT_CLASS_BITS 8
0155 #define OID_FMT_META_BITS 16
0156 
0157 #define OID_FMT_TYPE_SHIFT (64 - OID_FMT_TYPE_BITS)
0158 #define OID_FMT_CLASS_SHIFT (OID_FMT_TYPE_SHIFT - OID_FMT_CLASS_BITS)
0159 #define OID_FMT_META_SHIFT (OID_FMT_CLASS_SHIFT - OID_FMT_META_BITS)
0160 
0161 /// DAOS object type
0162 enum daos_otype_t {
0163    DAOS_OT_MULTI_HASHED = 0, // default: multi-level KV with hashed [ad]keys
0164    DAOS_OT_DKEY_UINT64 = 2,
0165    DAOS_OT_AKEY_UINT64 = 3,
0166    DAOS_OT_MULTI_UINT64 = 4,
0167    DAOS_OT_ARRAY = 11,
0168    DAOS_OT_ARRAY_BYTE = 13,
0169    DAOS_OT_MAX = 13,
0170 };
0171 
0172 static inline bool daos_otype_t_is_valid(enum daos_otype_t type)
0173 {
0174    return type <= DAOS_OT_MAX;
0175 }
0176 
0177 enum {
0178    DAOS_COND_DKEY_FETCH = (1 << 3),
0179    DAOS_COND_AKEY_FETCH = (1 << 6),
0180 };
0181 
0182 /** Object open modes */
0183 enum {
0184    DAOS_OO_RO = (1 << 1),
0185    DAOS_OO_RW = (1 << 2),
0186 };
0187 
0188 typedef struct {
0189     uint64_t    rx_idx;
0190     uint64_t    rx_nr;
0191 } daos_recx_t;
0192 
0193 /** Type of the value accessed in an IOD */
0194 typedef enum {
0195     DAOS_IOD_SINGLE     = 1,
0196 } daos_iod_type_t;
0197 
0198 typedef struct {
0199    daos_key_t iod_name;
0200    daos_iod_type_t iod_type;
0201    daos_size_t iod_size;
0202    uint64_t iod_flags;
0203    unsigned int iod_nr;
0204    daos_recx_t *iod_recxs;
0205 } daos_iod_t;
0206 
0207 typedef struct {
0208     char        unused; // silence [-Wextern-c-compat]
0209 } daos_iom_t;
0210 
0211 enum {
0212     /** Any record size, it is used by fetch */
0213     DAOS_REC_ANY        = 0,
0214 };
0215 
0216 /// Flags for oclass hints
0217 enum {
0218    // OC Redundancy flags
0219    DAOS_OCH_RDD_DEF = (1 << 0), // Default: RF prop
0220    // OC Sharding flags
0221    DAOS_OCH_SHD_DEF = (1 << 4), // Default: MAX for array & flat KV, else 1
0222 };
0223 
0224 int daos_obj_generate_oid(daos_handle_t coh, daos_obj_id_t *oid, enum daos_otype_t type, daos_oclass_id_t cid,
0225                           daos_oclass_hints_t hints, uint32_t args);
0226 int daos_obj_open(daos_handle_t coh, daos_obj_id_t oid, unsigned int mode, daos_handle_t *oh, daos_event_t *ev);
0227 int daos_obj_close(daos_handle_t oh, daos_event_t *ev);
0228 int daos_obj_fetch(daos_handle_t oh, daos_handle_t th, uint64_t flags,
0229            daos_key_t *dkey, unsigned int nr, daos_iod_t *iods,
0230            d_sg_list_t *sgls, daos_iom_t *ioms, daos_event_t *ev);
0231 int daos_obj_update(daos_handle_t oh, daos_handle_t th, uint64_t flags,
0232         daos_key_t *dkey, unsigned int nr, daos_iod_t *iods,
0233         d_sg_list_t *sgls, daos_event_t *ev);
0234 
0235 
0236 //////////////////////////////////////////////////////////////////////////////// daos_prop.h
0237 
0238 /** daos properties, for pool or container */
0239 typedef struct {
0240     char        unused; // silence [-Wextern-c-compat]
0241 } daos_prop_t;
0242 
0243 #define DAOS_PROP_LABEL_MAX_LEN (127)
0244 #define DAOS_PROP_MAX_LABEL_BUF_LEN (DAOS_PROP_LABEL_MAX_LEN + 1)
0245 #define DAOS_UUID_STR_SIZE (37) // 36 + 1 for '\0'
0246 
0247 static inline bool daos_label_is_valid(const char * /*label*/)
0248 {
0249    return true;
0250 }
0251 
0252 //////////////////////////////////////////////////////////////////////////////// daos_cont.h
0253 
0254 
0255 #define DAOS_COO_RO (1U << 0)
0256 #define DAOS_COO_RW (1U << 1)
0257 
0258 /** Container information */
0259 typedef struct {
0260    uuid_t ci_uuid;
0261 } daos_cont_info_t;
0262 
0263 int daos_cont_create_with_label(daos_handle_t poh, const char *label, daos_prop_t *cont_prop, uuid_t *uuid,
0264                                 daos_event_t *ev);
0265 int daos_cont_open(daos_handle_t poh, const char *uuid, unsigned int flags, daos_handle_t *coh, daos_cont_info_t *info,
0266                    daos_event_t *ev);
0267 int daos_cont_close(daos_handle_t coh, daos_event_t *ev);
0268 
0269 //////////////////////////////////////////////////////////////////////////////// daos_pool.h
0270 
0271 
0272 /** Storage pool */
0273 typedef struct {
0274    uuid_t pi_uuid;
0275 } daos_pool_info_t;
0276 
0277 int daos_pool_connect(const char *pool, const char *grp, unsigned int flags, daos_handle_t *poh, daos_pool_info_t *info,
0278                       daos_event_t *ev);
0279 int daos_pool_disconnect(daos_handle_t poh, daos_event_t *ev);
0280 
0281 //////////////////////////////////////////////////////////////////////////////// daos_errno.h
0282 
0283 #define DER_ERR_GURT_BASE 1000
0284 #define DER_INVAL (DER_ERR_GURT_BASE + 3)
0285 #define DER_EXIST (DER_ERR_GURT_BASE + 4)
0286 
0287 const char *d_errstr(int rc);
0288 
0289 
0290 //////////////////////////////////////////////////////////////////////////////// daos.h
0291 
0292 
0293 int daos_init(void);
0294 int daos_fini(void);
0295 }
0296 #endif /* __DAOS_H__ */