diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2016-07-08 21:30:51 +0200 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2016-07-08 21:30:51 +0200 |
commit | f4f3fc402c9d6c32150fb65a39e03a2dae0b9fc2 (patch) | |
tree | 8adf091d861767483773e5c35d59d0856599e667 /fastos/src | |
parent | 1acc6d2e210aebb60e2cff64a4b2aaa4b3491e17 (diff) |
Also take padAfter into account.
Diffstat (limited to 'fastos/src')
-rw-r--r-- | fastos/src/vespa/fastos/linux_file.cpp | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/fastos/src/vespa/fastos/linux_file.cpp b/fastos/src/vespa/fastos/linux_file.cpp index 747ceef4880..e57e00645af 100644 --- a/fastos/src/vespa/fastos/linux_file.cpp +++ b/fastos/src/vespa/fastos/linux_file.cpp @@ -322,19 +322,23 @@ bool FastOS_Linux_File::DirectIOPadding (int64_t offset, size_t length, size_t &padBefore, size_t &padAfter) { if (_directIOEnabled) { - if (int64_t(offset+length) > _cachedSize) { - // _cachedSize is not really trustworthy, so if we suspect it is not correct, we correct it. - // The main reason is that it will not reflect the file being extended by another filedescriptor. - _cachedSize = GetSize(); - } + padBefore = offset & (_directIOFileAlign - 1); padAfter = _directIOFileAlign - ((padBefore + length) & (_directIOFileAlign - 1)); if (padAfter == _directIOFileAlign) { padAfter = 0; - } else if ((static_cast<int64_t>(offset + length + padAfter) > _cachedSize) && - (static_cast<int64_t>(offset + length) <= _cachedSize)) { - padAfter = _cachedSize - offset - length; + } + if (int64_t(offset+length+padAfter) > _cachedSize) { + // _cachedSize is not really trustworthy, so if we suspect it is not correct, we correct it. + // The main reason is that it will not reflect the file being extended by another filedescriptor. + _cachedSize = GetSize(); + } + if ((padAfter != 0) && + (static_cast<int64_t>(offset + length + padAfter) > _cachedSize) && + (static_cast<int64_t>(offset + length) <= _cachedSize)) + { + padAfter = _cachedSize - (offset + length); } if (static_cast<uint64_t>(offset + length + padAfter) <= static_cast<uint64_t>(_cachedSize)) { |