Make MMapMemoryAllocator map files in read-only (O_RDONLY) mode. Mapping with O_RDWR will cause copy_up across Docker layers.

This commit is contained in:
Vyacheslav Napadovsky 2020-09-07 23:04:43 +03:00
parent 78160c0fe4
commit f545f2293e
2 changed files with 4 additions and 4 deletions

View File

@ -33,7 +33,7 @@ class MMapMemoryAllocator : public ContiguousBlockAllocator
private:
storage::SharedDataIndex index;
std::vector<boost::iostreams::mapped_file> mapped_memory_files;
std::vector<boost::iostreams::mapped_file_source> mapped_memory_files;
std::string rtree_filename;
};

View File

@ -52,11 +52,11 @@ MMapMemoryAllocator::MMapMemoryAllocator(const storage::StorageConfig &config)
{
std::unique_ptr<storage::BaseDataLayout> layout =
std::make_unique<storage::TarDataLayout>();
boost::iostreams::mapped_file mapped_memory_file;
util::mmapFile<char>(file.second, mapped_memory_file);
boost::iostreams::mapped_file_source mapped_memory_file;
auto data = util::mmapFile<char>(file.second, mapped_memory_file).data();
mapped_memory_files.push_back(std::move(mapped_memory_file));
storage::populateLayoutFromFile(file.second, *layout);
allocated_regions.push_back({mapped_memory_file.data(), std::move(layout)});
allocated_regions.push_back({const_cast<char *>(data), std::move(layout)});
}
}