From 39eca1bb088c960299c8a14a90d25640ff0e3cfc Mon Sep 17 00:00:00 2001 From: Mohamad Chaarawi Date: Thu, 14 Mar 2019 21:17:37 +0000 Subject: [PATCH] add DAOS_Access routine to check if a container exists before deleting it. Signed-off-by: Mohamad Chaarawi --- src/aiori-DAOS.c | 26 ++++++++++++++++++++++++-- src/ior.c | 6 ++---- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/src/aiori-DAOS.c b/src/aiori-DAOS.c index f06c917..1555c57 100644 --- a/src/aiori-DAOS.c +++ b/src/aiori-DAOS.c @@ -83,6 +83,7 @@ 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 *); @@ -98,6 +99,7 @@ ior_aiori_t daos_aiori = { .name = "DAOS", .create = DAOS_Create, .open = DAOS_Open, + .access = DAOS_Access, .xfer = DAOS_Xfer, .close = DAOS_Close, .delete = DAOS_Delete, @@ -568,6 +570,26 @@ static void *DAOS_Create(char *testFileName, IOR_param_t *param) return DAOS_Open(testFileName, param); } +static int +DAOS_Access(const char *testFileName, int mode, IOR_param_t * param) +{ + uuid_t uuid; + unsigned int dFlags; + daos_handle_t coh; + daos_cont_info_t info; + int rc; + + rc = uuid_parse(testFileName, uuid); + DCHECK(rc, "Failed to parse 'testFile': %s", testFileName); + + rc = daos_cont_open(pool, uuid, DAOS_COO_RO, &coh, &info, NULL); + if (rc) + return rc; + + rc = daos_cont_close(coh, NULL); + return rc; +} + static void *DAOS_Open(char *testFileName, IOR_param_t *param) { struct fileDescriptor *fd; @@ -785,8 +807,8 @@ static void DAOS_Delete(char *testFileName, IOR_param_t *param) DCHECK(rc, "Failed to parse 'testFile': %s", testFileName); rc = daos_cont_destroy(pool, uuid, 1 /* force */, NULL /* ev */); - if (rc != -DER_NONEXIST) - DCHECK(rc, "Failed to destroy container %s", testFileName); + if (rc) + DCHECK(rc, "Failed to destroy container %s (%d)", testFileName, rc); } static char* DAOS_GetVersion() diff --git a/src/ior.c b/src/ior.c index 2a5532a..8dba156 100755 --- a/src/ior.c +++ b/src/ior.c @@ -910,8 +910,7 @@ static void RemoveFile(char *testFileName, int filePerProc, IOR_param_t * test) rankOffset = 0; GetTestFileName(testFileName, test); } - if (backend->access(testFileName, F_OK, test) == 0 || - strcasecmp(test->api, "DAOS") == 0) { + if (backend->access(testFileName, F_OK, test) == 0) { backend->delete(testFileName, test); } if (test->reorderTasksRandom == TRUE) { @@ -919,8 +918,7 @@ static void RemoveFile(char *testFileName, int filePerProc, IOR_param_t * test) GetTestFileName(testFileName, test); } } else { - if ((rank == 0) && (backend->access(testFileName, F_OK, test) == 0 || - strcasecmp(test->api, "DAOS") == 0)) { + if (rank == 0 && backend->access(testFileName, F_OK, test) == 0) { backend->delete(testFileName, test); } }