diff --git a/include/ircd/db/database/env/random_rw_file.h b/include/ircd/db/database/env/random_rw_file.h index 6f55f9c16..a8086e675 100644 --- a/include/ircd/db/database/env/random_rw_file.h +++ b/include/ircd/db/database/env/random_rw_file.h @@ -26,6 +26,7 @@ struct ircd::db::database::env::random_rw_file final database &d; fs::fd::opts opts; fs::fd fd; + size_t _buffer_align; bool use_direct_io() const noexcept override; size_t GetRequiredBufferAlignment() const noexcept override; diff --git a/include/ircd/db/database/env/sequential_file.h b/include/ircd/db/database/env/sequential_file.h index 3c67727ac..b237aa719 100644 --- a/include/ircd/db/database/env/sequential_file.h +++ b/include/ircd/db/database/env/sequential_file.h @@ -26,6 +26,7 @@ struct ircd::db::database::env::sequential_file final database &d; fs::fd::opts opts; fs::fd fd; + size_t _buffer_align; off_t offset; bool use_direct_io() const noexcept override; diff --git a/include/ircd/db/database/env/writable_file.h b/include/ircd/db/database/env/writable_file.h index 8df9571f6..d664b8675 100644 --- a/include/ircd/db/database/env/writable_file.h +++ b/include/ircd/db/database/env/writable_file.h @@ -28,6 +28,7 @@ struct ircd::db::database::env::writable_file final fs::fd::opts opts; fs::fd fd; IOPriority prio {IO_LOW}; + size_t _buffer_align; size_t preallocation_block_size {0}; size_t preallocation_last_block {0}; diff --git a/ircd/db.cc b/ircd/db.cc index 09a5bf819..c35738552 100644 --- a/ircd/db.cc +++ b/ircd/db.cc @@ -4252,14 +4252,19 @@ try { name, this->opts } +,_buffer_align +{ + fs::block_size(fd) +} { #ifdef RB_DEBUG_DB_ENV log::debug { - log, "'%s': opened wfile:%p fd:%d '%s'", + log, "'%s': opened wfile:%p fd:%d bs:%zu '%s'", d->name, this, int(fd), + _buffer_align, name }; #endif @@ -5003,6 +5008,10 @@ try { name, this->opts } +,_buffer_align +{ + fs::block_size(fd) +} ,offset { 0 @@ -5011,10 +5020,11 @@ try #ifdef RB_DEBUG_DB_ENV log::debug { - log, "'%s': opened seqfile:%p fd:%d '%s'", + log, "'%s': opened seqfile:%p fd:%d bs:%zu '%s'", d->name, this, int(fd), + _buffer_align, name }; #endif @@ -5266,22 +5276,11 @@ size_t ircd::db::database::env::sequential_file::GetRequiredBufferAlignment() const noexcept { - const auto ret + const auto &ret { - fs::block_size(fd) + _buffer_align }; - #ifdef RB_DEBUG_DB_ENV - log::debug - { - "'%s': seqfile:%p fd:%d required alignment (logical block size) %zu", - d.name, - this, - int(fd), - ret - }; - #endif - return ret; } @@ -5322,10 +5321,11 @@ try #ifdef RB_DEBUG_DB_ENV log::debug { - log, "'%s': opened rfile:%p fd:%d '%s'", + log, "'%s': opened rfile:%p fd:%d bs:%zu '%s'", d->name, this, int(fd), + _buffer_align, name }; #endif @@ -5556,18 +5556,12 @@ size_t ircd::db::database::env::random_access_file::GetRequiredBufferAlignment() const noexcept { - #ifdef RB_DEBUG_DB_ENV - log::debug + const auto &ret { - "'%s': rfile:%p fd:%d required alignment (logical block size) %zu", - d.name, - this, - int(fd), _buffer_align }; - #endif - return _buffer_align; + return ret; } // @@ -5603,14 +5597,19 @@ try { name, this->opts } +,_buffer_align +{ + fs::block_size(fd) +} { #ifdef RB_DEBUG_DB_ENV log::debug { - log, "'%s': opened rwfile:%p fd:%d '%s'", + log, "'%s': opened rwfile:%p fd:%d bs:%zu '%s'", d->name, this, int(fd), + _buffer_align, name }; #endif @@ -5650,7 +5649,7 @@ noexcept try #ifdef RB_DEBUG_DB_ENV log::debug { - log, "'%s': opened rwfile:%p fd:%d '%s'", + log, "'%s': close rwfile:%p fd:%d '%s'", d.name, this, int(fd) @@ -5967,22 +5966,11 @@ size_t ircd::db::database::env::random_rw_file::GetRequiredBufferAlignment() const noexcept { - const auto ret + const auto &ret { - fs::block_size(fd) + _buffer_align }; - #ifdef RB_DEBUG_DB_ENV - log::debug - { - "'%s': rwfile:%p fd:%d required alignment (logical block size) %zu", - d.name, - this, - int(fd), - ret - }; - #endif - return ret; }