Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/mongo/platform/bits.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions src/mongo/util/alignedbuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
15 changes: 13 additions & 2 deletions src/mongo/util/logfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
#include "mongo/util/startup_test.h"
#include "mongo/util/text.h"


using namespace mongoutils;

namespace mongo {
Expand Down Expand Up @@ -160,6 +159,11 @@ namespace mongo {
#include <sys/stat.h>
#include <fcntl.h>
#include "paths.h"
#include <sys/ioctl.h>

#ifdef __linux__
#include <linux/fs.h>
#endif

namespace mongo {

Expand All @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -238,7 +249,7 @@ namespace mongo {

fassert( 16144, charsToWrite >= 0 );
fassert( 16142, _fd >= 0 );
fassert( 16143, reinterpret_cast<ssize_t>( buf ) % g_minOSPageSizeBytes == 0 ); // aligned
fassert( 16143, reinterpret_cast<ssize_t>( 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
Expand Down
4 changes: 4 additions & 0 deletions src/mongo/util/logfile.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

}