From c8e988c34e749c5f3acf78c051a7466ec3a48816 Mon Sep 17 00:00:00 2001 From: Marcus Holland-Moritz Date: Thu, 3 Dec 2020 18:35:48 +0100 Subject: [PATCH] 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. --- src/dwarfs/filesystem_v2.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/dwarfs/filesystem_v2.cpp b/src/dwarfs/filesystem_v2.cpp index 827f3428..1f884157 100644 --- a/src/dwarfs/filesystem_v2.cpp +++ b/src/dwarfs/filesystem_v2.cpp @@ -159,11 +159,13 @@ make_metadata(logger& lgr, std::shared_ptr mm, throw std::runtime_error("no metadata found"); } - auto meta_section = - get_section_data(mm, meta_it->second, meta_buffer, force_buffers); + auto& meta_section = meta_it->second; + + auto meta_section_range = + get_section_data(mm, meta_section, meta_buffer, force_buffers); 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) { throw boost::system::system_error(ec, "mlock"); } else { @@ -172,10 +174,17 @@ make_metadata(logger& lgr, std::shared_ptr 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( lgr, 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