Merging in latest from upstream (HDFFV/hdf5:refs/heads/hdf5_1_10)
* commit 'd22f49d830b8d1385c7335c6f41c1785cd06ac66': Fixed bugs in pread/pwrite I/O in VFDs.
This commit is contained in:
@@ -337,6 +337,7 @@ H5FD__core_write_to_bstore(H5FD_core_t *file, haddr_t addr, size_t size)
|
||||
unsigned char *ptr = file->mem + addr; /* mutable pointer into the
|
||||
* buffer (can't change mem)
|
||||
*/
|
||||
HDoff_t offset = (HDoff_t)addr; /* Offset to write at */
|
||||
herr_t ret_value = SUCCEED; /* Return value */
|
||||
|
||||
FUNC_ENTER_NOAPI_NOINIT
|
||||
@@ -353,7 +354,6 @@ H5FD__core_write_to_bstore(H5FD_core_t *file, haddr_t addr, size_t size)
|
||||
|
||||
h5_posix_io_t bytes_in = 0; /* # of bytes to write */
|
||||
h5_posix_io_ret_t bytes_wrote = -1; /* # of bytes written */
|
||||
HDoff_t offset = (HDoff_t)addr;
|
||||
|
||||
/* Trying to write more bytes than the return type can handle is
|
||||
* undefined behavior in POSIX.
|
||||
@@ -366,7 +366,8 @@ H5FD__core_write_to_bstore(H5FD_core_t *file, haddr_t addr, size_t size)
|
||||
do {
|
||||
#ifdef H5_HAVE_PREADWRITE
|
||||
bytes_wrote = HDpwrite(file->fd, ptr, bytes_in, offset);
|
||||
offset += bytes_wrote;
|
||||
if(bytes_wrote > 0)
|
||||
offset += bytes_wrote;
|
||||
#else
|
||||
bytes_wrote = HDwrite(file->fd, ptr, bytes_in);
|
||||
#endif /* H5_HAVE_PREADWRITE */
|
||||
@@ -749,12 +750,12 @@ H5FD__core_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr
|
||||
* partial results, and the end of the file.
|
||||
*/
|
||||
|
||||
uint8_t *mem = file->mem; /* memory pointer for writes */
|
||||
uint8_t *mem = file->mem; /* memory pointer for writes */
|
||||
HDoff_t offset = (HDoff_t)0; /* offset for reading */
|
||||
|
||||
while(size > 0) {
|
||||
h5_posix_io_t bytes_in = 0; /* # of bytes to read */
|
||||
h5_posix_io_ret_t bytes_read = -1; /* # of bytes actually read */
|
||||
HDoff_t offset = (HDoff_t)0;
|
||||
|
||||
/* Trying to read more bytes than the return type can handle is
|
||||
* undefined behavior in POSIX.
|
||||
@@ -767,7 +768,8 @@ H5FD__core_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr
|
||||
do {
|
||||
#ifdef H5_HAVE_PREADWRITE
|
||||
bytes_read = HDpread(file->fd, mem, bytes_in, offset);
|
||||
offset += bytes_read;
|
||||
if(bytes_read > 0)
|
||||
offset += bytes_read;
|
||||
#else
|
||||
bytes_read = HDread(file->fd, mem, bytes_in);
|
||||
#endif /* H5_HAVE_PREADWRITE */
|
||||
|
||||
@@ -1163,6 +1163,7 @@ H5FD_log_read(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, hadd
|
||||
#ifdef H5_HAVE_GETTIMEOFDAY
|
||||
struct timeval timeval_start, timeval_stop;
|
||||
#endif /* H5_HAVE_GETTIMEOFDAY */
|
||||
HDoff_t offset = (HDoff_t)addr;
|
||||
herr_t ret_value = SUCCEED; /* Return value */
|
||||
|
||||
FUNC_ENTER_NOAPI_NOINIT
|
||||
@@ -1247,7 +1248,6 @@ H5FD_log_read(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, hadd
|
||||
|
||||
h5_posix_io_t bytes_in = 0; /* # of bytes to read */
|
||||
h5_posix_io_ret_t bytes_read = -1; /* # of bytes actually read */
|
||||
HDoff_t offset = (HDoff_t)addr;
|
||||
|
||||
/* Trying to read more bytes than the return type can handle is
|
||||
* undefined behavior in POSIX.
|
||||
@@ -1260,7 +1260,8 @@ H5FD_log_read(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, hadd
|
||||
do {
|
||||
#ifdef H5_HAVE_PREADWRITE
|
||||
bytes_read = HDpread(file->fd, buf, bytes_in, offset);
|
||||
offset += bytes_read;
|
||||
if(bytes_read > 0)
|
||||
offset += bytes_read;
|
||||
#else
|
||||
bytes_read = HDread(file->fd, buf, bytes_in);
|
||||
#endif /* H5_HAVE_PREADWRITE */
|
||||
@@ -1374,6 +1375,7 @@ H5FD_log_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, had
|
||||
#ifdef H5_HAVE_GETTIMEOFDAY
|
||||
struct timeval timeval_start, timeval_stop;
|
||||
#endif /* H5_HAVE_GETTIMEOFDAY */
|
||||
HDoff_t offset = (HDoff_t)addr;
|
||||
herr_t ret_value = SUCCEED; /* Return value */
|
||||
|
||||
FUNC_ENTER_NOAPI_NOINIT
|
||||
@@ -1463,7 +1465,6 @@ H5FD_log_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, had
|
||||
|
||||
h5_posix_io_t bytes_in = 0; /* # of bytes to write */
|
||||
h5_posix_io_ret_t bytes_wrote = -1; /* # of bytes written */
|
||||
HDoff_t offset = (HDoff_t)addr;
|
||||
|
||||
/* Trying to write more bytes than the return type can handle is
|
||||
* undefined behavior in POSIX.
|
||||
@@ -1476,7 +1477,8 @@ H5FD_log_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, had
|
||||
do {
|
||||
#ifdef H5_HAVE_PREADWRITE
|
||||
bytes_wrote = HDpwrite(file->fd, buf, bytes_in, offset);
|
||||
offset += bytes_wrote;
|
||||
if(bytes_wrote > 0)
|
||||
offset += bytes_wrote;
|
||||
#else
|
||||
bytes_wrote = HDwrite(file->fd, buf, bytes_in);
|
||||
#endif /* H5_HAVE_PREADWRITE */
|
||||
|
||||
@@ -669,6 +669,7 @@ H5FD_sec2_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNUS
|
||||
haddr_t addr, size_t size, void *buf /*out*/)
|
||||
{
|
||||
H5FD_sec2_t *file = (H5FD_sec2_t *)_file;
|
||||
HDoff_t offset = (HDoff_t)addr;
|
||||
herr_t ret_value = SUCCEED; /* Return value */
|
||||
|
||||
FUNC_ENTER_NOAPI_NOINIT
|
||||
@@ -687,7 +688,7 @@ H5FD_sec2_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNUS
|
||||
if(addr != file->pos || OP_READ != file->op) {
|
||||
if(HDlseek(file->fd, (HDoff_t)addr, SEEK_SET) < 0)
|
||||
HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to seek to proper position")
|
||||
} /* end if */
|
||||
}
|
||||
#endif /* H5_HAVE_PREADWRITE */
|
||||
|
||||
/* Read data, being careful of interrupted system calls, partial results,
|
||||
@@ -697,7 +698,6 @@ H5FD_sec2_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNUS
|
||||
|
||||
h5_posix_io_t bytes_in = 0; /* # of bytes to read */
|
||||
h5_posix_io_ret_t bytes_read = -1; /* # of bytes actually read */
|
||||
HDoff_t offset = (HDoff_t)addr;
|
||||
|
||||
/* Trying to read more bytes than the return type can handle is
|
||||
* undefined behavior in POSIX.
|
||||
@@ -710,7 +710,8 @@ H5FD_sec2_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNUS
|
||||
do {
|
||||
#ifdef H5_HAVE_PREADWRITE
|
||||
bytes_read = HDpread(file->fd, buf, bytes_in, offset);
|
||||
offset += bytes_read;
|
||||
if(bytes_read > 0)
|
||||
offset += bytes_read;
|
||||
#else
|
||||
bytes_read = HDread(file->fd, buf, bytes_in);
|
||||
#endif /* H5_HAVE_PREADWRITE */
|
||||
@@ -773,6 +774,7 @@ H5FD_sec2_write(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNU
|
||||
haddr_t addr, size_t size, const void *buf)
|
||||
{
|
||||
H5FD_sec2_t *file = (H5FD_sec2_t *)_file;
|
||||
HDoff_t offset = (HDoff_t)addr;
|
||||
herr_t ret_value = SUCCEED; /* Return value */
|
||||
|
||||
FUNC_ENTER_NOAPI_NOINIT
|
||||
@@ -791,7 +793,7 @@ H5FD_sec2_write(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNU
|
||||
if(addr != file->pos || OP_WRITE != file->op) {
|
||||
if(HDlseek(file->fd, (HDoff_t)addr, SEEK_SET) < 0)
|
||||
HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to seek to proper position")
|
||||
} /* end if */
|
||||
}
|
||||
#endif /* H5_HAVE_PREADWRITE */
|
||||
|
||||
/* Write the data, being careful of interrupted system calls and partial
|
||||
@@ -801,7 +803,6 @@ H5FD_sec2_write(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNU
|
||||
|
||||
h5_posix_io_t bytes_in = 0; /* # of bytes to write */
|
||||
h5_posix_io_ret_t bytes_wrote = -1; /* # of bytes written */
|
||||
HDoff_t offset = (HDoff_t)addr;
|
||||
|
||||
/* Trying to write more bytes than the return type can handle is
|
||||
* undefined behavior in POSIX.
|
||||
@@ -814,7 +815,8 @@ H5FD_sec2_write(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNU
|
||||
do {
|
||||
#ifdef H5_HAVE_PREADWRITE
|
||||
bytes_wrote = HDpwrite(file->fd, buf, bytes_in, offset);
|
||||
offset += bytes_wrote;
|
||||
if(bytes_wrote > 0)
|
||||
offset += bytes_wrote;
|
||||
#else
|
||||
bytes_wrote = HDwrite(file->fd, buf, bytes_in);
|
||||
#endif /* H5_HAVE_PREADWRITE */
|
||||
|
||||
Reference in New Issue
Block a user