From 58c78dbaf357def4c7bf6fb95a0248a1ccf6c3c6 Mon Sep 17 00:00:00 2001 From: Noah Watkins Date: Sun, 21 Jul 2013 10:54:00 -0700 Subject: [PATCH] FileJournal: fix posix_fallocate error handling 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 Reviewed-by: Sage Weil --- src/os/FileJournal.cc | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/os/FileJournal.cc b/src/os/FileJournal.cc index 3acadf0958219..4a2af08dd4c0a 100644 --- a/src/os/FileJournal.cc +++ b/src/os/FileJournal.cc @@ -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; } -- 2.39.5