summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2017-10-27 18:59:22 +0300
committerMarko Mäkelä <marko.makela@mariadb.com>2017-10-27 18:59:22 +0300
commit5f5ffdc76bdf9237e15e5f8a83fe41a9ca8a5288 (patch)
tree59fce5826d0822c9986176535db1a5004a10c71a
parent057a6cf768e8308b79bf571c30e62ca81d31d68d (diff)
downloadmariadb-git-5f5ffdc76bdf9237e15e5f8a83fe41a9ca8a5288.tar.gz
MDEV-14132 follow-up fix: Validate the posix_fallocate() argument
os_file_set_size(): Sometimes the file already is large enough. Avoid calling posix_fallocate() with a non-positive argument. Also, add a missing space to an error message.
-rw-r--r--storage/innobase/os/os0file.cc6
1 files changed, 4 insertions, 2 deletions
diff --git a/storage/innobase/os/os0file.cc b/storage/innobase/os/os0file.cc
index dc84c159f3c..633a27226d9 100644
--- a/storage/innobase/os/os0file.cc
+++ b/storage/innobase/os/os0file.cc
@@ -5382,14 +5382,16 @@ fallback:
int err;
do {
os_offset_t current_size = os_file_get_size(file);
- err = posix_fallocate(file, current_size, size - current_size);
+ err = current_size >= size
+ ? 0 : posix_fallocate(file, current_size,
+ size - current_size);
} while (err == EINTR
&& srv_shutdown_state == SRV_SHUTDOWN_NONE);
if (err) {
ib::error() <<
"preallocating " << size << " bytes for" <<
- "file " << name << "failed with error " << err;
+ "file " << name << " failed with error " << err;
}
errno = err;
return(!err);