summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDana Robinson <43805+derobins@users.noreply.github.com>2021-01-13 04:12:51 (GMT)
committerGitHub <noreply@github.com>2021-01-13 04:12:51 (GMT)
commitb84f48f929ec02b9a2fefa036c63656af2f4aa89 (patch)
tree7a6eb6609b553f9262b69970d96a775c69d2f50a /src
parent0e09b0b636b25bfe6226cc5ef5fa52e75383c32c (diff)
downloadhdf5-b84f48f929ec02b9a2fefa036c63656af2f4aa89.zip
hdf5-b84f48f929ec02b9a2fefa036c63656af2f4aa89.tar.gz
hdf5-b84f48f929ec02b9a2fefa036c63656af2f4aa89.tar.bz2
Allow read-only VFD registration (#257)
* Removes no-op callback stubs from read-only VFDs Also changes VFD registration to allow read-only VFDs with no write callback to be registered. * Adds a RELEASE.txt note for HDFFV-11205 For the read-only VFD registration change
Diffstat (limited to 'src')
-rw-r--r--src/H5FD.c10
-rw-r--r--src/H5FDhdfs.c142
-rw-r--r--src/H5FDint.c4
-rw-r--r--src/H5FDros3.c143
4 files changed, 19 insertions, 280 deletions
diff --git a/src/H5FD.c b/src/H5FD.c
index d12bb57..5498644 100644
--- a/src/H5FD.c
+++ b/src/H5FD.c
@@ -231,9 +231,9 @@ H5FDregister(const H5FD_class_t *cls)
"'get_eoa' and/or 'set_eoa' methods are not defined")
if (!cls->get_eof)
HGOTO_ERROR(H5E_ARGS, H5E_UNINITIALIZED, H5I_INVALID_HID, "'get_eof' method is not defined")
- if (!cls->read || !cls->write)
+ if (!cls->read)
HGOTO_ERROR(H5E_ARGS, H5E_UNINITIALIZED, H5I_INVALID_HID,
- "'read' and/or 'write' method is not defined")
+ "'read' method is not defined")
for (type = H5FD_MEM_DEFAULT; type < H5FD_MEM_NTYPES; type++)
if (cls->fl_map[type] < H5FD_MEM_NOLIST || cls->fl_map[type] >= H5FD_MEM_NTYPES)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "invalid free-list mapping")
@@ -277,7 +277,7 @@ H5FD_register(const void *_cls, size_t size, hbool_t app_ref)
HDassert(cls->open && cls->close);
HDassert(cls->get_eoa && cls->set_eoa);
HDassert(cls->get_eof);
- HDassert(cls->read && cls->write);
+ HDassert(cls->read);
for (type = H5FD_MEM_DEFAULT; type < H5FD_MEM_NTYPES; type++) {
HDassert(cls->fl_map[type] >= H5FD_MEM_NOLIST && cls->fl_map[type] < H5FD_MEM_NTYPES);
}
@@ -1417,6 +1417,10 @@ H5FDwrite(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t siz
if (!buf)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "result buffer parameter can't be NULL")
+ /* Make sure this isn't being called on a read-only VFD */
+ if (!file->cls->write)
+ HGOTO_ERROR(H5E_VFL, H5E_WRITEERROR, FAIL, "write request made to read-only VFD")
+
/* Get the default dataset transfer property list if the user didn't provide one */
if (H5P_DEFAULT == dxpl_id)
dxpl_id = H5P_DATASET_XFER_DEFAULT;
diff --git a/src/H5FDhdfs.c b/src/H5FDhdfs.c
index 43ad9a1..1b28168 100644
--- a/src/H5FDhdfs.c
+++ b/src/H5FDhdfs.c
@@ -271,12 +271,6 @@ static haddr_t H5FD__hdfs_get_eof(const H5FD_t *_file, H5FD_mem_t type);
static herr_t H5FD__hdfs_get_handle(H5FD_t *_file, hid_t fapl, void **file_handle);
static herr_t H5FD__hdfs_read(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, size_t size,
void *buf);
-static herr_t H5FD__hdfs_write(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, size_t size,
- const void *buf);
-static herr_t H5FD__hdfs_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing);
-static herr_t H5FD__hdfs_lock(H5FD_t *_file, hbool_t rw);
-static herr_t H5FD__hdfs_unlock(H5FD_t *_file);
-
static herr_t H5FD__hdfs_validate_config(const H5FD_hdfs_fapl_t *fa);
static const H5FD_class_t H5FD_hdfs_g = {
@@ -306,11 +300,11 @@ static const H5FD_class_t H5FD_hdfs_g = {
H5FD__hdfs_get_eof, /* get_eof */
H5FD__hdfs_get_handle, /* get_handle */
H5FD__hdfs_read, /* read */
- H5FD__hdfs_write, /* write */
+ NULL, /* write */
NULL, /* flush */
- H5FD__hdfs_truncate, /* truncate */
- H5FD__hdfs_lock, /* lock */
- H5FD__hdfs_unlock, /* unlock */
+ NULL, /* truncate */
+ NULL, /* lock */
+ NULL, /* unlock */
H5FD_FLMAP_DICHOTOMY /* fl_map */
};
@@ -1571,132 +1565,4 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5FD__hdfs_read() */
-/*-------------------------------------------------------------------------
- *
- * Function: H5FD__hdfs_write()
- *
- * Purpose:
- *
- * Write bytes to file.
- * UNSUPPORTED IN READ-ONLY HDFS VFD.
- *
- * Return:
- *
- * FAIL (Not possible with Read-Only S3 file.)
- *
- * Programmer: Jacob Smith
- * 2017-10-23
- *
- *-------------------------------------------------------------------------
- */
-static herr_t
-H5FD__hdfs_write(H5FD_t H5_ATTR_UNUSED *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNUSED dxpl_id,
- haddr_t H5_ATTR_UNUSED addr, size_t H5_ATTR_UNUSED size, const void H5_ATTR_UNUSED *buf)
-{
- herr_t ret_value = FAIL;
-
- FUNC_ENTER_STATIC
-
-#if HDFS_DEBUG
- HDfprintf(stdout, "called %s.\n", FUNC);
-#endif
-
- HGOTO_ERROR(H5E_VFL, H5E_UNSUPPORTED, FAIL, "cannot write to read-only file")
-
-done:
- FUNC_LEAVE_NOAPI(ret_value)
-} /* H5FD__hdfs_write() */
-
-/*-------------------------------------------------------------------------
- *
- * Function: H5FD__hdfs_truncate()
- *
- * Purpose:
- *
- * Makes sure that the true file size is the same (or larger)
- * than the end-of-address.
- *
- * NOT POSSIBLE ON READ-ONLY S3 FILES.
- *
- * Return:
- *
- * FAIL (Not possible on Read-Only S3 files.)
- *
- * Programmer: Jacob Smith
- * 2017-10-23
- *
- *-------------------------------------------------------------------------
- */
-static herr_t
-H5FD__hdfs_truncate(H5FD_t H5_ATTR_UNUSED *_file, hid_t H5_ATTR_UNUSED dxpl_id,
- hbool_t H5_ATTR_UNUSED closing)
-{
- herr_t ret_value = SUCCEED;
-
- FUNC_ENTER_STATIC
-
-#if HDFS_DEBUG
- HDfprintf(stdout, "called %s.\n", FUNC);
-#endif
-
- HGOTO_ERROR(H5E_VFL, H5E_UNSUPPORTED, FAIL, "cannot truncate read-only file")
-
-done:
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5FD__hdfs_truncate() */
-
-/*-------------------------------------------------------------------------
- *
- * Function: H5FD__hdfs_lock()
- *
- * Purpose:
- *
- * Place an advisory lock on a file.
- * No effect on Read-Only S3 file.
- *
- * Suggestion: remove lock/unlock from class
- * would result in error at H5FD_[un]lock() (H5FD.c)
- *
- * Return:
- *
- * SUCCEED (No-op always succeeds)
- *
- * Programmer: Jacob Smith
- * 2017-11-03
- *
- *-------------------------------------------------------------------------
- */
-static herr_t
-H5FD__hdfs_lock(H5FD_t H5_ATTR_UNUSED *_file, hbool_t H5_ATTR_UNUSED rw)
-{
- FUNC_ENTER_STATIC_NOERR
-
- FUNC_LEAVE_NOAPI(SUCCEED)
-} /* end H5FD__hdfs_lock() */
-
-/*-------------------------------------------------------------------------
- *
- * Function: H5FD__hdfs_unlock()
- *
- * Purpose:
- *
- * Remove the existing lock on the file.
- * No effect on Read-Only S3 file.
- *
- * Return:
- *
- * SUCCEED (No-op always succeeds)
- *
- * Programmer: Jacob Smith
- * 2017-11-03
- *
- *-------------------------------------------------------------------------
- */
-static herr_t
-H5FD__hdfs_unlock(H5FD_t H5_ATTR_UNUSED *_file)
-{
- FUNC_ENTER_STATIC_NOERR
-
- FUNC_LEAVE_NOAPI(SUCCEED)
-} /* end H5FD__hdfs_unlock() */
#endif /* H5_HAVE_LIBHDFS */
diff --git a/src/H5FDint.c b/src/H5FDint.c
index b651c23..8c93f1c 100644
--- a/src/H5FDint.c
+++ b/src/H5FDint.c
@@ -215,6 +215,10 @@ H5FD_write(H5FD_t *file, H5FD_mem_t type, haddr_t addr, size_t size, const void
HDassert(file->cls);
HDassert(buf);
+ /* Make sure this isn't being called on a read-only VFD */
+ if (!file->cls->write)
+ HGOTO_ERROR(H5E_VFL, H5E_WRITEERROR, FAIL, "write request made to read-only VFD")
+
/* Get proper DXPL for I/O */
dxpl_id = H5CX_get_dxpl();
diff --git a/src/H5FDros3.c b/src/H5FDros3.c
index 83e4315..df90528 100644
--- a/src/H5FDros3.c
+++ b/src/H5FDros3.c
@@ -228,12 +228,6 @@ static haddr_t H5FD__ros3_get_eof(const H5FD_t *_file, H5FD_mem_t type);
static herr_t H5FD__ros3_get_handle(H5FD_t *_file, hid_t fapl, void **file_handle);
static herr_t H5FD__ros3_read(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, size_t size,
void *buf);
-static herr_t H5FD__ros3_write(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, size_t size,
- const void *buf);
-static herr_t H5FD__ros3_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing);
-static herr_t H5FD__ros3_lock(H5FD_t *_file, hbool_t rw);
-static herr_t H5FD__ros3_unlock(H5FD_t *_file);
-
static herr_t H5FD__ros3_validate_config(const H5FD_ros3_fapl_t *fa);
static const H5FD_class_t H5FD_ros3_g = {
@@ -263,11 +257,11 @@ static const H5FD_class_t H5FD_ros3_g = {
H5FD__ros3_get_eof, /* get_eof */
H5FD__ros3_get_handle, /* get_handle */
H5FD__ros3_read, /* read */
- H5FD__ros3_write, /* write */
+ NULL, /* write */
NULL, /* flush */
- H5FD__ros3_truncate, /* truncate */
- H5FD__ros3_lock, /* lock */
- H5FD__ros3_unlock, /* unlock */
+ NULL, /* truncate */
+ NULL, /* lock */
+ NULL, /* unlock */
H5FD_FLMAP_DICHOTOMY /* fl_map */
};
@@ -1507,133 +1501,4 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5FD__ros3_read() */
-/*-------------------------------------------------------------------------
- *
- * Function: H5FD__ros3_write()
- *
- * Purpose:
- *
- * Write bytes to file.
- * UNSUPPORTED IN READ-ONLY ROS3 VFD.
- *
- * Return:
- *
- * FAIL (Not possible with Read-Only S3 file.)
- *
- * Programmer: Jacob Smith
- * 2017-10-23
- *
- *-------------------------------------------------------------------------
- */
-static herr_t
-H5FD__ros3_write(H5FD_t H5_ATTR_UNUSED *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNUSED dxpl_id,
- haddr_t H5_ATTR_UNUSED addr, size_t H5_ATTR_UNUSED size, const void H5_ATTR_UNUSED *buf)
-{
- herr_t ret_value = FAIL;
-
- FUNC_ENTER_STATIC
-
-#if ROS3_DEBUG
- HDfprintf(stdout, "H5FD__ros3_write() called.\n");
-#endif
-
- HGOTO_ERROR(H5E_VFL, H5E_UNSUPPORTED, FAIL, "cannot write to read-only file.")
-
-done:
- FUNC_LEAVE_NOAPI(ret_value)
-} /* H5FD__ros3_write() */
-
-/*-------------------------------------------------------------------------
- *
- * Function: H5FD__ros3_truncate()
- *
- * Purpose:
- *
- * Makes sure that the true file size is the same (or larger)
- * than the end-of-address.
- *
- * NOT POSSIBLE ON READ-ONLY S3 FILES.
- *
- * Return:
- *
- * FAIL (Not possible on Read-Only S3 files.)
- *
- * Programmer: Jacob Smith
- * 2017-10-23
- *
- *-------------------------------------------------------------------------
- */
-static herr_t
-H5FD__ros3_truncate(H5FD_t H5_ATTR_UNUSED *_file, hid_t H5_ATTR_UNUSED dxpl_id,
- hbool_t H5_ATTR_UNUSED closing)
-{
- herr_t ret_value = SUCCEED;
-
- FUNC_ENTER_STATIC
-
-#if ROS3_DEBUG
- HDfprintf(stdout, "H5FD__ros3_truncate() called.\n");
-#endif
-
- HGOTO_ERROR(H5E_VFL, H5E_UNSUPPORTED, FAIL, "cannot truncate read-only file.")
-
-done:
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5FD__ros3_truncate() */
-
-/*-------------------------------------------------------------------------
- *
- * Function: H5FD__ros3_lock()
- *
- * Purpose:
- *
- * Place an advisory lock on a file.
- * No effect on Read-Only S3 file.
- *
- * Suggestion: remove lock/unlock from class
- * > would result in error at H5FD_[un]lock() (H5FD.c)
- *
- * Return:
- *
- * SUCCEED (No-op always succeeds)
- *
- * Programmer: Jacob Smith
- * 2017-11-03
- *
- *-------------------------------------------------------------------------
- */
-static herr_t
-H5FD__ros3_lock(H5FD_t H5_ATTR_UNUSED *_file, hbool_t H5_ATTR_UNUSED rw)
-{
- FUNC_ENTER_STATIC_NOERR
-
- FUNC_LEAVE_NOAPI(SUCCEED)
-} /* end H5FD__ros3_lock() */
-
-/*-------------------------------------------------------------------------
- *
- * Function: H5FD__ros3_unlock()
- *
- * Purpose:
- *
- * Remove the existing lock on the file.
- * No effect on Read-Only S3 file.
- *
- * Return:
- *
- * SUCCEED (No-op always succeeds)
- *
- * Programmer: Jacob Smith
- * 2017-11-03
- *
- *-------------------------------------------------------------------------
- */
-static herr_t
-H5FD__ros3_unlock(H5FD_t H5_ATTR_UNUSED *_file)
-{
- FUNC_ENTER_STATIC_NOERR
-
- FUNC_LEAVE_NOAPI(SUCCEED)
-} /* end H5FD__ros3_unlock() */
-
#endif /* H5_HAVE_ROS3_VFD */