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.
This commit is contained in:
Marko Mäkelä 2017-10-27 18:59:22 +03:00
parent 057a6cf768
commit 5f5ffdc76b

View file

@ -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);