From 8d0cddd21e7461a4bc26cac0c9d391dcfcf9a891 Mon Sep 17 00:00:00 2001 From: Mohamad Chaarawi Date: Wed, 13 Jun 2018 18:37:37 +0000 Subject: [PATCH 1/5] Add DFS ior/mdtest driver Signed-off-by: Mohamad Chaarawi --- configure.ac | 19 ++ src/Makefile.am | 4 + src/aiori-DFS.c | 562 ++++++++++++++++++++++++++++++++++++++++++++++++ src/aiori.c | 3 + src/aiori.h | 4 + src/ior.c | 11 +- src/mdtest.c | 10 + 7 files changed, 612 insertions(+), 1 deletion(-) create mode 100755 src/aiori-DFS.c diff --git a/configure.ac b/configure.ac index 4f9461c..af6e49a 100755 --- a/configure.ac +++ b/configure.ac @@ -142,8 +142,27 @@ AM_COND_IF([USE_POSIX_AIORI],[ AC_DEFINE([USE_POSIX_AIORI], [], [Build POSIX backend AIORI]) ]) +# DFS IO support +AC_ARG_WITH([daos], + [AS_HELP_STRING([--with-daos], + [support IO with DFS backend @<:@default=no@:>@])], + [], + [with_daos=no]) +AS_IF([test "x$with_daos" != xno], + DAOS="yes" + LDFLAGS="$LDFLAGS -L$with_daos/lib" + CPPFLAGS="$CPPFLAGS -I$with_daos/include" + AC_CHECK_HEADERS(daos_types.h,, [unset DAOS]) + AC_CHECK_LIB([uuid], [uuid_generate],, [unset DAOS]) + AC_CHECK_LIB([daos_common], [daos_sgl_init],, [unset DAOS]) + AC_CHECK_LIB([daos], [daos_init],, [unset DAOS]) + AC_CHECK_LIB([dfs], [dfs_mkdir],, [unset DAOS])) +AM_CONDITIONAL([USE_DFS_AIORI], [test x$DAOS = xyes]) +AM_COND_IF([USE_DFS_AIORI],[ + AC_DEFINE([USE_DFS_AIORI], [], [Build DFS backend AIORI]) +]) # aws4c is needed for the S3 backend (see --with-S3, below). # Version 0.5.2 of aws4c is available at https://github.com/jti-lanl/aws4c.git diff --git a/src/Makefile.am b/src/Makefile.am index 7d2575b..aea1824 100755 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -53,6 +53,10 @@ if USE_POSIX_AIORI extraSOURCES += aiori-POSIX.c endif +if USE_DFS_AIORI +extraSOURCES += aiori-DFS.c +endif + if USE_S3_AIORI extraSOURCES += aiori-S3.c diff --git a/src/aiori-DFS.c b/src/aiori-DFS.c new file mode 100755 index 0000000..ad0c712 --- /dev/null +++ b/src/aiori-DFS.c @@ -0,0 +1,562 @@ +/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- + * vim:expandtab:shiftwidth=8:tabstop=8: + */ +/******************************************************************************\ +* * +* Copyright (c) 2003, The Regents of the University of California * +* See the file COPYRIGHT for a complete copyright notice and license. * +* * +******************************************************************************** +* +* Implement of abstract I/O interface for DFS. +* +\******************************************************************************/ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "ior.h" +#include "aiori.h" +#include "iordef.h" +#include "utilities.h" + +dfs_t *dfs; + +static int +parse_filename(const char *path, char **_obj_name, char **_cont_name) +{ + char *f1 = NULL; + char *f2 = NULL; + char *fname = NULL; + char *cont_name = NULL; + int rc = 0; + + if (path == NULL || _obj_name == NULL || _cont_name == NULL) + return -EINVAL; + + if (strcmp(path, "/") == 0) { + *_cont_name = strdup("/"); + if (*_cont_name == NULL) + return -ENOMEM; + *_obj_name = NULL; + return 0; + } + + f1 = strdup(path); + if (f1 == NULL) + D_GOTO(out, rc = -ENOMEM); + + f2 = strdup(path); + if (f2 == NULL) + D_GOTO(out, rc = -ENOMEM); + + fname = basename(f1); + cont_name = dirname(f2); + + if (cont_name[0] == '.' || cont_name[0] != '/') { + char *cwd; + + //getcwd(cwd, 1024); + cwd = strdup("/"); + if (strcmp(cont_name, ".") == 0) { + cont_name = strdup(cwd); + if (cont_name == NULL) + D_GOTO(out, rc = -ENOMEM); + } else { + char *new_dir = calloc(strlen(cwd) + strlen(cont_name) + + 1, sizeof(char)); + if (new_dir == NULL) + D_GOTO(out, rc = -ENOMEM); + + strcpy(new_dir, cwd); + if (cont_name[0] == '.') { + strcat(new_dir, &cont_name[1]); + } else { + strcat(new_dir, "/"); + strcat(new_dir, cont_name); + } + cont_name = new_dir; + } + *_cont_name = cont_name; + } else { + *_cont_name = strdup(cont_name); + if (*_cont_name == NULL) + D_GOTO(out, rc = -ENOMEM); + } + + *_obj_name = strdup(fname); + if (*_obj_name == NULL) { + free(*_cont_name); + *_cont_name = NULL; + D_GOTO(out, rc = -ENOMEM); + } + +out: + if (f1) + free(f1); + if (f2) + free(f2); + return rc; +} + +/**************************** 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_SetVersion(IOR_param_t *); +static void DFS_Fsync(void *, 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 *); + +/************************** D E C L A R A T I O N S ***************************/ + +ior_aiori_t dfs_aiori = { + .name = "DFS", + .create = DFS_Create, + .open = DFS_Open, + .xfer = DFS_Xfer, + .close = DFS_Close, + .delete = DFS_Delete, + .set_version = DFS_SetVersion, + .fsync = DFS_Fsync, + .get_file_size = DFS_GetFileSize, + .statfs = DFS_Statfs, + .mkdir = DFS_Mkdir, + .rmdir = DFS_Rmdir, + .access = DFS_Access, + .stat = DFS_Stat, +}; + +/***************************** F U N C T I O N S ******************************/ + +int +dfs_init(void) { + int rc; + + rc = daos_init(); + if (rc) { + fprintf(stderr, "daos_init() failed with %d\n", rc); + return rc; + } + + rc = dfs_mount(&dfs); + if (rc) { + fprintf(stderr, "dfs_mount failed (%d)\n", rc); + return 1; + } + + return rc; +} + +int dfs_finalize(void) +{ + dfs_umount(dfs); + daos_fini(); + return 0; +} + +/* + * Creat and open a file through the DFS interface. + */ +static void * +DFS_Create(char *testFileName, IOR_param_t *param) +{ + char *name = NULL, *dir_name = NULL; + dfs_obj_t *obj = NULL, *parent = NULL; + mode_t pmode; + int fd_oflag = 0; + int rc; + + fd_oflag |= O_CREAT | O_RDWR; + + rc = parse_filename(testFileName, &name, &dir_name); + if (rc) + goto out; + + assert(dir_name); + assert(name); + + rc = dfs_lookup(dfs, dir_name, &parent, &pmode); + if (rc || !S_ISDIR(pmode)) + goto out; + + mode_t mode = S_IFREG | param->mode; + rc = dfs_open(dfs, parent, name, mode, fd_oflag, NULL, &obj); + if (rc) + goto out; + +out: + if (name) + free(name); + if (dir_name) + free(dir_name); + if (parent) + dfs_release(parent); + + return ((void *)obj); +} + +/* + * Open a file through the DFS interface. + */ +static void *DFS_Open(char *testFileName, IOR_param_t *param) +{ + char *name = NULL, *dir_name = NULL; + dfs_obj_t *obj = NULL, *parent = NULL; + mode_t pmode; + int rc; + int fd_oflag = 0; + + fd_oflag |= O_RDWR; + + rc = parse_filename(testFileName, &name, &dir_name); + if (rc) + goto out; + + assert(dir_name); + assert(name); + + rc = dfs_lookup(dfs, dir_name, &parent, &pmode); + if (rc || !S_ISDIR(pmode)) + goto out; + + rc = dfs_open(dfs, parent, name, S_IFREG, fd_oflag, NULL, &obj); + if (rc) + goto out; + +out: + if (name) + free(name); + if (dir_name) + free(dir_name); + if (parent) + dfs_release(parent); + + return ((void *)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) +{ + int xferRetries = 0; + long long remaining = (long long)length; + char *ptr = (char *)buffer; + daos_size_t ret; + int rc; + dfs_obj_t *obj; + + obj = (dfs_obj_t *)file; + + while (remaining > 0) { + daos_iov_t iov; + daos_sg_list_t sgl; + + /** set memory location */ + sgl.sg_nr = 1; + sgl.sg_nr_out = 0; + daos_iov_set(&iov, (void *)ptr, remaining); + sgl.sg_iovs = &iov; + + /* write/read file */ + if (access == WRITE) { + rc = dfs_write(dfs, obj, sgl, param->offset); + if (rc) + ERR("write() failed"); + ret = remaining; + } else { + rc = dfs_read(dfs, obj, sgl, param->offset, &ret); + if (rc || ret == 0) + ERR("read() failed"); + } + + if (ret < remaining) { + if (param->singleXferAttempt == TRUE) + MPI_CHECK(MPI_Abort(MPI_COMM_WORLD, -1), + "barrier error"); + if (xferRetries > MAX_RETRY) + ERR("too many retries -- aborting"); + } + + assert(ret >= 0); + assert(ret <= remaining); + remaining -= ret; + ptr += ret; + xferRetries++; + } + + return (length); +} + +/* + * Perform fsync(). + */ +static void DFS_Fsync(void *fd, IOR_param_t * param) +{ + return; +} + +/* + * Close a file through the DFS interface. + */ +static void DFS_Close(void *fd, IOR_param_t * param) +{ + dfs_release((dfs_obj_t *)fd); +} + +/* + * Delete a file through the DFS interface. + */ +static void DFS_Delete(char *testFileName, IOR_param_t * param) +{ + char *name = NULL, *dir_name = NULL; + dfs_obj_t *parent = NULL; + mode_t pmode; + int rc; + + rc = parse_filename(testFileName, &name, &dir_name); + if (rc) + goto out; + + assert(dir_name); + assert(name); + + rc = dfs_lookup(dfs, dir_name, &parent, &pmode); + if (rc || !S_ISDIR(pmode)) + goto out; + + rc = dfs_remove(dfs, parent, name); + if (rc) + goto out; + +out: + if (name) + free(name); + if (dir_name) + free(dir_name); + if (parent) + dfs_release(parent); +} + +/* + * Determine api version. + */ +static void DFS_SetVersion(IOR_param_t * test) +{ + strcpy(test->apiVersion, test->api); +} + +/* + * Use DFS stat() to return aggregate file size. + */ +static IOR_offset_t DFS_GetFileSize(IOR_param_t * test, MPI_Comm testComm, + char *testFileName) +{ + dfs_obj_t *obj; + daos_size_t fsize, tmpMin, tmpMax, tmpSum; + int rc; + + rc = dfs_lookup(dfs, testFileName, &obj, NULL); + if (rc) + return -1; + + rc = dfs_get_size(dfs, obj, &fsize); + if (rc) + return -1; + + dfs_release(obj); + + if (test->filePerProc == TRUE) { + MPI_CHECK(MPI_Allreduce(&fsize, &tmpSum, 1, + MPI_LONG_LONG_INT, MPI_SUM, testComm), + "cannot total data moved"); + fsize = tmpSum; + } else { + MPI_CHECK(MPI_Allreduce(&fsize, &tmpMin, 1, + MPI_LONG_LONG_INT, MPI_MIN, testComm), + "cannot total data moved"); + MPI_CHECK(MPI_Allreduce(&fsize, &tmpMax, 1, + MPI_LONG_LONG_INT, MPI_MAX, testComm), + "cannot total data moved"); + if (tmpMin != tmpMax) { + if (rank == 0) { + WARN("inconsistent file size by different tasks"); + } + /* incorrect, but now consistent across tasks */ + fsize = tmpMin; + } + } + + return (fsize); +} + +static int +DFS_Statfs(const char *path, ior_aiori_statfs_t *sfs, IOR_param_t * param) +{ + return 0; +} + +static int +DFS_Mkdir (const char *path, mode_t mode, IOR_param_t * param) +{ + dfs_obj_t *parent = NULL; + mode_t pmode; + char *name = NULL, *dir_name = NULL; + int rc; + + rc = parse_filename(path, &name, &dir_name); + if (rc) + return rc; + + assert(dir_name); + assert(name); + + rc = dfs_lookup(dfs, dir_name, &parent, &pmode); + if (rc || !S_ISDIR(pmode)) + goto out; + + rc = dfs_mkdir(dfs, parent, name, mode); + if (rc) + goto out; + +out: + if (name) + free(name); + if (dir_name) + free(dir_name); + if (parent) + dfs_release(parent); + return rc; +} + +static int +DFS_Rmdir (const char *path, IOR_param_t * param) +{ + dfs_obj_t *parent = NULL; + mode_t pmode; + char *name = NULL, *dir_name = NULL; + int rc; + + rc = parse_filename(path, &name, &dir_name); + if (rc) + return rc; + + assert(dir_name); + assert(name); + + rc = dfs_lookup(dfs, dir_name, &parent, &pmode); + if (rc || !S_ISDIR(pmode)) + goto out; + + rc = dfs_remove(dfs, parent, name); + if (rc) + goto out; + +out: + if (name) + free(name); + if (dir_name) + free(dir_name); + if (parent) + dfs_release(parent); + return rc; +} + +static int +DFS_Access (const char *path, int mode, IOR_param_t * param) +{ + dfs_obj_t *parent = NULL; + mode_t pmode; + char *name = NULL, *dir_name = NULL; + struct stat stbuf; + int rc; + + rc = parse_filename(path, &name, &dir_name); + if (rc) + return rc; + + assert(dir_name); + assert(name); + + rc = dfs_lookup(dfs, dir_name, &parent, &pmode); + if (rc || !S_ISDIR(pmode)) + goto out; + + if (strcmp(name, ".") == 0) { + free(name); + name = NULL; + } + rc = dfs_stat(dfs, parent, name, &stbuf); + if (rc) { + rc = -1; + errno = -ENOENT; + goto out; + } + +out: + if (name) + free(name); + if (dir_name) + free(dir_name); + if (parent) + dfs_release(parent); + return rc; +} + +static int +DFS_Stat (const char *path, struct stat *buf, IOR_param_t * param) +{ + dfs_obj_t *parent = NULL; + mode_t pmode; + char *name = NULL, *dir_name = NULL; + int rc; + + rc = parse_filename(path, &name, &dir_name); + if (rc) + return rc; + + assert(dir_name); + assert(name); + + rc = dfs_lookup(dfs, dir_name, &parent, &pmode); + if (rc || !S_ISDIR(pmode)) + goto out; + + rc = dfs_stat(dfs, parent, name, buf); + if (rc) + goto out; + +out: + if (name) + free(name); + if (dir_name) + free(dir_name); + if (parent) + dfs_release(parent); + return rc; +} diff --git a/src/aiori.c b/src/aiori.c index 677c1ea..a40cbd6 100644 --- a/src/aiori.c +++ b/src/aiori.c @@ -51,6 +51,9 @@ ior_aiori_t *available_aiori[] = { &s3_aiori, &s3_plus_aiori, &s3_emc_aiori, +#endif +#ifdef USE_DFS_AIORI + &dfs_aiori, #endif NULL }; diff --git a/src/aiori.h b/src/aiori.h index 4ee400a..9e5695e 100755 --- a/src/aiori.h +++ b/src/aiori.h @@ -88,11 +88,15 @@ extern ior_aiori_t mmap_aiori; extern ior_aiori_t s3_aiori; extern ior_aiori_t s3_plus_aiori; extern ior_aiori_t s3_emc_aiori; +extern ior_aiori_t dfs_aiori; const ior_aiori_t *aiori_select (const char *api); int aiori_count (void); const char *aiori_default (void); +int dfs_init(void); +int dfs_finalize(void); + IOR_offset_t MPIIO_GetFileSize(IOR_param_t * test, MPI_Comm testComm, char *testFileName); diff --git a/src/ior.c b/src/ior.c index b92b40d..e4dc03b 100755 --- a/src/ior.c +++ b/src/ior.c @@ -733,7 +733,7 @@ static void DisplayUsage(char **argv) { char *opts[] = { "OPTIONS:", - " -a S api -- API for I/O [POSIX|MMAP|MPIIO|HDF5|HDFS|S3|S3_EMC|NCMPI]", + " -a S api -- API for I/O [POSIX|DFS|MMAP|MPIIO|HDF5|HDFS|S3|S3_EMC|NCMPI]", " -A N refNum -- user supplied reference number to include in the summary", " -b N blockSize -- contiguous bytes to write per task (e.g.: 8, 4k, 2m, 1g)", " -B useO_DIRECT -- uses O_DIRECT for POSIX, bypassing I/O buffers", @@ -2037,6 +2037,11 @@ static void TestIoSys(IOR_test_t *test) /* bind I/O calls to specific API */ AioriBind(params->api, params); +#ifdef USE_DFS_AIORI + if (strcmp(params->api, "DFS") == 0) + dfs_init(); +#endif + /* show test setup */ if (rank == 0 && verbose >= VERBOSE_0) ShowSetup(params); @@ -2310,6 +2315,10 @@ static void TestIoSys(IOR_test_t *test) /* Sync with the tasks that did not participate in this test */ MPI_CHECK(MPI_Barrier(MPI_COMM_WORLD), "barrier error"); +#ifdef USE_DFS_AIORI + if (strcmp(params->api, "DFS") == 0) + dfs_finalize(); +#endif } /* diff --git a/src/mdtest.c b/src/mdtest.c index aadbf78..3245c47 100644 --- a/src/mdtest.c +++ b/src/mdtest.c @@ -1936,6 +1936,11 @@ int main(int argc, char **argv) { } } +#ifdef USE_DFS_AIORI + if (strcmp(backend_name, "DFS") == 0) + dfs_init(); +#endif + if (!create_only && !stat_only && !read_only && !remove_only) { create_only = stat_only = read_only = remove_only = 1; if (( rank == 0 ) && ( verbose >= 1 )) { @@ -2411,6 +2416,11 @@ int main(int argc, char **argv) { free(rand_array); } +#ifdef USE_DFS_AIORI + if (strcmp(backend_name, "DFS") == 0) + dfs_finalize(); +#endif + MPI_Finalize(); exit(0); } From 1768eff5529f4b99cb322b096d2dd52546af8ac3 Mon Sep 17 00:00:00 2001 From: Mohamad Chaarawi Date: Wed, 20 Jun 2018 21:25:22 +0000 Subject: [PATCH 2/5] update DFS plugin Signed-off-by: Mohamad Chaarawi --- .gitignore | 4 ++ configure.ac | 14 +++++ src/aiori-DFS.c | 132 +++++++++++++++++++++++++++++++++++++++++++----- 3 files changed, 136 insertions(+), 14 deletions(-) diff --git a/.gitignore b/.gitignore index 73dd929..5ba0f00 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,8 @@ Makefile.in aclocal.m4 config.log config.status +COPYING +INSTALL config/compile config/config.guess config/config.sub @@ -11,11 +13,13 @@ config/install-sh config/missing configure contrib/.deps/ +contrib/cbif contrib/Makefile contrib/Makefile.in doc/Makefile doc/Makefile.in src/.deps/ +src/mdtest src/Makefile src/Makefile.in src/config.h diff --git a/configure.ac b/configure.ac index af6e49a..9394f59 100755 --- a/configure.ac +++ b/configure.ac @@ -142,6 +142,18 @@ AM_COND_IF([USE_POSIX_AIORI],[ AC_DEFINE([USE_POSIX_AIORI], [], [Build POSIX backend AIORI]) ]) +AC_ARG_WITH([cart], + [AS_HELP_STRING([--with-cart], + [Build DAOS ROMIO driver[default=no]])],, + [with_cart=no]) + +AS_IF([test "x$with_cart" != xno], + CART="yes" + LDFLAGS="$LDFLAGS -L$with_cart/lib" + CPPFLAGS="$CPPFLAGS -I$with_cart/include/" + AC_CHECK_HEADERS(gurt/common.h,, [unset CART]) + AC_CHECK_LIB([gurt], [d_rank_list_alloc],, [unset CART])) + # DFS IO support AC_ARG_WITH([daos], [AS_HELP_STRING([--with-daos], @@ -159,6 +171,8 @@ AS_IF([test "x$with_daos" != xno], AC_CHECK_LIB([daos], [daos_init],, [unset DAOS]) AC_CHECK_LIB([dfs], [dfs_mkdir],, [unset DAOS])) +AS_IF([test "x$CART" != xyes], [unset DAOS]) + AM_CONDITIONAL([USE_DFS_AIORI], [test x$DAOS = xyes]) AM_COND_IF([USE_DFS_AIORI],[ AC_DEFINE([USE_DFS_AIORI], [], [Build DFS backend AIORI]) diff --git a/src/aiori-DFS.c b/src/aiori-DFS.c index ad0c712..4e70d3b 100755 --- a/src/aiori-DFS.c +++ b/src/aiori-DFS.c @@ -36,6 +36,7 @@ #include "utilities.h" dfs_t *dfs; +daos_handle_t poh, coh; static int parse_filename(const char *path, char **_obj_name, char **_cont_name) @@ -151,20 +152,121 @@ ior_aiori_t dfs_aiori = { /***************************** F U N C T I O N S ******************************/ +/* MSC - Make a generic DAOS function instead */ +static d_rank_list_t * +daos_rank_list_parse(const char *str, const char *sep) +{ + d_rank_t *buf; + int cap = 8; + d_rank_list_t *ranks = NULL; + char *s, *p; + int n = 0; + + buf = malloc(sizeof(d_rank_t) * cap); + if (buf == NULL) + goto out; + s = strdup(str); + if (s == NULL) + goto out_buf; + + while ((s = strtok_r(s, sep, &p)) != NULL) { + if (n == cap) { + d_rank_t *buf_new; + int cap_new; + + /* Double the buffer. */ + cap_new = cap * 2; + buf_new = malloc(sizeof(d_rank_t) * cap_new); + if (buf_new == NULL) + goto out_s; + memcpy(buf_new, buf, sizeof(d_rank_t) * n); + free(buf); + buf = buf_new; + cap = cap_new; + } + buf[n] = atoi(s); + n++; + s = NULL; + } + + ranks = d_rank_list_alloc(n); + if (ranks == NULL) + goto out_s; + memcpy(ranks->rl_ranks, buf, sizeof(*buf) * n); + +out_s: + if (s) + free(s); +out_buf: + free(buf); +out: + return ranks; +} + int dfs_init(void) { - int rc; - + char *pool_str, *svcl_str, *group_str; + uuid_t pool_uuid, co_uuid; + daos_pool_info_t pool_info; + daos_cont_info_t co_info; + d_rank_list_t *svcl = NULL; + int rc; + rc = daos_init(); if (rc) { fprintf(stderr, "daos_init() failed with %d\n", rc); return rc; } - rc = dfs_mount(&dfs); + pool_str = getenv("DAOS_POOL"); + if (!pool_str) { + fprintf(stderr, "missing pool uuid\n"); + return -1; + } + if (uuid_parse(pool_str, pool_uuid) < 0) { + fprintf(stderr, "Invalid pool uuid\n"); + return -1; + } + + svcl_str = getenv("DAOS_SVCL"); + if (!svcl_str) { + fprintf(stderr, "missing pool service rank list\n"); + return -1; + } + svcl = daos_rank_list_parse(svcl_str, ":"); + if (svcl == NULL) { + fprintf(stderr, "Invalid pool service rank list\n"); + return -1; + } + + group_str = getenv("DAOS_GROUP"); + + /** Connect to DAOS pool */ + rc = daos_pool_connect(pool_uuid, group_str, svcl, DAOS_PC_RW, + &poh, &pool_info, NULL); + if (rc < 0) { + fprintf(stderr, "Failed to connect to pool %s %s (%d)\n", + pool_str, svcl_str, rc); + return -1; + } + + uuid_generate(co_uuid); + rc = daos_cont_create(poh, co_uuid, NULL); + if (rc) { + fprintf(stderr, "Failed to create container (%d)\n", rc); + return -1; + } + + rc = daos_cont_open(poh, co_uuid, DAOS_COO_RW, &coh, &co_info, NULL); + if (rc) { + fprintf(stderr, "Failed to open container (%d)\n", rc); + return -1; + } + + rc = dfs_mount(poh, coh, &dfs); if (rc) { fprintf(stderr, "dfs_mount failed (%d)\n", rc); - return 1; + return -1; } return rc; @@ -173,6 +275,8 @@ dfs_init(void) { int dfs_finalize(void) { dfs_umount(dfs); + daos_cont_close(coh, NULL); + daos_pool_disconnect(poh, NULL); daos_fini(); return 0; } @@ -198,7 +302,7 @@ DFS_Create(char *testFileName, IOR_param_t *param) assert(dir_name); assert(name); - rc = dfs_lookup(dfs, dir_name, &parent, &pmode); + rc = dfs_lookup(dfs, dir_name, O_RDWR, &parent, &pmode); if (rc || !S_ISDIR(pmode)) goto out; @@ -238,7 +342,7 @@ static void *DFS_Open(char *testFileName, IOR_param_t *param) assert(dir_name); assert(name); - rc = dfs_lookup(dfs, dir_name, &parent, &pmode); + rc = dfs_lookup(dfs, dir_name, O_RDWR, &parent, &pmode); if (rc || !S_ISDIR(pmode)) goto out; @@ -346,11 +450,11 @@ static void DFS_Delete(char *testFileName, IOR_param_t * param) assert(dir_name); assert(name); - rc = dfs_lookup(dfs, dir_name, &parent, &pmode); + rc = dfs_lookup(dfs, dir_name, O_RDWR, &parent, &pmode); if (rc || !S_ISDIR(pmode)) goto out; - rc = dfs_remove(dfs, parent, name); + rc = dfs_remove(dfs, parent, name, false); if (rc) goto out; @@ -381,7 +485,7 @@ static IOR_offset_t DFS_GetFileSize(IOR_param_t * test, MPI_Comm testComm, daos_size_t fsize, tmpMin, tmpMax, tmpSum; int rc; - rc = dfs_lookup(dfs, testFileName, &obj, NULL); + rc = dfs_lookup(dfs, testFileName, O_RDONLY, &obj, NULL); if (rc) return -1; @@ -436,7 +540,7 @@ DFS_Mkdir (const char *path, mode_t mode, IOR_param_t * param) assert(dir_name); assert(name); - rc = dfs_lookup(dfs, dir_name, &parent, &pmode); + rc = dfs_lookup(dfs, dir_name, O_RDWR, &parent, &pmode); if (rc || !S_ISDIR(pmode)) goto out; @@ -469,11 +573,11 @@ DFS_Rmdir (const char *path, IOR_param_t * param) assert(dir_name); assert(name); - rc = dfs_lookup(dfs, dir_name, &parent, &pmode); + rc = dfs_lookup(dfs, dir_name, O_RDWR, &parent, &pmode); if (rc || !S_ISDIR(pmode)) goto out; - rc = dfs_remove(dfs, parent, name); + rc = dfs_remove(dfs, parent, name, false); if (rc) goto out; @@ -503,7 +607,7 @@ DFS_Access (const char *path, int mode, IOR_param_t * param) assert(dir_name); assert(name); - rc = dfs_lookup(dfs, dir_name, &parent, &pmode); + rc = dfs_lookup(dfs, dir_name, O_RDWR, &parent, &pmode); if (rc || !S_ISDIR(pmode)) goto out; @@ -543,7 +647,7 @@ DFS_Stat (const char *path, struct stat *buf, IOR_param_t * param) assert(dir_name); assert(name); - rc = dfs_lookup(dfs, dir_name, &parent, &pmode); + rc = dfs_lookup(dfs, dir_name, O_RDONLY, &parent, &pmode); if (rc || !S_ISDIR(pmode)) goto out; From 07ec65c0d58adeacac4dd989190201350182b771 Mon Sep 17 00:00:00 2001 From: Mohamad Chaarawi Date: Thu, 19 Jul 2018 21:36:29 +0000 Subject: [PATCH 3/5] remoce rank_list_parse as it is exposed by DAOS API now. Signed-off-by: Mohamad Chaarawi --- src/aiori-DFS.c | 51 ------------------------------------------------- 1 file changed, 51 deletions(-) diff --git a/src/aiori-DFS.c b/src/aiori-DFS.c index 4e70d3b..6f0c07b 100755 --- a/src/aiori-DFS.c +++ b/src/aiori-DFS.c @@ -152,57 +152,6 @@ ior_aiori_t dfs_aiori = { /***************************** F U N C T I O N S ******************************/ -/* MSC - Make a generic DAOS function instead */ -static d_rank_list_t * -daos_rank_list_parse(const char *str, const char *sep) -{ - d_rank_t *buf; - int cap = 8; - d_rank_list_t *ranks = NULL; - char *s, *p; - int n = 0; - - buf = malloc(sizeof(d_rank_t) * cap); - if (buf == NULL) - goto out; - s = strdup(str); - if (s == NULL) - goto out_buf; - - while ((s = strtok_r(s, sep, &p)) != NULL) { - if (n == cap) { - d_rank_t *buf_new; - int cap_new; - - /* Double the buffer. */ - cap_new = cap * 2; - buf_new = malloc(sizeof(d_rank_t) * cap_new); - if (buf_new == NULL) - goto out_s; - memcpy(buf_new, buf, sizeof(d_rank_t) * n); - free(buf); - buf = buf_new; - cap = cap_new; - } - buf[n] = atoi(s); - n++; - s = NULL; - } - - ranks = d_rank_list_alloc(n); - if (ranks == NULL) - goto out_s; - memcpy(ranks->rl_ranks, buf, sizeof(*buf) * n); - -out_s: - if (s) - free(s); -out_buf: - free(buf); -out: - return ranks; -} - int dfs_init(void) { char *pool_str, *svcl_str, *group_str; From 5fb850c8108eb3c06fa3d0201908b3bc074a20bb Mon Sep 17 00:00:00 2001 From: Mohamad Chaarawi Date: Thu, 23 Aug 2018 21:58:53 +0000 Subject: [PATCH 4/5] - update the DFS driver to latest DFS API. - update cmd line options to add DAOS Pool and Container uuid and SVCL - Add init/finalize backend functions. Signed-off-by: Mohamad Chaarawi --- src/aiori-DFS.c | 195 +++++++++++++++++++++++++++++--------------- src/aiori.h | 5 +- src/ior.c | 17 ++-- src/ior.h | 6 ++ src/mdtest.c | 95 +++++++++++++++++---- src/parse_options.c | 9 +- 6 files changed, 231 insertions(+), 96 deletions(-) diff --git a/src/aiori-DFS.c b/src/aiori-DFS.c index 6f0c07b..f22bbbd 100755 --- a/src/aiori-DFS.c +++ b/src/aiori-DFS.c @@ -6,6 +6,14 @@ * Copyright (c) 2003, The Regents of the University of California * * See the file COPYRIGHT for a complete copyright notice and license. * * * +* Copyright (C) 2018 Intel Corporation +* +* GOVERNMENT LICENSE RIGHTS-OPEN SOURCE SOFTWARE +* The Government's rights to use, modify, reproduce, release, perform, display, +* or disclose this software are subject to the terms of the Apache License as +* provided in Contract No. 8F-30005. +* Any reproduction of computer software, computer software documentation, or +* portions thereof marked with this legend must also reproduce the markings. ******************************************************************************** * * Implement of abstract I/O interface for DFS. @@ -70,10 +78,11 @@ parse_filename(const char *path, char **_obj_name, char **_cont_name) cont_name = dirname(f2); if (cont_name[0] == '.' || cont_name[0] != '/') { - char *cwd; + char cwd[1024]; + + if (getcwd(cwd, 1024) == NULL) + D_GOTO(out, rc = -ENOMEM); - //getcwd(cwd, 1024); - cwd = strdup("/"); if (strcmp(cont_name, ".") == 0) { cont_name = strdup(cwd); if (cont_name == NULL) @@ -130,6 +139,8 @@ 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 int DFS_Init(IOR_param_t *param); +static int DFS_Finalize(IOR_param_t *param); /************************** D E C L A R A T I O N S ***************************/ @@ -148,85 +159,122 @@ ior_aiori_t dfs_aiori = { .rmdir = DFS_Rmdir, .access = DFS_Access, .stat = DFS_Stat, + .init = DFS_Init, + .finalize = DFS_Finalize, }; /***************************** F U N C T I O N S ******************************/ -int -dfs_init(void) { - char *pool_str, *svcl_str, *group_str; +static int +DFS_Init(IOR_param_t *param) { uuid_t pool_uuid, co_uuid; daos_pool_info_t pool_info; daos_cont_info_t co_info; d_rank_list_t *svcl = NULL; + bool cont_created = false; int rc; - + + if (uuid_parse(param->daosPool, pool_uuid) < 0) { + fprintf(stderr, "Invalid pool uuid\n"); + return -1; + } + + if (uuid_parse(param->daosCont, co_uuid) < 0) { + fprintf(stderr, "Invalid pool uuid\n"); + return -1; + } + + svcl = daos_rank_list_parse(param->daosPoolSvc, ":"); + if (svcl == NULL) { + fprintf(stderr, "Invalid pool service rank list\n"); + return -1; + } + + printf("Pool uuid = %s, SVCL = %s\n", param->daosPool, + param->daosPoolSvc); + + printf("DFS Container namespace uuid = %s\n", param->daosCont); + rc = daos_init(); if (rc) { fprintf(stderr, "daos_init() failed with %d\n", rc); return rc; } - pool_str = getenv("DAOS_POOL"); - if (!pool_str) { - fprintf(stderr, "missing pool uuid\n"); - return -1; - } - if (uuid_parse(pool_str, pool_uuid) < 0) { - fprintf(stderr, "Invalid pool uuid\n"); - return -1; - } - - svcl_str = getenv("DAOS_SVCL"); - if (!svcl_str) { - fprintf(stderr, "missing pool service rank list\n"); - return -1; - } - svcl = daos_rank_list_parse(svcl_str, ":"); - if (svcl == NULL) { - fprintf(stderr, "Invalid pool service rank list\n"); - return -1; - } - - group_str = getenv("DAOS_GROUP"); - /** Connect to DAOS pool */ - rc = daos_pool_connect(pool_uuid, group_str, svcl, DAOS_PC_RW, - &poh, &pool_info, NULL); + rc = daos_pool_connect(pool_uuid, + strlen(param->daosGroup) ? param->daosGroup : NULL, + svcl, DAOS_PC_RW, &poh, &pool_info, NULL); if (rc < 0) { - fprintf(stderr, "Failed to connect to pool %s %s (%d)\n", - pool_str, svcl_str, rc); - return -1; + fprintf(stderr, "Failed to connect to pool (%d)\n", rc); + goto err_daos; } - uuid_generate(co_uuid); - rc = daos_cont_create(poh, co_uuid, NULL); + rc = daos_cont_open(poh, co_uuid, DAOS_COO_RW, &coh, &co_info, NULL); + /* If NOEXIST we create it */ + if (rc == -DER_NONEXIST) { + printf("Creating DFS Container ...\n"); + rc = daos_cont_create(poh, co_uuid, NULL); + if (rc == 0) { + cont_created = true; + rc = daos_cont_open(poh, co_uuid, DAOS_COO_RW, &coh, + &co_info, NULL); + } + } if (rc) { fprintf(stderr, "Failed to create container (%d)\n", rc); - return -1; + goto err_pool; } - rc = daos_cont_open(poh, co_uuid, DAOS_COO_RW, &coh, &co_info, NULL); - if (rc) { - fprintf(stderr, "Failed to open container (%d)\n", rc); - return -1; - } - - rc = dfs_mount(poh, coh, &dfs); + rc = dfs_mount(poh, coh, O_RDWR, &dfs); if (rc) { fprintf(stderr, "dfs_mount failed (%d)\n", rc); - return -1; + goto err_cont; } +out: + daos_rank_list_free(svcl); return rc; +err_cont: + daos_cont_close(coh, NULL); +err_pool: + if (cont_created) + daos_cont_destroy(poh, co_uuid, 1, NULL); + daos_pool_disconnect(poh, NULL); +err_daos: + daos_fini(); + goto out; } -int dfs_finalize(void) +int +DFS_Finalize(IOR_param_t *param) { - dfs_umount(dfs); - daos_cont_close(coh, NULL); + int rc; + + rc = dfs_umount(dfs, true); + if (rc) { + fprintf(stderr, "dfs_umount() failed (%d)\n", rc); + return -1; + } + + rc = daos_cont_close(coh, NULL); + if (rc) { + fprintf(stderr, "daos_cont_close() failed (%d)\n", rc); + return -1; + } + daos_pool_disconnect(poh, NULL); - daos_fini(); + if (rc) { + fprintf(stderr, "daos_pool_disconnect() failed (%d)\n", rc); + return -1; + } + + rc = daos_fini(); + if (rc) { + fprintf(stderr, "daos_fini() failed (%d)\n", rc); + return -1; + } + return 0; } @@ -238,11 +286,14 @@ DFS_Create(char *testFileName, IOR_param_t *param) { char *name = NULL, *dir_name = NULL; dfs_obj_t *obj = NULL, *parent = NULL; - mode_t pmode; + mode_t pmode, mode; int fd_oflag = 0; int rc; + assert(param); + fd_oflag |= O_CREAT | O_RDWR; + mode = S_IFREG | param->mode; rc = parse_filename(testFileName, &name, &dir_name); if (rc) @@ -255,8 +306,8 @@ DFS_Create(char *testFileName, IOR_param_t *param) if (rc || !S_ISDIR(pmode)) goto out; - mode_t mode = S_IFREG | param->mode; - rc = dfs_open(dfs, parent, name, mode, fd_oflag, NULL, &obj); + rc = dfs_open(dfs, parent, name, mode, fd_oflag, DAOS_OC_LARGE_RW, + NULL, &obj); if (rc) goto out; @@ -274,7 +325,8 @@ out: /* * Open a file through the DFS interface. */ -static void *DFS_Open(char *testFileName, IOR_param_t *param) +static void * +DFS_Open(char *testFileName, IOR_param_t *param) { char *name = NULL, *dir_name = NULL; dfs_obj_t *obj = NULL, *parent = NULL; @@ -295,7 +347,7 @@ static void *DFS_Open(char *testFileName, IOR_param_t *param) if (rc || !S_ISDIR(pmode)) goto out; - rc = dfs_open(dfs, parent, name, S_IFREG, fd_oflag, NULL, &obj); + rc = dfs_open(dfs, parent, name, S_IFREG, fd_oflag, 0, NULL, &obj); if (rc) goto out; @@ -369,15 +421,18 @@ 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) +static void +DFS_Fsync(void *fd, IOR_param_t * param) { + dfs_sync(dfs); return; } /* * Close a file through the DFS interface. */ -static void DFS_Close(void *fd, IOR_param_t * param) +static void +DFS_Close(void *fd, IOR_param_t * param) { dfs_release((dfs_obj_t *)fd); } @@ -385,7 +440,8 @@ static void 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) +static void +DFS_Delete(char *testFileName, IOR_param_t * param) { char *name = NULL, *dir_name = NULL; dfs_obj_t *parent = NULL; @@ -419,7 +475,8 @@ out: /* * Determine api version. */ -static void DFS_SetVersion(IOR_param_t * test) +static void +DFS_SetVersion(IOR_param_t * test) { strcpy(test->apiVersion, test->api); } @@ -427,8 +484,8 @@ static void DFS_SetVersion(IOR_param_t * test) /* * Use DFS stat() to return aggregate file size. */ -static IOR_offset_t DFS_GetFileSize(IOR_param_t * test, MPI_Comm testComm, - char *testFileName) +static IOR_offset_t +DFS_GetFileSize(IOR_param_t * test, MPI_Comm testComm, char *testFileName) { dfs_obj_t *obj; daos_size_t fsize, tmpMin, tmpMax, tmpSum; @@ -475,7 +532,7 @@ DFS_Statfs(const char *path, ior_aiori_statfs_t *sfs, IOR_param_t * param) } static int -DFS_Mkdir (const char *path, mode_t mode, IOR_param_t * param) +DFS_Mkdir(const char *path, mode_t mode, IOR_param_t * param) { dfs_obj_t *parent = NULL; mode_t pmode; @@ -504,11 +561,13 @@ out: free(dir_name); if (parent) dfs_release(parent); + if (rc) + return -1; return rc; } static int -DFS_Rmdir (const char *path, IOR_param_t * param) +DFS_Rmdir(const char *path, IOR_param_t * param) { dfs_obj_t *parent = NULL; mode_t pmode; @@ -537,11 +596,13 @@ out: free(dir_name); if (parent) dfs_release(parent); + if (rc) + return -1; return rc; } static int -DFS_Access (const char *path, int mode, IOR_param_t * param) +DFS_Access(const char *path, int mode, IOR_param_t * param) { dfs_obj_t *parent = NULL; mode_t pmode; @@ -578,11 +639,13 @@ out: free(dir_name); if (parent) dfs_release(parent); + if (rc) + return -1; return rc; } static int -DFS_Stat (const char *path, struct stat *buf, IOR_param_t * param) +DFS_Stat(const char *path, struct stat *buf, IOR_param_t * param) { dfs_obj_t *parent = NULL; mode_t pmode; @@ -611,5 +674,7 @@ out: free(dir_name); if (parent) dfs_release(parent); + if (rc) + return -1; return rc; } diff --git a/src/aiori.h b/src/aiori.h index 9e5695e..b2c4818 100755 --- a/src/aiori.h +++ b/src/aiori.h @@ -77,6 +77,8 @@ typedef struct ior_aiori { int (*rmdir) (const char *path, IOR_param_t * param); int (*access) (const char *path, int mode, IOR_param_t * param); int (*stat) (const char *path, struct stat *buf, IOR_param_t * param); + int (*init)(IOR_param_t *); + int (*finalize)(IOR_param_t *); } ior_aiori_t; extern ior_aiori_t hdf5_aiori; @@ -94,9 +96,6 @@ const ior_aiori_t *aiori_select (const char *api); int aiori_count (void); const char *aiori_default (void); -int dfs_init(void); -int dfs_finalize(void); - IOR_offset_t MPIIO_GetFileSize(IOR_param_t * test, MPI_Comm testComm, char *testFileName); diff --git a/src/ior.c b/src/ior.c index e4dc03b..aa64436 100755 --- a/src/ior.c +++ b/src/ior.c @@ -2037,10 +2037,10 @@ static void TestIoSys(IOR_test_t *test) /* bind I/O calls to specific API */ AioriBind(params->api, params); -#ifdef USE_DFS_AIORI - if (strcmp(params->api, "DFS") == 0) - dfs_init(); -#endif + /* initialize API session */ + if (backend->init != NULL) + if (backend->init(params) != 0) + ERR("Could not init backend"); /* show test setup */ if (rank == 0 && verbose >= VERBOSE_0) @@ -2312,13 +2312,12 @@ static void TestIoSys(IOR_test_t *test) free(timer[i]); } + /* finalize API session */ + if (backend->finalize != NULL) + backend->finalize(params); + /* Sync with the tasks that did not participate in this test */ MPI_CHECK(MPI_Barrier(MPI_COMM_WORLD), "barrier error"); - -#ifdef USE_DFS_AIORI - if (strcmp(params->api, "DFS") == 0) - dfs_finalize(); -#endif } /* diff --git a/src/ior.h b/src/ior.h index ce1b4ec..31b962a 100755 --- a/src/ior.h +++ b/src/ior.h @@ -213,6 +213,12 @@ typedef struct int beegfs_numTargets; /* number storage targets to use */ int beegfs_chunkSize; /* srtipe pattern for new files */ + /* daos variables */ + char daosGroup[MAX_STR]; /* group name */ + char daosPool[37]; /* pool UUID */ + char daosPoolSvc[MAX_STR]; /* pool service ranks */ + char daosCont[37]; /* Container UUID */ + int id; /* test's unique ID */ int intraTestBarriers; /* barriers between open/op and op/close */ } IOR_param_t; diff --git a/src/mdtest.c b/src/mdtest.c index 3245c47..b95211d 100644 --- a/src/mdtest.c +++ b/src/mdtest.c @@ -1801,6 +1801,59 @@ void create_remove_directory_tree(int create, } } +/* + * Set flags from commandline string/value pairs. + */ +static void +DecodeDirective(char *line, IOR_param_t *params) +{ + char option[MAX_STR]; + char value[MAX_STR]; + int rc; + + rc = sscanf(line, " %[^=# \t\r\n] = %[^# \t\r\n] ", option, value); + if (rc != 2 && rank == 0) { + fprintf(stdout, "Syntax error in configuration options: %s\n", + line); + MPI_CHECK(MPI_Abort(MPI_COMM_WORLD, -1), "MPI_Abort() error"); + } + + if (strcasecmp(option, "daospool") == 0) { + strcpy(params->daosPool, value); + } else if (strcasecmp(option, "daospoolsvc") == 0) { + strcpy(params->daosPoolSvc, value); + } else if (strcasecmp(option, "daosgroup") == 0) { + strcpy(params->daosGroup, value); + } else if (strcasecmp(option, "daoscont") == 0) { + strcpy(params->daosCont, value); + } + else { + if (rank == 0) + fprintf(stdout, "Unrecognized parameter \"%s\"\n", + option); + MPI_CHECK(MPI_Abort(MPI_COMM_WORLD, -1), "MPI_Abort() error"); + } +} + +/* + * Parse a single line, which may contain multiple comma-seperated directives + */ +static void +ParseLine(char *line, IOR_param_t * test) +{ + char *start, *end; + + start = line; + do { + end = strchr(start, ','); + if (end != NULL) + *end = '\0'; + DecodeDirective(start, test); + start = end + 1; + } while (end != NULL); + +} + int main(int argc, char **argv) { int i, j, k, c; int nodeCount; @@ -1853,7 +1906,7 @@ int main(int argc, char **argv) { /* Parse command line options */ while (1) { - c = getopt(argc, argv, "a:b:BcCd:De:Ef:Fhi:I:l:Ln:N:p:rR::s:StTuvV:w:yz:"); + c = getopt(argc, argv, "a:b:BcCd:De:Ef:Fhi:I:l:Ln:N:O:p:rR::s:StTuvV:w:yz:"); if (c == -1) { break; } @@ -1898,6 +1951,9 @@ int main(int argc, char **argv) { //items = atoi(optarg); break; case 'N': nstride = atoi(optarg); break; + case 'O': + ParseLine(optarg, ¶m); + break; case 'p': pre_delay = atoi(optarg); break; case 'r': @@ -1936,11 +1992,6 @@ int main(int argc, char **argv) { } } -#ifdef USE_DFS_AIORI - if (strcmp(backend_name, "DFS") == 0) - dfs_init(); -#endif - if (!create_only && !stat_only && !read_only && !remove_only) { create_only = stat_only = read_only = remove_only = 1; if (( rank == 0 ) && ( verbose >= 1 )) { @@ -2082,6 +2133,11 @@ int main(int argc, char **argv) { FAIL("Could not find suitable backend to use"); } + /* initialize API session */ + if (backend->init != NULL) + if (backend->init(¶m) != 0) + FAIL("Could not init backend"); + /* if directory does not exist, create it */ if ((rank < path_count) && backend->access(testdirpath, F_OK, ¶m) != 0) { if (backend->mkdir(testdirpath, DIRMODE, ¶m) != 0) { @@ -2090,16 +2146,20 @@ int main(int argc, char **argv) { } /* display disk usage */ - if (verbose >= 3 && rank == 0) { - printf( "V-3: main (before display_freespace): testdirpath is \"%s\"\n", testdirpath ); - fflush( stdout ); - } + if (strcmp(backend->name, "DFS")) { + if (verbose >= 3 && rank == 0) { + printf( "V-3: main (before display_freespace): testdirpath is \"%s\"\n", + testdirpath ); + fflush( stdout ); + } - if (rank == 0) display_freespace(testdirpath); + if (rank == 0) display_freespace(testdirpath); - if (verbose >= 3 && rank == 0) { - printf( "V-3: main (after display_freespace): testdirpath is \"%s\"\n", testdirpath ); - fflush( stdout ); + if (verbose >= 3 && rank == 0) { + printf( "V-3: main (after display_freespace): testdirpath is \"%s\"\n", + testdirpath ); + fflush( stdout ); + } } if (rank == 0) { @@ -2416,10 +2476,9 @@ int main(int argc, char **argv) { free(rand_array); } -#ifdef USE_DFS_AIORI - if (strcmp(backend_name, "DFS") == 0) - dfs_finalize(); -#endif + /* finalize API session */ + if (backend->finalize != NULL) + backend->finalize(¶m); MPI_Finalize(); exit(0); diff --git a/src/parse_options.c b/src/parse_options.c index cfa388a..1126559 100755 --- a/src/parse_options.c +++ b/src/parse_options.c @@ -327,7 +327,14 @@ void DecodeDirective(char *line, IOR_param_t *params) RecalculateExpectedFileSize(params); } else if (strcasecmp(option, "summaryalways") == 0) { params->summary_every_test = atoi(value); - } else { + } else if (strcasecmp(option, "daospool") == 0) { + strcpy(params->daosPool, value); + } else if (strcasecmp(option, "daospoolsvc") == 0) { + strcpy(params->daosPoolSvc, value); + } else if (strcasecmp(option, "daosgroup") == 0) { + strcpy(params->daosGroup, value); + } + else { if (rank == 0) fprintf(stdout, "Unrecognized parameter \"%s\"\n", option); From 14d67c19d9b4abb9c382f8b8f9a840a223ead1a8 Mon Sep 17 00:00:00 2001 From: Mohamad Chaarawi Date: Wed, 29 Aug 2018 22:25:48 +0000 Subject: [PATCH 5/5] fix DAOS plugin options passing. Signed-off-by: Mohamad Chaarawi --- src/aiori-DAOS.c | 45 ++++++++++++++++++++++----------------------- src/ior.c | 2 +- 2 files changed, 23 insertions(+), 24 deletions(-) diff --git a/src/aiori-DAOS.c b/src/aiori-DAOS.c index 73d7837..3aadba9 100644 --- a/src/aiori-DAOS.c +++ b/src/aiori-DAOS.c @@ -98,21 +98,23 @@ static void DAOS_Delete(char *, IOR_param_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 option_help * DAOS_options(); /************************** D E C L A R A T I O N S ***************************/ ior_aiori_t daos_aiori = { - .name = "DAOS", - .create = DAOS_Create, - .open = DAOS_Open, - .xfer = DAOS_Xfer, - .close = DAOS_Close, - .delete = DAOS_Delete, - .get_version = DAOS_GetVersion, - .fsync = DAOS_Fsync, - .get_file_size = DAOS_GetFileSize, - .initialize = DAOS_Init, - .finalize = DAOS_Fini, + .name = "DAOS", + .create = DAOS_Create, + .open = DAOS_Open, + .xfer = DAOS_Xfer, + .close = DAOS_Close, + .delete = DAOS_Delete, + .get_version = DAOS_GetVersion, + .fsync = DAOS_Fsync, + .get_file_size = DAOS_GetFileSize, + .initialize = DAOS_Init, + .finalize = DAOS_Fini, + .get_options = DAOS_options, }; enum handleType { @@ -536,13 +538,6 @@ static void ObjectClassParse(const char *string) GERR("Invalid 'daosObjectClass' argument: '%s'", string); } -static const char *GetGroup(IOR_param_t *param) -{ - if (strlen(o.daosGroup) == 0) - return NULL; - return o.daosGroup; -} - static void ParseService(IOR_param_t *param, int max, d_rank_list_t *ranks) { char *s; @@ -563,11 +558,15 @@ static void ParseService(IOR_param_t *param, int max, d_rank_list_t *ranks) free(s); } +static option_help * DAOS_options(){ + return options; +} + static void DAOS_Init(IOR_param_t *param) { int rc; - if (strlen(o.daosObjectClass) != 0) + if (o.daosObjectClass) ObjectClassParse(o.daosObjectClass); if (param->filePerProc) @@ -601,9 +600,9 @@ static void DAOS_Init(IOR_param_t *param) d_rank_t rank[13]; d_rank_list_t ranks; - if (strlen(o.daosPool) == 0) + if (o.daosPool == NULL) GERR("'daosPool' must be specified"); - if (strlen(o.daosPoolSvc) == 0) + if (o.daosPoolSvc == NULL) GERR("'daosPoolSvc' must be specified"); INFO(VERBOSE_2, param, "Connecting to pool %s %s", @@ -614,7 +613,7 @@ static void DAOS_Init(IOR_param_t *param) ranks.rl_ranks = rank; ParseService(param, sizeof(rank) / sizeof(rank[0]), &ranks); - rc = daos_pool_connect(uuid, GetGroup(param), &ranks, + rc = daos_pool_connect(uuid, o.daosGroup, &ranks, DAOS_PC_RW, &pool, &poolInfo, NULL /* ev */); DCHECK(rc, "Failed to connect to pool %s", o.daosPool); @@ -729,7 +728,7 @@ kill_daos_server(IOR_param_t *param) rank, info.pi_ndisabled, info.pi_ntargets); fflush(stdout); - rc = daos_mgmt_svc_rip(GetGroup(param), rank, true, NULL); + rc = daos_mgmt_svc_rip(o.daosGroup, rank, true, NULL); DCHECK(rc, "Error in killing server\n"); targets.rl_nr = 1; diff --git a/src/ior.c b/src/ior.c index 7c7dffe..781a134 100755 --- a/src/ior.c +++ b/src/ior.c @@ -1187,7 +1187,7 @@ static void TestIoSys(IOR_test_t *test) backend = aiori_select(params->api); if (backend->initialize) - backend->initialize(NULL); + backend->initialize(params); /* show test setup */ if (rank == 0 && verbose >= VERBOSE_0)