Fix caching issue in ROS3 VFD (#5507)

Fix an incorrect range check that would prevent reads
from being served from the ROS3 VFD's internal cache
when the offset + length of the read extends exactly
to the end of the cached range of bytes.
This commit is contained in:
jhendersonHDF
2025-05-05 07:53:01 -05:00
committed by GitHub
parent 2a7fc63be7
commit f38cea902a
2 changed files with 15 additions and 5 deletions
+10
View File
@@ -549,6 +549,16 @@ Bug Fixes since HDF5-2.0.0 release
=================================== ===================================
Library Library
------- -------
- Fixed an issue with caching in the ROS3 VFD
The ROS3 VFD uses a very simple caching mechanism that caches the
first 16MiB of a file during file open and serves later reads from
that cache if the offset + length falls within the cached range of
bytes. Combinations of offset + length that extended exactly to the
end of the cached range of bytes (for example, offset=0 and
len=16777216) would end up not being served from the cache due to
an incorrect range check. This has now been fixed.
- Fixed an error with H5Fget_file_image() with the latest file format - Fixed an error with H5Fget_file_image() with the latest file format
When using H5Fget_file_image() on a file created with the latest file When using H5Fget_file_image() on a file created with the latest file
+5 -5
View File
@@ -789,8 +789,8 @@ done:
if (H5FD__s3comms_s3r_close(handle) < 0) if (H5FD__s3comms_s3r_close(handle) < 0)
HDONE_ERROR(H5E_VFL, H5E_CANTCLOSEFILE, NULL, "unable to close s3 file handle"); HDONE_ERROR(H5E_VFL, H5E_CANTCLOSEFILE, NULL, "unable to close s3 file handle");
if (file != NULL) { if (file != NULL) {
H5MM_xfree(file->cache); file->cache = H5MM_xfree(file->cache);
file = H5FL_FREE(H5FD_ros3_t, file); file = H5FL_FREE(H5FD_ros3_t, file);
} }
curl_global_cleanup(); curl_global_cleanup();
} }
@@ -827,8 +827,8 @@ H5FD__ros3_close(H5FD_t H5_ATTR_UNUSED *_file)
HGOTO_ERROR(H5E_VFL, H5E_CANTCLOSEFILE, FAIL, "unable to close S3 request handle"); HGOTO_ERROR(H5E_VFL, H5E_CANTCLOSEFILE, FAIL, "unable to close S3 request handle");
/* Release the file info */ /* Release the file info */
H5MM_xfree(file->cache); file->cache = H5MM_xfree(file->cache);
file = H5FL_FREE(H5FD_ros3_t, file); file = H5FL_FREE(H5FD_ros3_t, file);
done: done:
curl_global_cleanup(); curl_global_cleanup();
@@ -1097,7 +1097,7 @@ H5FD__ros3_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNU
/* Copy from the cache when accessing the first N bytes of the file. /* Copy from the cache when accessing the first N bytes of the file.
* Saves network I/O operations when opening files. * Saves network I/O operations when opening files.
*/ */
if (addr + size < file->cache_size) { if (addr + size <= file->cache_size) {
memcpy(buf, file->cache + addr, size); memcpy(buf, file->cache + addr, size);
} }
else { else {