From: xie xingguo Date: Wed, 13 Jul 2016 07:05:29 +0000 (+0800) Subject: os/bluestore: fix error handling of posix_fallocate() X-Git-Tag: ses5-milestone5~363^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=38c4286b4a31fd22298080ad950aa18bded66db2;p=ceph.git os/bluestore: fix error handling of posix_fallocate() According to Linux man page: posix_fallocate() returns zero on success, or an error number on failure. Note that errno is not set. Signed-off-by: xie xingguo --- diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index cc91d89af6f2..f3b97bd8a128 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -2483,12 +2483,11 @@ int BlueStore::_setup_block_symlink_or_file( if (g_conf->bluestore_block_preallocate_file) { #ifdef HAVE_POSIX_FALLOCATE r = ::posix_fallocate(fd, 0, size); - if (r < 0) { - r = -errno; + if (r) { derr << __func__ << " failed to prefallocate " << name << " file to " << size << ": " << cpp_strerror(r) << dendl; VOID_TEMP_FAILURE_RETRY(::close(fd)); - return r; + return -r; } #else char data[1024*128];