diff options
author | Raymond Lu <songyulu@hdfgroup.org> | 2007-03-15 21:17:09 (GMT) |
---|---|---|
committer | Raymond Lu <songyulu@hdfgroup.org> | 2007-03-15 21:17:09 (GMT) |
commit | 24fb6ed7c69e5a3f372c6b65eae8fa4ccba8db13 (patch) | |
tree | a4bbeb35f36623e14d575cd44a73076f67b3f08f | |
parent | 4a6abb3ac5c42efdfc3ffba6173bd3c3a1d330fd (diff) | |
download | hdf5-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.
-rw-r--r-- | src/H5FDdirect.c | 32 | ||||
-rw-r--r-- | test/vfd.c | 11 |
2 files changed, 31 insertions, 12 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; @@ -188,8 +188,15 @@ test_direct(void) if(H5Pset_alignment(fapl, (hsize_t)THRESHOLD, (hsize_t)FBSIZE)<0) TEST_ERROR; - if((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl))<0) - TEST_ERROR; + H5E_BEGIN_TRY { + file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); + } H5E_END_TRY; + if(file<0) { + H5Pclose (fapl); + SKIPPED(); + printf(" Probably the file system doesn't support Direct I/O\n"); + return 0; + } /* Retrieve the access property list... */ if ((access_fapl = H5Fget_access_plist(file)) < 0) |