Skip to content

Commit

Permalink
BUG#20383215 - POSIX_FALLOCATE() CAN BE INTERRUPTED (OS ERROR NUMBER 4)
Browse files Browse the repository at this point in the history
Because posix_fallocate() could be interrupted, the related error messages
may be printed out in this case, which makes the internal MTR test case
failing with errors/warnings. Since this error message about the
interruption may not help users too much, it is proper to just ignore
this error of EINTR and go through to write zeroes to the file.
Along with this change, it now also tries writing zeroes when the error
is EINVAL.

RB: 19056
Reviewed-by: Jimmy Yang <jimmy.yang@oracle.com>
  • Loading branch information
Bin Su committed Mar 16, 2018
1 parent 7a689ac commit 262e665
Showing 1 changed file with 35 additions and 19 deletions.
54 changes: 35 additions & 19 deletions storage/innobase/fil/fil0fil.cc
@@ -1,6 +1,6 @@
/*****************************************************************************
Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 1995, 2018, Oracle and/or its affiliates. All Rights Reserved.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Expand Down Expand Up @@ -5070,24 +5070,40 @@ fil_space_extend(

#if !defined(NO_FALLOCATE) && defined(UNIV_LINUX)
int ret = posix_fallocate(node->handle.m_file, node_start, len);
/* We already pass the valid offset and len in, if EINVAL
is returned, it could only mean that the file system doesn't
support fallocate(), currently one known case is
ext3 FS with O_DIRECT. We ignore EINVAL here so that the
error message won't flood. */
if (ret != 0 && ret != EINVAL) {
ib::error()
<< "posix_fallocate(): Failed to preallocate"
" data for file "
<< node->name << ", desired size "
<< len << " bytes."
" Operating system error number "
<< ret << ". Check"
" that the disk is not full or a disk quota"
" exceeded. Make sure the file system supports"
" this function. Some operating system error"
" numbers are described at " REFMAN
" operating-system-error-codes.html";

DBUG_EXECUTE_IF("ib_posix_fallocate_fail_eintr",
ret = EINTR;);

DBUG_EXECUTE_IF("ib_posix_fallocate_fail_einval",
ret = EINVAL;);

if (ret != 0) {
/* We already pass the valid offset and len in,
if EINVAL is returned, it could only mean that the
file system doesn't support fallocate(), currently
one known case is ext3 with O_DIRECT.
Also because above call could be interrupted,
in this case, simply go to plan B by writing zeroes.
Both error messages for above two scenarios are
skipped in case of flooding error messages, because
they can be ignored by users. */
if (ret != EINTR && ret != EINVAL) {
ib::error()
<< "posix_fallocate(): Failed to"
" preallocate data for file "
<< node->name << ", desired size "
<< len << " bytes."
" Operating system error number "
<< ret << ". Check"
" that the disk is not full or a disk"
" quota exceeded. Make sure the file"
" system supports this function."
" Some operating system error"
" numbers are described at " REFMAN
"operating-system-error-codes.html";
}

err = DB_IO_ERROR;
}
Expand Down

0 comments on commit 262e665

Please sign in to comment.