diff options
Diffstat (limited to 'src/H5VLrados.c')
-rw-r--r-- | src/H5VLrados.c | 204 |
1 files changed, 191 insertions, 13 deletions
diff --git a/src/H5VLrados.c b/src/H5VLrados.c index 76a865e..0ee5c92 100644 --- a/src/H5VLrados.c +++ b/src/H5VLrados.c @@ -200,6 +200,11 @@ static herr_t H5VL_rados_file_flush(H5VL_rados_file_t *file); static herr_t H5VL_rados_file_close_helper(H5VL_rados_file_t *file, hid_t dxpl_id, void **req); +/* read/write_op equivalents for some RADOS calls */ +static int H5VL_rados_read(rados_ioctx_t io, const char *oid, char *buf, size_t len, uint64_t off); +static int H5VL_rados_write_full(rados_ioctx_t io, const char *oid, const char *buf, size_t len); +static int H5VL_rados_stat(rados_ioctx_t io, const char *oid, uint64_t *psize, time_t * pmtime); + static herr_t H5VL_rados_link_read(H5VL_rados_group_t *grp, const char *name, H5VL_rados_link_val_t *val); static herr_t H5VL_rados_link_write(H5VL_rados_group_t *grp, const char *name, @@ -348,6 +353,179 @@ rados_ioctx_t ioctx_g; hbool_t ioctx_init_g = FALSE; +/*------------------------------------------------------------------------- + * Function: H5VL_rados_read + * + * Purpose: Recreates rados_read(). We are trying to use all read_op + * calls and this lets us do that without duplicating all + * the RADOS boilerplate. + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Dana Robinson + * February, 2019 + * + *------------------------------------------------------------------------- + */ +static int +H5VL_rados_read(rados_ioctx_t io, const char *oid, char *buf, size_t len, uint64_t off) +{ + int ret = 0; + int ret_value = 0; + + FUNC_ENTER_NOAPI_NOINIT + +#ifdef OLD_RADOS_CALLS + /* Read data from the object */ + if((ret = rados_read(io, oid, buf, len, off)) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTDECODE, (-1), "can't read metadata from dataset: %s", strerror(-ret)) +#else +{ + rados_read_op_t read_op; + hbool_t read_op_init = FALSE; + size_t bytes_read = 0; + int prval; + + /* Create read op */ + if(NULL == (read_op = rados_create_read_op())) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, (-1), "can't create read operation") + read_op_init = TRUE; + + /* Add the read operation (returns void) */ + rados_read_op_read(read_op, off, len, buf, &bytes_read, &prval); + + /* Execute read operation */ + if((ret = rados_read_op_operate(read_op, io, oid, LIBRADOS_OPERATION_NOFLAG)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, (-1), "can't perform read operation: %s", strerror(-ret)) + if(0 < prval) + HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, (-1), "RADOS read operation failed for object") + if(0 == bytes_read) + HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, (-1), "metadata not found for object") + + /* clean up */ + if(read_op_init) + rados_release_read_op(read_op); +} +#endif + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_rados_read() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_rados_write_full + * + * Purpose: Recreates rados_write_full(). We are trying to use all + * write_op calls and this lets us do that without duplicating + * all the RADOS boilerplate. + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Dana Robinson + * February, 2019 + * + *------------------------------------------------------------------------- + */ +static int +H5VL_rados_write_full(rados_ioctx_t io, const char *oid, const char *buf, size_t len) +{ + int ret = 0; + int ret_value = 0; + + FUNC_ENTER_NOAPI_NOINIT + +#ifdef OLD_RADOS_CALLS + if((ret = rados_write_full(io, oid, buf, len)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, (-1), "can't write metadata to object: %s", strerror(-ret)) +#else +{ + rados_write_op_t write_op; + hbool_t write_op_init = FALSE; + + /* Create write op */ + if(NULL == (write_op = rados_create_write_op())) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, (-1), "can't create write operation") + write_op_init = TRUE; + + /* Add the write full operation (returns void) */ + rados_write_op_write_full(write_op, buf, len); + + /* Execute write operation */ + if((ret = rados_write_op_operate(write_op, io, oid, NULL, LIBRADOS_OPERATION_NOFLAG)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, (-1), "can't perform write operation: %s", strerror(-ret)) + + /* clean up */ + if(write_op_init) + rados_release_write_op(write_op); +} +#endif + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_rados_write_full() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_rados_stat + * + * Purpose: Recreates rados_stat(). We are trying to use all read_op + * calls and this lets us do that without duplicating all + * the RADOS boilerplate. + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Dana Robinson + * February, 2019 + * + *------------------------------------------------------------------------- + */ +static int +H5VL_rados_stat(rados_ioctx_t io, const char *oid, uint64_t *psize, time_t * pmtime) +{ + int ret = 0; + int ret_value = 0; + + FUNC_ENTER_NOAPI_NOINIT + +#ifdef OLD_RADOS_CALLS + /* Get the object size and time */ + if((ret = rados_stat(io, oid, psize, pmtime)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTDECODE, (-1), "can't read object size and time: %s", strerror(-ret)) +#else +{ + rados_read_op_t read_op; + hbool_t read_op_init = FALSE; + int prval; + + /* Create read op */ + if(NULL == (read_op = rados_create_read_op())) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, (-1), "can't create read operation") + read_op_init = TRUE; + + /* Add the get stats operation (returns void) */ + rados_read_op_stat(read_op, psize, pmtime, &prval); + + /* Execute read operation */ + if((ret = rados_read_op_operate(read_op, io, oid, LIBRADOS_OPERATION_NOFLAG)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, (-1), "can't perform read operation: %s", strerror(-ret)) + if(0 < prval) + HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, (-1), "stats not found for object") + + /* clean up */ + if(read_op_init) + rados_release_read_op(read_op); +} +#endif + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_rados_stat() */ + + /* Create a RADOS string oid given the file name and binary oid */ static herr_t H5VL_rados_oid_create_string(const H5VL_rados_file_t *file, uint64_t bin_oid, @@ -964,7 +1142,7 @@ H5VL_rados_file_open(const char *name, unsigned flags, hid_t fapl_id, /* Read max oid directly to foi_buf */ /* Check for does not exist here and assume 0? -NAF */ - if((ret = rados_read(ioctx_g, file->glob_md_oid, foi_buf, 8, 0)) < 0) + if((ret = H5VL_rados_read(ioctx_g, file->glob_md_oid, foi_buf, 8, 0)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTDECODE, NULL, "can't read metadata from dataset: %s", strerror(-ret)) /* Decode max oid */ @@ -1272,7 +1450,7 @@ H5VL_rados_write_max_oid(H5VL_rados_file_t *file) UINT64ENCODE(p, file->max_oid) - if((ret = rados_write_full(ioctx_g, file->glob_md_oid, (const char *)wbuf, (size_t)8)) < 0) + if((ret = H5VL_rados_write_full(ioctx_g, file->glob_md_oid, (const char *)wbuf, (size_t)8)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't write metadata to group: %s", strerror(-ret)) file->max_oid_dirty = FALSE; } /* end if */ @@ -1822,7 +2000,7 @@ H5VL_rados_group_create_helper(H5VL_rados_file_t *file, hid_t gcpl_id, HGOTO_ERROR(H5E_SYM, H5E_CANTENCODE, NULL, "can't serialize gcpl") /* Write internal metadata to group */ - if((ret = rados_write_full(ioctx_g, grp->obj.oid, gcpl_buf, gcpl_size)) < 0) + if((ret = H5VL_rados_write_full(ioctx_g, grp->obj.oid, gcpl_buf, gcpl_size)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, NULL, "can't write metadata to group: %s", strerror(-ret)) /* Mark max OID as dirty */ @@ -1946,8 +2124,8 @@ H5VL_rados_group_open_helper(H5VL_rados_file_t *file, uint64_t oid, { H5VL_rados_group_t *grp = NULL; void *gcpl_buf = NULL; - uint64_t gcpl_len; - time_t pmtime; + uint64_t gcpl_len = 0; + time_t pmtime = 0; int ret; void *ret_value = NULL; @@ -1965,8 +2143,8 @@ H5VL_rados_group_open_helper(H5VL_rados_file_t *file, uint64_t oid, grp->gcpl_id = FAIL; grp->gapl_id = FAIL; - /* Read internal metadata size from group */ - if((ret = rados_stat(ioctx_g, grp->obj.oid, &gcpl_len, &pmtime)) < 0) + /* Get the object size and time */ + if((ret = H5VL_rados_stat(ioctx_g, grp->obj.oid, &gcpl_len, &pmtime)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTDECODE, NULL, "can't read metadata size from group: %s", strerror(-ret)) /* Check for metadata not found */ @@ -1978,7 +2156,7 @@ H5VL_rados_group_open_helper(H5VL_rados_file_t *file, uint64_t oid, HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, NULL, "can't allocate buffer for serialized gcpl") /* Read internal metadata from group */ - if((ret = rados_read(ioctx_g, grp->obj.oid, gcpl_buf, gcpl_len, 0)) < 0) + if((ret = H5VL_rados_read(ioctx_g, grp->obj.oid, gcpl_buf, gcpl_len, 0)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTDECODE, NULL, "can't read metadata from group: %s", strerror(-ret)) /* Decode GCPL */ @@ -2674,7 +2852,7 @@ H5VL_rados_dataset_create(void *_item, HGOTO_ERROR(H5E_DATASET, H5E_CANTENCODE, NULL, "can't serialize dcpl") /* Write internal metadata to dataset */ - if((ret = rados_write_full(ioctx_g, dset->obj.oid, (const char *)md_buf, md_size)) < 0) + if((ret = H5VL_rados_write_full(ioctx_g, dset->obj.oid, (const char *)md_buf, md_size)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "can't write metadata to dataset: %s", strerror(-ret)) /* Mark max OID as dirty */ @@ -2746,7 +2924,7 @@ H5VL_rados_dataset_open(void *_item, uint64_t type_len = 0; uint64_t space_len = 0; uint64_t dcpl_len = 0; - time_t pmtime; + time_t pmtime = 0; uint8_t dinfo_buf_static[H5VL_RADOS_DINFO_BUF_SIZE]; uint8_t *dinfo_buf_dyn = NULL; uint8_t *dinfo_buf = dinfo_buf_static; @@ -2804,8 +2982,8 @@ H5VL_rados_dataset_open(void *_item, HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "can't encode string oid") } /* end else */ - /* Read internal metadata size from dataset */ - if((ret = rados_stat(ioctx_g, dset->obj.oid, &md_len, &pmtime)) < 0) + /* Get the object size and time */ + if((ret = H5VL_rados_stat(ioctx_g, dset->obj.oid, &md_len, &pmtime)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTDECODE, NULL, "can't read metadata size from group: %s", strerror(-ret)) /* Check for metadata not found */ @@ -2820,7 +2998,7 @@ H5VL_rados_dataset_open(void *_item, } /* end if */ /* Read internal metadata from dataset */ - if((ret = rados_read(ioctx_g, dset->obj.oid, (char *)(dinfo_buf + sizeof(uint64_t)), md_len, 0)) < 0) + if((ret = H5VL_rados_read(ioctx_g, dset->obj.oid, (char *)(dinfo_buf + sizeof(uint64_t)), md_len, 0)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTDECODE, NULL, "can't read metadata from dataset: %s", strerror(-ret)) /* Decode info lengths */ |