Updated Branches: refs/heads/master 207df86f7 -> 813d3e1a2
TS-2305: fall back to ftruncate on posix_fallocate failure Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/813d3e1a Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/813d3e1a Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/813d3e1a Branch: refs/heads/master Commit: 813d3e1a261c46ff18e7837636b7b4ce5f931a2c Parents: 207df86 Author: James Peach <[email protected]> Authored: Mon Jan 20 10:52:46 2014 -0800 Committer: James Peach <[email protected]> Committed: Tue Jan 21 15:53:03 2014 -0800 ---------------------------------------------------------------------- CHANGES | 2 ++ lib/ts/ink_file.cc | 11 ++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/trafficserver/blob/813d3e1a/CHANGES ---------------------------------------------------------------------- diff --git a/CHANGES b/CHANGES index 5e1075e..c73e4c3 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,8 @@ -*- coding: utf-8 -*- Changes with Apache Traffic Server 4.2.0 + *) [TS-2305] Fall back to ftruncate if posix_fallocate fails. + *) [TS-2504] Support OpenSSL installations that use the lib64 directory. *) [TS-799] Have AdminClient.pm created from .in file. http://git-wip-us.apache.org/repos/asf/trafficserver/blob/813d3e1a/lib/ts/ink_file.cc ---------------------------------------------------------------------- diff --git a/lib/ts/ink_file.cc b/lib/ts/ink_file.cc index 53d064f..41891f1 100644 --- a/lib/ts/ink_file.cc +++ b/lib/ts/ink_file.cc @@ -344,14 +344,19 @@ ink_file_fd_zerofill(int fd, off_t size) return errno; } + // ZFS does not implement posix_fallocate() and fails with EINVAL. As a general workaround, + // just fall back to ftrucate if the preallocation fails. #if HAVE_POSIX_FALLOCATE - return posix_fallocate(fd, 0, size); -#else + if (posix_fallocate(fd, 0, size) == 0) { + return 0; + } +#endif + if (ftruncate(fd, size) < 0) { return errno; } + return 0; -#endif } bool
