Skip to content

Commit

Permalink
Simplify changes to keep I/O retry logic the same
Browse files Browse the repository at this point in the history
Signed-off-by: Quincey Koziol <quincey@koziol.cc>
  • Loading branch information
qkoziol committed May 20, 2024
1 parent 7bdacb0 commit ebdc0b9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
16 changes: 10 additions & 6 deletions src/H5FDlog.c
Original file line number Diff line number Diff line change
Expand Up @@ -1222,6 +1222,8 @@ H5FD__log_read(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, had
do {
#ifdef H5_HAVE_PREADWRITE
bytes_read = HDpread(file->fd, buf, bytes_in, offset);
if (bytes_read > 0)
offset += bytes_read;
#else
bytes_read = HDread(file->fd, buf, bytes_in);
#endif /* H5_HAVE_PREADWRITE */
Expand Down Expand Up @@ -1256,7 +1258,7 @@ H5FD__log_read(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, had
assert((size_t)bytes_read <= size);

size -= (size_t)bytes_read;
offset += (HDoff_t)bytes_read;
addr += (haddr_t)bytes_read;
buf = (char *)buf + bytes_read;
}

Expand Down Expand Up @@ -1300,7 +1302,7 @@ H5FD__log_read(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, had

#ifndef H5_HAVE_PREADWRITE
/* Update current position */
file->pos = (haddr_t)offset;
file->pos = addr;
file->op = OP_READ;
#endif /* H5_HAVE_PREADWRITE */

Expand Down Expand Up @@ -1443,6 +1445,8 @@ H5FD__log_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, ha
do {
#ifdef H5_HAVE_PREADWRITE
bytes_wrote = HDpwrite(file->fd, buf, bytes_in, offset);
if (bytes_wrote > 0)
offset += bytes_wrote;
#else
bytes_wrote = HDwrite(file->fd, buf, bytes_in);
#endif /* H5_HAVE_PREADWRITE */
Expand Down Expand Up @@ -1471,7 +1475,7 @@ H5FD__log_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, ha
assert((size_t)bytes_wrote <= size);

size -= (size_t)bytes_wrote;
offset += (HDoff_t)bytes_wrote;
addr += (haddr_t)bytes_wrote;
buf = (const char *)buf + bytes_wrote;
} /* end while */

Expand Down Expand Up @@ -1515,11 +1519,11 @@ H5FD__log_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, ha

/* Update current position and eof */
#ifndef H5_HAVE_PREADWRITE
file->pos = (haddr_t)offset;
file->pos = addr;
file->op = OP_WRITE;
#endif /* H5_HAVE_PREADWRITE */
if ((haddr_t)offset > file->eof)
file->eof = (haddr_t)offset;
if (addr > file->eof)
file->eof = addr;

done:
#ifndef H5_HAVE_PREADWRITE
Expand Down
14 changes: 9 additions & 5 deletions src/H5FDsec2.c
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,8 @@ H5FD__sec2_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNU
do {
#ifdef H5_HAVE_PREADWRITE
bytes_read = HDpread(file->fd, buf, bytes_in, offset);
if (bytes_read > 0)
offset += bytes_read;
#else
bytes_read = HDread(file->fd, buf, bytes_in);
#endif /* H5_HAVE_PREADWRITE */
Expand Down Expand Up @@ -719,13 +721,13 @@ H5FD__sec2_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNU
assert((size_t)bytes_read <= size);

size -= (size_t)bytes_read;
offset += (HDoff_t)bytes_read;
addr += (haddr_t)bytes_read;
buf = (char *)buf + bytes_read;
} /* end while */

#ifndef H5_HAVE_PREADWRITE
/* Update current position */
file->pos = (haddr_t)offset;
file->pos = addr;
file->op = OP_READ;
#endif /* H5_HAVE_PREADWRITE */

Expand Down Expand Up @@ -797,6 +799,8 @@ H5FD__sec2_write(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UN
do {
#ifdef H5_HAVE_PREADWRITE
bytes_wrote = HDpwrite(file->fd, buf, bytes_in, offset);
if (bytes_wrote > 0)
offset += bytes_wrote;
#else
bytes_wrote = HDwrite(file->fd, buf, bytes_in);
#endif /* H5_HAVE_PREADWRITE */
Expand All @@ -821,7 +825,7 @@ H5FD__sec2_write(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UN
assert((size_t)bytes_wrote <= size);

size -= (size_t)bytes_wrote;
offset += (HDoff_t)bytes_wrote;
addr += (haddr_t)bytes_wrote;
buf = (const char *)buf + bytes_wrote;
} /* end while */

Expand All @@ -830,8 +834,8 @@ H5FD__sec2_write(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UN
file->pos = addr;
file->op = OP_WRITE;
#endif /* H5_HAVE_PREADWRITE */
if ((haddr_t)offset > file->eof)
file->eof = (haddr_t)offset;
if (addr > file->eof)
file->eof = addr;

done:
#ifndef H5_HAVE_PREADWRITE
Expand Down

0 comments on commit ebdc0b9

Please sign in to comment.