]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: fix error handling of posix_fallocate()
authorxie xingguo <xie.xingguo@zte.com.cn>
Wed, 13 Jul 2016 07:05:29 +0000 (15:05 +0800)
committerxie xingguo <xie.xingguo@zte.com.cn>
Wed, 13 Jul 2016 07:05:29 +0000 (15:05 +0800)
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 <xie.xingguo@zte.com.cn>
src/os/bluestore/BlueStore.cc

index cc91d89af6f2ac9ec476038991a965a90bf33ca4..f3b97bd8a128cf8f0ed7267c561f02810c5e6341 100644 (file)
@@ -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];