]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
FileJournal: fix posix_fallocate error handling
authorNoah Watkins <noahwatkins@gmail.com>
Sun, 21 Jul 2013 17:54:00 +0000 (10:54 -0700)
committerSage Weil <sage@inktank.com>
Mon, 22 Jul 2013 18:43:01 +0000 (11:43 -0700)
From the man page for posix_fallocate:

    posix_fallocate() returns zero on success, or an error
    number on failure.  Note that errno is not set.

Signed-off-by: Noah Watkins <noahwatkins@gmail.com>
Reviewed-by: Sage Weil <sage@inktank.com>
src/os/FileJournal.cc

index 3acadf09582197e7b9a82e3e0eb52659d330f00e..4a2af08dd4c0a2b03a9b42161ae08738808cc41b 100644 (file)
@@ -299,11 +299,10 @@ int FileJournal::_open_file(int64_t oldsize, blksize_t blksize,
       return -err;
     }
     ret = ::posix_fallocate(fd, 0, newsize);
-    if (ret < 0) {
-      int err = errno;
+    if (ret) {
       derr << "FileJournal::_open_file : unable to preallocation journal to "
-          << newsize << " bytes: " << cpp_strerror(err) << dendl;
-      return -err;
+          << newsize << " bytes: " << cpp_strerror(ret) << dendl;
+      return -ret;
     }
     max_size = newsize;
   }