diff --git a/src/aiori-DAOS.c b/src/aiori-DAOS.c index 7f07f7c..c453b2e 100644 --- a/src/aiori-DAOS.c +++ b/src/aiori-DAOS.c @@ -24,15 +24,16 @@ #include #include +#include #include #include -#include "ior.h" #include "aiori.h" +#include "utilities.h" #include "iordef.h" /************************** O P T I O N S *****************************/ -struct daos_options{ +typedef struct { char *pool; char *svcl; char *group; @@ -40,49 +41,62 @@ struct daos_options{ int chunk_size; int destroy; char *oclass; -}; +} DAOS_options_t; -static struct daos_options o = { - .pool = NULL, - .svcl = NULL, - .group = NULL, - .cont = NULL, - .chunk_size = 1048576, - .destroy = 0, - .oclass = NULL, -}; +static option_help * DAOS_options(aiori_mod_opt_t ** init_backend_options, + aiori_mod_opt_t * init_values){ + DAOS_options_t * o = malloc(sizeof(DAOS_options_t)); -static option_help options [] = { - {0, "daos.pool", "pool uuid", OPTION_OPTIONAL_ARGUMENT, 's', &o.pool}, - {0, "daos.svcl", "pool SVCL", OPTION_OPTIONAL_ARGUMENT, 's', &o.svcl}, - {0, "daos.group", "server group", OPTION_OPTIONAL_ARGUMENT, 's', &o.group}, - {0, "daos.cont", "container uuid", OPTION_OPTIONAL_ARGUMENT, 's', &o.cont}, - {0, "daos.chunk_size", "chunk size", OPTION_OPTIONAL_ARGUMENT, 'd', &o.chunk_size}, - {0, "daos.destroy", "Destroy Container", OPTION_FLAG, 'd', &o.destroy}, - {0, "daos.oclass", "object class", OPTION_OPTIONAL_ARGUMENT, 's', &o.oclass}, - LAST_OPTION -}; + if (init_values != NULL) { + memcpy(o, init_values, sizeof(DAOS_options_t)); + } else { + memset(o, 0, sizeof(DAOS_options_t)); + /* initialize the options properly */ + o->chunk_size = 1048576; + } + + *init_backend_options = (aiori_mod_opt_t *) o; + + option_help h [] = { + {0, "daos.pool", "pool uuid", OPTION_OPTIONAL_ARGUMENT, 's', &o->pool}, + {0, "daos.svcl", "pool SVCL", OPTION_OPTIONAL_ARGUMENT, 's', &o->svcl}, + {0, "daos.group", "server group", OPTION_OPTIONAL_ARGUMENT, 's', &o->group}, + {0, "daos.cont", "container uuid", OPTION_OPTIONAL_ARGUMENT, 's', &o->cont}, + {0, "daos.chunk_size", "chunk size", OPTION_OPTIONAL_ARGUMENT, 'd', &o->chunk_size}, + {0, "daos.destroy", "Destroy Container", OPTION_FLAG, 'd', &o->destroy}, + {0, "daos.oclass", "object class", OPTION_OPTIONAL_ARGUMENT, 's', &o->oclass}, + LAST_OPTION + }; + + option_help * help = malloc(sizeof(h)); + memcpy(help, h, sizeof(h)); + return help; +} /**************************** P R O T O T Y P E S *****************************/ -static void DAOS_Init(); -static void DAOS_Fini(); -static void *DAOS_Create(char *, IOR_param_t *); -static void *DAOS_Open(char *, IOR_param_t *); -static int DAOS_Access(const char *, int, IOR_param_t *); -static IOR_offset_t DAOS_Xfer(int, void *, IOR_size_t *, - IOR_offset_t, IOR_param_t *); -static void DAOS_Close(void *, IOR_param_t *); -static void DAOS_Delete(char *, IOR_param_t *); +static void DAOS_Init(aiori_mod_opt_t *); +static void DAOS_Fini(aiori_mod_opt_t *); +static aiori_fd_t *DAOS_Create(char *, int, aiori_mod_opt_t *); +static aiori_fd_t *DAOS_Open(char *, int, aiori_mod_opt_t *); +static int DAOS_Access(const char *, int, aiori_mod_opt_t *); +static IOR_offset_t DAOS_Xfer(int, aiori_fd_t *, IOR_size_t *, IOR_offset_t, + IOR_offset_t, aiori_mod_opt_t *); +static void DAOS_Close(aiori_fd_t *, aiori_mod_opt_t *); +static void DAOS_Delete(char *, aiori_mod_opt_t *); static char* DAOS_GetVersion(); -static void DAOS_Fsync(void *, IOR_param_t *); -static IOR_offset_t DAOS_GetFileSize(IOR_param_t *, MPI_Comm, char *); +static void DAOS_Fsync(aiori_fd_t *, aiori_mod_opt_t *); +static IOR_offset_t DAOS_GetFileSize(aiori_mod_opt_t *, MPI_Comm, char *); static option_help * DAOS_options(); +static void DAOS_init_xfer_options(aiori_xfer_hint_t *); +static int DAOS_check_params(aiori_mod_opt_t *); /************************** D E C L A R A T I O N S ***************************/ ior_aiori_t daos_aiori = { .name = "DAOS", + .initialize = DAOS_Init, + .finalize = DAOS_Fini, .create = DAOS_Create, .open = DAOS_Open, .access = DAOS_Access, @@ -90,15 +104,17 @@ ior_aiori_t daos_aiori = { .close = DAOS_Close, .delete = DAOS_Delete, .get_version = DAOS_GetVersion, + .xfer_hints = DAOS_init_xfer_options, .fsync = DAOS_Fsync, .get_file_size = DAOS_GetFileSize, - .initialize = DAOS_Init, - .finalize = DAOS_Fini, - .get_options = DAOS_options, .statfs = aiori_posix_statfs, .mkdir = aiori_posix_mkdir, .rmdir = aiori_posix_rmdir, .stat = aiori_posix_stat, + .get_options = DAOS_options, + .xfer_hints = DAOS_init_xfer_options, + .check_params = DAOS_check_params, + .enable_mdtest = false, }; #define IOR_DAOS_MUR_SEED 0xDEAD10CC @@ -144,6 +160,22 @@ do { \ MPI_CHECK(MPI_Abort(MPI_COMM_WORLD, -1), "MPI_Abort() error"); \ } while (0) +static aiori_xfer_hint_t * hints = NULL; + +void DAOS_init_xfer_options(aiori_xfer_hint_t * params) +{ + hints = params; +} + +static int DAOS_check_params(aiori_mod_opt_t * options){ + DAOS_options_t *o = (DAOS_options_t *) options; + + if (o->pool == NULL || o->svcl == NULL || o->cont == NULL) + ERR("Invalid pool or container options\n"); + + return 0; +} + /* Distribute process 0's pool or container handle to others. */ static void HandleDistribute(daos_handle_t *handle, enum handleType type) @@ -202,29 +234,24 @@ HandleDistribute(daos_handle_t *handle, enum handleType type) free(global.iov_buf); } -static option_help * -DAOS_options() -{ - return options; -} - static void -DAOS_Init() +DAOS_Init(aiori_mod_opt_t * options) { + DAOS_options_t *o = (DAOS_options_t *)options; int rc; if (daos_initialized) return; - if (o.pool == NULL || o.svcl == NULL || o.cont == NULL) { + if (o->pool == NULL || o->svcl == NULL || o->cont == NULL) { GERR("Invalid DAOS pool/cont\n"); return; } - if (o.oclass) { - objectClass = daos_oclass_name2id(o.oclass); + if (o->oclass) { + objectClass = daos_oclass_name2id(o->oclass); if (objectClass == OC_UNKNOWN) - GERR("Invalid DAOS Object class %s\n", o.oclass); + GERR("Invalid DAOS Object class %s\n", o->oclass); } rc = daos_init(); @@ -237,25 +264,25 @@ DAOS_Init() static daos_pool_info_t po_info; static daos_cont_info_t co_info; - INFO(VERBOSE_1, "Connecting to pool %s", o.pool); + INFO(VERBOSE_1, "Connecting to pool %s", o->pool); - rc = uuid_parse(o.pool, uuid); - DCHECK(rc, "Failed to parse 'pool': %s", o.pool); + rc = uuid_parse(o->pool, uuid); + DCHECK(rc, "Failed to parse 'pool': %s", o->pool); - svcl = daos_rank_list_parse(o.svcl, ":"); + svcl = daos_rank_list_parse(o->svcl, ":"); if (svcl == NULL) ERR("Failed to allocate svcl"); - rc = daos_pool_connect(uuid, o.group, svcl, DAOS_PC_RW, + rc = daos_pool_connect(uuid, o->group, svcl, DAOS_PC_RW, &poh, &po_info, NULL); d_rank_list_free(svcl); - DCHECK(rc, "Failed to connect to pool %s", o.pool); + DCHECK(rc, "Failed to connect to pool %s", o->pool); - INFO(VERBOSE_1, "Create/Open Container %s", o.cont); + INFO(VERBOSE_1, "Create/Open Container %s", o->cont); uuid_clear(uuid); - rc = uuid_parse(o.cont, uuid); - DCHECK(rc, "Failed to parse 'cont': %s", o.cont); + rc = uuid_parse(o->cont, uuid); + DCHECK(rc, "Failed to parse 'cont': %s", o->cont); rc = daos_cont_open(poh, uuid, DAOS_COO_RW, &coh, &co_info, NULL); @@ -278,8 +305,9 @@ DAOS_Init() } static void -DAOS_Fini() +DAOS_Fini(aiori_mod_opt_t *options) { + DAOS_options_t *o = (DAOS_options_t *)options; int rc; if (!daos_initialized) @@ -288,18 +316,18 @@ DAOS_Fini() MPI_Barrier(MPI_COMM_WORLD); rc = daos_cont_close(coh, NULL); if (rc) { - DCHECK(rc, "Failed to close container %s (%d)", o.cont, rc); + DCHECK(rc, "Failed to close container %s (%d)", o->cont, rc); MPI_Abort(MPI_COMM_WORLD, -1); } MPI_Barrier(MPI_COMM_WORLD); - if (o.destroy) { + if (o->destroy) { if (rank == 0) { uuid_t uuid; double t1, t2; - INFO(VERBOSE_1, "Destroying DAOS Container %s", o.cont); - uuid_parse(o.cont, uuid); + INFO(VERBOSE_1, "Destroying DAOS Container %s", o->cont); + uuid_parse(o->cont, uuid); t1 = MPI_Wtime(); rc = daos_cont_destroy(poh, uuid, 1, NULL); t2 = MPI_Wtime(); @@ -310,7 +338,7 @@ DAOS_Fini() MPI_Bcast(&rc, 1, MPI_INT, 0, MPI_COMM_WORLD); if (rc) { if (rank == 0) - DCHECK(rc, "Failed to destroy container %s (%d)", o.cont, rc); + DCHECK(rc, "Failed to destroy container %s (%d)", o->cont, rc); MPI_Abort(MPI_COMM_WORLD, -1); } } @@ -319,7 +347,7 @@ DAOS_Fini() INFO(VERBOSE_1, "Disconnecting from DAOS POOL.."); rc = daos_pool_disconnect(poh, NULL); - DCHECK(rc, "Failed to disconnect from pool %s", o.pool); + DCHECK(rc, "Failed to disconnect from pool %s", o->pool); MPI_CHECK(MPI_Barrier(MPI_COMM_WORLD), "barrier error"); if (rank == 0) @@ -334,38 +362,38 @@ DAOS_Fini() static void gen_oid(const char *name, daos_obj_id_t *oid) { - oid->lo = d_hash_murmur64(name, strlen(name), IOR_DAOS_MUR_SEED); oid->hi = 0; daos_array_generate_id(oid, objectClass, true, 0); } -static void * -DAOS_Create(char *testFileName, IOR_param_t *param) +static aiori_fd_t * +DAOS_Create(char *testFileName, int flags, aiori_mod_opt_t *param) { + DAOS_options_t *o = (DAOS_options_t*) param; daos_obj_id_t oid; int rc; /** Convert file name into object ID */ gen_oid(testFileName, &oid); - + /** Create the array */ - if (param->filePerProc || rank == 0) { - rc = daos_array_create(coh, oid, DAOS_TX_NONE, 1, o.chunk_size, + if (hints->filePerProc || rank == 0) { + rc = daos_array_create(coh, oid, DAOS_TX_NONE, 1, o->chunk_size, &aoh, NULL); DCHECK(rc, "Failed to create array object\n"); } /** Distribute the array handle if not FPP */ - if (!param->filePerProc) + if (!hints->filePerProc) HandleDistribute(&aoh, ARRAY_HANDLE); - return &aoh; + return (aiori_fd_t*)(&aoh); } static int -DAOS_Access(const char *testFileName, int mode, IOR_param_t * param) +DAOS_Access(const char *testFileName, int mode, aiori_mod_opt_t * param) { daos_obj_id_t oid; daos_size_t cell_size, chunk_size; @@ -387,8 +415,8 @@ DAOS_Access(const char *testFileName, int mode, IOR_param_t * param) return rc; } -static void * -DAOS_Open(char *testFileName, IOR_param_t *param) +static aiori_fd_t * +DAOS_Open(char *testFileName, int flags, aiori_mod_opt_t *param) { daos_obj_id_t oid; @@ -396,7 +424,7 @@ DAOS_Open(char *testFileName, IOR_param_t *param) gen_oid(testFileName, &oid); /** Open the array */ - if (param->filePerProc || rank == 0) { + if (hints->filePerProc || rank == 0) { daos_size_t cell_size, chunk_size; int rc; @@ -409,15 +437,15 @@ DAOS_Open(char *testFileName, IOR_param_t *param) } /** Distribute the array handle if not FPP */ - if (!param->filePerProc) + if (!hints->filePerProc) HandleDistribute(&aoh, ARRAY_HANDLE); - return &aoh; + return (aiori_fd_t*)(&aoh); } static IOR_offset_t -DAOS_Xfer(int access, void *file, IOR_size_t *buffer, - IOR_offset_t length, IOR_param_t *param) +DAOS_Xfer(int access, aiori_fd_t *file, IOR_size_t *buffer, IOR_offset_t length, + IOR_offset_t off, aiori_mod_opt_t *param) { daos_array_iod_t iod; daos_range_t rg; @@ -428,7 +456,7 @@ DAOS_Xfer(int access, void *file, IOR_size_t *buffer, /** set array location */ iod.arr_nr = 1; rg.rg_len = length; - rg.rg_idx = param->offset; + rg.rg_idx = off; iod.arr_rgs = &rg; /** set memory location */ @@ -448,7 +476,7 @@ DAOS_Xfer(int access, void *file, IOR_size_t *buffer, } static void -DAOS_Close(void *file, IOR_param_t *param) +DAOS_Close(aiori_fd_t *file, aiori_mod_opt_t *param) { int rc; @@ -462,7 +490,7 @@ DAOS_Close(void *file, IOR_param_t *param) } static void -DAOS_Delete(char *testFileName, IOR_param_t *param) +DAOS_Delete(char *testFileName, aiori_mod_opt_t *param) { daos_obj_id_t oid; daos_size_t cell_size, chunk_size; @@ -500,13 +528,13 @@ DAOS_GetVersion() } static void -DAOS_Fsync(void *file, IOR_param_t *param) +DAOS_Fsync(aiori_fd_t *file, aiori_mod_opt_t *param) { return; } static IOR_offset_t -DAOS_GetFileSize(IOR_param_t *param, MPI_Comm testComm, char *testFileName) +DAOS_GetFileSize(aiori_mod_opt_t *param, MPI_Comm comm, char *testFileName) { daos_obj_id_t oid; daos_size_t size; @@ -519,7 +547,7 @@ DAOS_GetFileSize(IOR_param_t *param, MPI_Comm testComm, char *testFileName) gen_oid(testFileName, &oid); /** open the array to verify it exists */ - if (param->filePerProc || rank == 0) { + if (hints->filePerProc || rank == 0) { daos_size_t cell_size, chunk_size; rc = daos_array_open(coh, oid, DAOS_TX_NONE, DAOS_OO_RO, @@ -537,7 +565,7 @@ DAOS_GetFileSize(IOR_param_t *param, MPI_Comm testComm, char *testFileName) aoh.cookie = 0; } - if (!param->filePerProc) + if (!hints->filePerProc) MPI_Bcast(&size, 1, MPI_LONG, 0, MPI_COMM_WORLD); return size; diff --git a/src/aiori-DFS.c b/src/aiori-DFS.c index 6487488..7f8ab7a 100755 --- a/src/aiori-DFS.c +++ b/src/aiori-DFS.c @@ -27,15 +27,15 @@ #include #include +#include #include #include #include #include -#include "ior.h" -#include "iordef.h" #include "aiori.h" #include "utilities.h" +#include "iordef.h" dfs_t *dfs; static daos_handle_t poh, coh; @@ -56,7 +56,7 @@ enum handleType { }; /************************** O P T I O N S *****************************/ -struct dfs_options{ +typedef struct { char *pool; char *svcl; char *group; @@ -66,57 +66,69 @@ struct dfs_options{ char *dir_oclass; char *prefix; int destroy; -}; +} DFS_options_t; -static struct dfs_options o = { - .pool = NULL, - .svcl = NULL, - .group = NULL, - .cont = NULL, - .chunk_size = 1048576, - .oclass = NULL, - .dir_oclass = NULL, - .prefix = NULL, - .destroy = 0, -}; +static option_help * DFS_options(aiori_mod_opt_t ** init_backend_options, + aiori_mod_opt_t * init_values){ + DFS_options_t * o = malloc(sizeof(DFS_options_t)); -static option_help options [] = { - {0, "dfs.pool", "pool uuid", OPTION_OPTIONAL_ARGUMENT, 's', & o.pool}, - {0, "dfs.svcl", "pool SVCL", OPTION_OPTIONAL_ARGUMENT, 's', & o.svcl}, - {0, "dfs.group", "server group", OPTION_OPTIONAL_ARGUMENT, 's', & o.group}, - {0, "dfs.cont", "DFS container uuid", OPTION_OPTIONAL_ARGUMENT, 's', & o.cont}, - {0, "dfs.chunk_size", "chunk size", OPTION_OPTIONAL_ARGUMENT, 'd', &o.chunk_size}, - {0, "dfs.oclass", "object class", OPTION_OPTIONAL_ARGUMENT, 's', &o.oclass}, - {0, "dfs.dir_oclass", "directory object class", OPTION_OPTIONAL_ARGUMENT, 's', &o.dir_oclass}, - {0, "dfs.prefix", "mount prefix", OPTION_OPTIONAL_ARGUMENT, 's', & o.prefix}, - {0, "dfs.destroy", "Destroy DFS Container", OPTION_FLAG, 'd', &o.destroy}, - LAST_OPTION -}; + if (init_values != NULL) { + memcpy(o, init_values, sizeof(DFS_options_t)); + } else { + memset(o, 0, sizeof(DFS_options_t)); + /* initialize the options properly */ + o->chunk_size = 1048576; + } + + *init_backend_options = (aiori_mod_opt_t *) o; + + option_help h [] = { + {0, "dfs.pool", "pool uuid", OPTION_OPTIONAL_ARGUMENT, 's', &o->pool}, + {0, "dfs.svcl", "pool SVCL", OPTION_OPTIONAL_ARGUMENT, 's', &o->svcl}, + {0, "dfs.group", "server group", OPTION_OPTIONAL_ARGUMENT, 's', &o->group}, + {0, "dfs.cont", "DFS container uuid", OPTION_OPTIONAL_ARGUMENT, 's', &o->cont}, + {0, "dfs.chunk_size", "chunk size", OPTION_OPTIONAL_ARGUMENT, 'd', &o->chunk_size}, + {0, "dfs.oclass", "object class", OPTION_OPTIONAL_ARGUMENT, 's', &o->oclass}, + {0, "dfs.dir_oclass", "directory object class", OPTION_OPTIONAL_ARGUMENT, 's', + &o->dir_oclass}, + {0, "dfs.prefix", "mount prefix", OPTION_OPTIONAL_ARGUMENT, 's', &o->prefix}, + {0, "dfs.destroy", "Destroy DFS Container", OPTION_FLAG, 'd', &o->destroy}, + LAST_OPTION + }; + + option_help * help = malloc(sizeof(h)); + memcpy(help, h, sizeof(h)); + return help; +} /**************************** P R O T O T Y P E S *****************************/ -static void *DFS_Create(char *, IOR_param_t *); -static void *DFS_Open(char *, IOR_param_t *); -static IOR_offset_t DFS_Xfer(int, void *, IOR_size_t *, - IOR_offset_t, IOR_param_t *); -static void DFS_Close(void *, IOR_param_t *); -static void DFS_Delete(char *, IOR_param_t *); +static void DFS_Init(aiori_mod_opt_t *); +static void DFS_Finalize(aiori_mod_opt_t *); +static aiori_fd_t *DFS_Create(char *, int, aiori_mod_opt_t *); +static aiori_fd_t *DFS_Open(char *, int, aiori_mod_opt_t *); +static IOR_offset_t DFS_Xfer(int, aiori_fd_t *, IOR_size_t *, IOR_offset_t, + IOR_offset_t, aiori_mod_opt_t *); +static void DFS_Close(aiori_fd_t *, aiori_mod_opt_t *); +static void DFS_Delete(char *, aiori_mod_opt_t *); static char* DFS_GetVersion(); -static void DFS_Fsync(void *, IOR_param_t *); -static void DFS_Sync(IOR_param_t *); -static IOR_offset_t DFS_GetFileSize(IOR_param_t *, MPI_Comm, char *); -static int DFS_Statfs (const char *, ior_aiori_statfs_t *, IOR_param_t *); -static int DFS_Stat (const char *, struct stat *, IOR_param_t *); -static int DFS_Mkdir (const char *, mode_t, IOR_param_t *); -static int DFS_Rmdir (const char *, IOR_param_t *); -static int DFS_Access (const char *, int, IOR_param_t *); -static void DFS_Init(); -static void DFS_Finalize(); +static void DFS_Fsync(aiori_fd_t *, aiori_mod_opt_t *); +static void DFS_Sync(aiori_mod_opt_t *); +static IOR_offset_t DFS_GetFileSize(aiori_mod_opt_t *, MPI_Comm, char *); +static int DFS_Statfs (const char *, ior_aiori_statfs_t *, aiori_mod_opt_t *); +static int DFS_Stat (const char *, struct stat *, aiori_mod_opt_t *); +static int DFS_Mkdir (const char *, mode_t, aiori_mod_opt_t *); +static int DFS_Rmdir (const char *, aiori_mod_opt_t *); +static int DFS_Access (const char *, int, aiori_mod_opt_t *); static option_help * DFS_options(); +static void DFS_init_xfer_options(aiori_xfer_hint_t *); +static int DFS_check_params(aiori_mod_opt_t *); /************************** D E C L A R A T I O N S ***************************/ ior_aiori_t dfs_aiori = { .name = "DFS", + .initialize = DFS_Init, + .finalize = DFS_Finalize, .create = DFS_Create, .open = DFS_Open, .xfer = DFS_Xfer, @@ -126,14 +138,14 @@ ior_aiori_t dfs_aiori = { .fsync = DFS_Fsync, .sync = DFS_Sync, .get_file_size = DFS_GetFileSize, + .xfer_hints = DFS_init_xfer_options, .statfs = DFS_Statfs, .mkdir = DFS_Mkdir, .rmdir = DFS_Rmdir, .access = DFS_Access, .stat = DFS_Stat, - .initialize = DFS_Init, - .finalize = DFS_Finalize, .get_options = DFS_options, + .check_params = DFS_check_params, .enable_mdtest = true, }; @@ -165,6 +177,22 @@ do { \ MPI_CHECK(MPI_Abort(MPI_COMM_WORLD, -1), "MPI_Abort() error"); \ } while (0) +static aiori_xfer_hint_t * hints = NULL; + +void DFS_init_xfer_options(aiori_xfer_hint_t * params) +{ + hints = params; +} + +static int DFS_check_params(aiori_mod_opt_t * options){ + DFS_options_t *o = (DFS_options_t *) options; + + if (o->pool == NULL || o->svcl == NULL || o->cont == NULL) + ERR("Invalid pool or container options\n"); + + return 0; +} + static inline struct aiori_dir_hdl * hdl_obj(d_list_t *rlink) { @@ -378,27 +406,25 @@ lookup_insert_dir(const char *name, mode_t *mode) return hdl->oh; } -static option_help * DFS_options(){ - return options; -} - static void -DFS_Init() { +DFS_Init(aiori_mod_opt_t * options) +{ + DFS_options_t *o = (DFS_options_t *)options; int rc; - if (o.pool == NULL || o.svcl == NULL || o.cont == NULL) + if (o->pool == NULL || o->svcl == NULL || o->cont == NULL) ERR("Invalid pool or container options\n"); - if (o.oclass) { - objectClass = daos_oclass_name2id(o.oclass); + if (o->oclass) { + objectClass = daos_oclass_name2id(o->oclass); if (objectClass == OC_UNKNOWN) - GERR("Invalid DAOS object class %s\n", o.oclass); + GERR("Invalid DAOS object class %s\n", o->oclass); } - if (o.dir_oclass) { - dir_oclass = daos_oclass_name2id(o.dir_oclass); + if (o->dir_oclass) { + dir_oclass = daos_oclass_name2id(o->dir_oclass); if (dir_oclass == OC_UNKNOWN) - GERR("Invalid DAOS directory object class %s\n", o.dir_oclass); + GERR("Invalid DAOS directory object class %s\n", o->dir_oclass); } rc = daos_init(); @@ -413,21 +439,21 @@ DFS_Init() { daos_pool_info_t pool_info; daos_cont_info_t co_info; - rc = uuid_parse(o.pool, pool_uuid); - DCHECK(rc, "Failed to parse 'Pool uuid': %s", o.pool); + rc = uuid_parse(o->pool, pool_uuid); + DCHECK(rc, "Failed to parse 'Pool uuid': %s", o->pool); - rc = uuid_parse(o.cont, co_uuid); - DCHECK(rc, "Failed to parse 'Cont uuid': %s", o.cont); + rc = uuid_parse(o->cont, co_uuid); + DCHECK(rc, "Failed to parse 'Cont uuid': %s", o->cont); - svcl = daos_rank_list_parse(o.svcl, ":"); + svcl = daos_rank_list_parse(o->svcl, ":"); if (svcl == NULL) ERR("Failed to allocate svcl"); - INFO(VERBOSE_1, "Pool uuid = %s, SVCL = %s\n", o.pool, o.svcl); - INFO(VERBOSE_1, "DFS Container namespace uuid = %s\n", o.cont); + INFO(VERBOSE_1, "Pool uuid = %s, SVCL = %s\n", o->pool, o->svcl); + INFO(VERBOSE_1, "DFS Container namespace uuid = %s\n", o->cont); /** Connect to DAOS pool */ - rc = daos_pool_connect(pool_uuid, o.group, svcl, DAOS_PC_RW, + rc = daos_pool_connect(pool_uuid, o->group, svcl, DAOS_PC_RW, &poh, &pool_info, NULL); d_rank_list_free(svcl); DCHECK(rc, "Failed to connect to pool"); @@ -453,15 +479,16 @@ DFS_Init() { HandleDistribute(CONT_HANDLE); HandleDistribute(DFS_HANDLE); - if (o.prefix) { - rc = dfs_set_prefix(dfs, o.prefix); + if (o->prefix) { + rc = dfs_set_prefix(dfs, o->prefix); DCHECK(rc, "Failed to set DFS Prefix"); } } static void -DFS_Finalize() +DFS_Finalize(aiori_mod_opt_t *options) { + DFS_options_t *o = (DFS_options_t *)options; int rc; MPI_Barrier(MPI_COMM_WORLD); @@ -472,16 +499,16 @@ DFS_Finalize() MPI_Barrier(MPI_COMM_WORLD); rc = daos_cont_close(coh, NULL); - DCHECK(rc, "Failed to close container %s (%d)", o.cont, rc); + DCHECK(rc, "Failed to close container %s (%d)", o->cont, rc); MPI_Barrier(MPI_COMM_WORLD); - if (o.destroy) { + if (o->destroy) { if (rank == 0) { uuid_t uuid; double t1, t2; - INFO(VERBOSE_1, "Destorying DFS Container: %s\n", o.cont); - uuid_parse(o.cont, uuid); + INFO(VERBOSE_1, "Destorying DFS Container: %s\n", o->cont); + uuid_parse(o->cont, uuid); t1 = MPI_Wtime(); rc = daos_cont_destroy(poh, uuid, 1, NULL); t2 = MPI_Wtime(); @@ -492,7 +519,7 @@ DFS_Finalize() MPI_Bcast(&rc, 1, MPI_INT, 0, MPI_COMM_WORLD); if (rc) { if (rank == 0) - DCHECK(rc, "Failed to destroy container %s (%d)", o.cont, rc); + DCHECK(rc, "Failed to destroy container %s (%d)", o->cont, rc); MPI_Abort(MPI_COMM_WORLD, -1); } } @@ -515,17 +542,16 @@ DFS_Finalize() /* * Creat and open a file through the DFS interface. */ -static void * -DFS_Create(char *testFileName, IOR_param_t *param) +static aiori_fd_t * +DFS_Create(char *testFileName, int flags, aiori_mod_opt_t *param) { + DFS_options_t *o = (DFS_options_t*) param; char *name = NULL, *dir_name = NULL; dfs_obj_t *obj = NULL, *parent = NULL; - mode_t mode = 0644; + mode_t mode = 0664; int fd_oflag = 0; int rc; - assert(param); - rc = parse_filename(testFileName, &name, &dir_name); DCHECK(rc, "Failed to parse path %s", testFileName); assert(dir_name); @@ -535,20 +561,20 @@ DFS_Create(char *testFileName, IOR_param_t *param) if (parent == NULL) GERR("Failed to lookup parent dir"); - mode = S_IFREG | param->mode; - if (param->filePerProc || rank == 0) { + mode = S_IFREG | mode; + if (hints->filePerProc || rank == 0) { fd_oflag |= O_CREAT | O_RDWR | O_EXCL; rc = dfs_open(dfs, parent, name, mode, fd_oflag, - objectClass, o.chunk_size, NULL, &obj); + objectClass, o->chunk_size, NULL, &obj); DCHECK(rc, "dfs_open() of %s Failed", name); } - if (!param->filePerProc) { + if (!hints->filePerProc) { MPI_Barrier(MPI_COMM_WORLD); if (rank != 0) { fd_oflag |= O_RDWR; rc = dfs_open(dfs, parent, name, mode, fd_oflag, - objectClass, o.chunk_size, NULL, &obj); + objectClass, o->chunk_size, NULL, &obj); DCHECK(rc, "dfs_open() of %s Failed", name); } } @@ -558,27 +584,27 @@ DFS_Create(char *testFileName, IOR_param_t *param) if (dir_name) free(dir_name); - return ((void *)obj); + return (aiori_fd_t *)(obj); } /* * Open a file through the DFS interface. */ -static void * -DFS_Open(char *testFileName, IOR_param_t *param) +static aiori_fd_t * +DFS_Open(char *testFileName, int flags, aiori_mod_opt_t *param) { + DFS_options_t *o = (DFS_options_t*) param; char *name = NULL, *dir_name = NULL; dfs_obj_t *obj = NULL, *parent = NULL; - mode_t mode; - int rc; + mode_t mode = 0664; int fd_oflag = 0; + int rc; fd_oflag |= O_RDWR; - mode = S_IFREG | param->mode; + mode = S_IFREG | flags; rc = parse_filename(testFileName, &name, &dir_name); DCHECK(rc, "Failed to parse path %s", testFileName); - assert(dir_name); assert(name); @@ -587,7 +613,7 @@ DFS_Open(char *testFileName, IOR_param_t *param) GERR("Failed to lookup parent dir"); rc = dfs_open(dfs, parent, name, mode, fd_oflag, objectClass, - o.chunk_size, NULL, &obj); + o->chunk_size, NULL, &obj); DCHECK(rc, "dfs_open() of %s Failed", name); if (name) @@ -595,15 +621,15 @@ DFS_Open(char *testFileName, IOR_param_t *param) if (dir_name) free(dir_name); - return ((void *)obj); + return (aiori_fd_t *)(obj); } /* * Write or read access to file using the DFS interface. */ static IOR_offset_t -DFS_Xfer(int access, void *file, IOR_size_t *buffer, IOR_offset_t length, - IOR_param_t *param) +DFS_Xfer(int access, aiori_fd_t *file, IOR_size_t *buffer, IOR_offset_t length, + IOR_offset_t off, aiori_mod_opt_t *param) { int xferRetries = 0; long long remaining = (long long)length; @@ -626,20 +652,20 @@ DFS_Xfer(int access, void *file, IOR_size_t *buffer, IOR_offset_t length, /* write/read file */ if (access == WRITE) { - rc = dfs_write(dfs, obj, &sgl, param->offset, NULL); + rc = dfs_write(dfs, obj, &sgl, off, NULL); if (rc) { fprintf(stderr, "dfs_write() failed (%d)", rc); return -1; } ret = remaining; } else { - rc = dfs_read(dfs, obj, &sgl, param->offset, &ret, NULL); + rc = dfs_read(dfs, obj, &sgl, off, &ret, NULL); if (rc || ret == 0) fprintf(stderr, "dfs_read() failed(%d)", rc); } if (ret < remaining) { - if (param->singleXferAttempt == TRUE) + if (hints->singleXferAttempt == TRUE) exit(-1); if (xferRetries > MAX_RETRY) ERR("too many retries -- aborting"); @@ -659,7 +685,7 @@ DFS_Xfer(int access, void *file, IOR_size_t *buffer, IOR_offset_t length, * Perform fsync(). */ static void -DFS_Fsync(void *fd, IOR_param_t * param) +DFS_Fsync(aiori_fd_t *fd, aiori_mod_opt_t * param) { /* no cache in DFS, so this is a no-op currently */ dfs_sync(dfs); @@ -670,7 +696,7 @@ DFS_Fsync(void *fd, IOR_param_t * param) * Perform sync() on the dfs mount. */ static void -DFS_Sync(IOR_param_t * param) +DFS_Sync(aiori_mod_opt_t * param) { /* no cache in DFS, so this is a no-op currently */ dfs_sync(dfs); @@ -681,7 +707,7 @@ DFS_Sync(IOR_param_t * param) * Close a file through the DFS interface. */ static void -DFS_Close(void *fd, IOR_param_t * param) +DFS_Close(aiori_fd_t *fd, aiori_mod_opt_t * param) { dfs_release((dfs_obj_t *)fd); } @@ -690,7 +716,7 @@ DFS_Close(void *fd, IOR_param_t * param) * Delete a file through the DFS interface. */ static void -DFS_Delete(char *testFileName, IOR_param_t * param) +DFS_Delete(char *testFileName, aiori_mod_opt_t * param) { char *name = NULL, *dir_name = NULL; dfs_obj_t *parent = NULL; @@ -727,7 +753,7 @@ static char* DFS_GetVersion() * Use DFS stat() to return aggregate file size. */ static IOR_offset_t -DFS_GetFileSize(IOR_param_t * test, MPI_Comm comm, char *testFileName) +DFS_GetFileSize(aiori_mod_opt_t * test, MPI_Comm comm, char *testFileName) { dfs_obj_t *obj; daos_size_t fsize, tmpMin, tmpMax, tmpSum; @@ -745,7 +771,7 @@ DFS_GetFileSize(IOR_param_t * test, MPI_Comm comm, char *testFileName) dfs_release(obj); - if (test->filePerProc == TRUE) { + if (hints->filePerProc == TRUE) { MPI_CHECK(MPI_Allreduce(&fsize, &tmpSum, 1, MPI_LONG_LONG_INT, MPI_SUM, comm), "cannot total data moved"); @@ -770,13 +796,13 @@ DFS_GetFileSize(IOR_param_t * test, MPI_Comm comm, char *testFileName) } static int -DFS_Statfs(const char *path, ior_aiori_statfs_t *sfs, IOR_param_t * param) +DFS_Statfs(const char *path, ior_aiori_statfs_t *sfs, aiori_mod_opt_t * param) { return 0; } static int -DFS_Mkdir(const char *path, mode_t mode, IOR_param_t * param) +DFS_Mkdir(const char *path, mode_t mode, aiori_mod_opt_t * param) { dfs_obj_t *parent = NULL; char *name = NULL, *dir_name = NULL; @@ -804,7 +830,7 @@ DFS_Mkdir(const char *path, mode_t mode, IOR_param_t * param) } static int -DFS_Rmdir(const char *path, IOR_param_t * param) +DFS_Rmdir(const char *path, aiori_mod_opt_t * param) { dfs_obj_t *parent = NULL; char *name = NULL, *dir_name = NULL; @@ -833,7 +859,7 @@ DFS_Rmdir(const char *path, IOR_param_t * param) } static int -DFS_Access(const char *path, int mode, IOR_param_t * param) +DFS_Access(const char *path, int mode, aiori_mod_opt_t * param) { dfs_obj_t *obj = NULL; mode_t fmode; @@ -850,7 +876,7 @@ DFS_Access(const char *path, int mode, IOR_param_t * param) } static int -DFS_Stat(const char *path, struct stat *buf, IOR_param_t * param) +DFS_Stat(const char *path, struct stat *buf, aiori_mod_opt_t * param) { dfs_obj_t *parent = NULL; char *name = NULL, *dir_name = NULL;