diff --git a/src/mongo/platform/bits.h b/src/mongo/platform/bits.h index 860bfbdccedad..f3f443209024b 100644 --- a/src/mongo/platform/bits.h +++ b/src/mongo/platform/bits.h @@ -19,7 +19,7 @@ // figure out if we're on a 64 or 32 bit system -#if defined(__x86_64__) || defined(__amd64__) || defined(_WIN64) || defined(__aarch64__) +#if defined(__x86_64__) || defined(__amd64__) || defined(_WIN64) || defined(__aarch64__) || defined(__powerpc64__) #define MONGO_PLATFORM_64 #elif defined(__i386__) || defined(_WIN32) || defined(__arm__) #define MONGO_PLATFORM_32 diff --git a/src/mongo/util/alignedbuilder.h b/src/mongo/util/alignedbuilder.h index 600ea1c191409..8f8064628ccc3 100644 --- a/src/mongo/util/alignedbuilder.h +++ b/src/mongo/util/alignedbuilder.h @@ -107,7 +107,11 @@ namespace mongo { unsigned len() const { return _len; } private: +#ifndef __PPC64__ static const unsigned Alignment = 8192; +#else + static const unsigned Alignment = 65536; +#endif /** returns the pre-grow write position */ inline char* grow(unsigned by) { diff --git a/src/mongo/util/logfile.cpp b/src/mongo/util/logfile.cpp index affbba0a9dda5..14ee1aa3d1ca1 100644 --- a/src/mongo/util/logfile.cpp +++ b/src/mongo/util/logfile.cpp @@ -38,7 +38,6 @@ #include "mongo/util/startup_test.h" #include "mongo/util/text.h" - using namespace mongoutils; namespace mongo { @@ -160,6 +159,11 @@ namespace mongo { #include #include #include "paths.h" +#include + +#ifdef __linux__ +#include +#endif namespace mongo { @@ -175,6 +179,7 @@ namespace mongo { ; _fd = open(name.c_str(), options, S_IRUSR | S_IWUSR); + _blkSize = g_minOSPageSizeBytes; #if defined(O_DIRECT) _direct = true; @@ -183,6 +188,12 @@ namespace mongo { options &= ~O_DIRECT; _fd = open(name.c_str(), options, S_IRUSR | S_IWUSR); } +#ifdef __linux__ + _blkSize = ioctl(_fd, BLKBSZGET); + if (_blkSize < 0) { + _blkSize = g_minOSPageSizeBytes; + } +#endif #else _direct = false; #endif @@ -238,7 +249,7 @@ namespace mongo { fassert( 16144, charsToWrite >= 0 ); fassert( 16142, _fd >= 0 ); - fassert( 16143, reinterpret_cast( buf ) % g_minOSPageSizeBytes == 0 ); // aligned + fassert( 16143, reinterpret_cast( buf ) % _blkSize == 0 ); // aligned #ifdef POSIX_FADV_DONTNEED const off_t pos = lseek(_fd, 0, SEEK_CUR); // doesn't actually seek, just get current position diff --git a/src/mongo/util/logfile.h b/src/mongo/util/logfile.h index 62b3c2e9c4a4c..ee1fdbf3d5a21 100644 --- a/src/mongo/util/logfile.h +++ b/src/mongo/util/logfile.h @@ -67,6 +67,10 @@ namespace mongo { #endif fd_type _fd; bool _direct; // are we using direct I/O + + // Block size, in case of direct I/O we need to test alignment against the page size, + // which can be different than 4kB. + ssize_t _blkSize; }; }