summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2023-10-17 15:28:12 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2023-10-17 15:28:12 +0000
commite046d2e730876d5f4ffa0442bd226da76ff1a7dd (patch)
tree88ca26a4c430a668c234805577a3e5c4fae28add
parent602844c8e92a1e7839942dbec4c03f81e1ca0ed2 (diff)
Relaxed store is sufficient.
-rw-r--r--vespalib/src/vespa/fastos/linux_file.cpp8
-rw-r--r--vespalib/src/vespa/fastos/linux_file.h5
2 files changed, 7 insertions, 6 deletions
diff --git a/vespalib/src/vespa/fastos/linux_file.cpp b/vespalib/src/vespa/fastos/linux_file.cpp
index 4348f8ea7e9..0f32aa953a8 100644
--- a/vespalib/src/vespa/fastos/linux_file.cpp
+++ b/vespalib/src/vespa/fastos/linux_file.cpp
@@ -202,7 +202,7 @@ FastOS_Linux_File::Write2(const void *buffer, size_t length)
if (writtenNow > 0) {
written += writtenNow;
} else {
- return (written > 0) ? written : writtenNow;;
+ return (written > 0) ? written : writtenNow;
}
}
return written;
@@ -240,7 +240,7 @@ FastOS_Linux_File::internalWrite2(const void *buffer, size_t length)
if (writeRes > 0) {
_filePointer += writeRes;
if (_filePointer > _cachedSize.load(std::memory_order_relaxed)) {
- _cachedSize.store(_filePointer, std::memory_order_release);
+ _cachedSize.store(_filePointer, std::memory_order_relaxed);
}
}
} else {
@@ -277,7 +277,7 @@ FastOS_Linux_File::SetSize(int64_t newSize)
bool rc = FastOS_UNIX_File::SetSize(newSize);
if (rc) {
- _cachedSize.store(newSize, std::memory_order_release);
+ _cachedSize.store(newSize, std::memory_order_relaxed);
}
return rc;
}
@@ -339,7 +339,7 @@ FastOS_Linux_File::DirectIOPadding (int64_t offset, size_t length, size_t &padBe
// _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.
fileSize = getSize();
- _cachedSize.store(fileSize, std::memory_order_release);
+ _cachedSize.store(fileSize, std::memory_order_relaxed);
}
if ((padAfter != 0) &&
(static_cast<int64_t>(offset + length + padAfter) > fileSize) &&
diff --git a/vespalib/src/vespa/fastos/linux_file.h b/vespalib/src/vespa/fastos/linux_file.h
index 6338c4e7757..af6e6af51af 100644
--- a/vespalib/src/vespa/fastos/linux_file.h
+++ b/vespalib/src/vespa/fastos/linux_file.h
@@ -16,7 +16,7 @@
* This is the Linux implementation of @ref FastOS_File. Most
* methods are inherited from @ref FastOS_UNIX_File.
*/
-class FastOS_Linux_File : public FastOS_UNIX_File
+class FastOS_Linux_File final : public FastOS_UNIX_File
{
public:
using FastOS_UNIX_File::ReadBuf;
@@ -25,7 +25,8 @@ protected:
int64_t _filePointer; // Only maintained/used in directio mode
public:
- FastOS_Linux_File (const char *filename = nullptr);
+ FastOS_Linux_File() : FastOS_Linux_File(nullptr) {}
+ explicit FastOS_Linux_File(const char *filename);
~FastOS_Linux_File () override;
bool GetDirectIORestrictions(size_t &memoryAlignment, size_t &transferGranularity, size_t &transferMaximum) override;
bool DirectIOPadding(int64_t offset, size_t length, size_t &padBefore, size_t &padAfter) override;