From 47bbf670e5614fb19f4da301ef71a906db665537 Mon Sep 17 00:00:00 2001 From: Neil Fortner Date: Wed, 1 Feb 2017 11:41:04 -0600 Subject: H5F_ACC_TRUNC now correctly deletes the file (container) before creating it. H5F_ACC_EXCL not currently implemented. --- src/H5VLdaosm.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/src/H5VLdaosm.c b/src/H5VLdaosm.c index dcfcd24..d5d3df3 100644 --- a/src/H5VLdaosm.c +++ b/src/H5VLdaosm.c @@ -714,20 +714,16 @@ H5VL_daosm_file_create(const char *name, unsigned flags, hid_t fcpl_id, if(0 != (ret = daos_pool_connect(fa->pool_uuid, fa->pool_grp, NULL /*pool_svc*/, DAOS_PC_RW, &file->poh, NULL /*&file->pool_info*/, NULL /*event*/))) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "can't connect to pool: %d", ret) + /* Delete the container if H5F_ACC_TRUNC is set. This shouldn't cause a + * problem even if the container doesn't exist. */ + /* Need to handle EXCL correctly DSMINC */ + if(flags & H5F_ACC_TRUNC) + if(0 != (ret = daos_cont_destroy(file->poh, file->uuid, 1, NULL /*event*/))) + HGOTO_ERROR(H5E_FILE, H5E_CANTCREATE, NULL, "can't destroy container: %d", ret) + /* Create the container for the file */ - if(0 != (ret = daos_cont_create(file->poh, file->uuid, NULL /*event*/))) { - /* Check for failure due to the container already existing and - * opening with H5F_ACC_TRUNC */ - if((ret == -(int)DER_EXIST) && (flags & H5F_ACC_TRUNC)) { - /* Destroy and re-create container */ - if(0 != (ret = daos_cont_destroy(file->poh, file->uuid, 0, NULL /*event*/))) - HGOTO_ERROR(H5E_FILE, H5E_CANTCREATE, NULL, "can't destroy container: %d", ret) - if(0 != (ret = daos_cont_create(file->poh, file->uuid, NULL /*event*/))) - HGOTO_ERROR(H5E_FILE, H5E_CANTCREATE, NULL, "can't create container: %d", ret) - } /* end if */ - else - HGOTO_ERROR(H5E_FILE, H5E_CANTCREATE, NULL, "can't create container: %d", ret) - } /* end if */ + if(0 != (ret = daos_cont_create(file->poh, file->uuid, NULL /*event*/))) + HGOTO_ERROR(H5E_FILE, H5E_CANTCREATE, NULL, "can't create container: %d", ret) /* Open the container */ if(0 != (ret = daos_cont_open(file->poh, file->uuid, DAOS_COO_RW, &file->coh, NULL /*&file->co_info*/, NULL /*event*/))) -- cgit v0.12