diff --git a/include/dwarfs/block_cache.h b/include/dwarfs/block_cache.h index 225512f2..30f8350d 100644 --- a/include/dwarfs/block_cache.h +++ b/include/dwarfs/block_cache.h @@ -28,6 +28,7 @@ #include #include "dwarfs/block_compressor.h" +#include "dwarfs/block_range.h" #include "dwarfs/fstypes.h" namespace dwarfs { @@ -35,7 +36,6 @@ namespace dwarfs { struct block_cache_options; struct cache_tidy_config; -class block_range; class fs_section; class logger; class mmif; diff --git a/include/dwarfs/block_range.h b/include/dwarfs/block_range.h new file mode 100644 index 00000000..9316c694 --- /dev/null +++ b/include/dwarfs/block_range.h @@ -0,0 +1,48 @@ +/* vim:set ts=2 sw=2 sts=2 et: */ +/** + * \author Marcus Holland-Moritz (github@mhxnet.de) + * \copyright Copyright (c) Marcus Holland-Moritz + * + * This file is part of dwarfs. + * + * dwarfs is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * dwarfs is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with dwarfs. If not, see . + */ + +#pragma once + +#include +#include + +namespace dwarfs { + +class cached_block; + +class block_range { + public: + block_range(uint8_t const* data, size_t offset, size_t size); + block_range(std::shared_ptr block, size_t offset, + size_t size); + + uint8_t const* data() const { return begin_; } + uint8_t const* begin() const { return begin_; } + uint8_t const* end() const { return end_; } + size_t size() const { return end_ - begin_; } + + private: + uint8_t const* const begin_; + uint8_t const* const end_; + std::shared_ptr block_; +}; + +} // namespace dwarfs diff --git a/include/dwarfs/filesystem_v2.h b/include/dwarfs/filesystem_v2.h index 17701812..fa8a854c 100644 --- a/include/dwarfs/filesystem_v2.h +++ b/include/dwarfs/filesystem_v2.h @@ -35,6 +35,7 @@ #include #include +#include "dwarfs/block_range.h" #include "dwarfs/fstypes.h" #include "dwarfs/metadata_types.h" #include "dwarfs/types.h" diff --git a/include/dwarfs/fstypes.h b/include/dwarfs/fstypes.h index 6eb7e8c7..d589b6da 100644 --- a/include/dwarfs/fstypes.h +++ b/include/dwarfs/fstypes.h @@ -24,46 +24,13 @@ #include #include #include -#include #include -#include -#include - #include "dwarfs/block_compressor.h" // TODO: or the other way round? #include "dwarfs/checksum.h" namespace dwarfs { -class cached_block; - -// TODO: move elsewhere -class block_range { - public: - block_range(uint8_t const* data, size_t offset, size_t size); - block_range(std::shared_ptr block, size_t offset, - size_t size); - - uint8_t const* data() const { return begin_; } - uint8_t const* begin() const { return begin_; } - uint8_t const* end() const { return end_; } - size_t size() const { return end_ - begin_; } - - private: - uint8_t const* const begin_; - uint8_t const* const end_; - std::shared_ptr block_; -}; - -// TODO: move elsewhere -struct iovec_read_buf { - // This covers more than 95% of reads - static constexpr size_t inline_storage = 16; - - folly::small_vector buf; - folly::small_vector ranges; -}; - constexpr uint8_t MAJOR_VERSION = 2; constexpr uint8_t MINOR_VERSION = 5; diff --git a/include/dwarfs/inode_reader_v2.h b/include/dwarfs/inode_reader_v2.h index 07a77254..5ac3125d 100644 --- a/include/dwarfs/inode_reader_v2.h +++ b/include/dwarfs/inode_reader_v2.h @@ -28,6 +28,7 @@ #include +#include "dwarfs/block_range.h" #include "dwarfs/metadata_types.h" #include "dwarfs/types.h" diff --git a/include/dwarfs/iovec_read_buf.h b/include/dwarfs/iovec_read_buf.h new file mode 100644 index 00000000..c9fee6fb --- /dev/null +++ b/include/dwarfs/iovec_read_buf.h @@ -0,0 +1,39 @@ +/* vim:set ts=2 sw=2 sts=2 et: */ +/** + * \author Marcus Holland-Moritz (github@mhxnet.de) + * \copyright Copyright (c) Marcus Holland-Moritz + * + * This file is part of dwarfs. + * + * dwarfs is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * dwarfs is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with dwarfs. If not, see . + */ + +#pragma once + +#include +#include + +#include "dwarfs/block_range.h" + +namespace dwarfs { + +struct iovec_read_buf { + // This covers more than 95% of reads + static constexpr size_t inline_storage = 16; + + folly::small_vector buf; + folly::small_vector ranges; +}; + +} // namespace dwarfs diff --git a/src/dwarfs/inode_reader_v2.cpp b/src/dwarfs/inode_reader_v2.cpp index ac29a4a0..0d8e86f9 100644 --- a/src/dwarfs/inode_reader_v2.cpp +++ b/src/dwarfs/inode_reader_v2.cpp @@ -36,6 +36,7 @@ #include "dwarfs/block_cache.h" #include "dwarfs/fstypes.h" #include "dwarfs/inode_reader_v2.h" +#include "dwarfs/iovec_read_buf.h" #include "dwarfs/logger.h" #include "dwarfs/offset_cache.h" #include "dwarfs/performance_monitor.h" diff --git a/src/dwarfs_main.cpp b/src/dwarfs_main.cpp index f6a4a5f4..f54695d7 100644 --- a/src/dwarfs_main.cpp +++ b/src/dwarfs_main.cpp @@ -66,6 +66,7 @@ #include "dwarfs/file_stat.h" #include "dwarfs/filesystem_v2.h" #include "dwarfs/fstypes.h" +#include "dwarfs/iovec_read_buf.h" #include "dwarfs/logger.h" #include "dwarfs/metadata_v2.h" #include "dwarfs/mmap.h" diff --git a/test/dwarfs_benchmark.cpp b/test/dwarfs_benchmark.cpp index 824be44d..7aa9464c 100644 --- a/test/dwarfs_benchmark.cpp +++ b/test/dwarfs_benchmark.cpp @@ -31,6 +31,7 @@ #include "dwarfs/file_stat.h" #include "dwarfs/filesystem_v2.h" #include "dwarfs/filesystem_writer.h" +#include "dwarfs/iovec_read_buf.h" #include "dwarfs/logger.h" #include "dwarfs/options.h" #include "dwarfs/progress.h"