summaryrefslogtreecommitdiffstats
path: root/src/H5FDdirect.c
diff options
context:
space:
mode:
authorRaymond Lu <songyulu@hdfgroup.org>2007-03-15 21:17:09 (GMT)
committerRaymond Lu <songyulu@hdfgroup.org>2007-03-15 21:17:09 (GMT)
commit24fb6ed7c69e5a3f372c6b65eae8fa4ccba8db13 (patch)
treea4bbeb35f36623e14d575cd44a73076f67b3f08f /src/H5FDdirect.c
parent4a6abb3ac5c42efdfc3ffba6173bd3c3a1d330fd (diff)
downloadhdf5-24fb6ed7c69e5a3f372c6b65eae8fa4ccba8db13.zip
hdf5-24fb6ed7c69e5a3f372c6b65eae8fa4ccba8db13.tar.gz
hdf5-24fb6ed7c69e5a3f372c6b65eae8fa4ccba8db13.tar.bz2
[svn-r13517] To deal with the situation that compiler supports direct I/O but file system doesn't, added a
condition check of writing aligned data. Skip the test for direct VFD if it's this situation.
Diffstat (limited to 'src/H5FDdirect.c')
-rw-r--r--src/H5FDdirect.c32
1 files changed, 22 insertions, 10 deletions
diff --git a/src/H5FDdirect.c b/src/H5FDdirect.c
index 81bd5df..78db28e 100644
--- a/src/H5FDdirect.c
+++ b/src/H5FDdirect.c
@@ -497,7 +497,7 @@ H5FD_direct_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxadd
#endif
h5_stat_t sb;
H5P_genplist_t *plist; /* Property list */
- int *buf;
+ int *buf1, *buf2;
H5FD_t *ret_value;
FUNC_ENTER_NOAPI(H5FD_direct_open, NULL)
@@ -565,22 +565,34 @@ H5FD_direct_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxadd
* is to handle correctly the case that the file is in a different file system
* than the one where the program is running.
*/
- buf = (int*)HDmalloc(sizeof(int));
+ buf1 = (int*)HDmalloc(sizeof(int));
+ if (HDposix_memalign(&buf2, file->fa.mboundary, file->fa.fbsize) != 0)
+ HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, NULL, "HDposix_memalign failed")
+
if(o_flags &= O_CREAT) {
- if(write(file->fd, (void*)buf, sizeof(int))<0)
- file->fa.must_align = TRUE;
- else {
+ if(write(file->fd, (void*)buf1, sizeof(int))<0) {
+ if(write(file->fd, (void*)buf2, file->fa.fbsize)<0)
+ HGOTO_ERROR(H5E_FILE, H5E_WRITEERROR, NULL, "file system may not support Direct I/O")
+ else
+ file->fa.must_align = TRUE;
+ } else {
file->fa.must_align = FALSE;
file_truncate(file->fd, (file_offset_t)0);
}
} else {
- if(read(file->fd, (void*)buf, sizeof(int))<0)
- file->fa.must_align = TRUE;
- else
+ if(read(file->fd, (void*)buf1, sizeof(int))<0) {
+ if(read(file->fd, (void*)buf2, file->fa.fbsize)<0)
+ HGOTO_ERROR(H5E_FILE, H5E_READERROR, NULL, "file system may not support Direct I/O")
+ else
+ file->fa.must_align = TRUE;
+ } else
file->fa.must_align = FALSE;
}
- if(buf)
- HDfree(buf);
+
+ if(buf1)
+ HDfree(buf1);
+ if(buf2)
+ HDfree(buf2);
/* Set return value */
ret_value=(H5FD_t*)file;