diff options
-rw-r--r-- | src/H5FDlog.c | 571 | ||||
-rw-r--r-- | src/H5FDlog.h | 39 | ||||
-rw-r--r-- | src/H5FDprivate.h | 31 | ||||
-rw-r--r-- | src/H5FDsec2.c | 165 | ||||
-rw-r--r-- | src/H5FScache.c | 2 | ||||
-rw-r--r-- | src/H5private.h | 5 |
6 files changed, 425 insertions, 388 deletions
diff --git a/src/H5FDlog.c b/src/H5FDlog.c index 8546e01..96df596 100644 --- a/src/H5FDlog.c +++ b/src/H5FDlog.c @@ -35,27 +35,18 @@ #include "H5Fprivate.h" /* File access */ #include "H5FDprivate.h" /* File drivers */ #include "H5FDlog.h" /* Logging file driver */ +#include "H5FLprivate.h" /* Free Lists */ #include "H5Iprivate.h" /* IDs */ #include "H5MMprivate.h" /* Memory management */ #include "H5Pprivate.h" /* Property lists */ -#ifdef MAX -#undef MAX -#define MAX(X,Y) ((X)>(Y)?(X):(Y)) -#endif /* MAX */ - /* The driver identification number, initialized at runtime */ static hid_t H5FD_LOG_g = 0; -/* File operations */ -#define OP_UNKNOWN 0 -#define OP_READ 1 -#define OP_WRITE 2 - /* Driver-specific file access properties */ typedef struct H5FD_log_fapl_t { char *logfile; /* Allocated log file name */ - unsigned flags; /* Flags for logging behavior */ + unsigned long long flags; /* Flags for logging behavior */ size_t buf_size; /* Size of buffers for track flavor and number of times each byte is accessed */ } H5FD_log_fapl_t; @@ -88,23 +79,19 @@ typedef struct H5FD_log_t { haddr_t eoa; /*end of allocated region */ haddr_t eof; /*end of file; current file size*/ haddr_t pos; /*current file I/O position */ - int op; /*last operation */ - unsigned char *nread; /* Number of reads from a file location */ - unsigned char *nwrite; /* Number of write to a file location */ - unsigned char *flavor; /* Flavor of information written to file location */ - double total_read_time; /* Total time spent in read operations */ - double total_seek_time; /* Total time spent in seek operations */ - double total_write_time; /* Total time spent in write operations */ - size_t iosize; /* Size of I/O information buffers */ - FILE *logfp; /* Log file pointer */ - H5FD_log_fapl_t fa; /* Driver-specific file access properties*/ + H5FD_file_op_t op; /*last operation */ + char filename[H5FD_MAX_FILENAME_LEN]; /* Copy of file name from open operation */ #ifndef _WIN32 /* * On most systems the combination of device and i-node number uniquely * identify a file. */ dev_t device; /*file device number */ +#ifdef H5_VMS + ino_t inode[3]; /*file i-node number */ +#else ino_t inode; /*file i-node number */ +#endif /*H5_VMS*/ #else /* * On _WIN32 the low-order word of a unique identifier associated with the @@ -118,6 +105,25 @@ typedef struct H5FD_log_t { DWORD fileindexlo; DWORD fileindexhi; #endif + + /* Information from properties set by 'h5repart' tool */ + hbool_t fam_to_sec2; /* Whether to eliminate the family driver info + * and convert this file to a single file */ + + /* Fields for tracking I/O operations */ + unsigned char *nread; /* Number of reads from a file location */ + unsigned char *nwrite; /* Number of write to a file location */ + unsigned char *flavor; /* Flavor of information written to file location */ + unsigned long long total_read_ops; /* Total number of read operations */ + unsigned long long total_write_ops; /* Total number of write operations */ + unsigned long long total_seek_ops; /* Total number of seek operations */ + unsigned long long total_truncate_ops; /* Total number of truncate operations */ + double total_read_time; /* Total time spent in read operations */ + double total_write_time; /* Total time spent in write operations */ + double total_seek_time; /* Total time spent in seek operations */ + size_t iosize; /* Size of I/O information buffers */ + FILE *logfp; /* Log file pointer */ + H5FD_log_fapl_t fa; /* Driver-specific file access properties*/ } H5FD_log_t; @@ -126,30 +132,14 @@ typedef struct H5FD_log_t { * some macros here so we don't have to have conditional compilations later * throughout the code. * - * file_offset_t: The datatype for file offsets, the second argument of - * the lseek() or lseek64() call. + * HDoff_t: The datatype for file offsets, the second argument of + * the lseek() or lseek64() call. * - * file_seek: The function which adjusts the current file position, - * either lseek() or lseek64(). */ -/* adding for windows NT file system support. */ - -#ifdef H5_HAVE_LSEEK64 -# define file_offset_t off64_t -# define file_seek lseek64 -#elif defined (_WIN32) -# /*MSVC*/ -# define file_offset_t __int64 -# define file_seek _lseeki64 -#else -# define file_offset_t off_t -# define file_seek lseek -#endif - /* * These macros check for overflow of various quantities. These macros - * assume that file_offset_t is signed and haddr_t and size_t are unsigned. + * assume that HDoff_t is signed and haddr_t and size_t are unsigned. * * ADDR_OVERFLOW: Checks whether a file address of type `haddr_t' * is too large to be represented by the second argument @@ -162,14 +152,13 @@ typedef struct H5FD_log_t { * which can be addressed entirely by the second * argument of the file seek function. */ -#define MAXADDR (((haddr_t)1<<(8*sizeof(file_offset_t)-1))-1) +#define MAXADDR (((haddr_t)1<<(8*sizeof(HDoff_t)-1))-1) #define ADDR_OVERFLOW(A) (HADDR_UNDEF==(A) || \ ((A) & ~(haddr_t)MAXADDR)) #define SIZE_OVERFLOW(Z) ((Z) & ~(hsize_t)MAXADDR) #define REGION_OVERFLOW(A,Z) (ADDR_OVERFLOW(A) || SIZE_OVERFLOW(Z) || \ - sizeof(file_offset_t)<sizeof(size_t) || \ HADDR_UNDEF==(A)+(Z) || \ - (file_offset_t)((A)+(Z))<(file_offset_t)(A)) + (HDoff_t)((A)+(Z))<(HDoff_t)(A)) /* Prototypes */ static void *H5FD_log_fapl_get(H5FD_t *file); @@ -191,21 +180,6 @@ static herr_t H5FD_log_write(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, hadd size_t size, const void *buf); static herr_t H5FD_log_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing); -#ifdef OLD_WAY -/* - * The free list map which causes each request type to use no free lists - */ -#define H5FD_FLMAP_NOLIST { \ - H5FD_MEM_NOLIST, /*default*/ \ - H5FD_MEM_NOLIST, /*super*/ \ - H5FD_MEM_NOLIST, /*btree*/ \ - H5FD_MEM_NOLIST, /*draw*/ \ - H5FD_MEM_NOLIST, /*gheap*/ \ - H5FD_MEM_NOLIST, /*lheap*/ \ - H5FD_MEM_NOLIST /*ohdr*/ \ -} -#endif /* OLD_WAY */ - static const H5FD_class_t H5FD_log_g = { "log", /*name */ MAXADDR, /*maxaddr */ @@ -240,6 +214,9 @@ static const H5FD_class_t H5FD_log_g = { H5FD_FLMAP_SINGLE /*fl_map */ }; +/* Declare a free list to manage the H5FD_log_t struct */ +H5FL_DEFINE_STATIC(H5FD_log_t); + /*-------------------------------------------------------------------------- NAME @@ -270,32 +247,29 @@ H5FD_log_init_interface(void) * library. * * Return: Success: The driver ID for the log driver. - * * Failure: Negative. * * Programmer: Robb Matzke * Thursday, July 29, 1999 * - * Modifications: - * *------------------------------------------------------------------------- */ hid_t H5FD_log_init(void) { - hid_t ret_value; /* Return value */ + hid_t ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5FD_log_init, FAIL) - if (H5I_VFL!=H5Iget_type(H5FD_LOG_g)) - H5FD_LOG_g = H5FD_register(&H5FD_log_g,sizeof(H5FD_class_t),FALSE); + if(H5I_VFL != H5I_get_type(H5FD_LOG_g)) + H5FD_LOG_g = H5FD_register(&H5FD_log_g, sizeof(H5FD_class_t), FALSE); /* Set return value */ - ret_value=H5FD_LOG_g; + ret_value = H5FD_LOG_g; done: FUNC_LEAVE_NOAPI(ret_value) -} +} /* end H5FD_log_init() */ /*--------------------------------------------------------------------------- @@ -308,8 +282,6 @@ done: * Programmer: Quincey Koziol * Friday, Jan 30, 2004 * - * Modification: - * *--------------------------------------------------------------------------- */ void @@ -318,7 +290,7 @@ H5FD_log_term(void) FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FD_log_term) /* Reset VFL ID */ - H5FD_LOG_g=0; + H5FD_LOG_g = 0; FUNC_LEAVE_NOAPI_VOID } /* end H5FD_log_term() */ @@ -339,7 +311,7 @@ H5FD_log_term(void) *------------------------------------------------------------------------- */ herr_t -H5Pset_fapl_log(hid_t fapl_id, const char *logfile, unsigned flags, size_t buf_size) +H5Pset_fapl_log(hid_t fapl_id, const char *logfile, unsigned long long flags, size_t buf_size) { H5FD_log_fapl_t fa; /* File access property list information */ H5P_genplist_t *plist; /* Property list pointer */ @@ -370,28 +342,24 @@ done: * * Return: Success: Ptr to new file access property list with all * members copied from the file struct. - * * Failure: NULL * * Programmer: Quincey Koziol * Thursday, April 20, 2000 * - * Modifications: - * *------------------------------------------------------------------------- */ static void * H5FD_log_fapl_get(H5FD_t *_file) { - H5FD_log_t *file = (H5FD_log_t*)_file; + H5FD_log_t *file = (H5FD_log_t *)_file; void *ret_value; /* Return value */ - FUNC_ENTER_NOAPI(H5FD_log_fapl_get, NULL) + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FD_log_fapl_get) /* Set return value */ ret_value = H5FD_log_fapl_copy(&(file->fa)); -done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_log_fapl_get() */ @@ -416,7 +384,7 @@ H5FD_log_fapl_copy(const void *_old_fa) H5FD_log_fapl_t *new_fa = NULL; /* New FAPL info */ void *ret_value; /* Return value */ - FUNC_ENTER_NOAPI(H5FD_log_fapl_copy, NULL) + FUNC_ENTER_NOAPI_NOINIT(H5FD_log_fapl_copy) HDassert(old_fa); @@ -492,25 +460,29 @@ H5FD_log_fapl_free(void *_fa) *------------------------------------------------------------------------- */ static H5FD_t * -H5FD_log_open(const char *name, unsigned flags, hid_t fapl_id, - haddr_t maxaddr) +H5FD_log_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) { - int o_flags; - int fd = (-1); H5FD_log_t *file = NULL; - H5FD_log_fapl_t *fa; /* File access property list information */ + H5P_genplist_t *plist; /* Property list */ + H5FD_log_fapl_t *fa; /* File access property list information */ + int fd = (-1); /* File descriptor */ + int o_flags; /* Flags for open() call */ #ifdef _WIN32 HFILE filehandle; struct _BY_HANDLE_FILE_INFORMATION fileinfo; #endif #ifdef H5_HAVE_GETTIMEOFDAY - struct timeval timeval_start, timeval_stop; + struct timeval timeval_start; + struct timeval open_timeval_diff; + struct timeval stat_timeval_diff; #endif /* H5_HAVE_GETTIMEOFDAY */ - h5_stat_t sb; - H5P_genplist_t *plist; /* Property list */ - H5FD_t *ret_value; + h5_stat_t sb; + H5FD_t *ret_value; /* Return value */ - FUNC_ENTER_NOAPI(H5FD_log_open, NULL) + FUNC_ENTER_NOAPI_NOINIT(H5FD_log_open) + + /* Sanity check on file offsets */ + HDcompile_assert(sizeof(HDoff_t) >= sizeof(size_t)); /* Check arguments */ if(!name || !*name) @@ -540,17 +512,52 @@ H5FD_log_open(const char *name, unsigned flags, hid_t fapl_id, HDgettimeofday(&timeval_start, NULL); #endif /* H5_HAVE_GETTIMEOFDAY */ /* Open the file */ - if((fd = HDopen(name, o_flags, 0666)) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open file") + if((fd = HDopen(name, o_flags, 0666)) < 0) { + int myerrno = errno; + + HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open file: name = '%s', errno = %d, error message = '%s', flags = %x, o_flags = %x", name, myerrno, HDstrerror(myerrno), flags, (unsigned)o_flags); + } /* end if */ #ifdef H5_HAVE_GETTIMEOFDAY - if(fa->flags & H5FD_LOG_TIME_OPEN) + if(fa->flags & H5FD_LOG_TIME_OPEN) { + struct timeval timeval_stop; + HDgettimeofday(&timeval_stop, NULL); + + /* Calculate the elapsed gettimeofday time */ + open_timeval_diff.tv_usec = timeval_stop.tv_usec - timeval_start.tv_usec; + open_timeval_diff.tv_sec = timeval_stop.tv_sec - timeval_start.tv_sec; + if(open_timeval_diff.tv_usec < 0) { + open_timeval_diff.tv_usec += 1000000; + open_timeval_diff.tv_sec--; + } /* end if */ + } /* end if */ +#endif /* H5_HAVE_GETTIMEOFDAY */ + +#ifdef H5_HAVE_GETTIMEOFDAY + if(fa->flags & H5FD_LOG_TIME_STAT) + HDgettimeofday(&timeval_start, NULL); #endif /* H5_HAVE_GETTIMEOFDAY */ + /* Get the file stats */ if(HDfstat(fd, &sb) < 0) - HGOTO_ERROR(H5E_FILE, H5E_BADFILE, NULL, "unable to fstat file") + HSYS_GOTO_ERROR(H5E_FILE, H5E_BADFILE, NULL, "unable to fstat file") +#ifdef H5_HAVE_GETTIMEOFDAY + if(fa->flags & H5FD_LOG_TIME_STAT) { + struct timeval timeval_stop; + + HDgettimeofday(&timeval_stop, NULL); + + /* Calculate the elapsed gettimeofday time */ + stat_timeval_diff.tv_usec = timeval_stop.tv_usec - timeval_start.tv_usec; + stat_timeval_diff.tv_sec = timeval_stop.tv_sec - timeval_start.tv_sec; + if(stat_timeval_diff.tv_usec < 0) { + stat_timeval_diff.tv_usec += 1000000; + stat_timeval_diff.tv_sec--; + } /* end if */ + } /* end if */ +#endif /* H5_HAVE_GETTIMEOFDAY */ /* Create the new file struct */ - if(NULL == (file = (H5FD_log_t *)H5MM_calloc(sizeof(H5FD_log_t)))) + if(NULL == (file = H5FL_CALLOC(H5FD_log_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "unable to allocate file struct") file->fd = fd; @@ -562,10 +569,21 @@ H5FD_log_open(const char *name, unsigned flags, hid_t fapl_id, (void)GetFileInformationByHandle((HANDLE)filehandle, &fileinfo); file->fileindexhi = fileinfo.nFileIndexHigh; file->fileindexlo = fileinfo.nFileIndexLow; -#else +#else /* _WIN32 */ file->device = sb.st_dev; +#ifdef H5_VMS + file->inode[0] = sb.st_ino[0]; + file->inode[1] = sb.st_ino[1]; + file->inode[2] = sb.st_ino[2]; +#else file->inode = sb.st_ino; -#endif +#endif /*H5_VMS*/ + +#endif /* _WIN32 */ + + /* Retain a copy of the name used to open the file, for possible error reporting */ + HDstrncpy(file->filename, name, sizeof(file->filename)); + file->filename[sizeof(file->filename) - 1] = '\0'; /* Get the flags for logging */ file->fa.flags = fa->flags; @@ -587,11 +605,6 @@ H5FD_log_open(const char *name, unsigned flags, hid_t fapl_id, HDassert(file->flavor); } /* end if */ - /* Initialize the total read/write/seek times to zero */ - file->total_read_time = (double)0.0; - file->total_seek_time = (double)0.0; - file->total_write_time = (double)0.0; - /* Set the log file pointer */ if(fa->logfile) file->logfp = HDfopen(fa->logfile, "w"); @@ -599,19 +612,24 @@ H5FD_log_open(const char *name, unsigned flags, hid_t fapl_id, file->logfp = stderr; #ifdef H5_HAVE_GETTIMEOFDAY - if(file->fa.flags & H5FD_LOG_TIME_OPEN) { - struct timeval timeval_diff; - - /* Calculate the elapsed gettimeofday time */ - timeval_diff.tv_usec = timeval_stop.tv_usec - timeval_start.tv_usec; - timeval_diff.tv_sec = timeval_stop.tv_sec - timeval_start.tv_sec; - if(timeval_diff.tv_usec < 0) { - timeval_diff.tv_usec += 1000000; - timeval_diff.tv_sec--; - } /* end if */ - HDfprintf(file->logfp, "Open took: (%f s)\n", (double)timeval_diff.tv_sec + ((double)timeval_diff.tv_usec / (double)1000000.0)); - } /* end if */ + if(file->fa.flags & H5FD_LOG_TIME_OPEN) + HDfprintf(file->logfp, "Open took: (%f s)\n", (double)open_timeval_diff.tv_sec + ((double)open_timeval_diff.tv_usec / (double)1000000.0)); + if(file->fa.flags & H5FD_LOG_TIME_STAT) + HDfprintf(file->logfp, "Stat took: (%f s)\n", (double)stat_timeval_diff.tv_sec + ((double)stat_timeval_diff.tv_usec / (double)1000000.0)); #endif /* H5_HAVE_GETTIMEOFDAY */ + + } /* end if */ + + /* Check for non-default FAPL */ + if(H5P_FILE_ACCESS_DEFAULT != fapl_id) { + /* This step is for h5repart tool only. If user wants to change file driver from + * family to sec2 while using h5repart, this private property should be set so that + * in the later step, the library can ignore the family driver information saved + * in the superblock. + */ + if(H5P_exist_plist(plist, H5F_ACS_FAMILY_TO_SEC2_NAME) > 0) + if(H5P_get(plist, H5F_ACS_FAMILY_TO_SEC2_NAME, &file->fam_to_sec2) < 0) + HGOTO_ERROR(H5E_VFL, H5E_CANTGET, NULL, "can't get property of changing family to sec2") } /* end if */ /* Set return value */ @@ -621,7 +639,8 @@ done: if(NULL == ret_value) { if(fd >= 0) HDclose(fd); - file = (H5FD_log_t *)H5MM_xfree(file); + if(file) + file = H5FL_FREE(H5FD_log_t, file); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) @@ -644,23 +663,27 @@ done: static herr_t H5FD_log_close(H5FD_t *_file) { - H5FD_log_t *file = (H5FD_log_t*)_file; + H5FD_log_t *file = (H5FD_log_t *)_file; #ifdef H5_HAVE_GETTIMEOFDAY - struct timeval timeval_start,timeval_stop; + struct timeval timeval_start, timeval_stop; #endif /* H5_HAVE_GETTIMEOFDAY */ - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT(H5FD_log_close) - FUNC_ENTER_NOAPI(H5FD_log_close, FAIL) + /* Sanity check */ + HDassert(file); #ifdef H5_HAVE_GETTIMEOFDAY if(file->fa.flags&H5FD_LOG_TIME_CLOSE) - HDgettimeofday(&timeval_start,NULL); + HDgettimeofday(&timeval_start, NULL); #endif /* H5_HAVE_GETTIMEOFDAY */ + /* Close the underlying file */ if(HDclose(file->fd) < 0) - HGOTO_ERROR(H5E_IO, H5E_CANTCLOSEFILE, FAIL, "unable to close file") + HSYS_GOTO_ERROR(H5E_IO, H5E_CANTCLOSEFILE, FAIL, "unable to close file") #ifdef H5_HAVE_GETTIMEOFDAY if(file->fa.flags&H5FD_LOG_TIME_CLOSE) - HDgettimeofday(&timeval_stop,NULL); + HDgettimeofday(&timeval_stop, NULL); #endif /* H5_HAVE_GETTIMEOFDAY */ /* Dump I/O information */ @@ -684,6 +707,16 @@ H5FD_log_close(H5FD_t *_file) } /* end if */ #endif /* H5_HAVE_GETTIMEOFDAY */ + /* Dump the total number of seek/read/write operations */ + if(file->fa.flags & H5FD_LOG_NUM_READ) + HDfprintf(file->logfp, "Total number of read operations: %llu\n", file->total_read_ops); + if(file->fa.flags & H5FD_LOG_NUM_WRITE) + HDfprintf(file->logfp, "Total number of write operations: %llu\n", file->total_write_ops); + if(file->fa.flags & H5FD_LOG_NUM_SEEK) + HDfprintf(file->logfp, "Total number of seek operations: %llu\n", file->total_seek_ops); + if(file->fa.flags & H5FD_LOG_NUM_TRUNCATE) + HDfprintf(file->logfp, "Total number of truncate operations: %llu\n", file->total_truncate_ops); + /* Dump the total time in seek/read/write */ if(file->fa.flags & H5FD_LOG_TIME_READ) HDfprintf(file->logfp, "Total time in read operations: %f s\n", file->total_read_time); @@ -754,7 +787,8 @@ H5FD_log_close(H5FD_t *_file) fclose(file->logfp); } /* end if */ - H5MM_xfree(file); + /* Release the file info */ + file = H5FL_FREE(H5FD_log_t, file); done: FUNC_LEAVE_NOAPI(ret_value) @@ -768,53 +802,56 @@ done: * arbitrary (but consistent) ordering. * * Return: Success: A value like strcmp() - * * Failure: never fails (arguments were checked by the * caller). * * Programmer: Robb Matzke * Thursday, July 29, 1999 * - * Modifications: - * *------------------------------------------------------------------------- */ static int H5FD_log_cmp(const H5FD_t *_f1, const H5FD_t *_f2) { - const H5FD_log_t *f1 = (const H5FD_log_t*)_f1; - const H5FD_log_t *f2 = (const H5FD_log_t*)_f2; - int ret_value=0; + const H5FD_log_t *f1 = (const H5FD_log_t *)_f1; + const H5FD_log_t *f2 = (const H5FD_log_t *)_f2; + int ret_value = 0; - FUNC_ENTER_NOAPI(H5FD_log_cmp, H5FD_VFD_DEFAULT) + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FD_log_cmp) #ifdef _WIN32 - if (f1->fileindexhi < f2->fileindexhi) HGOTO_DONE(-1) - if (f1->fileindexhi > f2->fileindexhi) HGOTO_DONE(1) + if(f1->fileindexhi < f2->fileindexhi) HGOTO_DONE(-1) + if(f1->fileindexhi > f2->fileindexhi) HGOTO_DONE(1) - if (f1->fileindexlo < f2->fileindexlo) HGOTO_DONE(-1) - if (f1->fileindexlo > f2->fileindexlo) HGOTO_DONE(1) + if(f1->fileindexlo < f2->fileindexlo) HGOTO_DONE(-1) + if(f1->fileindexlo > f2->fileindexlo) HGOTO_DONE(1) #else #ifdef H5_DEV_T_IS_SCALAR - if (f1->device < f2->device) HGOTO_DONE(-1) - if (f1->device > f2->device) HGOTO_DONE(1) + if(f1->device < f2->device) HGOTO_DONE(-1) + if(f1->device > f2->device) HGOTO_DONE(1) #else /* H5_DEV_T_IS_SCALAR */ /* If dev_t isn't a scalar value on this system, just use memcmp to * determine if the values are the same or not. The actual return value * shouldn't really matter... */ - if(HDmemcmp(&(f1->device),&(f2->device),sizeof(dev_t))<0) HGOTO_DONE(-1) - if(HDmemcmp(&(f1->device),&(f2->device),sizeof(dev_t))>0) HGOTO_DONE(1) + if(HDmemcmp(&(f1->device),&(f2->device),sizeof(dev_t)) < 0) HGOTO_DONE(-1) + if(HDmemcmp(&(f1->device),&(f2->device),sizeof(dev_t)) > 0) HGOTO_DONE(1) #endif /* H5_DEV_T_IS_SCALAR */ - if (f1->inode < f2->inode) HGOTO_DONE(-1) - if (f1->inode > f2->inode) HGOTO_DONE(1) +#ifndef H5_VMS + if(f1->inode < f2->inode) HGOTO_DONE(-1) + if(f1->inode > f2->inode) HGOTO_DONE(1) +#else + if(HDmemcmp(&(f1->inode), &(f2->inode), 3 * sizeof(ino_t)) < 0) HGOTO_DONE(-1) + if(HDmemcmp(&(f1->inode), &(f2->inode), 3 * sizeof(ino_t)) > 0) HGOTO_DONE(1) +#endif /*H5_VMS*/ + #endif done: FUNC_LEAVE_NOAPI(ret_value) -} +} /* end H5FD_log_cmp() */ /*------------------------------------------------------------------------- @@ -824,20 +861,18 @@ done: * (listed in H5FDpublic.h) * * Return: Success: non-negative - * * Failure: negative * * Programmer: Quincey Koziol * Friday, August 25, 2000 * - * Modifications: - * *------------------------------------------------------------------------- */ -/* ARGSUSED */ static herr_t -H5FD_log_query(const H5FD_t UNUSED * _f, unsigned long *flags /* out */) +H5FD_log_query(const H5FD_t *_file, unsigned long *flags /* out */) { + const H5FD_log_t *file = (const H5FD_log_t *)_file; + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FD_log_query) /* Set the VFL feature flags that this driver supports */ @@ -848,6 +883,10 @@ H5FD_log_query(const H5FD_t UNUSED * _f, unsigned long *flags /* out */) *flags |= H5FD_FEAT_DATA_SIEVE; /* OK to perform data sieving for faster raw data reads & writes */ *flags |= H5FD_FEAT_AGGREGATE_SMALLDATA; /* OK to aggregate "small" raw data allocations */ *flags |= H5FD_FEAT_POSIX_COMPAT_HANDLE; /* VFD handle is POSIX I/O call compatible */ + + /* Check for flags that are set by h5repart */ + if(file->fam_to_sec2) + *flags |= H5FD_FEAT_IGNORE_DRVRINFO; /* Ignore the driver info when file is opened (which eliminates it) */ } /* end if */ FUNC_LEAVE_NOAPI(SUCCEED) @@ -860,56 +899,52 @@ H5FD_log_query(const H5FD_t UNUSED * _f, unsigned long *flags /* out */) * Purpose: Allocate file memory. * * Return: Success: Address of new memory - * * Failure: HADDR_UNDEF * * Programmer: Quincey Koziol * Monday, April 17, 2000 * - * Modifications: - * *------------------------------------------------------------------------- */ /* ARGSUSED */ static haddr_t H5FD_log_alloc(H5FD_t *_file, H5FD_mem_t type, hid_t UNUSED dxpl_id, hsize_t size) { - H5FD_log_t *file = (H5FD_log_t*)_file; - haddr_t addr; + H5FD_log_t *file = (H5FD_log_t *)_file; + haddr_t addr; haddr_t ret_value; /* Return value */ - FUNC_ENTER_NOAPI(H5FD_log_alloc, HADDR_UNDEF) + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FD_log_alloc) /* Compute the address for the block to allocate */ addr = file->eoa; /* Check if we need to align this block */ - if(size>=file->pub.threshold) { + if(size >= file->pub.threshold) { /* Check for an already aligned block */ - if(addr%file->pub.alignment!=0) - addr=((addr/file->pub.alignment)+1)*file->pub.alignment; + if(addr % file->pub.alignment != 0) + addr = ((addr / file->pub.alignment) + 1) * file->pub.alignment; } /* end if */ - file->eoa = addr+size; + file->eoa = addr + size; /* Retain the (first) flavor of the information written to the file */ - if(file->fa.flags!=0) { - if(file->fa.flags&H5FD_LOG_FLAVOR) { - assert(addr<file->iosize); - H5_CHECK_OVERFLOW(size,hsize_t,size_t); - HDmemset(&file->flavor[addr],(int)type,(size_t)size); + if(file->fa.flags != 0) { + if(file->fa.flags & H5FD_LOG_FLAVOR) { + HDassert(addr < file->iosize); + H5_CHECK_OVERFLOW(size, hsize_t, size_t); + HDmemset(&file->flavor[addr], (int)type, (size_t)size); } /* end if */ - if(file->fa.flags&H5FD_LOG_ALLOC) - HDfprintf(file->logfp,"%10a-%10a (%10Hu bytes) (%s) Allocated\n",addr,addr+size-1,size,flavors[type]); + if(file->fa.flags & H5FD_LOG_ALLOC) + HDfprintf(file->logfp, "%10a-%10a (%10Hu bytes) (%s) Allocated\n", addr, (addr + size) - 1, size, flavors[type]); } /* end if */ /* Set return value */ - ret_value=addr; + ret_value = addr; -done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5FD_log_alloc() */ +} /* end H5FD_log_alloc() */ /*------------------------------------------------------------------------- @@ -920,33 +955,22 @@ done: * format address space. * * Return: Success: The end-of-address marker. - * * Failure: HADDR_UNDEF * * Programmer: Robb Matzke * Monday, August 2, 1999 * - * Modifications: - * Raymond Lu - * 21 Dec. 2006 - * Added the parameter TYPE. It's only used for MULTI driver. - * *------------------------------------------------------------------------- */ static haddr_t H5FD_log_get_eoa(const H5FD_t *_file, H5FD_mem_t UNUSED type) { - const H5FD_log_t *file = (const H5FD_log_t*)_file; - haddr_t ret_value; /* Return value */ - - FUNC_ENTER_NOAPI(H5FD_log_get_eoa, HADDR_UNDEF) + const H5FD_log_t *file = (const H5FD_log_t *)_file; - /* Set return value */ - ret_value=file->eoa; + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FD_log_get_eoa) -done: - FUNC_LEAVE_NOAPI(ret_value) -} + FUNC_LEAVE_NOAPI(file->eoa) +} /* end H5FD_log_get_eoa() */ /*------------------------------------------------------------------------- @@ -957,32 +981,24 @@ done: * to tell the driver where the end of the HDF5 data is located. * * Return: Success: 0 - * * Failure: -1 * * Programmer: Robb Matzke * Thursday, July 29, 1999 * - * Modifications: - * Raymond Lu - * 21 Dec. 2006 - * Added the parameter TYPE. It's only used for MULTI driver. - * *------------------------------------------------------------------------- */ static herr_t H5FD_log_set_eoa(H5FD_t *_file, H5FD_mem_t UNUSED type, haddr_t addr) { - H5FD_log_t *file = (H5FD_log_t*)_file; - herr_t ret_value=SUCCEED; /* Return value */ + H5FD_log_t *file = (H5FD_log_t *)_file; - FUNC_ENTER_NOAPI(H5FD_log_set_eoa, FAIL) + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FD_log_set_eoa) file->eoa = addr; -done: - FUNC_LEAVE_NOAPI(ret_value) -} + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5FD_log_set_eoa() */ /*------------------------------------------------------------------------- @@ -995,30 +1011,22 @@ done: * Return: Success: End of file address, the first address past * the end of the "file", either the Unix file * or the HDF5 file. - * * Failure: HADDR_UNDEF * * Programmer: Robb Matzke * Thursday, July 29, 1999 * - * Modifications: - * *------------------------------------------------------------------------- */ static haddr_t H5FD_log_get_eof(const H5FD_t *_file) { - const H5FD_log_t *file = (const H5FD_log_t*)_file; - haddr_t ret_value; /* Return value */ + const H5FD_log_t *file = (const H5FD_log_t *)_file; - FUNC_ENTER_NOAPI(H5FD_log_get_eof, HADDR_UNDEF) + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FD_log_get_eof) - /* Set return value */ - ret_value=MAX(file->eof, file->eoa); - -done: - FUNC_LEAVE_NOAPI(ret_value) -} + FUNC_LEAVE_NOAPI(MAX(file->eof, file->eoa)) +} /* end H5FD_log_get_eof() */ /*------------------------------------------------------------------------- @@ -1031,18 +1039,16 @@ done: * Programmer: Raymond Lu * Sept. 16, 2002 * - * Modifications: - * *------------------------------------------------------------------------- */ /* ARGSUSED */ static herr_t -H5FD_log_get_handle(H5FD_t *_file, hid_t UNUSED fapl, void** file_handle) +H5FD_log_get_handle(H5FD_t *_file, hid_t UNUSED fapl, void **file_handle) { H5FD_log_t *file = (H5FD_log_t *)_file; herr_t ret_value = SUCCEED; - FUNC_ENTER_NOAPI(H5FD_log_get_handle, FAIL) + FUNC_ENTER_NOAPI_NOINIT(H5FD_log_get_handle) if(!file_handle) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file handle not valid") @@ -1051,7 +1057,7 @@ H5FD_log_get_handle(H5FD_t *_file, hid_t UNUSED fapl, void** file_handle) done: FUNC_LEAVE_NOAPI(ret_value) -} +} /* end H5FD_log_get_handle() */ /*------------------------------------------------------------------------- @@ -1063,7 +1069,6 @@ done: * * Return: Success: Zero. Result is stored in caller-supplied * buffer BUF. - * * Failure: -1, Contents of buffer BUF are undefined. * * Programmer: Robb Matzke @@ -1076,7 +1081,7 @@ static herr_t H5FD_log_read(H5FD_t *_file, H5FD_mem_t type, hid_t UNUSED dxpl_id, haddr_t addr, size_t size, void *buf/*out*/) { - H5FD_log_t *file = (H5FD_log_t*)_file; + H5FD_log_t *file = (H5FD_log_t *)_file; ssize_t nbytes; size_t orig_size = size; /* Save the original size for later */ haddr_t orig_addr = addr; @@ -1085,18 +1090,18 @@ H5FD_log_read(H5FD_t *_file, H5FD_mem_t type, hid_t UNUSED dxpl_id, haddr_t addr #endif /* H5_HAVE_GETTIMEOFDAY */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(H5FD_log_read, FAIL) + FUNC_ENTER_NOAPI_NOINIT(H5FD_log_read) HDassert(file && file->pub.cls); HDassert(buf); /* Check for overflow conditions */ - if(HADDR_UNDEF == addr) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "addr undefined") + if(!H5F_addr_defined(addr)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "addr undefined, addr = %llu", (unsigned long long)addr) if(REGION_OVERFLOW(addr, size)) - HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow") + HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow, addr = %llu", (unsigned long long)addr) if((addr + size) > file->eoa) - HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow") + HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow, addr = %llu", (unsigned long long)addr) /* Log the I/O information about the read */ if(file->fa.flags != 0) { @@ -1117,17 +1122,16 @@ H5FD_log_read(H5FD_t *_file, H5FD_mem_t type, hid_t UNUSED dxpl_id, haddr_t addr if(file->fa.flags & H5FD_LOG_TIME_SEEK) HDgettimeofday(&timeval_start, NULL); #endif /* H5_HAVE_GETTIMEOFDAY */ - if(file_seek(file->fd, (file_offset_t)addr, SEEK_SET) < 0) { - file->pos = HADDR_UNDEF; - file->op = OP_UNKNOWN; - HGOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to seek to proper position") - } /* end if */ + if(HDlseek(file->fd, (HDoff_t)addr, SEEK_SET) < 0) + HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to seek to proper position") #ifdef H5_HAVE_GETTIMEOFDAY if(file->fa.flags & H5FD_LOG_TIME_SEEK) HDgettimeofday(&timeval_stop, NULL); #endif /* H5_HAVE_GETTIMEOFDAY */ /* Log information about the seek */ + if(file->fa.flags & H5FD_LOG_NUM_SEEK) + file->total_seek_ops++; if(file->fa.flags & H5FD_LOG_LOC_SEEK) { HDfprintf(file->logfp, "Seek: From %10a To %10a", file->pos, addr); #ifdef H5_HAVE_GETTIMEOFDAY @@ -1168,16 +1172,20 @@ H5FD_log_read(H5FD_t *_file, H5FD_mem_t type, hid_t UNUSED dxpl_id, haddr_t addr do { nbytes = HDread(file->fd, buf, size); } while(-1 == nbytes && EINTR == errno); - if(-1 == nbytes) { - /* error */ - file->pos = HADDR_UNDEF; - file->op = OP_UNKNOWN; - HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "file read failed") + if(-1 == nbytes) { /* error */ + int myerrno = errno; + time_t mytime = HDtime(NULL); + HDoff_t myoffset = HDlseek(file->fd, (HDoff_t)0, SEEK_CUR); + + if(file->fa.flags & H5FD_LOG_LOC_READ) + HDfprintf(file->logfp, "Error! Reading: %10a-%10a (%10Zu bytes)\n", orig_addr, (orig_addr + orig_size) - 1, orig_size); + + HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "file read failed: time = %s, filename = '%s', file descriptor = %d, errno = %d, error message = '%s', buf = %p, size = %lu, offset = %llu", HDctime(&mytime), file->filename, file->fd, myerrno, HDstrerror(myerrno), buf, (unsigned long)size, (unsigned long long)myoffset); } /* end if */ if(0 == nbytes) { /* end of file but not end of format address space */ HDmemset(buf, 0, size); - size = 0; + break; } /* end if */ HDassert(nbytes >= 0); HDassert((size_t)nbytes <= size); @@ -1185,7 +1193,7 @@ H5FD_log_read(H5FD_t *_file, H5FD_mem_t type, hid_t UNUSED dxpl_id, haddr_t addr size -= (size_t)nbytes; H5_CHECK_OVERFLOW(nbytes, ssize_t, haddr_t); addr += (haddr_t)nbytes; - buf = (char*)buf + nbytes; + buf = (char *)buf + nbytes; } /* end while */ #ifdef H5_HAVE_GETTIMEOFDAY if(file->fa.flags & H5FD_LOG_TIME_READ) @@ -1193,6 +1201,8 @@ H5FD_log_read(H5FD_t *_file, H5FD_mem_t type, hid_t UNUSED dxpl_id, haddr_t addr #endif /* H5_HAVE_GETTIMEOFDAY */ /* Log information about the read */ + if(file->fa.flags & H5FD_LOG_NUM_READ) + file->total_read_ops++; if(file->fa.flags & H5FD_LOG_LOC_READ) { HDfprintf(file->logfp, "%10a-%10a (%10Zu bytes) (%s) Read", orig_addr, (orig_addr + orig_size) - 1, orig_size, flavors[type]); @@ -1228,6 +1238,12 @@ H5FD_log_read(H5FD_t *_file, H5FD_mem_t type, hid_t UNUSED dxpl_id, haddr_t addr file->op = OP_READ; done: + if(ret_value < 0) { + /* Reset last file I/O information */ + file->pos = HADDR_UNDEF; + file->op = OP_UNKNOWN; + } /* end if */ + FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_log_read() */ @@ -1240,14 +1256,11 @@ done: * DXPL_ID. * * Return: Success: Zero - * * Failure: -1 * * Programmer: Robb Matzke * Thursday, July 29, 1999 * - * Modifications: - * *------------------------------------------------------------------------- */ /* ARGSUSED */ @@ -1255,7 +1268,7 @@ static herr_t H5FD_log_write(H5FD_t *_file, H5FD_mem_t type, hid_t UNUSED dxpl_id, haddr_t addr, size_t size, const void *buf) { - H5FD_log_t *file = (H5FD_log_t*)_file; + H5FD_log_t *file = (H5FD_log_t *)_file; ssize_t nbytes; size_t orig_size = size; /* Save the original size for later */ haddr_t orig_addr = addr; @@ -1264,7 +1277,7 @@ H5FD_log_write(H5FD_t *_file, H5FD_mem_t type, hid_t UNUSED dxpl_id, haddr_t add #endif /* H5_HAVE_GETTIMEOFDAY */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(H5FD_log_write, FAIL) + FUNC_ENTER_NOAPI_NOINIT(H5FD_log_write) HDassert(file && file->pub.cls); HDassert(size > 0); @@ -1277,12 +1290,12 @@ H5FD_log_write(H5FD_t *_file, H5FD_mem_t type, hid_t UNUSED dxpl_id, haddr_t add } /* end if */ /* Check for overflow conditions */ - if(HADDR_UNDEF == addr) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "addr undefined") + if(!H5F_addr_defined(addr)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "addr undefined, addr = %llu", (unsigned long long)addr) if(REGION_OVERFLOW(addr, size)) - HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow") + HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow, addr = %llu, size = %llu", (unsigned long long)addr, (unsigned long long)size) if((addr + size) > file->eoa) - HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow") + HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow, addr = %llu, size = %llu, eoa = %llu", (unsigned long long)addr, (unsigned long long)size, (unsigned long long)file->eoa) /* Log the I/O information about the write */ if(file->fa.flags & H5FD_LOG_FILE_WRITE) { @@ -1301,17 +1314,16 @@ H5FD_log_write(H5FD_t *_file, H5FD_mem_t type, hid_t UNUSED dxpl_id, haddr_t add if(file->fa.flags & H5FD_LOG_TIME_SEEK) HDgettimeofday(&timeval_start, NULL); #endif /* H5_HAVE_GETTIMEOFDAY */ - if(file_seek(file->fd, (file_offset_t)addr, SEEK_SET) < 0) { - file->pos = HADDR_UNDEF; - file->op = OP_UNKNOWN; - HGOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to seek to proper position") - } /* end if */ + if(HDlseek(file->fd, (HDoff_t)addr, SEEK_SET) < 0) + HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to seek to proper position") #ifdef H5_HAVE_GETTIMEOFDAY if(file->fa.flags & H5FD_LOG_TIME_SEEK) HDgettimeofday(&timeval_stop, NULL); #endif /* H5_HAVE_GETTIMEOFDAY */ /* Log information about the seek */ + if(file->fa.flags & H5FD_LOG_NUM_SEEK) + file->total_seek_ops++; if(file->fa.flags & H5FD_LOG_LOC_SEEK) { HDfprintf(file->logfp, "Seek: From %10a To %10a", file->pos, addr); #ifdef H5_HAVE_GETTIMEOFDAY @@ -1346,19 +1358,21 @@ H5FD_log_write(H5FD_t *_file, H5FD_mem_t type, hid_t UNUSED dxpl_id, haddr_t add */ #ifdef H5_HAVE_GETTIMEOFDAY if(file->fa.flags&H5FD_LOG_TIME_WRITE) - HDgettimeofday(&timeval_start,NULL); + HDgettimeofday(&timeval_start, NULL); #endif /* H5_HAVE_GETTIMEOFDAY */ while(size > 0) { do { nbytes = HDwrite(file->fd, buf, size); } while(-1 == nbytes && EINTR == errno); - if(-1 == nbytes) { - /* error */ - file->pos = HADDR_UNDEF; - file->op = OP_UNKNOWN; + if(-1 == nbytes) { /* error */ + int myerrno = errno; + time_t mytime = HDtime(NULL); + HDoff_t myoffset = HDlseek(file->fd, (HDoff_t)0, SEEK_CUR); + if(file->fa.flags & H5FD_LOG_LOC_WRITE) HDfprintf(file->logfp, "Error! Writing: %10a-%10a (%10Zu bytes)\n", orig_addr, (orig_addr + orig_size) - 1, orig_size); - HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "file write failed") + + HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "file write failed: time = %s, filename = '%s', file descriptor = %d, errno = %d, error message = '%s', buf = %p, size = %lu, offset = %llu", HDctime(&mytime), file->filename, file->fd, myerrno, HDstrerror(myerrno), buf, (unsigned long)size, (unsigned long long)myoffset); } /* end if */ HDassert(nbytes > 0); HDassert((size_t)nbytes <= size); @@ -1366,7 +1380,7 @@ H5FD_log_write(H5FD_t *_file, H5FD_mem_t type, hid_t UNUSED dxpl_id, haddr_t add size -= (size_t)nbytes; H5_CHECK_OVERFLOW(nbytes, ssize_t, haddr_t); addr += (haddr_t)nbytes; - buf = (const char*)buf + nbytes; + buf = (const char *)buf + nbytes; } /* end while */ #ifdef H5_HAVE_GETTIMEOFDAY if(file->fa.flags & H5FD_LOG_TIME_WRITE) @@ -1374,6 +1388,8 @@ H5FD_log_write(H5FD_t *_file, H5FD_mem_t type, hid_t UNUSED dxpl_id, haddr_t add #endif /* H5_HAVE_GETTIMEOFDAY */ /* Log information about the write */ + if(file->fa.flags & H5FD_LOG_NUM_WRITE) + file->total_write_ops++; if(file->fa.flags & H5FD_LOG_LOC_WRITE) { HDfprintf(file->logfp, "%10a-%10a (%10Zu bytes) (%s) Written", orig_addr, (orig_addr + orig_size) - 1, orig_size, flavors[type]); @@ -1415,6 +1431,12 @@ H5FD_log_write(H5FD_t *_file, H5FD_mem_t type, hid_t UNUSED dxpl_id, haddr_t add file->eof = file->pos; done: + if(ret_value < 0) { + /* Reset last file I/O information */ + file->pos = HADDR_UNDEF; + file->op = OP_UNKNOWN; + } /* end if */ + FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_log_write() */ @@ -1435,22 +1457,53 @@ done: */ /* ARGSUSED */ static herr_t -H5FD_log_truncate(H5FD_t *_file, hid_t UNUSED dxpl_id, unsigned UNUSED closing) +H5FD_log_truncate(H5FD_t *_file, hid_t UNUSED dxpl_id, hbool_t UNUSED closing) { - H5FD_log_t *file = (H5FD_log_t*)_file; - herr_t ret_value=SUCCEED; /* Return value */ + H5FD_log_t *file = (H5FD_log_t *)_file; + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(H5FD_log_truncate, FAIL) + FUNC_ENTER_NOAPI_NOINIT(H5FD_log_truncate) - if(file->eoa>file->eof) { - if(-1 == file_seek(file->fd, (file_offset_t)(file->eoa - 1), SEEK_SET)) - HGOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to seek to proper position") - if(HDwrite(file->fd, "", (size_t)1) != 1) - HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "file write failed") + HDassert(file); + + /* Extend the file to make sure it's large enough */ + if(!H5F_addr_eq(file->eoa, file->eof)) { +#ifdef _WIN32 + HFILE filehandle; /* Windows file handle */ + LARGE_INTEGER li; /* 64-bit integer for SetFilePointer() call */ + + /* Map the posix file handle to a Windows file handle */ + filehandle = _get_osfhandle(file->fd); + + /* Translate 64-bit integers into form Windows wants */ + /* [This algorithm is from the Windows documentation for SetFilePointer()] */ + li.QuadPart = (LONGLONG)file->eoa; + (void)SetFilePointer((HANDLE)filehandle, li.LowPart, &li.HighPart, FILE_BEGIN); + if(SetEndOfFile((HANDLE)filehandle) == 0) + HGOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to extend file properly") +#else /* _WIN32 */ +#ifdef H5_VMS + /* Reset seek offset to the beginning of the file, so that the file isn't + * re-extended later. This may happen on Open VMS. */ + if(-1 == HDlseek(file->fd, (HDoff_t)0, SEEK_SET)) + HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to seek to proper position") +#endif + + if(-1 == HDftruncate(file->fd, (HDoff_t)file->eoa)) + HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to extend file properly") +#endif /* _WIN32 */ + + /* Log information about the truncate */ + if(file->fa.flags & H5FD_LOG_NUM_TRUNCATE) + file->total_truncate_ops++; + + /* Update the eof value */ file->eof = file->eoa; - file->pos = file->eoa; - file->op = OP_WRITE; - } + + /* Reset last file I/O information */ + file->pos = HADDR_UNDEF; + file->op = OP_UNKNOWN; + } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5FDlog.h b/src/H5FDlog.h index 1ed4561..bd1bbe2 100644 --- a/src/H5FDlog.h +++ b/src/H5FDlog.h @@ -28,30 +28,32 @@ /* Flags for H5Pset_fapl_log() */ /* Flags for tracking where reads/writes/seeks occur */ -#define H5FD_LOG_LOC_READ 0x0001 -#define H5FD_LOG_LOC_WRITE 0x0002 -#define H5FD_LOG_LOC_SEEK 0x0004 +#define H5FD_LOG_LOC_READ 0x00000001 +#define H5FD_LOG_LOC_WRITE 0x00000002 +#define H5FD_LOG_LOC_SEEK 0x00000004 #define H5FD_LOG_LOC_IO (H5FD_LOG_LOC_READ|H5FD_LOG_LOC_WRITE|H5FD_LOG_LOC_SEEK) /* Flags for tracking number of times each byte is read/written */ -#define H5FD_LOG_FILE_READ 0x0008 -#define H5FD_LOG_FILE_WRITE 0x0010 +#define H5FD_LOG_FILE_READ 0x00000008 +#define H5FD_LOG_FILE_WRITE 0x00000010 #define H5FD_LOG_FILE_IO (H5FD_LOG_FILE_READ|H5FD_LOG_FILE_WRITE) /* Flag for tracking "flavor" (type) of information stored at each byte */ -#define H5FD_LOG_FLAVOR 0x0020 +#define H5FD_LOG_FLAVOR 0x00000020 /* Flags for tracking total number of reads/writes/seeks */ -#define H5FD_LOG_NUM_READ 0x0040 -#define H5FD_LOG_NUM_WRITE 0x0080 -#define H5FD_LOG_NUM_SEEK 0x0100 -#define H5FD_LOG_NUM_IO (H5FD_LOG_NUM_READ|H5FD_LOG_NUM_WRITE|H5FD_LOG_NUM_SEEK) +#define H5FD_LOG_NUM_READ 0x00000040 +#define H5FD_LOG_NUM_WRITE 0x00000080 +#define H5FD_LOG_NUM_SEEK 0x00000100 +#define H5FD_LOG_NUM_TRUNCATE 0x00000200 +#define H5FD_LOG_NUM_IO (H5FD_LOG_NUM_READ|H5FD_LOG_NUM_WRITE|H5FD_LOG_NUM_SEEK|H5FD_LOG_NUM_TRUNCATE) /* Flags for tracking time spent in open/read/write/seek/close */ -#define H5FD_LOG_TIME_OPEN 0x0200 -#define H5FD_LOG_TIME_READ 0x0400 -#define H5FD_LOG_TIME_WRITE 0x0800 -#define H5FD_LOG_TIME_SEEK 0x1000 -#define H5FD_LOG_TIME_CLOSE 0x2000 -#define H5FD_LOG_TIME_IO (H5FD_LOG_TIME_OPEN|H5FD_LOG_TIME_READ|H5FD_LOG_TIME_WRITE|H5FD_LOG_TIME_SEEK|H5FD_LOG_TIME_CLOSE) +#define H5FD_LOG_TIME_OPEN 0x00000400 +#define H5FD_LOG_TIME_STAT 0x00000800 +#define H5FD_LOG_TIME_READ 0x00001000 +#define H5FD_LOG_TIME_WRITE 0x00002000 +#define H5FD_LOG_TIME_SEEK 0x00004000 +#define H5FD_LOG_TIME_CLOSE 0x00008000 +#define H5FD_LOG_TIME_IO (H5FD_LOG_TIME_OPEN|H5FD_LOG_TIME_STAT|H5FD_LOG_TIME_READ|H5FD_LOG_TIME_WRITE|H5FD_LOG_TIME_SEEK|H5FD_LOG_TIME_CLOSE) /* Flag for tracking allocation of space in file */ -#define H5FD_LOG_ALLOC 0x4000 +#define H5FD_LOG_ALLOC 0x00010000 #define H5FD_LOG_ALL (H5FD_LOG_ALLOC|H5FD_LOG_TIME_IO|H5FD_LOG_NUM_IO|H5FD_LOG_FLAVOR|H5FD_LOG_FILE_IO|H5FD_LOG_LOC_IO) #ifdef __cplusplus @@ -60,10 +62,11 @@ extern "C" { H5_DLL hid_t H5FD_log_init(void); H5_DLL void H5FD_log_term(void); -H5_DLL herr_t H5Pset_fapl_log(hid_t fapl_id, const char *logfile, unsigned flags, size_t buf_size); +H5_DLL herr_t H5Pset_fapl_log(hid_t fapl_id, const char *logfile, unsigned long long flags, size_t buf_size); #ifdef __cplusplus } #endif #endif + diff --git a/src/H5FDprivate.h b/src/H5FDprivate.h index cb40e5c..fe770d2 100644 --- a/src/H5FDprivate.h +++ b/src/H5FDprivate.h @@ -31,13 +31,40 @@ */ #include "H5FDmpi.h" /* MPI-based file drivers */ -/* Macros */ + +/**************************/ +/* Library Private Macros */ +/**************************/ + +/* Length of filename buffer */ +#define H5FD_MAX_FILENAME_LEN 1024 + + +/****************************/ +/* Library Private Typedefs */ +/****************************/ + +/* File operations */ +typedef enum { + OP_UNKNOWN = 0, /* Unknown last file operation */ + OP_READ = 1, /* Last file I/O operation was a read */ + OP_WRITE = 2 /* Last file I/O operation was a write */ +} H5FD_file_op_t; + + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + + +/******************************/ +/* Library Private Prototypes */ +/******************************/ /* Forward declarations for prototype arguments */ struct H5P_genplist_t; struct H5F_t; -/* Prototypes */ H5_DLL int H5FD_term_interface(void); H5_DLL H5FD_class_t *H5FD_get_class(hid_t id); H5_DLL hsize_t H5FD_sb_size(H5FD_t *file); diff --git a/src/H5FDsec2.c b/src/H5FDsec2.c index d9fa4d9..1153df7 100644 --- a/src/H5FDsec2.c +++ b/src/H5FDsec2.c @@ -42,15 +42,6 @@ /* The driver identification number, initialized at runtime */ static hid_t H5FD_SEC2_g = 0; -/* File operations */ -typedef enum { - OP_UNKNOWN = 0, /* Unknown last file operation */ - OP_READ = 1, /* Last file I/O operation was a read */ - OP_WRITE = 2 /* Last file I/O operation was a write */ -} H5FD_sec2_file_op_t; - -#define H5FD_SEC2_MAX_FILENAME_LEN 1024 - /* * The description of a file belonging to this driver. The `eoa' and `eof' * determine the amount of hdf5 address space in use and the high-water mark @@ -69,8 +60,8 @@ typedef struct H5FD_sec2_t { haddr_t eoa; /*end of allocated region */ haddr_t eof; /*end of file; current file size*/ haddr_t pos; /*current file I/O position */ - H5FD_sec2_file_op_t op; /*last operation */ - char filename[H5FD_SEC2_MAX_FILENAME_LEN]; /* Copy of file name from open operation */ + H5FD_file_op_t op; /*last operation */ + char filename[H5FD_MAX_FILENAME_LEN]; /* Copy of file name from open operation */ #ifndef _WIN32 /* * On most systems the combination of device and i-node number uniquely @@ -165,10 +156,10 @@ static const H5FD_class_t H5FD_sec2_g = { 0, /*dxpl_size */ NULL, /*dxpl_copy */ NULL, /*dxpl_free */ - H5FD_sec2_open, /*open */ - H5FD_sec2_close, /*close */ - H5FD_sec2_cmp, /*cmp */ - H5FD_sec2_query, /*query */ + H5FD_sec2_open, /*open */ + H5FD_sec2_close, /*close */ + H5FD_sec2_cmp, /*cmp */ + H5FD_sec2_query, /*query */ NULL, /*get_type_map */ NULL, /*alloc */ NULL, /*free */ @@ -228,7 +219,7 @@ H5FD_sec2_init_interface(void) hid_t H5FD_sec2_init(void) { - hid_t ret_value; /* Return value */ + hid_t ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5FD_sec2_init, FAIL) @@ -290,14 +281,14 @@ H5Pset_fapl_sec2(hid_t fapl_id) FUNC_ENTER_API(H5Pset_fapl_sec2, FAIL) H5TRACE1("e", "i", fapl_id); - if(NULL == (plist = H5P_object_verify(fapl_id,H5P_FILE_ACCESS))) + if(NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") - ret_value= H5P_set_driver(plist, H5FD_SEC2, NULL); + ret_value = H5P_set_driver(plist, H5FD_SEC2, NULL); done: FUNC_LEAVE_API(ret_value) -} +} /* end H5Pset_fapl_sec2() */ /*------------------------------------------------------------------------- @@ -308,22 +299,19 @@ done: * Return: Success: A pointer to a new file data structure. The * public fields will be initialized by the * caller, which is always H5FD_open(). - * * Failure: NULL * * Programmer: Robb Matzke * Thursday, July 29, 1999 * - * Modifications: - * *------------------------------------------------------------------------- */ static H5FD_t * H5FD_sec2_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) { H5FD_sec2_t *file = NULL; /* sec2 VFD info */ - int fd = (-1); /* File descriptor */ - int o_flags; /* Flags for open() call */ + int fd = (-1); /* File descriptor */ + int o_flags; /* Flags for open() call */ #ifdef _WIN32 HFILE filehandle; struct _BY_HANDLE_FILE_INFORMATION fileinfo; @@ -331,10 +319,10 @@ H5FD_sec2_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) h5_stat_t sb; H5FD_t *ret_value; /* Return value */ - FUNC_ENTER_NOAPI(H5FD_sec2_open, NULL) + FUNC_ENTER_NOAPI_NOINIT(H5FD_sec2_open) /* Sanity check on file offsets */ - HDassert(sizeof(HDoff_t) >= sizeof(size_t)); + HDcompile_assert(sizeof(HDoff_t) >= sizeof(size_t)); /* Check arguments */ if(!name || !*name) @@ -430,7 +418,6 @@ done: * Purpose: Closes a Unix file. * * Return: Success: 0 - * * Failure: -1, file not closed. * * Programmer: Robb Matzke @@ -441,10 +428,10 @@ done: static herr_t H5FD_sec2_close(H5FD_t *_file) { - H5FD_sec2_t *file = (H5FD_sec2_t*)_file; + H5FD_sec2_t *file = (H5FD_sec2_t *)_file; herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(H5FD_sec2_close, FAIL) + FUNC_ENTER_NOAPI_NOINIT(H5FD_sec2_close) /* Sanity check */ HDassert(file); @@ -468,59 +455,56 @@ done: * arbitrary (but consistent) ordering. * * Return: Success: A value like strcmp() - * * Failure: never fails (arguments were checked by the * caller). * * Programmer: Robb Matzke * Thursday, July 29, 1999 * - * Modifications: - * *------------------------------------------------------------------------- */ static int H5FD_sec2_cmp(const H5FD_t *_f1, const H5FD_t *_f2) { - const H5FD_sec2_t *f1 = (const H5FD_sec2_t*)_f1; - const H5FD_sec2_t *f2 = (const H5FD_sec2_t*)_f2; - int ret_value=0; + const H5FD_sec2_t *f1 = (const H5FD_sec2_t *)_f1; + const H5FD_sec2_t *f2 = (const H5FD_sec2_t *)_f2; + int ret_value = 0; - FUNC_ENTER_NOAPI(H5FD_sec2_cmp, H5FD_VFD_DEFAULT) + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FD_sec2_cmp) #ifdef _WIN32 - if (f1->fileindexhi < f2->fileindexhi) HGOTO_DONE(-1) - if (f1->fileindexhi > f2->fileindexhi) HGOTO_DONE(1) + if(f1->fileindexhi < f2->fileindexhi) HGOTO_DONE(-1) + if(f1->fileindexhi > f2->fileindexhi) HGOTO_DONE(1) - if (f1->fileindexlo < f2->fileindexlo) HGOTO_DONE(-1) - if (f1->fileindexlo > f2->fileindexlo) HGOTO_DONE(1) + if(f1->fileindexlo < f2->fileindexlo) HGOTO_DONE(-1) + if(f1->fileindexlo > f2->fileindexlo) HGOTO_DONE(1) #else #ifdef H5_DEV_T_IS_SCALAR - if (f1->device < f2->device) HGOTO_DONE(-1) - if (f1->device > f2->device) HGOTO_DONE(1) + if(f1->device < f2->device) HGOTO_DONE(-1) + if(f1->device > f2->device) HGOTO_DONE(1) #else /* H5_DEV_T_IS_SCALAR */ /* If dev_t isn't a scalar value on this system, just use memcmp to * determine if the values are the same or not. The actual return value * shouldn't really matter... */ - if(HDmemcmp(&(f1->device),&(f2->device),sizeof(dev_t))<0) HGOTO_DONE(-1) - if(HDmemcmp(&(f1->device),&(f2->device),sizeof(dev_t))>0) HGOTO_DONE(1) + if(HDmemcmp(&(f1->device),&(f2->device),sizeof(dev_t)) < 0) HGOTO_DONE(-1) + if(HDmemcmp(&(f1->device),&(f2->device),sizeof(dev_t)) > 0) HGOTO_DONE(1) #endif /* H5_DEV_T_IS_SCALAR */ #ifndef H5_VMS - if (f1->inode < f2->inode) HGOTO_DONE(-1) - if (f1->inode > f2->inode) HGOTO_DONE(1) + if(f1->inode < f2->inode) HGOTO_DONE(-1) + if(f1->inode > f2->inode) HGOTO_DONE(1) #else - if(HDmemcmp(&(f1->inode),&(f2->inode),3*sizeof(ino_t))<0) HGOTO_DONE(-1) - if(HDmemcmp(&(f1->inode),&(f2->inode),3*sizeof(ino_t))>0) HGOTO_DONE(1) + if(HDmemcmp(&(f1->inode), &(f2->inode), 3 * sizeof(ino_t)) < 0) HGOTO_DONE(-1) + if(HDmemcmp(&(f1->inode), &(f2->inode), 3 * sizeof(ino_t)) > 0) HGOTO_DONE(1) #endif /*H5_VMS*/ #endif done: FUNC_LEAVE_NOAPI(ret_value) -} +} /* end H5FD_sec2_cmp() */ /*------------------------------------------------------------------------- @@ -540,7 +524,7 @@ done: static herr_t H5FD_sec2_query(const H5FD_t *_file, unsigned long *flags /* out */) { - const H5FD_sec2_t *file = (const H5FD_sec2_t*)_file; /* sec2 VFD info */ + const H5FD_sec2_t *file = (const H5FD_sec2_t *)_file; /* sec2 VFD info */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FD_sec2_query) @@ -570,32 +554,21 @@ H5FD_sec2_query(const H5FD_t *_file, unsigned long *flags /* out */) * format address space. * * Return: Success: The end-of-address marker. - * * Failure: HADDR_UNDEF * * Programmer: Robb Matzke * Monday, August 2, 1999 * - * Modifications: - * Raymond Lu - * 21 Dec. 2006 - * Added the parameter TYPE. It's only used for MULTI driver. - * *------------------------------------------------------------------------- */ static haddr_t H5FD_sec2_get_eoa(const H5FD_t *_file, H5FD_mem_t UNUSED type) { - const H5FD_sec2_t *file = (const H5FD_sec2_t*)_file; - haddr_t ret_value; /* Return value */ - - FUNC_ENTER_NOAPI(H5FD_sec2_get_eoa, HADDR_UNDEF) + const H5FD_sec2_t *file = (const H5FD_sec2_t *)_file; - /* Set return value */ - ret_value = file->eoa; + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FD_sec2_get_eoa) -done: - FUNC_LEAVE_NOAPI(ret_value) + FUNC_LEAVE_NOAPI(file->eoa) } /* end H5FD_sec2_get_eoa() */ @@ -607,31 +580,23 @@ done: * to tell the driver where the end of the HDF5 data is located. * * Return: Success: 0 - * * Failure: -1 * * Programmer: Robb Matzke * Thursday, July 29, 1999 * - * Modifications: - * Raymond Lu - * 21 Dec. 2006 - * Added the parameter TYPE. It's only used for MULTI driver. - * *------------------------------------------------------------------------- */ static herr_t H5FD_sec2_set_eoa(H5FD_t *_file, H5FD_mem_t UNUSED type, haddr_t addr) { - H5FD_sec2_t *file = (H5FD_sec2_t*)_file; - herr_t ret_value=SUCCEED; /* Return value */ + H5FD_sec2_t *file = (H5FD_sec2_t *)_file; - FUNC_ENTER_NOAPI(H5FD_sec2_set_eoa, FAIL) + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FD_sec2_set_eoa) file->eoa = addr; -done: - FUNC_LEAVE_NOAPI(ret_value) + FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5FD_sec2_set_eoa() */ @@ -645,30 +610,22 @@ done: * Return: Success: End of file address, the first address past * the end of the "file", either the Unix file * or the HDF5 file. - * * Failure: HADDR_UNDEF * * Programmer: Robb Matzke * Thursday, July 29, 1999 * - * Modifications: - * *------------------------------------------------------------------------- */ static haddr_t H5FD_sec2_get_eof(const H5FD_t *_file) { - const H5FD_sec2_t *file = (const H5FD_sec2_t*)_file; - haddr_t ret_value; /* Return value */ + const H5FD_sec2_t *file = (const H5FD_sec2_t *)_file; - FUNC_ENTER_NOAPI(H5FD_sec2_get_eof, HADDR_UNDEF) + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FD_sec2_get_eof) - /* Set return value */ - ret_value=MAX(file->eof, file->eoa); - -done: - FUNC_LEAVE_NOAPI(ret_value) -} + FUNC_LEAVE_NOAPI(MAX(file->eof, file->eoa)) +} /* end H5FD_sec2_get_eof() */ /*------------------------------------------------------------------------- @@ -690,10 +647,11 @@ H5FD_sec2_get_handle(H5FD_t *_file, hid_t UNUSED fapl, void **file_handle) H5FD_sec2_t *file = (H5FD_sec2_t *)_file; herr_t ret_value = SUCCEED; - FUNC_ENTER_NOAPI(H5FD_sec2_get_handle, FAIL) + FUNC_ENTER_NOAPI_NOINIT(H5FD_sec2_get_handle) if(!file_handle) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file handle not valid") + *file_handle = &(file->fd); done: @@ -722,11 +680,11 @@ static herr_t H5FD_sec2_read(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, haddr_t addr, size_t size, void *buf/*out*/) { - H5FD_sec2_t *file = (H5FD_sec2_t*)_file; + H5FD_sec2_t *file = (H5FD_sec2_t *)_file; ssize_t nbytes; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(H5FD_sec2_read, FAIL) + FUNC_ENTER_NOAPI_NOINIT(H5FD_sec2_read) HDassert(file && file->pub.cls); HDassert(buf); @@ -740,9 +698,10 @@ H5FD_sec2_read(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow, addr = %llu", (unsigned long long)addr) /* Seek to the correct location */ - if((addr != file->pos || OP_READ != file->op) && - HDlseek(file->fd, (HDoff_t)addr, SEEK_SET) < 0) - HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to seek to proper position") + 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 */ /* * Read data, being careful of interrupted system calls, partial results, @@ -808,11 +767,11 @@ static herr_t H5FD_sec2_write(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, haddr_t addr, size_t size, const void *buf) { - H5FD_sec2_t *file = (H5FD_sec2_t*)_file; + H5FD_sec2_t *file = (H5FD_sec2_t *)_file; ssize_t nbytes; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(H5FD_sec2_write, FAIL) + FUNC_ENTER_NOAPI_NOINIT(H5FD_sec2_write) HDassert(file && file->pub.cls); HDassert(buf); @@ -826,9 +785,10 @@ H5FD_sec2_write(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, had HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow, addr = %llu, size = %llu, eoa = %llu", (unsigned long long)addr, (unsigned long long)size, (unsigned long long)file->eoa) /* Seek to the correct location */ - if((addr != file->pos || OP_WRITE != file->op) && - HDlseek(file->fd, (HDoff_t)addr, SEEK_SET) < 0) - HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to seek to proper position") + 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 */ /* * Write the data, being careful of interrupted system calls and partial @@ -878,7 +838,6 @@ done: * than the end-of-address. * * Return: Success: Non-negative - * * Failure: Negative * * Programmer: Robb Matzke @@ -890,10 +849,10 @@ done: static herr_t H5FD_sec2_truncate(H5FD_t *_file, hid_t UNUSED dxpl_id, hbool_t UNUSED closing) { - H5FD_sec2_t *file = (H5FD_sec2_t*)_file; + H5FD_sec2_t *file = (H5FD_sec2_t *)_file; herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(H5FD_sec2_truncate, FAIL) + FUNC_ENTER_NOAPI_NOINIT(H5FD_sec2_truncate) HDassert(file); diff --git a/src/H5FScache.c b/src/H5FScache.c index 0908755..b681b2c 100644 --- a/src/H5FScache.c +++ b/src/H5FScache.c @@ -562,7 +562,7 @@ H5FS_cache_hdr_size(const H5F_t UNUSED *f, const H5FS_t *fspace, size_t *size_pt *------------------------------------------------------------------------- */ static H5FS_sinfo_t * -H5FS_cache_sinfo_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_udata) +H5FS_cache_sinfo_load(H5F_t *f, hid_t dxpl_id, haddr_t UNUSED addr, void *_udata) { H5FS_sinfo_t *sinfo = NULL; /* Free space section info */ H5FS_sinfo_cache_ud_t *udata = (H5FS_sinfo_cache_ud_t *)_udata; /* user data for callback */ diff --git a/src/H5private.h b/src/H5private.h index 01c1735..d1862f9 100644 --- a/src/H5private.h +++ b/src/H5private.h @@ -400,11 +400,6 @@ # error "nothing appropriate for int32_t" #endif -/* Definition of uint32_t was moved to H5public.h */ - -/* Definition of int64_t was moved to H5public.h */ -/* Definition of uint64_t was moved to H5public.h */ - /* * Maximum and minimum values. These should be defined in <limits.h> for the * most part. |