summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeil Fortner <nfortne2@hdfgroup.org>2017-05-01 22:25:02 (GMT)
committerNeil Fortner <nfortne2@hdfgroup.org>2017-05-01 22:25:02 (GMT)
commit58c4806cd961e30d9b5658ca449bcb695e7fcb56 (patch)
tree14cf3d453e5824ef88532cb04ea8fdb94590dfbe
parent72b57518eb02e1df92d0e3ae7b29f09bbafe937c (diff)
downloadhdf5-58c4806cd961e30d9b5658ca449bcb695e7fcb56.zip
hdf5-58c4806cd961e30d9b5658ca449bcb695e7fcb56.tar.gz
hdf5-58c4806cd961e30d9b5658ca449bcb695e7fcb56.tar.bz2
Implement H5Oopen, H5Oopen_by_addr, H5Acreate_by_name, H5Aopen_by_name,
and H5Aiterate_by_name. Add h5dsm_obj_open.c example. Fix memory leak on dataset open. Other minor fixes/cleanup.
-rw-r--r--examples/h5dsm_attr_create.c25
-rw-r--r--examples/h5dsm_attr_iter.c27
-rw-r--r--examples/h5dsm_attr_open.c27
-rw-r--r--examples/h5dsm_attr_read.c27
-rw-r--r--examples/h5dsm_attr_write.c25
-rw-r--r--examples/h5dsm_group_open.c1
-rw-r--r--examples/h5dsm_link_exists.c1
-rw-r--r--examples/h5dsm_obj_open.c88
-rw-r--r--examples/h5dsm_ttconv.c20
-rw-r--r--src/H5VLdaosm.c473
10 files changed, 514 insertions, 200 deletions
diff --git a/examples/h5dsm_attr_create.c b/examples/h5dsm_attr_create.c
index d4281b4..50a9acf 100644
--- a/examples/h5dsm_attr_create.c
+++ b/examples/h5dsm_attr_create.c
@@ -3,14 +3,14 @@
int main(int argc, char *argv[]) {
uuid_t pool_uuid;
char *pool_grp = NULL;
- hid_t file = -1, obj = -1, attr = -1, space = -1, fapl = -1;
+ hid_t file = -1, attr = -1, space = -1, fapl = -1;
hsize_t dims[2] = {4, 6};
H5VL_daosm_snap_id_t snap_id;
(void)MPI_Init(&argc, &argv);
- if(argc < 6 || argc > 7)
- PRINTF_ERROR("argc must be 6 or 7\n");
+ if(argc < 5 || argc > 6)
+ PRINTF_ERROR("argc must be 5 or 6\n");
/* Parse UUID */
if(0 != uuid_parse(argv[1], pool_uuid))
@@ -36,26 +36,14 @@ int main(int argc, char *argv[]) {
if((file = H5Fopen(argv[2], H5F_ACC_RDWR, fapl)) < 0)
ERROR;
- /* Open object */
- if(!strcmp(argv[3], "-d") || !strcmp(argv[3], "-D")) {
- if((obj = H5Dopen2(file, argv[4], H5P_DEFAULT)) < 0)
- ERROR;
- }
- else {
- if(strcmp(argv[3], "-g") && strcmp(argv[3], "-G"))
- PRINTF_ERROR("argv[3] must be -d, -D, -g, or -G\n");
- if((obj = H5Gopen2(file, argv[4], H5P_DEFAULT)) < 0)
- ERROR;
- }
-
printf("Creating attribute\n");
/* Create attribute */
- if((attr = H5Acreate2(obj, argv[5], H5T_NATIVE_INT, space, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ if((attr = H5Acreate_by_name(file, argv[3], argv[4], H5T_NATIVE_INT, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
ERROR;
/* Save snapshot if requested */
- if(argc == 7) {
+ if(argc == 6) {
if(H5VLdaosm_snap_create(file, &snap_id) < 0)
ERROR;
printf("Saved snapshot: snap_id = %llu\n", (long long unsigned)snap_id);
@@ -64,8 +52,6 @@ int main(int argc, char *argv[]) {
/* Close */
if(H5Aclose(attr) < 0)
ERROR;
- if(H5Oclose(obj) < 0)
- ERROR;
if(H5Fclose(file) < 0)
ERROR;
if(H5Sclose(space) < 0)
@@ -81,7 +67,6 @@ int main(int argc, char *argv[]) {
error:
H5E_BEGIN_TRY {
H5Aclose(attr);
- H5Oclose(obj);
H5Fclose(file);
H5Sclose(space);
H5Pclose(fapl);
diff --git a/examples/h5dsm_attr_iter.c b/examples/h5dsm_attr_iter.c
index c29926e..5ec561c 100644
--- a/examples/h5dsm_attr_iter.c
+++ b/examples/h5dsm_attr_iter.c
@@ -20,15 +20,15 @@ error:
int main(int argc, char *argv[]) {
uuid_t pool_uuid;
char *pool_grp = NULL;
- hid_t file = -1, obj = -1, fapl = -1;
+ hid_t file = -1, fapl = -1;
hsize_t num_attr = 0;
herr_t ret;
H5VL_daosm_snap_id_t snap_id;
(void)MPI_Init(&argc, &argv);
- if(argc < 5 || argc > 6)
- PRINTF_ERROR("argc must be 5 or 6\n");
+ if(argc < 4 || argc > 5)
+ PRINTF_ERROR("argc must be 4 or 5\n");
/* Parse UUID */
if(0 != uuid_parse(argv[1], pool_uuid))
@@ -47,8 +47,8 @@ int main(int argc, char *argv[]) {
ERROR;
/* Open snapshot if specified */
- if(argc == 6) {
- snap_id = (H5VL_daosm_snap_id_t)atoi(argv[5]);
+ if(argc == 5) {
+ snap_id = (H5VL_daosm_snap_id_t)atoi(argv[4]);
printf("Opening snapshot %llu\n", (long long unsigned)snap_id);
if(H5Pset_daosm_snap_open(fapl, snap_id) < 0)
ERROR;
@@ -58,29 +58,15 @@ int main(int argc, char *argv[]) {
if((file = H5Fopen(argv[2], H5F_ACC_RDONLY, fapl)) < 0)
ERROR;
- /* Open object */
- if(!strcmp(argv[3], "-d") || !strcmp(argv[3], "-D")) {
- if((obj = H5Dopen2(file, argv[4], H5P_DEFAULT)) < 0)
- ERROR;
- }
- else {
- if(strcmp(argv[3], "-g") && strcmp(argv[3], "-G"))
- PRINTF_ERROR("argv[3] must be -d, -D, -g, or -G\n");
- if((obj = H5Gopen2(file, argv[4], H5P_DEFAULT)) < 0)
- ERROR;
- }
-
printf("Iterating over attributes\n");
/* Iterate */
- if((ret = H5Aiterate(obj, H5_INDEX_NAME, H5_ITER_NATIVE, &num_attr, iter_cb, &od_test_g)) < 0)
+ if((ret = H5Aiterate_by_name(file, argv[3], H5_INDEX_NAME, H5_ITER_NATIVE, &num_attr, iter_cb, &od_test_g, H5P_DEFAULT)) < 0)
ERROR;
printf("Complete. Number of attributes: %d\n", (int)num_attr);
/* Close */
- if(H5Oclose(obj) < 0)
- ERROR;
if(H5Fclose(file) < 0)
ERROR;
if(H5Pclose(fapl) < 0)
@@ -93,7 +79,6 @@ int main(int argc, char *argv[]) {
error:
H5E_BEGIN_TRY {
- H5Oclose(obj);
H5Fclose(file);
H5Pclose(fapl);
} H5E_END_TRY;
diff --git a/examples/h5dsm_attr_open.c b/examples/h5dsm_attr_open.c
index adc0ce2..30eb075 100644
--- a/examples/h5dsm_attr_open.c
+++ b/examples/h5dsm_attr_open.c
@@ -3,13 +3,13 @@
int main(int argc, char *argv[]) {
uuid_t pool_uuid;
char *pool_grp = NULL;
- hid_t file = -1, obj = -1, attr = -1, fapl = -1;
+ hid_t file = -1, attr = -1, fapl = -1;
H5VL_daosm_snap_id_t snap_id;
(void)MPI_Init(&argc, &argv);
- if(argc < 6 || argc > 7)
- PRINTF_ERROR("argc must be 6 or 7\n");
+ if(argc < 5 || argc > 6)
+ PRINTF_ERROR("argc must be 5 or 6\n");
/* Parse UUID */
if(0 != uuid_parse(argv[1], pool_uuid))
@@ -28,8 +28,8 @@ int main(int argc, char *argv[]) {
ERROR;
/* Open snapshot if specified */
- if(argc == 7) {
- snap_id = (H5VL_daosm_snap_id_t)atoi(argv[6]);
+ if(argc == 6) {
+ snap_id = (H5VL_daosm_snap_id_t)atoi(argv[5]);
printf("Opening snapshot %llu\n", (long long unsigned)snap_id);
if(H5Pset_daosm_snap_open(fapl, snap_id) < 0)
ERROR;
@@ -39,29 +39,15 @@ int main(int argc, char *argv[]) {
if((file = H5Fopen(argv[2], H5F_ACC_RDONLY, fapl)) < 0)
ERROR;
- /* Open object */
- if(!strcmp(argv[3], "-d") || !strcmp(argv[3], "-D")) {
- if((obj = H5Dopen2(file, argv[4], H5P_DEFAULT)) < 0)
- ERROR;
- }
- else {
- if(strcmp(argv[3], "-g") && strcmp(argv[3], "-G"))
- PRINTF_ERROR("argv[3] must be -d, -D, -g, or -G\n");
- if((obj = H5Gopen2(file, argv[4], H5P_DEFAULT)) < 0)
- ERROR;
- }
-
printf("Opening attribute\n");
/* Open attribute */
- if((attr = H5Aopen(obj, argv[5], H5P_DEFAULT)) < 0)
+ if((attr = H5Aopen_by_name(file, argv[3], argv[4], H5P_DEFAULT, H5P_DEFAULT)) < 0)
ERROR;
/* Close */
if(H5Aclose(attr) < 0)
ERROR;
- if(H5Oclose(obj) < 0)
- ERROR;
if(H5Fclose(file) < 0)
ERROR;
if(H5Pclose(fapl) < 0)
@@ -75,7 +61,6 @@ int main(int argc, char *argv[]) {
error:
H5E_BEGIN_TRY {
H5Aclose(attr);
- H5Oclose(obj);
H5Fclose(file);
H5Pclose(fapl);
} H5E_END_TRY;
diff --git a/examples/h5dsm_attr_read.c b/examples/h5dsm_attr_read.c
index 8059ba3..c316167 100644
--- a/examples/h5dsm_attr_read.c
+++ b/examples/h5dsm_attr_read.c
@@ -4,7 +4,7 @@
int main(int argc, char *argv[]) {
uuid_t pool_uuid;
char *pool_grp = NULL;
- hid_t file = -1, obj = -1, attr = -1, fapl = -1;
+ hid_t file = -1, attr = -1, fapl = -1;
int buf[4][6];
int i, j;
H5VL_daosm_snap_id_t snap_id;
@@ -14,8 +14,8 @@ int main(int argc, char *argv[]) {
/* Seed random number generator */
srand(time(NULL));
- if(argc < 6 || argc > 7)
- PRINTF_ERROR("argc must be 6 or 7\n");
+ if(argc < 5 || argc > 6)
+ PRINTF_ERROR("argc must be 5 or 6\n");
/* Parse UUID */
if(0 != uuid_parse(argv[1], pool_uuid))
@@ -34,8 +34,8 @@ int main(int argc, char *argv[]) {
ERROR;
/* Open snapshot if specified */
- if(argc == 7) {
- snap_id = (H5VL_daosm_snap_id_t)atoi(argv[6]);
+ if(argc == 6) {
+ snap_id = (H5VL_daosm_snap_id_t)atoi(argv[5]);
printf("Opening snapshot %llu\n", (long long unsigned)snap_id);
if(H5Pset_daosm_snap_open(fapl, snap_id) < 0)
ERROR;
@@ -45,20 +45,8 @@ int main(int argc, char *argv[]) {
if((file = H5Fopen(argv[2], H5F_ACC_RDONLY, fapl)) < 0)
ERROR;
- /* Open object */
- if(!strcmp(argv[3], "-d") || !strcmp(argv[3], "-D")) {
- if((obj = H5Dopen2(file, argv[4], H5P_DEFAULT)) < 0)
- ERROR;
- }
- else {
- if(strcmp(argv[3], "-g") && strcmp(argv[3], "-G"))
- PRINTF_ERROR("argv[3] must be -d, -D, -g, or -G\n");
- if((obj = H5Gopen2(file, argv[4], H5P_DEFAULT)) < 0)
- ERROR;
- }
-
/* Open attribute */
- if((attr = H5Aopen(obj, argv[5], H5P_DEFAULT)) < 0)
+ if((attr = H5Aopen_by_name(file, argv[3], argv[4], H5P_DEFAULT, H5P_DEFAULT)) < 0)
ERROR;
printf("Reading attribute\n");
@@ -83,8 +71,6 @@ int main(int argc, char *argv[]) {
/* Close */
if(H5Aclose(attr) < 0)
ERROR;
- if(H5Oclose(obj) < 0)
- ERROR;
if(H5Fclose(file) < 0)
ERROR;
if(H5Pclose(fapl) < 0)
@@ -98,7 +84,6 @@ int main(int argc, char *argv[]) {
error:
H5E_BEGIN_TRY {
H5Aclose(attr);
- H5Oclose(obj);
H5Fclose(file);
H5Pclose(fapl);
} H5E_END_TRY;
diff --git a/examples/h5dsm_attr_write.c b/examples/h5dsm_attr_write.c
index 1b233d2..8bb8f6e 100644
--- a/examples/h5dsm_attr_write.c
+++ b/examples/h5dsm_attr_write.c
@@ -4,7 +4,7 @@
int main(int argc, char *argv[]) {
uuid_t pool_uuid;
char *pool_grp = NULL;
- hid_t file = -1, obj = -1, attr = -1, fapl = -1;
+ hid_t file = -1, attr = -1, fapl = -1;
H5VL_daosm_snap_id_t snap_id;
int buf[4][6];
int i, j;
@@ -14,8 +14,8 @@ int main(int argc, char *argv[]) {
/* Seed random number generator */
srand(time(NULL));
- if(argc < 6 || argc > 7)
- PRINTF_ERROR("argc must be 6 or 7\n");
+ if(argc < 5 || argc > 6)
+ PRINTF_ERROR("argc must be 5 or 6\n");
/* Parse UUID */
if(0 != uuid_parse(argv[1], pool_uuid))
@@ -37,20 +37,8 @@ int main(int argc, char *argv[]) {
if((file = H5Fopen(argv[2], H5F_ACC_RDWR, fapl)) < 0)
ERROR;
- /* Open object */
- if(!strcmp(argv[3], "-d") || !strcmp(argv[3], "-D")) {
- if((obj = H5Dopen2(file, argv[4], H5P_DEFAULT)) < 0)
- ERROR;
- }
- else {
- if(strcmp(argv[3], "-g") && strcmp(argv[3], "-G"))
- PRINTF_ERROR("argv[3] must be -d, -D, -g, or -G\n");
- if((obj = H5Gopen2(file, argv[4], H5P_DEFAULT)) < 0)
- ERROR;
- }
-
/* Open attribute */
- if((attr = H5Aopen(obj, argv[5], H5P_DEFAULT)) < 0)
+ if((attr = H5Aopen_by_name(file, argv[3], argv[4], H5P_DEFAULT, H5P_DEFAULT)) < 0)
ERROR;
/* Fill and print buffer */
@@ -68,7 +56,7 @@ int main(int argc, char *argv[]) {
ERROR;
/* Save snapshot if requested */
- if(argc == 7) {
+ if(argc == 6) {
if(H5VLdaosm_snap_create(file, &snap_id) < 0)
ERROR;
printf("Saved snapshot: snap_id = %llu\n", (long long unsigned)snap_id);
@@ -77,8 +65,6 @@ int main(int argc, char *argv[]) {
/* Close */
if(H5Aclose(attr) < 0)
ERROR;
- if(H5Oclose(obj) < 0)
- ERROR;
if(H5Fclose(file) < 0)
ERROR;
if(H5Pclose(fapl) < 0)
@@ -92,7 +78,6 @@ int main(int argc, char *argv[]) {
error:
H5E_BEGIN_TRY {
H5Aclose(attr);
- H5Oclose(obj);
H5Fclose(file);
H5Pclose(fapl);
} H5E_END_TRY;
diff --git a/examples/h5dsm_group_open.c b/examples/h5dsm_group_open.c
index 54ebd92..77db2db 100644
--- a/examples/h5dsm_group_open.c
+++ b/examples/h5dsm_group_open.c
@@ -4,7 +4,6 @@ int main(int argc, char *argv[]) {
uuid_t pool_uuid;
char *pool_grp = NULL;
hid_t file = -1, grp = -1, fapl = -1;
- hsize_t dims[1] = {1};
H5VL_daosm_snap_id_t snap_id;
(void)MPI_Init(&argc, &argv);
diff --git a/examples/h5dsm_link_exists.c b/examples/h5dsm_link_exists.c
index 0ed091a..b3ed0fc 100644
--- a/examples/h5dsm_link_exists.c
+++ b/examples/h5dsm_link_exists.c
@@ -4,7 +4,6 @@ int main(int argc, char *argv[]) {
uuid_t pool_uuid;
char *pool_grp = NULL;
hid_t file = -1, fapl = -1;
- hsize_t dims[1] = {1};
H5VL_daosm_snap_id_t snap_id;
htri_t link_exists;
diff --git a/examples/h5dsm_obj_open.c b/examples/h5dsm_obj_open.c
new file mode 100644
index 0000000..05716d4
--- /dev/null
+++ b/examples/h5dsm_obj_open.c
@@ -0,0 +1,88 @@
+#include "h5dsm_example.h"
+
+int main(int argc, char *argv[]) {
+ uuid_t pool_uuid;
+ char *pool_grp = NULL;
+ hid_t file = -1, obj = -1, fapl = -1;
+ H5I_type_t obj_type;
+ char *obj_str = NULL;
+ hsize_t dims[1] = {1};
+ H5VL_daosm_snap_id_t snap_id;
+
+ (void)MPI_Init(&argc, &argv);
+
+ if(argc < 4 || argc > 5)
+ PRINTF_ERROR("argc must be 4 or 5\n");
+
+ /* Parse UUID */
+ if(0 != uuid_parse(argv[1], pool_uuid))
+ ERROR;
+
+ /* Initialize VOL */
+ if(H5VLdaosm_init(MPI_COMM_WORLD, pool_uuid, pool_grp) < 0)
+ ERROR;
+
+ /* Set up FAPL */
+ if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
+ ERROR;
+ if(H5Pset_fapl_daosm(fapl, MPI_COMM_WORLD, MPI_INFO_NULL) < 0)
+ ERROR;
+ if(H5Pset_all_coll_metadata_ops(fapl, true) < 0)
+ ERROR;
+
+ /* Open snapshot if specified */
+ if(argc == 5) {
+ snap_id = (H5VL_daosm_snap_id_t)atoi(argv[4]);
+ printf("Opening snapshot %llu\n", (long long unsigned)snap_id);
+ if(H5Pset_daosm_snap_open(fapl, snap_id) < 0)
+ ERROR;
+ } /* end if */
+
+ /* Open file */
+ if((file = H5Fopen(argv[2], H5F_ACC_RDONLY, fapl)) < 0)
+ ERROR;
+
+ printf("Opening object\n");
+
+ /* Open object */
+ if((obj = H5Oopen(file, argv[3], H5P_DEFAULT)) < 0)
+ ERROR;
+
+ /* Get object type */
+ if(H5I_BADID == (obj_type = H5Iget_type(obj)))
+ ERROR;
+
+ if(obj_type == H5I_GROUP)
+ obj_str = "group";
+ else if(obj_type == H5I_DATASET)
+ obj_str = "dataset";
+ else if(obj_type == H5I_DATATYPE)
+ obj_str = "datatype";
+ else
+ obj_str = "unknown";
+ printf("Object type is %s\n", obj_str);
+
+ /* Close */
+ if(H5Oclose(obj) < 0)
+ ERROR;
+ if(H5Fclose(file) < 0)
+ ERROR;
+ if(H5Pclose(fapl) < 0)
+ ERROR;
+
+ printf("Success\n");
+
+ (void)MPI_Finalize();
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ H5Oclose(obj);
+ H5Fclose(file);
+ H5Pclose(fapl);
+ } H5E_END_TRY;
+
+ (void)MPI_Finalize();
+ return 1;
+}
+
diff --git a/examples/h5dsm_ttconv.c b/examples/h5dsm_ttconv.c
index c59c86c..7aa0375 100644
--- a/examples/h5dsm_ttconv.c
+++ b/examples/h5dsm_ttconv.c
@@ -1852,18 +1852,6 @@ int main(int argc, char *argv[]) {
PRINTF_ERROR("Member c at location %d, %d does not match", i, j);
} /* end for */
- /*! ----------------------------------------------*/
- /*! Temporary hack until overwrites are supported */
- /* Fill in unwritten parts of file_buf_2, as read above */
- for(i = 0; i< dims[0]; i++) {
- file_buf2[i][0].a = (int)buf2[i][0].a;
- file_buf2[i][0].b = buf2[i][0].b;
- file_buf2[i][0].c = (double)buf2[i][0].c;
- file_buf2[i][1].b = buf2[i][1].b;
- file_buf2[i][1].c = (double)buf2[i][1].c;
- }
- /*! ----------------------------------------------*/
-
printf("\n");
/*
@@ -1904,6 +1892,10 @@ int main(int argc, char *argv[]) {
/* Check buffer */
for(i = 0; i< dims[0]; i++)
for(j = 0; j < dims[1]; j++) {
+ /*! ----------------------------------------------*/
+ /*! Temporary hack until overwrites are supported */
+ if((j == 1) || (i == 0) || (i == 3))
+ /*! ----------------------------------------------*/
if(((i == 1 || i == 2)
? (long long)file_buf2[i][j].a : buf2_init[i][j].a)
!= buf2[i][j].a)
@@ -1955,6 +1947,10 @@ int main(int argc, char *argv[]) {
/* Check buffer */
for(i = 0; i< dims[0]; i++)
for(j = 0; j < dims[1]; j++) {
+ /*! ----------------------------------------------*/
+ /*! Temporary hack until overwrites are supported */
+ if((j == 0) || (i == 1) || (i == 3))
+ /*! ----------------------------------------------*/
if(((j == 1) ? (long long)file_buf2[i / 2 + 1][i % 2].a
: buf2_init[i][j].a)
!= buf2[i][j].a)
diff --git a/src/H5VLdaosm.c b/src/H5VLdaosm.c
index 0924b77..8cce975 100644
--- a/src/H5VLdaosm.c
+++ b/src/H5VLdaosm.c
@@ -59,6 +59,13 @@ hid_t H5VL_DAOSM_g = -1;
#define H5VL_DAOSM_ITER_LEN 128
#define H5VL_DAOSM_ITER_SIZE_INIT (4 * 1024)
+/* Definitions for building oids */
+#define H5VL_DAOSM_IDX_MASK 0x3fffffffffffffffull
+#define H5VL_DAOSM_TYPE_MASK 0xc000000000000000ull
+#define H5VL_DAOSM_TYPE_GRP 0x0000000000000000ull
+#define H5VL_DAOSM_TYPE_DSET 0x4000000000000000ull
+#define H5VL_DAOSM_TYPE_DTYPE 0x8000000000000000ull
+
/* DAOSM-specific file access properties */
typedef struct H5VL_daosm_fapl_t {
MPI_Comm comm; /*communicator */
@@ -129,9 +136,15 @@ static herr_t H5VL_daosm_dataset_get(void *_dset, H5VL_dataset_get_t get_type,
static herr_t H5VL_daosm_dataset_close(void *_dset, hid_t dxpl_id, void **req);
/* Datatype callbacks */
+static void *H5VL_daosm_datatype_open(void *_item, H5VL_loc_params_t loc_params,
+ const char *name, hid_t tapl_id, hid_t dxpl_id, void **req);
static herr_t H5VL_daosm_datatype_close(void *_dtype, hid_t dxpl_id,
void **req);
+/* Object callbacks */
+static void *H5VL_daosm_object_open(void *_item, H5VL_loc_params_t loc_params,
+ H5I_type_t *opened_type, hid_t dxpl_id, void **req);
+
/* Attribute callbacks */
static void *H5VL_daosm_attribute_create(void *_obj,
H5VL_loc_params_t loc_params, const char *name, hid_t acpl_id,
@@ -185,6 +198,7 @@ static herr_t H5VL_daosm_sel_to_recx_iov(H5S_t *space, size_t type_size,
void *buf, daos_recx_t **recxs, daos_iov_t **sg_iovs, size_t *list_nused);
static herr_t H5VL_daosm_scatter_cb(const void **src_buf,
size_t *src_buf_bytes_used, void *_udata);
+
static herr_t H5VL_daosm_object_close(void *_obj, hid_t dxpl_id, void **req);
/* Free list definitions */
@@ -256,7 +270,7 @@ static H5VL_class_t H5VL_daosm_g = {
NULL /* optional */
},
{ /* object_cls */
- NULL,//H5VL_iod_object_open, /* open */
+ H5VL_daosm_object_open, /* open */
NULL, /* copy */
NULL, /* get */
NULL,//H5VL_iod_object_specific, /* specific */
@@ -485,6 +499,16 @@ H5VL_daosm_init(void)
FUNC_ENTER_NOAPI(FAIL)
+ /* Register interfaces that might not be initialized in time (for example if
+ * we open an object without knowing its type first, H5Oopen will not
+ * initialize that type) */
+ if(H5G_init() < 0)
+ HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL, "unable to initialize group interface")
+ if(H5D_init() < 0)
+ HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL, "unable to initialize dataset interface")
+ if(H5T_init() < 0)
+ HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL, "unable to initialize datatype interface")
+
/* Register the DAOS-M VOL, if it isn't already */
if(NULL == H5I_object_verify(H5VL_DAOSM_g, H5I_VOL)) {
if((H5VL_DAOSM_g = H5VL_register((const H5VL_class_t *)&H5VL_daosm_g,
@@ -781,6 +805,60 @@ done:
} /* end H5VL_daosm_fapl_free() */
+/* Create a DAOS oid given the object type and a 64 bit index (top 2 bits are
+ * ignored) */
+static void
+H5VL_daosm_oid_encode(daos_obj_id_t *oid, H5I_type_t obj_type, uint64_t idx)
+{
+ uint64_t type_bits;
+
+ /* Set type_bits */
+ if(obj_type == H5I_GROUP)
+ type_bits = H5VL_DAOSM_TYPE_GRP;
+ else if(obj_type == H5I_DATASET)
+ type_bits = H5VL_DAOSM_TYPE_DSET;
+ else {
+ HDassert(obj_type == H5I_DATATYPE);
+ type_bits = H5VL_DAOSM_TYPE_DTYPE;
+ } /* end else */
+
+ /* Encode type and address */
+ oid->lo = type_bits | (idx & H5VL_DAOSM_IDX_MASK);
+
+ /* Generate oid */
+ daos_obj_id_generate(oid, DAOS_OC_TINY_RW);
+
+ return;
+} /* end H5VL_daosm_oid_encode() */
+
+
+/* Retrieve the 64 bit address from a DAOS oid */
+static H5I_type_t
+H5VL_daosm_oid_to_type(daos_obj_id_t oid)
+{
+ uint64_t type_bits;
+
+ /* Retrieve type */
+ type_bits = oid.lo & H5VL_DAOSM_TYPE_MASK;
+ if(type_bits == H5VL_DAOSM_TYPE_GRP)
+ return(H5I_GROUP);
+ else if(type_bits == H5VL_DAOSM_TYPE_DSET)
+ return(H5I_DATASET);
+ else if(type_bits == H5VL_DAOSM_TYPE_DTYPE)
+ return(H5I_DATATYPE);
+ else
+ return(H5I_BADID);
+} /* end H5VL_daosm_oid_to_type() */
+
+
+/* Retrieve the 64 bit object index from a DAOS oid */
+static uint64_t
+H5VL_daosm_oid_to_idx(daos_obj_id_t oid)
+{
+ return oid.lo & H5VL_DAOSM_IDX_MASK;
+} /* end H5VL_daosm_oid_to_lid() */
+
+
/* Multiply two 128 bit unsigned integers to yield a 128 bit unsigned integer */
static void
H5VL_daosm_mult128(uint64_t x_lo, uint64_t x_hi, uint64_t y_lo, uint64_t y_hi,
@@ -1178,7 +1256,7 @@ H5VL_daosm_file_open(const char *name, unsigned flags, hid_t fapl_id,
void *gcpl_buf = NULL;
uint64_t gcpl_len;
daos_obj_id_t gmd_oid = {0, 0, 0};
- daos_obj_id_t root_grp_oid = {1, 0, 0};
+ daos_obj_id_t root_grp_oid = {0, 0, 0};
uint8_t *p;
hbool_t must_bcast = FALSE;
int ret;
@@ -1233,7 +1311,7 @@ H5VL_daosm_file_open(const char *name, unsigned flags, hid_t fapl_id,
daos_obj_id_generate(&gmd_oid, DAOS_OC_TINY_RW);
/* Generate root group oid */
- daos_obj_id_generate(&root_grp_oid, DAOS_OC_TINY_RW);
+ H5VL_daosm_oid_encode(&root_grp_oid, H5I_GROUP, (uint64_t)1);
/* Determine if we requested collective object ops for the file */
if(H5Pget_all_coll_metadata_ops(fapl_id, &file->collective) < 0)
@@ -1671,7 +1749,8 @@ done:
/*-------------------------------------------------------------------------
* Function: H5VL_daosm_write_max_oid
*
- * Purpose: Writes the max OID to the global metadata object
+ * Purpose: Writes the max OID (object index) to the global metadata
+ * object
*
* Return: Success: 0
* Failure: 1
@@ -2319,8 +2398,7 @@ H5VL_daosm_group_create_helper(H5VL_daosm_file_t *file, hid_t gcpl_id,
grp->gapl_id = FAIL;
/* Generate group oid */
- grp->obj.oid.lo = file->max_oid + (uint64_t)1;
- daos_obj_id_generate(&grp->obj.oid, DAOS_OC_TINY_RW);
+ H5VL_daosm_oid_encode(&grp->obj.oid, H5I_GROUP, file->max_oid + (uint64_t)1);
/* Create group and write metadata if this process should */
if(!collective || (file->my_rank == 0)) {
@@ -2335,7 +2413,7 @@ H5VL_daosm_group_create_helper(H5VL_daosm_file_t *file, hid_t gcpl_id,
/* Create group */
if(0 != (ret = daos_obj_declare(file->coh, grp->obj.oid, file->epoch, NULL /*oa*/, NULL /*event*/)))
HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, NULL, "can't create dataset: %d", ret)
- file->max_oid = grp->obj.oid.lo;
+ file->max_oid = H5VL_daosm_oid_to_idx(grp->obj.oid);
/* Write max OID */
if(H5VL_daosm_write_max_oid(file) < 0)
@@ -2676,9 +2754,8 @@ done:
*-------------------------------------------------------------------------
*/
static void *
-H5VL_daosm_group_open(void *_item,
- H5VL_loc_params_t H5_ATTR_UNUSED loc_params, const char *name,
- hid_t gapl_id, hid_t dxpl_id, void **req)
+H5VL_daosm_group_open(void *_item, H5VL_loc_params_t loc_params,
+ const char *name, hid_t gapl_id, hid_t dxpl_id, void **req)
{
H5VL_daosm_item_t *item = (H5VL_daosm_item_t *)_item;
H5VL_daosm_group_t *grp = NULL;
@@ -2706,39 +2783,53 @@ H5VL_daosm_group_open(void *_item,
if(collective && (item->file->num_procs > 1))
must_bcast = TRUE;
- /* Traverse the path */
- if(NULL == (target_grp = H5VL_daosm_group_traverse(item, name, dxpl_id, req, &target_name, (collective && (item->file->num_procs > 1)) ? (void **)&gcpl_buf : NULL, &gcpl_len)))
- HGOTO_ERROR(H5E_SYM, H5E_BADITER, NULL, "can't traverse path")
+ /* Check for open by address */
+ if(H5VL_OBJECT_BY_ADDR == loc_params.type) {
+ /* Generate oid from address */
+ HDmemset(&oid, 0, sizeof(oid));
+ oid.lo = (uint64_t)loc_params.loc_data.loc_by_addr.addr;
+ daos_obj_id_generate(&oid, DAOS_OC_TINY_RW);
- /* Check for no target_name, in this case just return target_grp */
- if(target_name[0] == '\0'
- || (target_name[0] == '.' && target_name[1] == '\0')) {
- size_t gcpl_size;
-
- /* Take ownership of target_grp */
- grp = target_grp;
- target_grp = NULL;
-
- /* Encode GCPL */
- if(H5Pencode(grp->gcpl_id, NULL, &gcpl_size) < 0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "can't determine serialized length of gcpl")
- if(NULL == (gcpl_buf = H5MM_malloc(gcpl_size)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, NULL, "can't allocate buffer for serialized gcpl")
- gcpl_len = (uint64_t)gcpl_size;
- if(H5Pencode(grp->gcpl_id, gcpl_buf, &gcpl_size) < 0)
- HGOTO_ERROR(H5E_SYM, H5E_CANTENCODE, NULL, "can't serialize gcpl")
+ /* Open group */
+ if(NULL == (grp = (H5VL_daosm_group_t *)H5VL_daosm_group_open_helper(item->file, oid, gapl_id, dxpl_id, req, (collective && (item->file->num_procs > 1)) ? (void **)&gcpl_buf : NULL, &gcpl_len)))
+ HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, NULL, "can't open group")
} /* end if */
else {
- gcpl_buf = (uint8_t *)H5MM_xfree(gcpl_buf);
- gcpl_len = 0;
+ /* Open using name parameter */
+ /* Traverse the path */
+ if(NULL == (target_grp = H5VL_daosm_group_traverse(item, name, dxpl_id, req, &target_name, (collective && (item->file->num_procs > 1)) ? (void **)&gcpl_buf : NULL, &gcpl_len)))
+ HGOTO_ERROR(H5E_SYM, H5E_BADITER, NULL, "can't traverse path")
+
+ /* Check for no target_name, in this case just return target_grp */
+ if(target_name[0] == '\0'
+ || (target_name[0] == '.' && target_name[1] == '\0')) {
+ size_t gcpl_size;
+
+ /* Take ownership of target_grp */
+ grp = target_grp;
+ target_grp = NULL;
+
+ /* Encode GCPL */
+ if(H5Pencode(grp->gcpl_id, NULL, &gcpl_size) < 0)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "can't determine serialized length of gcpl")
+ if(NULL == (gcpl_buf = (uint8_t *)H5MM_malloc(gcpl_size)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, NULL, "can't allocate buffer for serialized gcpl")
+ gcpl_len = (uint64_t)gcpl_size;
+ if(H5Pencode(grp->gcpl_id, gcpl_buf, &gcpl_size) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTENCODE, NULL, "can't serialize gcpl")
+ } /* end if */
+ else {
+ gcpl_buf = (uint8_t *)H5MM_xfree(gcpl_buf);
+ gcpl_len = 0;
- /* Follow link to group */
- if(H5VL_daosm_link_follow(target_grp, target_name, HDstrlen(target_name), dxpl_id, req, &oid, NULL, NULL) < 0)
- HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, NULL, "can't follow link to group")
+ /* Follow link to group */
+ if(H5VL_daosm_link_follow(target_grp, target_name, HDstrlen(target_name), dxpl_id, req, &oid, NULL, NULL) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, NULL, "can't follow link to group")
- /* Open group */
- if(NULL == (grp = (H5VL_daosm_group_t *)H5VL_daosm_group_open_helper(item->file, oid, gapl_id, dxpl_id, req, (collective && (item->file->num_procs > 1)) ? (void **)&gcpl_buf : NULL, &gcpl_len)))
- HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, NULL, "can't open group")
+ /* Open group */
+ if(NULL == (grp = (H5VL_daosm_group_t *)H5VL_daosm_group_open_helper(item->file, oid, gapl_id, dxpl_id, req, (collective && (item->file->num_procs > 1)) ? (void **)&gcpl_buf : NULL, &gcpl_len)))
+ HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, NULL, "can't open group")
+ } /* end else */
} /* end else */
/* Broadcast group info if there are other processes that need it */
@@ -2747,7 +2838,7 @@ H5VL_daosm_group_open(void *_item,
HDassert(sizeof(ginfo_buf_static) >= 4 * sizeof(uint64_t));
/* Encode oid */
- p = (uint8_t *)ginfo_buf_static;
+ p = ginfo_buf_static;
UINT64ENCODE(p, grp->obj.oid.lo)
UINT64ENCODE(p, grp->obj.oid.mid)
UINT64ENCODE(p, grp->obj.oid.hi)
@@ -2759,6 +2850,9 @@ H5VL_daosm_group_open(void *_item,
if((gcpl_len + 4 * sizeof(uint64_t)) <= sizeof(ginfo_buf_static))
(void)HDmemcpy(p, gcpl_buf, gcpl_len);
+ /* We are about to bcast so we no longer need to bcast on failure */
+ must_bcast = FALSE;
+
/* MPI_Bcast ginfo_buf */
if(MPI_SUCCESS != MPI_Bcast((char *)ginfo_buf_static, sizeof(ginfo_buf_static), MPI_BYTE, 0, item->file->comm))
HGOTO_ERROR(H5E_SYM, H5E_MPI, NULL, "can't bcast group info")
@@ -2776,7 +2870,7 @@ H5VL_daosm_group_open(void *_item,
HGOTO_ERROR(H5E_SYM, H5E_MPI, NULL, "can't bcast group info")
/* Decode oid */
- p = (uint8_t *)ginfo_buf_static;
+ p = ginfo_buf_static;
UINT64DECODE(p, oid.lo)
UINT64DECODE(p, oid.mid)
UINT64DECODE(p, oid.hi)
@@ -2816,7 +2910,7 @@ done:
/* Cleanup on failure */
if(NULL == ret_value) {
/* Bcast gcpl_buf as '0' if necessary - this will trigger failures in
- * in other processes so we do not need to do the second bcast. */
+ * other processes so we do not need to do the second bcast. */
if(must_bcast) {
HDmemset(ginfo_buf_static, 0, sizeof(ginfo_buf_static));
if(MPI_SUCCESS != MPI_Bcast(ginfo_buf_static, sizeof(ginfo_buf_static), MPI_BYTE, 0, item->file->comm))
@@ -3217,8 +3311,7 @@ H5VL_daosm_dataset_create(void *_item,
dset->dapl_id = FAIL;
/* Generate dataset oid */
- dset->obj.oid.lo = item->file->max_oid + (uint64_t)1;
- daos_obj_id_generate(&dset->obj.oid, DAOS_OC_LARGE_RW);
+ H5VL_daosm_oid_encode(&dset->obj.oid, H5I_DATASET, item->file->max_oid + (uint64_t)1);
/* Create dataset and write metadata if this process should */
if(!collective || (item->file->my_rank == 0)) {
@@ -3243,7 +3336,7 @@ H5VL_daosm_dataset_create(void *_item,
/* Create dataset */
if(0 != (ret = daos_obj_declare(item->file->coh, dset->obj.oid, item->file->epoch, NULL /*oa*/, NULL /*event*/)))
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "can't create dataset: %d", ret)
- item->file->max_oid = dset->obj.oid.lo;
+ item->file->max_oid = H5VL_daosm_oid_to_idx(dset->obj.oid);
/* Write max OID */
if(H5VL_daosm_write_max_oid(item->file) < 0)
@@ -3425,10 +3518,6 @@ H5VL_daosm_dataset_open(void *_item,
if(H5Pget_all_coll_metadata_ops(dapl_id, &collective) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, NULL, "can't get collective access property")
- /* Traverse the path */
- if(NULL == (target_grp = H5VL_daosm_group_traverse(item, name, dxpl_id, req, &target_name, NULL, NULL)))
- HGOTO_ERROR(H5E_DATASET, H5E_BADITER, NULL, "can't traverse path")
-
/* Allocate the dataset object that is returned to the user */
if(NULL == (dset = H5FL_CALLOC(H5VL_daosm_dset_t)))
HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, NULL, "can't allocate DAOS-M dataset struct")
@@ -3447,13 +3536,23 @@ H5VL_daosm_dataset_open(void *_item,
if(collective && (item->file->num_procs > 1))
must_bcast = TRUE;
- /* Traverse the path */
- if(NULL == (target_grp = H5VL_daosm_group_traverse(item, name, dxpl_id, req, &target_name, NULL, NULL)))
- HGOTO_ERROR(H5E_DATASET, H5E_BADITER, NULL, "can't traverse path")
-
- /* Follow link to dataset */
- if(H5VL_daosm_link_follow(target_grp, target_name, HDstrlen(target_name), dxpl_id, req, &dset->obj.oid, NULL, NULL) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "can't follow link to dataset")
+ /* Check for open by address */
+ if(H5VL_OBJECT_BY_ADDR == loc_params.type) {
+ /* Generate oid from address */
+ HDmemset(&dset->obj.oid, 0, sizeof(dset->obj.oid));
+ dset->obj.oid.lo = (uint64_t)loc_params.loc_data.loc_by_addr.addr;
+ daos_obj_id_generate(&dset->obj.oid, DAOS_OC_TINY_RW);
+ } /* end if */
+ else {
+ /* Open using name parameter */
+ /* Traverse the path */
+ if(NULL == (target_grp = H5VL_daosm_group_traverse(item, name, dxpl_id, req, &target_name, NULL, NULL)))
+ HGOTO_ERROR(H5E_DATASET, H5E_BADITER, NULL, "can't traverse path")
+
+ /* Follow link to dataset */
+ if(H5VL_daosm_link_follow(target_grp, target_name, HDstrlen(target_name), dxpl_id, req, &dset->obj.oid, NULL, NULL) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "can't follow link to dataset")
+ } /* end else */
/* Open dataset */
if(0 != (ret = daos_obj_open(item->file->coh, dset->obj.oid, item->file->epoch, item->file->flags & H5F_ACC_RDWR ? DAOS_COO_RW : DAOS_COO_RO, &dset->obj.obj_oh, NULL /*event*/)))
@@ -3531,7 +3630,7 @@ H5VL_daosm_dataset_open(void *_item,
HDassert(sizeof(dinfo_buf_static) >= 6 * sizeof(uint64_t));
/* Encode oid */
- p = (uint8_t *)dinfo_buf;
+ p = dinfo_buf;
UINT64ENCODE(p, dset->obj.oid.lo)
UINT64ENCODE(p, dset->obj.oid.mid)
UINT64ENCODE(p, dset->obj.oid.hi)
@@ -3560,7 +3659,7 @@ H5VL_daosm_dataset_open(void *_item,
HGOTO_ERROR(H5E_DATASET, H5E_MPI, NULL, "can't bcast dataset info")
/* Decode oid */
- p = (uint8_t *)dinfo_buf_static;
+ p = dinfo_buf_static;
UINT64DECODE(p, dset->obj.oid.lo)
UINT64DECODE(p, dset->obj.oid.mid)
UINT64DECODE(p, dset->obj.oid.hi)
@@ -4311,6 +4410,35 @@ H5VL_daosm_dataset_close(void *_dset, hid_t H5_ATTR_UNUSED dxpl_id,
/*-------------------------------------------------------------------------
+ * Function: H5VL_daosm_datatype_open
+ *
+ * Purpose: Opens a DAOS HDF5 datatype.
+ *
+ * Return: Success: datatype id.
+ * Failure: NULL
+ *
+ * Programmer: Neil Fortner
+ * April, 2017
+ *
+ *-------------------------------------------------------------------------
+ */
+static void *
+H5VL_daosm_datatype_open(void H5_ATTR_UNUSED *_item,
+ H5VL_loc_params_t H5_ATTR_UNUSED loc_params,
+ const char H5_ATTR_UNUSED *name, hid_t H5_ATTR_UNUSED tapl_id,
+ hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req)
+{
+ void *ret_value = NULL;
+
+ FUNC_ENTER_NOAPI_NOINIT_NOERR
+
+ HDassert(0 && "Not implemented (should not be called)");
+
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5VL_daosm_datatype_open() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5VL_daosm_datatype_close
*
* Purpose: Closes a daos-m HDF5 datatype.
@@ -4338,6 +4466,163 @@ H5VL_daosm_datatype_close(void H5_ATTR_UNUSED *_dtype,
/*-------------------------------------------------------------------------
+ * Function: H5VL_daosm_object_open
+ *
+ * Purpose: Opens a DAOS HDF5 object.
+ *
+ * Return: Success: object.
+ * Failure: NULL
+ *
+ * Programmer: Neil Fortner
+ * November, 2016
+ *
+ *-------------------------------------------------------------------------
+ */
+static void *
+H5VL_daosm_object_open(void *_item, H5VL_loc_params_t loc_params,
+ H5I_type_t *opened_type, hid_t dxpl_id, void **req)
+{
+ H5VL_daosm_item_t *item = (H5VL_daosm_item_t *)_item;
+ H5VL_daosm_obj_t *obj = NULL;
+ H5VL_daosm_group_t *target_grp = NULL;
+ const char *target_name = NULL;
+ daos_obj_id_t oid;
+ uint8_t oid_buf[3 * sizeof(uint64_t)];
+ uint8_t *p;
+ hbool_t collective = item->file->collective;
+ hbool_t must_bcast = FALSE;
+ H5I_type_t obj_type;
+ H5VL_loc_params_t sub_loc_params;
+ void *ret_value = NULL;
+
+ FUNC_ENTER_NOAPI_NOINIT
+
+ /* Check loc_params type */
+ if(H5VL_OBJECT_BY_ADDR == loc_params.type) {
+ /* Generate oid from address */
+ HDmemset(&oid, 0, sizeof(oid));
+ oid.lo = (uint64_t)loc_params.loc_data.loc_by_addr.addr;
+ daos_obj_id_generate(&oid, DAOS_OC_TINY_RW);
+ } /* end if */
+ else {
+ HDassert(H5VL_OBJECT_BY_NAME == loc_params.type);
+
+ /* Check for collective access, if not already set by the file */
+ if(!collective)
+ if(H5Pget_all_coll_metadata_ops(loc_params.loc_data.loc_by_name.lapl_id, &collective) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, NULL, "can't get collective access property")
+
+ /* Check if we're actually opening the group or just receiving the group
+ * info from the leader */
+ if(!collective || (item->file->my_rank == 0)) {
+ if(collective && (item->file->num_procs > 1))
+ must_bcast = TRUE;
+
+ /* Traverse the path */
+ if(NULL == (target_grp = H5VL_daosm_group_traverse(item, loc_params.loc_data.loc_by_name.name, dxpl_id, req, &target_name, NULL, NULL)))
+ HGOTO_ERROR(H5E_OHDR, H5E_BADITER, NULL, "can't traverse path")
+
+ /* Check for no target_name, in this case just reopen target_grp */
+ if(target_name[0] == '\0'
+ || (target_name[0] == '.' && target_name[1] == '\0'))
+ oid = target_grp->obj.oid;
+ else
+ /* Follow link to group */
+ if(H5VL_daosm_link_follow(target_grp, target_name, HDstrlen(target_name), dxpl_id, req, &oid, NULL, NULL) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "can't follow link to group")
+
+ /* Broadcast group info if there are other processes that need it */
+ if(collective && (item->file->num_procs > 1)) {
+ /* Encode oid */
+ p = oid_buf;
+ UINT64ENCODE(p, oid.lo)
+ UINT64ENCODE(p, oid.mid)
+ UINT64ENCODE(p, oid.hi)
+
+ /* We are about to bcast so we no longer need to bcast on failure */
+ must_bcast = FALSE;
+
+ /* MPI_Bcast oid_buf */
+ if(MPI_SUCCESS != MPI_Bcast((char *)oid_buf, sizeof(oid_buf), MPI_BYTE, 0, item->file->comm))
+ HGOTO_ERROR(H5E_OHDR, H5E_MPI, NULL, "can't bcast object id")
+ } /* end if */
+ } /* end if */
+ else {
+ /* Receive oid_buf */
+ if(MPI_SUCCESS != MPI_Bcast((char *)oid_buf, sizeof(oid_buf), MPI_BYTE, 0, item->file->comm))
+ HGOTO_ERROR(H5E_OHDR, H5E_MPI, NULL, "can't bcast object id")
+
+ /* Decode oid */
+ p = oid_buf;
+ UINT64DECODE(p, oid.lo)
+ UINT64DECODE(p, oid.mid)
+ UINT64DECODE(p, oid.hi)
+
+ /* Check for oid.lo set to 0 - indicates failure */
+ if(oid.lo == 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "lead process failed to open object")
+ } /* end else */
+ } /* end else */
+
+ /* Set up sub_loc_params */
+ sub_loc_params.type = H5VL_OBJECT_BY_ADDR;
+ sub_loc_params.loc_data.loc_by_addr.addr = (haddr_t)oid.lo;
+
+ /* Get object type */
+ if(H5I_BADID == (obj_type = H5VL_daosm_oid_to_type(oid)))
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "can't get object type")
+
+ /* Call type's open function */
+ if(obj_type == H5I_GROUP) {
+ if(NULL == (obj = (H5VL_daosm_obj_t *)H5VL_daosm_group_open(item, sub_loc_params, NULL,
+ ((H5VL_OBJECT_BY_NAME == loc_params.type) && (loc_params.loc_data.loc_by_name.lapl_id != H5P_DEFAULT))
+ ? loc_params.loc_data.loc_by_name.lapl_id : H5P_GROUP_ACCESS_DEFAULT, dxpl_id, req)))
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, NULL, "can't open group")
+ } /* end if */
+ else if(obj_type == H5I_DATASET) {
+ if(NULL == (obj = (H5VL_daosm_obj_t *)H5VL_daosm_dataset_open(item, sub_loc_params, NULL,
+ ((H5VL_OBJECT_BY_NAME == loc_params.type) && (loc_params.loc_data.loc_by_name.lapl_id != H5P_DEFAULT))
+ ? loc_params.loc_data.loc_by_name.lapl_id : H5P_DATASET_ACCESS_DEFAULT, dxpl_id, req)))
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, NULL, "can't open dataset")
+ } /* end if */
+ else {
+ HDassert(obj_type == H5I_DATATYPE);
+ if(NULL == (obj = (H5VL_daosm_obj_t *)H5VL_daosm_datatype_open(item, sub_loc_params, NULL,
+ ((H5VL_OBJECT_BY_NAME == loc_params.type) && (loc_params.loc_data.loc_by_name.lapl_id != H5P_DEFAULT))
+ ? loc_params.loc_data.loc_by_name.lapl_id : H5P_DATATYPE_ACCESS_DEFAULT, dxpl_id, req)))
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, NULL, "can't open datatype")
+ } /* end if */
+
+ /* Set return value */
+ if(opened_type)
+ *opened_type = obj_type;
+ ret_value = (void *)obj;
+
+done:
+ /* Cleanup on failure */
+ if(NULL == ret_value) {
+ /* Bcast oid_buf as '0' if necessary - this will trigger failures in
+ * other processes */
+ if(must_bcast) {
+ HDmemset(oid_buf, 0, sizeof(oid_buf));
+ if(MPI_SUCCESS != MPI_Bcast(oid_buf, sizeof(oid_buf), MPI_BYTE, 0, item->file->comm))
+ HDONE_ERROR(H5E_OHDR, H5E_MPI, NULL, "can't bcast empty object id")
+ } /* end if */
+
+ /* Close object */
+ if(obj && H5VL_daosm_object_close(obj, dxpl_id, req) < 0)
+ HDONE_ERROR(H5E_OHDR, H5E_CLOSEERROR, NULL, "can't close object")
+ } /* end if */
+
+ /* Close target group */
+ if(target_grp && H5VL_daosm_group_close(target_grp, dxpl_id, req) < 0)
+ HDONE_ERROR(H5E_OHDR, H5E_CLOSEERROR, NULL, "can't close group")
+
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5VL_daosm_object_open() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5VL_daosm_object_close
*
* Purpose: Closes a daos-m HDF5 object.
@@ -4401,7 +4686,7 @@ H5VL_daosm_attribute_create(void *_item, H5VL_loc_params_t loc_params,
const char *name, hid_t acpl_id, hid_t H5_ATTR_UNUSED aapl_id,
hid_t dxpl_id, void **req)
{
- H5VL_daosm_item_t *item = (H5VL_daosm_item_t *)_item; /* Change to item when BY_NAME (and obj_open) is supported DSMINC */
+ H5VL_daosm_item_t *item = (H5VL_daosm_item_t *)_item;
H5VL_daosm_attr_t *attr = NULL;
H5P_genplist_t *plist = NULL; /* Property list pointer */
size_t akey_len;
@@ -4445,16 +4730,23 @@ H5VL_daosm_attribute_create(void *_item, H5VL_loc_params_t loc_params,
attr->type_id = FAIL;
attr->space_id = FAIL;
- /* Check loc_params - only SELF currently supported */
- if(loc_params.type != H5VL_OBJECT_BY_SELF)
- HGOTO_ERROR(H5E_ATTR, H5E_UNSUPPORTED, NULL, "attribute create by name unsupported")
-
- /* Set attribute parent object */
- if(item->type == H5I_FILE)
- attr->parent = (H5VL_daosm_obj_t *)((H5VL_daosm_file_t *)item)->root_grp;
+ /* Determine attribute object */
+ if(loc_params.type == H5VL_OBJECT_BY_SELF) {
+ /* Use item as attribute parent object, or the root group if item is a
+ * file */
+ if(item->type == H5I_FILE)
+ attr->parent = (H5VL_daosm_obj_t *)((H5VL_daosm_file_t *)item)->root_grp;
+ else
+ attr->parent = (H5VL_daosm_obj_t *)item;
+ attr->parent->item.rc++;
+ } /* end if */
+ else if(loc_params.type == H5VL_OBJECT_BY_NAME) {
+ /* Open target_obj */
+ if(NULL == (attr->parent = (H5VL_daosm_obj_t *)H5VL_daosm_object_open(item, loc_params, NULL, dxpl_id, req)))
+ HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, NULL, "can't open object for attribute")
+ } /* end else */
else
- attr->parent = (H5VL_daosm_obj_t *)item;
- attr->parent->item.rc++;
+ HGOTO_ERROR(H5E_ATTR, H5E_UNSUPPORTED, NULL, "unsupported attribute create location parameters type")
/* Encode datatype */
if(H5Tencode(type_id, NULL, &type_size) < 0)
@@ -4588,16 +4880,23 @@ H5VL_daosm_attribute_open(void *_item, H5VL_loc_params_t loc_params,
attr->type_id = FAIL;
attr->space_id = FAIL;
- /* Check loc_params - only SELF currently supported */
- if(loc_params.type != H5VL_OBJECT_BY_SELF)
- HGOTO_ERROR(H5E_ATTR, H5E_UNSUPPORTED, NULL, "attribute create by name unsupported")
-
- /* Set attribute parent object */
- if(item->type == H5I_FILE)
- attr->parent = (H5VL_daosm_obj_t *)((H5VL_daosm_file_t *)item)->root_grp;
+ /* Determine attribute object */
+ if(loc_params.type == H5VL_OBJECT_BY_SELF) {
+ /* Use item as attribute parent object, or the root group if item is a
+ * file */
+ if(item->type == H5I_FILE)
+ attr->parent = (H5VL_daosm_obj_t *)((H5VL_daosm_file_t *)item)->root_grp;
+ else
+ attr->parent = (H5VL_daosm_obj_t *)item;
+ attr->parent->item.rc++;
+ } /* end if */
+ else if(loc_params.type == H5VL_OBJECT_BY_NAME) {
+ /* Open target_obj */
+ if(NULL == (attr->parent = (H5VL_daosm_obj_t *)H5VL_daosm_object_open(item, loc_params, NULL, dxpl_id, req)))
+ HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, NULL, "can't open object for attribute")
+ } /* end else */
else
- attr->parent = (H5VL_daosm_obj_t *)item;
- attr->parent->item.rc++;
+ HGOTO_ERROR(H5E_ATTR, H5E_UNSUPPORTED, NULL, "unsupported attribute open location parameters type")
/* Set up operation to write datatype and dataspace to attribute */
/* Set up dkey */
@@ -4967,16 +5266,24 @@ H5VL_daosm_attribute_specific(void *_item, H5VL_loc_params_t loc_params,
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
-
- /* Determine the target group */
- if(H5VL_OBJECT_BY_SELF == loc_params.type) {
- target_obj = (H5VL_daosm_obj_t *)item;
+
+ /* Determine attribute object */
+ if(loc_params.type == H5VL_OBJECT_BY_SELF) {
+ /* Use item as attribute parent object, or the root group if item is a
+ * file */
+ if(item->type == H5I_FILE)
+ target_obj = (H5VL_daosm_obj_t *)((H5VL_daosm_file_t *)item)->root_grp;
+ else
+ target_obj = (H5VL_daosm_obj_t *)item;
target_obj->item.rc++;
} /* end if */
- else {
- HDassert(H5VL_OBJECT_BY_NAME == loc_params.type);
- /* Object open DSMINC */
+ else if(loc_params.type == H5VL_OBJECT_BY_NAME) {
+ /* Open target_obj */
+ if(NULL == (target_obj = (H5VL_daosm_obj_t *)H5VL_daosm_object_open(item, loc_params, NULL, dxpl_id, req)))
+ HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "can't open object for attribute")
} /* end else */
+ else
+ HGOTO_ERROR(H5E_ATTR, H5E_UNSUPPORTED, FAIL, "unsupported attribute operation location parameters type")
switch (specific_type) {
/* H5Lexists */