Changeset: 45acd0d7a20a for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=45acd0d7a20a Modified Files: configure.ag gdk/gdk_posix.c gdk/gdk_storage.c Branch: Jan2014 Log Message:
Use posix_fallocate if available to extend files. Using this function will ensure that disk blocks are allocated, so when the file is the memory mapped and the memory then written to, we should never get a Bus Error because the disk is full. This hopefully fixes bug 64, bug 3202, and bug 3507, and possibly also bug 3502. diffs (53 lines): diff --git a/configure.ag b/configure.ag --- a/configure.ag +++ b/configure.ag @@ -2812,6 +2812,7 @@ AC_CHECK_FUNCS([\ pipe \ popen \ posix_fadvise \ + posix_fallocate \ posix_madvise \ putenv \ round \ diff --git a/gdk/gdk_posix.c b/gdk/gdk_posix.c --- a/gdk/gdk_posix.c +++ b/gdk/gdk_posix.c @@ -537,9 +537,21 @@ MT_mremap(const char *path, int mode, vo } if (write(fd, old_address, old_size) < 0 || - ftruncate(fd, *new_size) < 0) { +#ifdef HAVE_POSIX_FALLOCATE + posix_fallocate(fd, 0, (off_t) *new_size) < 0 +#else + ftruncate(fd, (off_t) *new_size) < 0 +#endif + ) { close(fd); - fprintf(stderr, "= %s:%d: MT_mremap(%s,"PTRFMT","SZFMT","SZFMT"): write() or ftruncate() failed\n", __FILE__, __LINE__, path?path:"NULL", PTRFMTCAST old_address, old_size, *new_size); + fprintf(stderr, + "= %s:%d: MT_mremap(%s,"PTRFMT","SZFMT","SZFMT"): write() or " +#ifdef HAVE_POSIX_FALLOCATE + "posix_fallocate()" +#else + "ftruncate()" +#endif + " failed\n", __FILE__, __LINE__, path?path:"NULL", PTRFMTCAST old_address, old_size, *new_size); return NULL; } p = mmap(NULL, *new_size, prot, flags, diff --git a/gdk/gdk_storage.c b/gdk/gdk_storage.c --- a/gdk/gdk_storage.c +++ b/gdk/gdk_storage.c @@ -239,7 +239,11 @@ GDKextendf(int fd, size_t size) } /* if necessary, extend the underlying file */ if (stb.st_size < (off_t) size) { +#ifdef HAVE_POSIX_FALLOCATE + return posix_fallocate(fd, 0, (off_t) size); +#else return ftruncate(fd, (off_t) size); +#endif } return 0; } _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list