From: Noah Watkins Date: Sun, 21 Jul 2013 17:54:00 +0000 (-0700) Subject: FileJournal: fix posix_fallocate error handling X-Git-Tag: v0.67-rc1~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=58c78dbaf357def4c7bf6fb95a0248a1ccf6c3c6;p=ceph.git 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 --- diff --git a/src/os/FileJournal.cc b/src/os/FileJournal.cc index 3acadf09582..4a2af08dd4c 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; }