From 3dce0d77f039dc0dcf465636392efc086c30bcc0 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Wed, 15 May 2024 11:53:55 -0500 Subject: [PATCH 1/5] Improve spec. reading superblock into cache (a little) by using v2 size Instead of reading the absolute minimal possible, use the likely value of a v2+ superblock w/8-byte addresses & lengths. Signed-off-by: Quincey Koziol --- src/H5Fpkg.h | 5 +++++ src/H5Fsuper.c | 3 +-- src/H5Fsuper_cache.c | 3 +-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/H5Fpkg.h b/src/H5Fpkg.h index 7e12ff111d0..1a9ace0ceaf 100644 --- a/src/H5Fpkg.h +++ b/src/H5Fpkg.h @@ -131,6 +131,11 @@ (H5F_SUPERBLOCK_FIXED_SIZE + \ H5F_SUPERBLOCK_VARLEN_SIZE((s)->super_vers, (s)->sizeof_addr, (s)->sizeof_size)) +/* Optimistic read size for superblock */ +/* Size of a v2+ superblock, w/8-byte addresses & lengths */ +#define H5F_SUPERBLOCK_SPEC_READ_SIZE \ + (H5F_SUPERBLOCK_FIXED_SIZE + H5F_SUPERBLOCK_VARLEN_SIZE(2, 8, 8)) + /* For superblock version 0 & 1: Offset to the file consistency flags (status_flags) in the superblock (excluding H5F_SUPERBLOCK_FIXED_SIZE) */ diff --git a/src/H5Fsuper.c b/src/H5Fsuper.c index 6eb465ed9d1..f58bb153f34 100644 --- a/src/H5Fsuper.c +++ b/src/H5Fsuper.c @@ -416,8 +416,7 @@ H5F__super_read(H5F_t *f, H5P_genplist_t *fa_plist, bool initial_read) HGOTO_ERROR(H5E_FILE, H5E_BADTYPE, FAIL, "can't get property list"); /* Make certain we can read the fixed-size portion of the superblock */ - if (H5F__set_eoa(f, H5FD_MEM_SUPER, - (haddr_t)(H5F_SUPERBLOCK_FIXED_SIZE + H5F_SUPERBLOCK_MINIMAL_VARLEN_SIZE)) < 0) + if (H5F__set_eoa(f, H5FD_MEM_SUPER, (haddr_t)H5F_SUPERBLOCK_SPEC_READ_SIZE) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "set end of space allocation request failed"); /* Set up the user data for cache callbacks */ diff --git a/src/H5Fsuper_cache.c b/src/H5Fsuper_cache.c index 9c475ab26a2..2a425099b47 100644 --- a/src/H5Fsuper_cache.c +++ b/src/H5Fsuper_cache.c @@ -306,8 +306,7 @@ H5F__cache_superblock_get_initial_load_size(void H5_ATTR_UNUSED *_udata, size_t assert(image_len); /* Set the initial image length size */ - *image_len = H5F_SUPERBLOCK_FIXED_SIZE + /* Fixed size of superblock */ - H5F_SUPERBLOCK_MINIMAL_VARLEN_SIZE; + *image_len = H5F_SUPERBLOCK_SPEC_READ_SIZE; FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5F__cache_superblock_get_initial_load_size() */ From de64d91001760847c2e99f0a366806e5735989eb Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 15 May 2024 16:57:26 +0000 Subject: [PATCH 2/5] Committing clang-format changes --- src/H5Fpkg.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/H5Fpkg.h b/src/H5Fpkg.h index 1a9ace0ceaf..06d13ebffdd 100644 --- a/src/H5Fpkg.h +++ b/src/H5Fpkg.h @@ -133,8 +133,7 @@ /* Optimistic read size for superblock */ /* Size of a v2+ superblock, w/8-byte addresses & lengths */ -#define H5F_SUPERBLOCK_SPEC_READ_SIZE \ - (H5F_SUPERBLOCK_FIXED_SIZE + H5F_SUPERBLOCK_VARLEN_SIZE(2, 8, 8)) +#define H5F_SUPERBLOCK_SPEC_READ_SIZE (H5F_SUPERBLOCK_FIXED_SIZE + H5F_SUPERBLOCK_VARLEN_SIZE(2, 8, 8)) /* For superblock version 0 & 1: Offset to the file consistency flags (status_flags) in the superblock (excluding H5F_SUPERBLOCK_FIXED_SIZE) From 7f4f4fde5315cdd8aaad09f447317ff65e955ee8 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Wed, 15 May 2024 12:43:54 -0500 Subject: [PATCH 3/5] Don't update 'pos' and 'op' fields when using pread/pwrite Signed-off-by: Quincey Koziol --- src/H5FDlog.c | 30 ++++++++++++++++++++---------- src/H5FDsec2.c | 28 +++++++++++++++++++--------- 2 files changed, 39 insertions(+), 19 deletions(-) diff --git a/src/H5FDlog.c b/src/H5FDlog.c index 30eaa9287eb..f2ab69b6f43 100644 --- a/src/H5FDlog.c +++ b/src/H5FDlog.c @@ -71,8 +71,10 @@ typedef struct H5FD_log_t { int fd; /* the unix file */ haddr_t eoa; /* end of allocated region */ haddr_t eof; /* end of file; current file size */ +#ifndef H5_HAVE_PREADWRITE haddr_t pos; /* current file I/O position */ H5FD_file_op_t op; /* last operation */ +#endif /* H5_HAVE_PREADWRITE */ bool ignore_disabled_file_locks; char filename[H5FD_MAX_FILENAME_LEN]; /* Copy of file name from open operation */ #ifndef H5_HAVE_WIN32_API @@ -526,8 +528,10 @@ H5FD__log_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) file->fd = fd; H5_CHECKED_ASSIGN(file->eof, haddr_t, sb.st_size, h5_stat_size_t); +#ifndef H5_HAVE_PREADWRITE file->pos = HADDR_UNDEF; file->op = OP_UNKNOWN; +#endif /* H5_HAVE_PREADWRITE */ #ifdef H5_HAVE_WIN32_API file->hFile = (HANDLE)_get_osfhandle(fd); if (INVALID_HANDLE_VALUE == file->hFile) @@ -1218,8 +1222,6 @@ 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 */ @@ -1254,7 +1256,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; - addr += (haddr_t)bytes_read; + offset += (HDoff_t)bytes_read; buf = (char *)buf + bytes_read; } @@ -1296,16 +1298,20 @@ H5FD__log_read(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, had fprintf(file->logfp, "\n"); } +#ifndef H5_HAVE_PREADWRITE /* Update current position */ - file->pos = addr; + file->pos = (haddr_t)offset; file->op = OP_READ; +#endif /* H5_HAVE_PREADWRITE */ done: +#ifndef H5_HAVE_PREADWRITE if (ret_value < 0) { /* Reset last file I/O information */ file->pos = HADDR_UNDEF; file->op = OP_UNKNOWN; } +#endif /* H5_HAVE_PREADWRITE */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__log_read() */ @@ -1437,8 +1443,6 @@ 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 */ @@ -1467,7 +1471,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; - addr += (haddr_t)bytes_wrote; + offset += (HDoff_t)bytes_wrote; buf = (const char *)buf + bytes_wrote; } /* end while */ @@ -1510,17 +1514,21 @@ H5FD__log_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, ha } /* Update current position and eof */ - file->pos = addr; +#ifndef H5_HAVE_PREADWRITE + file->pos = (haddr_t)offset; file->op = OP_WRITE; - if (file->pos > file->eof) - file->eof = file->pos; +#endif /* H5_HAVE_PREADWRITE */ + if ((haddr_t)offset > file->eof) + file->eof = (haddr_t)offset; done: +#ifndef H5_HAVE_PREADWRITE if (ret_value < 0) { /* Reset last file I/O information */ file->pos = HADDR_UNDEF; file->op = OP_UNKNOWN; } +#endif /* H5_HAVE_PREADWRITE */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__log_write() */ @@ -1621,9 +1629,11 @@ H5FD__log_truncate(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, bool H5_ATTR_UNU /* Update the eof value */ file->eof = file->eoa; +#ifndef H5_HAVE_PREADWRITE /* Reset last file I/O information */ file->pos = HADDR_UNDEF; file->op = OP_UNKNOWN; +#endif /* H5_HAVE_PREADWRITE */ } /* end if */ done: diff --git a/src/H5FDsec2.c b/src/H5FDsec2.c index dcac912454c..bc9c78a3d81 100644 --- a/src/H5FDsec2.c +++ b/src/H5FDsec2.c @@ -52,8 +52,10 @@ typedef struct H5FD_sec2_t { int fd; /* the filesystem file descriptor */ haddr_t eoa; /* end of allocated region */ haddr_t eof; /* end of file; current file size */ +#ifndef H5_HAVE_PREADWRITE haddr_t pos; /* current file I/O position */ H5FD_file_op_t op; /* last operation */ +#endif /* H5_HAVE_PREADWRITE */ bool ignore_disabled_file_locks; char filename[H5FD_MAX_FILENAME_LEN]; /* Copy of file name from open operation */ #ifndef H5_HAVE_WIN32_API @@ -334,8 +336,10 @@ H5FD__sec2_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr file->fd = fd; H5_CHECKED_ASSIGN(file->eof, haddr_t, sb.st_size, h5_stat_size_t); +#ifndef H5_HAVE_PREADWRITE file->pos = HADDR_UNDEF; file->op = OP_UNKNOWN; +#endif /* H5_HAVE_PREADWRITE */ #ifdef H5_HAVE_WIN32_API file->hFile = (HANDLE)_get_osfhandle(fd); if (INVALID_HANDLE_VALUE == file->hFile) @@ -685,8 +689,6 @@ 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 */ @@ -717,20 +719,24 @@ 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; - addr += (haddr_t)bytes_read; + offset += (HDoff_t)bytes_read; buf = (char *)buf + bytes_read; } /* end while */ +#ifndef H5_HAVE_PREADWRITE /* Update current position */ - file->pos = addr; + file->pos = (haddr_t)offset; file->op = OP_READ; +#endif /* H5_HAVE_PREADWRITE */ done: +#ifndef H5_HAVE_PREADWRITE if (ret_value < 0) { /* Reset last file I/O information */ file->pos = HADDR_UNDEF; file->op = OP_UNKNOWN; } /* end if */ +#endif /* H5_HAVE_PREADWRITE */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__sec2_read() */ @@ -791,8 +797,6 @@ 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 */ @@ -817,22 +821,26 @@ 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; - addr += (haddr_t)bytes_wrote; + offset += (HDoff_t)bytes_wrote; buf = (const char *)buf + bytes_wrote; } /* end while */ /* Update current position and eof */ +#ifndef H5_HAVE_PREADWRITE file->pos = addr; file->op = OP_WRITE; - if (file->pos > file->eof) - file->eof = file->pos; +#endif /* H5_HAVE_PREADWRITE */ + if ((haddr_t)offset > file->eof) + file->eof = (haddr_t)offset; done: +#ifndef H5_HAVE_PREADWRITE if (ret_value < 0) { /* Reset last file I/O information */ file->pos = HADDR_UNDEF; file->op = OP_UNKNOWN; } /* end if */ +#endif /* H5_HAVE_PREADWRITE */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__sec2_write() */ @@ -893,9 +901,11 @@ H5FD__sec2_truncate(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, bool H5_ATTR_UN /* Update the eof value */ file->eof = file->eoa; +#ifndef H5_HAVE_PREADWRITE /* Reset last file I/O information */ file->pos = HADDR_UNDEF; file->op = OP_UNKNOWN; +#endif /* H5_HAVE_PREADWRITE */ } /* end if */ done: From 5abf01eae25fe8cdb903baddcb88b81609899c9d Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 15 May 2024 17:46:00 +0000 Subject: [PATCH 4/5] Committing clang-format changes --- src/H5FDlog.c | 16 ++++++++-------- src/H5FDsec2.c | 20 ++++++++++---------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/H5FDlog.c b/src/H5FDlog.c index f2ab69b6f43..cc82da1cd60 100644 --- a/src/H5FDlog.c +++ b/src/H5FDlog.c @@ -67,16 +67,16 @@ static const char *flavors[] = { * occurs), and `op' will be set to H5F_OP_UNKNOWN. */ typedef struct H5FD_log_t { - H5FD_t pub; /* public stuff, must be first */ - int fd; /* the unix file */ - haddr_t eoa; /* end of allocated region */ - haddr_t eof; /* end of file; current file size */ + H5FD_t pub; /* public stuff, must be first */ + int fd; /* the unix file */ + haddr_t eoa; /* end of allocated region */ + haddr_t eof; /* end of file; current file size */ #ifndef H5_HAVE_PREADWRITE haddr_t pos; /* current file I/O position */ H5FD_file_op_t op; /* last operation */ -#endif /* H5_HAVE_PREADWRITE */ - bool ignore_disabled_file_locks; - char filename[H5FD_MAX_FILENAME_LEN]; /* Copy of file name from open operation */ +#endif /* H5_HAVE_PREADWRITE */ + bool ignore_disabled_file_locks; + char filename[H5FD_MAX_FILENAME_LEN]; /* Copy of file name from open operation */ #ifndef H5_HAVE_WIN32_API /* On most systems the combination of device and i-node number uniquely * identify a file. Note that Cygwin, MinGW and other Windows POSIX @@ -1634,7 +1634,7 @@ H5FD__log_truncate(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, bool H5_ATTR_UNU file->pos = HADDR_UNDEF; file->op = OP_UNKNOWN; #endif /* H5_HAVE_PREADWRITE */ - } /* end if */ + } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5FDsec2.c b/src/H5FDsec2.c index bc9c78a3d81..1143c0500ab 100644 --- a/src/H5FDsec2.c +++ b/src/H5FDsec2.c @@ -48,16 +48,16 @@ static htri_t ignore_disabled_file_locks_s = FAIL; * occurs), and 'op' will be set to H5F_OP_UNKNOWN. */ typedef struct H5FD_sec2_t { - H5FD_t pub; /* public stuff, must be first */ - int fd; /* the filesystem file descriptor */ - haddr_t eoa; /* end of allocated region */ - haddr_t eof; /* end of file; current file size */ + H5FD_t pub; /* public stuff, must be first */ + int fd; /* the filesystem file descriptor */ + haddr_t eoa; /* end of allocated region */ + haddr_t eof; /* end of file; current file size */ #ifndef H5_HAVE_PREADWRITE haddr_t pos; /* current file I/O position */ H5FD_file_op_t op; /* last operation */ -#endif /* H5_HAVE_PREADWRITE */ - bool ignore_disabled_file_locks; - char filename[H5FD_MAX_FILENAME_LEN]; /* Copy of file name from open operation */ +#endif /* H5_HAVE_PREADWRITE */ + bool ignore_disabled_file_locks; + char filename[H5FD_MAX_FILENAME_LEN]; /* Copy of file name from open operation */ #ifndef H5_HAVE_WIN32_API /* On most systems the combination of device and i-node number uniquely * identify a file. Note that Cygwin, MinGW and other Windows POSIX @@ -735,7 +735,7 @@ H5FD__sec2_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNU /* Reset last file I/O information */ file->pos = HADDR_UNDEF; file->op = OP_UNKNOWN; - } /* end if */ + } /* end if */ #endif /* H5_HAVE_PREADWRITE */ FUNC_LEAVE_NOAPI(ret_value) @@ -839,7 +839,7 @@ H5FD__sec2_write(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UN /* Reset last file I/O information */ file->pos = HADDR_UNDEF; file->op = OP_UNKNOWN; - } /* end if */ + } /* end if */ #endif /* H5_HAVE_PREADWRITE */ FUNC_LEAVE_NOAPI(ret_value) @@ -906,7 +906,7 @@ H5FD__sec2_truncate(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, bool H5_ATTR_UN file->pos = HADDR_UNDEF; file->op = OP_UNKNOWN; #endif /* H5_HAVE_PREADWRITE */ - } /* end if */ + } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) From ebdc0b9815218e8f34f8c12bd6d1b6e57bbf8bdd Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Mon, 20 May 2024 14:56:13 -0500 Subject: [PATCH 5/5] Simplify changes to keep I/O retry logic the same Signed-off-by: Quincey Koziol --- src/H5FDlog.c | 16 ++++++++++------ src/H5FDsec2.c | 14 +++++++++----- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/H5FDlog.c b/src/H5FDlog.c index cc82da1cd60..e8131726fef 100644 --- a/src/H5FDlog.c +++ b/src/H5FDlog.c @@ -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 */ @@ -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; } @@ -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 */ @@ -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 */ @@ -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 */ @@ -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 diff --git a/src/H5FDsec2.c b/src/H5FDsec2.c index 1143c0500ab..0a623e9cb36 100644 --- a/src/H5FDsec2.c +++ b/src/H5FDsec2.c @@ -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 */ @@ -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 */ @@ -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 */ @@ -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 */ @@ -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