0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-09-30 04:38:52 +02:00

ircd::db: Simplify buffer alignment callback related; fix log message.

This commit is contained in:
Jason Volk 2018-10-31 14:09:10 -07:00
parent 2c957cc656
commit 34e330d77b
4 changed files with 30 additions and 39 deletions

View file

@ -26,6 +26,7 @@ struct ircd::db::database::env::random_rw_file final
database &d; database &d;
fs::fd::opts opts; fs::fd::opts opts;
fs::fd fd; fs::fd fd;
size_t _buffer_align;
bool use_direct_io() const noexcept override; bool use_direct_io() const noexcept override;
size_t GetRequiredBufferAlignment() const noexcept override; size_t GetRequiredBufferAlignment() const noexcept override;

View file

@ -26,6 +26,7 @@ struct ircd::db::database::env::sequential_file final
database &d; database &d;
fs::fd::opts opts; fs::fd::opts opts;
fs::fd fd; fs::fd fd;
size_t _buffer_align;
off_t offset; off_t offset;
bool use_direct_io() const noexcept override; bool use_direct_io() const noexcept override;

View file

@ -28,6 +28,7 @@ struct ircd::db::database::env::writable_file final
fs::fd::opts opts; fs::fd::opts opts;
fs::fd fd; fs::fd fd;
IOPriority prio {IO_LOW}; IOPriority prio {IO_LOW};
size_t _buffer_align;
size_t preallocation_block_size {0}; size_t preallocation_block_size {0};
size_t preallocation_last_block {0}; size_t preallocation_last_block {0};

View file

@ -4252,14 +4252,19 @@ try
{ {
name, this->opts name, this->opts
} }
,_buffer_align
{
fs::block_size(fd)
}
{ {
#ifdef RB_DEBUG_DB_ENV #ifdef RB_DEBUG_DB_ENV
log::debug log::debug
{ {
log, "'%s': opened wfile:%p fd:%d '%s'", log, "'%s': opened wfile:%p fd:%d bs:%zu '%s'",
d->name, d->name,
this, this,
int(fd), int(fd),
_buffer_align,
name name
}; };
#endif #endif
@ -5003,6 +5008,10 @@ try
{ {
name, this->opts name, this->opts
} }
,_buffer_align
{
fs::block_size(fd)
}
,offset ,offset
{ {
0 0
@ -5011,10 +5020,11 @@ try
#ifdef RB_DEBUG_DB_ENV #ifdef RB_DEBUG_DB_ENV
log::debug log::debug
{ {
log, "'%s': opened seqfile:%p fd:%d '%s'", log, "'%s': opened seqfile:%p fd:%d bs:%zu '%s'",
d->name, d->name,
this, this,
int(fd), int(fd),
_buffer_align,
name name
}; };
#endif #endif
@ -5266,22 +5276,11 @@ size_t
ircd::db::database::env::sequential_file::GetRequiredBufferAlignment() ircd::db::database::env::sequential_file::GetRequiredBufferAlignment()
const noexcept 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; return ret;
} }
@ -5322,10 +5321,11 @@ try
#ifdef RB_DEBUG_DB_ENV #ifdef RB_DEBUG_DB_ENV
log::debug log::debug
{ {
log, "'%s': opened rfile:%p fd:%d '%s'", log, "'%s': opened rfile:%p fd:%d bs:%zu '%s'",
d->name, d->name,
this, this,
int(fd), int(fd),
_buffer_align,
name name
}; };
#endif #endif
@ -5556,18 +5556,12 @@ size_t
ircd::db::database::env::random_access_file::GetRequiredBufferAlignment() ircd::db::database::env::random_access_file::GetRequiredBufferAlignment()
const noexcept const noexcept
{ {
#ifdef RB_DEBUG_DB_ENV const auto &ret
log::debug
{ {
"'%s': rfile:%p fd:%d required alignment (logical block size) %zu",
d.name,
this,
int(fd),
_buffer_align _buffer_align
}; };
#endif
return _buffer_align; return ret;
} }
// //
@ -5603,14 +5597,19 @@ try
{ {
name, this->opts name, this->opts
} }
,_buffer_align
{
fs::block_size(fd)
}
{ {
#ifdef RB_DEBUG_DB_ENV #ifdef RB_DEBUG_DB_ENV
log::debug log::debug
{ {
log, "'%s': opened rwfile:%p fd:%d '%s'", log, "'%s': opened rwfile:%p fd:%d bs:%zu '%s'",
d->name, d->name,
this, this,
int(fd), int(fd),
_buffer_align,
name name
}; };
#endif #endif
@ -5650,7 +5649,7 @@ noexcept try
#ifdef RB_DEBUG_DB_ENV #ifdef RB_DEBUG_DB_ENV
log::debug log::debug
{ {
log, "'%s': opened rwfile:%p fd:%d '%s'", log, "'%s': close rwfile:%p fd:%d '%s'",
d.name, d.name,
this, this,
int(fd) int(fd)
@ -5967,22 +5966,11 @@ size_t
ircd::db::database::env::random_rw_file::GetRequiredBufferAlignment() ircd::db::database::env::random_rw_file::GetRequiredBufferAlignment()
const noexcept 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; return ret;
} }