Evict compressed metadata from cache

This is usually what you want. If you're looking to *rapidly*
unmount, then mount the filesystem again, compressed metadata
isn't for you anyway.
This commit is contained in:
Marcus Holland-Moritz 2020-12-03 18:35:48 +01:00
parent 70c2a97fdd
commit c8e988c34e

View File

@ -159,11 +159,13 @@ make_metadata(logger& lgr, std::shared_ptr<mmif> mm,
throw std::runtime_error("no metadata found"); throw std::runtime_error("no metadata found");
} }
auto meta_section = auto& meta_section = meta_it->second;
get_section_data(mm, meta_it->second, meta_buffer, force_buffers);
auto meta_section_range =
get_section_data(mm, meta_section, meta_buffer, force_buffers);
if (lock_mode != mlock_mode::NONE) { if (lock_mode != mlock_mode::NONE) {
if (auto ec = mm->lock(meta_it->second.start, meta_section.size())) { if (auto ec = mm->lock(meta_section.start, meta_section_range.size())) {
if (lock_mode == mlock_mode::MUST) { if (lock_mode == mlock_mode::MUST) {
throw boost::system::system_error(ec, "mlock"); throw boost::system::system_error(ec, "mlock");
} else { } else {
@ -172,10 +174,17 @@ make_metadata(logger& lgr, std::shared_ptr<mmif> mm,
} }
} }
// don't keep the compressed metadata in cache
if (meta_section.header.compression != compression_type::NONE) {
if (auto ec = mm->release(meta_section.start, meta_section.header.length)) {
log.info() << "madvise() failed: " << ec.message();
}
}
return metadata_v2( return metadata_v2(
lgr, lgr,
get_section_data(mm, schema_it->second, schema_buffer, force_buffers), get_section_data(mm, schema_it->second, schema_buffer, force_buffers),
meta_section, options, stat_defaults, inode_offset); meta_section_range, options, stat_defaults, inode_offset);
} }
template <typename LoggerPolicy> template <typename LoggerPolicy>