diff options
author | Sachin Setiya <sachin.setiya@mariadb.com> | 2017-04-18 12:01:56 +0530 |
---|---|---|
committer | Sachin Setiya <sachin.setiya@mariadb.com> | 2017-04-18 12:01:56 +0530 |
commit | 5ca8121292df337849811458b6c6671f7e9b2080 (patch) | |
tree | f8b4cd35955681c5b2deea916f2e0dab33ce7c59 /storage/innobase/os | |
parent | fce9a0c46ab9a8a95345a8d661d2b047e64ad7d6 (diff) | |
parent | 663068c6eea736a38eff9ac183326d6c7e4e239b (diff) | |
download | mariadb-git-5ca8121292df337849811458b6c6671f7e9b2080.tar.gz |
Merge tag 'mariadb-5.5.55' into bb-5.5-sachin-merge
Signed-off-by: Sachin Setiya <sachin.setiya@mariadb.com>
Diffstat (limited to 'storage/innobase/os')
-rw-r--r-- | storage/innobase/os/os0file.c | 86 |
1 files changed, 32 insertions, 54 deletions
diff --git a/storage/innobase/os/os0file.c b/storage/innobase/os/os0file.c index 12b4ead3c7a..a6156e555b5 100644 --- a/storage/innobase/os/os0file.c +++ b/storage/innobase/os/os0file.c @@ -2,6 +2,7 @@ Copyright (c) 1995, 2015, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2009, Percona Inc. +Copyright (c) 2012, 2017, MariaDB Corporation. All Rights Reserved. Portions of this file contain modifications contributed and copyrighted by Percona Inc.. Those modifications are @@ -2045,48 +2046,48 @@ os_file_set_size( ut_a(size == (size & 0xFFFFFFFF)); - current_size = 0; desired_size = (ib_int64_t)size + (((ib_int64_t)size_high) << 32); #ifdef HAVE_POSIX_FALLOCATE - if (srv_use_posix_fallocate) { - if (posix_fallocate(file, current_size, desired_size) == -1) { + if (srv_use_posix_fallocate) { + int err; + do { + err = posix_fallocate(file, 0, desired_size); + } while (err == EINTR + && srv_shutdown_state == SRV_SHUTDOWN_NONE); + if (err) { fprintf(stderr, - "InnoDB: Error: preallocating data for" - " file %s failed at\n" - "InnoDB: offset 0 size %lld %lld. Operating system" - " error number %d.\n" - "InnoDB: Check that the disk is not full" - " or a disk quota exceeded.\n" - "InnoDB: Some operating system error numbers" - " are described at\n" - "InnoDB: " - REFMAN "operating-system-error-codes.html\n", - name, (long long)size_high, (long long)size, errno); - - return (FALSE); + "InnoDB: Error: preallocating %lld bytes for" + " file %s failed with error %d.\n", + desired_size, name, err); } - return (TRUE); + return(!err); } #endif +#ifdef _WIN32 + /* Write 1 page of zeroes at the desired end. */ + buf_size = UNIV_PAGE_SIZE; + current_size = desired_size - buf_size; +#else /* Write up to 1 megabyte at a time. */ buf_size = ut_min(64, (ulint) (desired_size / UNIV_PAGE_SIZE)) * UNIV_PAGE_SIZE; - buf2 = ut_malloc(buf_size + UNIV_PAGE_SIZE); + current_size = 0; +#endif + buf2 = calloc(1, buf_size + UNIV_PAGE_SIZE); + + if (!buf2) { + fprintf(stderr, "InnoDB: Cannot allocate " ULINTPF + " bytes to extend file\n", + buf_size + UNIV_PAGE_SIZE); + return(FALSE); + } /* Align the buffer for possible raw i/o */ buf = ut_align(buf2, UNIV_PAGE_SIZE); - /* Write buffer full of zeros */ - memset(buf, 0, buf_size); - - if (desired_size >= (ib_int64_t)(100 * 1024 * 1024)) { - - fprintf(stderr, "InnoDB: Progress in MB:"); - } - - while (current_size < desired_size) { + do { ulint n_bytes; if (desired_size - current_size < (ib_int64_t) buf_size) { @@ -2100,37 +2101,14 @@ os_file_set_size( (ulint)(current_size >> 32), n_bytes); if (!ret) { - ut_free(buf2); - goto error_handling; - } - - /* Print about progress for each 100 MB written */ - if ((ib_int64_t) (current_size + n_bytes) / (ib_int64_t)(100 * 1024 * 1024) - != current_size / (ib_int64_t)(100 * 1024 * 1024)) { - - fprintf(stderr, " %lu00", - (ulong) ((current_size + n_bytes) - / (ib_int64_t)(100 * 1024 * 1024))); + break; } current_size += n_bytes; - } - - if (desired_size >= (ib_int64_t)(100 * 1024 * 1024)) { - - fprintf(stderr, "\n"); - } + } while (current_size < desired_size); - ut_free(buf2); - - ret = os_file_flush(file); - - if (ret) { - return(TRUE); - } - -error_handling: - return(FALSE); + free(buf2); + return(ret && os_file_flush(file)); } /***********************************************************************//** |