diff options
author | Niall Douglas (s [underscore] sourceforge {at} nedprod [dot] com) <spamtrap@nedprod.com> | 2020-05-29 13:46:20 +0300 |
---|---|---|
committer | Niall Douglas (s [underscore] sourceforge {at} nedprod [dot] com) <spamtrap@nedprod.com> | 2020-05-29 13:46:20 +0300 |
commit | cf61babe2c82168438783b85424dc947d5e9c1c7 (patch) | |
tree | d1ba3c9f4fb667753c11432a63b025f57c1ae540 | |
parent | 4f890711d22755c75d2692c09192b34f69acd768 (diff) |
Fix symbol collision in reduce.ipp, and multiple warnings.
-rw-r--r-- | .clang-format | 2 | ||||
-rw-r--r-- | cmake/headers.cmake | 1 | ||||
-rw-r--r-- | include/llfio/revision.hpp | 6 | ||||
-rw-r--r-- | include/llfio/v2.0/algorithm/reduce.hpp | 7 | ||||
-rw-r--r-- | include/llfio/v2.0/algorithm/summarize.hpp | 17 | ||||
-rw-r--r-- | include/llfio/v2.0/detail/impl/reduce.ipp | 29 | ||||
-rw-r--r-- | include/llfio/v2.0/fs_handle.hpp | 2 | ||||
-rw-r--r-- | include/llfio/v2.0/utils.hpp | 43 |
8 files changed, 84 insertions, 23 deletions
diff --git a/.clang-format b/.clang-format index 6ac52227..effce6f7 100644 --- a/.clang-format +++ b/.clang-format @@ -16,7 +16,7 @@ BreakBeforeBraces: Allman BreakBeforeTernaryOperators: false BreakConstructorInitializersBeforeComma: true BinPackParameters: true -ColumnLimit: 320 +ColumnLimit: 160 CommentPragmas: '^!<' ConstructorInitializerAllOnOneLineOrOnePerLine: false ContinuationIndentWidth: 0 diff --git a/cmake/headers.cmake b/cmake/headers.cmake index 9cdc0e28..9f328626 100644 --- a/cmake/headers.cmake +++ b/cmake/headers.cmake @@ -18,6 +18,7 @@ set(llfio_HEADERS "include/llfio/v2.0/algorithm/shared_fs_mutex/lock_files.hpp" "include/llfio/v2.0/algorithm/shared_fs_mutex/memory_map.hpp" "include/llfio/v2.0/algorithm/shared_fs_mutex/safe_byte_ranges.hpp" + "include/llfio/v2.0/algorithm/summarize.hpp" "include/llfio/v2.0/algorithm/traverse.hpp" "include/llfio/v2.0/algorithm/trivial_vector.hpp" "include/llfio/v2.0/config.hpp" diff --git a/include/llfio/revision.hpp b/include/llfio/revision.hpp index 44f8c313..34e05237 100644 --- a/include/llfio/revision.hpp +++ b/include/llfio/revision.hpp @@ -1,4 +1,4 @@ // Note the second line of this file must ALWAYS be the git SHA, third line ALWAYS the git SHA update time -#define LLFIO_PREVIOUS_COMMIT_REF 50273d3c087bc6f9681d8c3e0568c41ffe9f4459 -#define LLFIO_PREVIOUS_COMMIT_DATE "2020-05-22 10:48:46 +00:00" -#define LLFIO_PREVIOUS_COMMIT_UNIQUE 50273d3c +#define LLFIO_PREVIOUS_COMMIT_REF 4f890711d22755c75d2692c09192b34f69acd768 +#define LLFIO_PREVIOUS_COMMIT_DATE "2020-05-25 21:44:08 +00:00" +#define LLFIO_PREVIOUS_COMMIT_UNIQUE 4f890711 diff --git a/include/llfio/v2.0/algorithm/reduce.hpp b/include/llfio/v2.0/algorithm/reduce.hpp index 7fc5eec6..856733ec 100644 --- a/include/llfio/v2.0/algorithm/reduce.hpp +++ b/include/llfio/v2.0/algorithm/reduce.hpp @@ -33,6 +33,10 @@ LLFIO_V2_NAMESPACE_BEGIN namespace algorithm { +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4275) // dll interface +#endif /*! \brief A visitor for the filesystem traversal and reduction algorithm. Note that at any time, returning a failure causes `reduce()` to exit as soon @@ -105,6 +109,9 @@ namespace algorithm return success(); } }; +#ifdef _MSC_VER +#pragma warning(pop) +#endif /*! \brief Reduce the directory identified `dirh`, and everything therein, to the null set. diff --git a/include/llfio/v2.0/algorithm/summarize.hpp b/include/llfio/v2.0/algorithm/summarize.hpp index e8cd5150..2894974c 100644 --- a/include/llfio/v2.0/algorithm/summarize.hpp +++ b/include/llfio/v2.0/algorithm/summarize.hpp @@ -52,7 +52,8 @@ namespace algorithm map_type<filesystem::file_type> types; //!< The number of items with the given type handle::extent_type size{0}; //!< The sum of maximum extents. On Windows, is for file content only. handle::extent_type allocated{0}; //!< The sum of allocated extents. On Windows, is for file content only. - handle::extent_type blocks{0}; //!< The sum of file and directory allocated blocks. + handle::extent_type file_blocks{0}; //!< The sum of file allocated blocks. + handle::extent_type directory_blocks{0}; //!< The sum of directory allocated blocks. size_t max_depth{0}; //!< The maximum depth of the hierarchy //! Adds another summary to this @@ -70,7 +71,8 @@ namespace algorithm } size += o.size; allocated += o.allocated; - blocks += o.blocks; + file_blocks += o.file_blocks; + directory_blocks += o.directory_blocks; max_depth = std::max(max_depth, o.max_depth); return *this; } @@ -85,7 +87,7 @@ namespace algorithm that `summarize()` is entirely implemented using `traverse()`, so not calling the implementations here will affect operation. */ - struct LLFIO_DECL summarize_visitor : public traverse_visitor + struct summarize_visitor : public traverse_visitor { static result<void> accumulate(traversal_summary &acc, traversal_summary *state, const directory_handle *dirh, directory_entry &entry, stat_t::want already_have_metadata) { @@ -121,7 +123,14 @@ namespace algorithm } if(state->want & stat_t::want::blocks) { - acc.blocks += entry.stat.st_blocks; + if(entry.stat.st_type == filesystem::file_type::directory) + { + acc.directory_blocks += entry.stat.st_blocks; + } + else + { + acc.file_blocks += entry.stat.st_blocks; + } } return success(); } diff --git a/include/llfio/v2.0/detail/impl/reduce.ipp b/include/llfio/v2.0/detail/impl/reduce.ipp index dd304e5e..49a270d8 100644 --- a/include/llfio/v2.0/detail/impl/reduce.ipp +++ b/include/llfio/v2.0/detail/impl/reduce.ipp @@ -60,8 +60,10 @@ namespace algorithm */ const DWORD access = SYNCHRONIZE | DELETE; const DWORD fileshare = FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE; - const DWORD deletefile_ntflags = 0x20 /*FILE_SYNCHRONOUS_IO_NONALERT*/ | 0x00200000 /*FILE_OPEN_REPARSE_POINT*/ | 0x00001000 /*FILE_DELETE_ON_CLOSE*/ | 0x040 /*FILE_NON_DIRECTORY_FILE*/; - const DWORD deletedir_ntflags = 0x20 /*FILE_SYNCHRONOUS_IO_NONALERT*/ | 0x00200000 /*FILE_OPEN_REPARSE_POINT*/ | 0x00001000 /*FILE_DELETE_ON_CLOSE*/ | 0x01 /*FILE_DIRECTORY_FILE*/; + const DWORD deletefile_ntflags = + 0x20 /*FILE_SYNCHRONOUS_IO_NONALERT*/ | 0x00200000 /*FILE_OPEN_REPARSE_POINT*/ | 0x00001000 /*FILE_DELETE_ON_CLOSE*/ | 0x040 /*FILE_NON_DIRECTORY_FILE*/; + const DWORD deletedir_ntflags = + 0x20 /*FILE_SYNCHRONOUS_IO_NONALERT*/ | 0x00200000 /*FILE_OPEN_REPARSE_POINT*/ | 0x00001000 /*FILE_DELETE_ON_CLOSE*/ | 0x01 /*FILE_DIRECTORY_FILE*/; const DWORD renamefile_ntflags = 0x20 /*FILE_SYNCHRONOUS_IO_NONALERT*/ | 0x00200000 /*FILE_OPEN_REPARSE_POINT*/ | 0x040 /*FILE_NON_DIRECTORY_FILE*/; const DWORD renamedir_ntflags = 0x20 /*FILE_SYNCHRONOUS_IO_NONALERT*/ | 0x00200000 /*FILE_OPEN_REPARSE_POINT*/ | 0x01 /*FILE_DIRECTORY_FILE*/; IO_STATUS_BLOCK isb = make_iostatus(); @@ -160,8 +162,10 @@ namespace algorithm using namespace windows_nt_kernel; const DWORD access = SYNCHRONIZE | DELETE; const DWORD fileshare = FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE; - const DWORD deletefile_ntflags = 0x20 /*FILE_SYNCHRONOUS_IO_NONALERT*/ | 0x00200000 /*FILE_OPEN_REPARSE_POINT*/ | 0x00001000 /*FILE_DELETE_ON_CLOSE*/ | 0x040 /*FILE_NON_DIRECTORY_FILE*/; - const DWORD deletedir_ntflags = 0x20 /*FILE_SYNCHRONOUS_IO_NONALERT*/ | 0x00200000 /*FILE_OPEN_REPARSE_POINT*/ | 0x00001000 /*FILE_DELETE_ON_CLOSE*/ | 0x01 /*FILE_DIRECTORY_FILE*/; + const DWORD deletefile_ntflags = + 0x20 /*FILE_SYNCHRONOUS_IO_NONALERT*/ | 0x00200000 /*FILE_OPEN_REPARSE_POINT*/ | 0x00001000 /*FILE_DELETE_ON_CLOSE*/ | 0x040 /*FILE_NON_DIRECTORY_FILE*/; + const DWORD deletedir_ntflags = + 0x20 /*FILE_SYNCHRONOUS_IO_NONALERT*/ | 0x00200000 /*FILE_OPEN_REPARSE_POINT*/ | 0x00001000 /*FILE_DELETE_ON_CLOSE*/ | 0x01 /*FILE_DIRECTORY_FILE*/; const DWORD renamefile_ntflags = 0x20 /*FILE_SYNCHRONOUS_IO_NONALERT*/ | 0x00200000 /*FILE_OPEN_REPARSE_POINT*/ | 0x040 /*FILE_NON_DIRECTORY_FILE*/; const DWORD renamedir_ntflags = 0x20 /*FILE_SYNCHRONOUS_IO_NONALERT*/ | 0x00200000 /*FILE_OPEN_REPARSE_POINT*/ | 0x01 /*FILE_DIRECTORY_FILE*/; IO_STATUS_BLOCK isb = make_iostatus(); @@ -254,7 +258,8 @@ namespace algorithm }; } // namespace detail - result<directory_handle> reduce_visitor::directory_open_failed(void *data, result<void>::error_type &&error, const directory_handle &dirh, path_view leaf, size_t depth) noexcept + LLFIO_HEADERS_ONLY_MEMFUNC_SPEC result<directory_handle> + reduce_visitor::directory_open_failed(void *data, result<void>::error_type &&error, const directory_handle &dirh, path_view leaf, size_t depth) noexcept { (void) error; (void) depth; @@ -268,7 +273,8 @@ namespace algorithm return success(); // ignore failure to enter } - result<void> reduce_visitor::post_enumeration(void *data, const directory_handle &dirh, directory_handle::buffers_type &contents, size_t depth) noexcept + LLFIO_HEADERS_ONLY_MEMFUNC_SPEC result<void> reduce_visitor::post_enumeration(void *data, const directory_handle &dirh, + directory_handle::buffers_type &contents, size_t depth) noexcept { auto *state = (detail::reduction_state *) data; bool removed_everything = true; @@ -324,7 +330,8 @@ namespace algorithm return success(); } - result<bool> reduce_visitor::unlink_failed(void *data, result<void>::error_type &&error, const directory_handle &dirh, directory_entry &entry, size_t depth) noexcept + LLFIO_HEADERS_ONLY_MEMFUNC_SPEC result<bool> reduce_visitor::unlink_failed(void *data, result<void>::error_type &&error, const directory_handle &dirh, + directory_entry &entry, size_t depth) noexcept { (void) error; auto *state = (detail::reduction_state *) data; @@ -341,7 +348,7 @@ namespace algorithm return false; } - result<size_t> reduce(directory_handle &&topdirh, reduce_visitor *visitor, size_t threads, bool force_slow_path) noexcept + LLFIO_HEADERS_ONLY_MEMFUNC_SPEC result<size_t> reduce(directory_handle &&topdirh, reduce_visitor *visitor, size_t threads, bool force_slow_path) noexcept { LLFIO_LOG_FUNCTION_CALL(&topdirh); reduce_visitor default_visitor; @@ -368,7 +375,8 @@ namespace algorithm size_t round = 0; detail::reduction_state state(topdirh, visitor); OUTCOME_TRY(traverse(topdirh, visitor, threads, &state, force_slow_path)); - auto not_removed = state.directory_open_failed.load(std::memory_order_relaxed) + state.failed_to_remove.load(std::memory_order_relaxed) + state.failed_to_rename.load(std::memory_order_relaxed); + auto not_removed = state.directory_open_failed.load(std::memory_order_relaxed) + state.failed_to_remove.load(std::memory_order_relaxed) + + state.failed_to_rename.load(std::memory_order_relaxed); OUTCOME_TRY(visitor->reduction_round(&state, round++, state.items_removed.load(std::memory_order_relaxed), not_removed)); while(not_removed > 0) { @@ -376,7 +384,8 @@ namespace algorithm state.failed_to_remove.store(0, std::memory_order_relaxed); state.failed_to_rename.store(0, std::memory_order_relaxed); OUTCOME_TRY(traverse(topdirh, visitor, (round > 16) ? 1 : threads, &state, force_slow_path)); - not_removed = state.directory_open_failed.load(std::memory_order_relaxed) + state.failed_to_remove.load(std::memory_order_relaxed) + state.failed_to_rename.load(std::memory_order_relaxed); + not_removed = state.directory_open_failed.load(std::memory_order_relaxed) + state.failed_to_remove.load(std::memory_order_relaxed) + + state.failed_to_rename.load(std::memory_order_relaxed); OUTCOME_TRY(visitor->reduction_round(&state, round++, state.items_removed.load(std::memory_order_relaxed), not_removed)); } OUTCOME_TRY(topdirh.unlink()); diff --git a/include/llfio/v2.0/fs_handle.hpp b/include/llfio/v2.0/fs_handle.hpp index 7caec3c9..2b19a3b0 100644 --- a/include/llfio/v2.0/fs_handle.hpp +++ b/include/llfio/v2.0/fs_handle.hpp @@ -1,5 +1,5 @@ /* A filing system handle -(C) 2017 Niall Douglas <http://www.nedproductions.biz/> (20 commits) +(C) 2017-2020 Niall Douglas <http://www.nedproductions.biz/> (20 commits) File Created: Aug 2017 diff --git a/include/llfio/v2.0/utils.hpp b/include/llfio/v2.0/utils.hpp index c7a029e5..c50514f7 100644 --- a/include/llfio/v2.0/utils.hpp +++ b/include/llfio/v2.0/utils.hpp @@ -65,10 +65,45 @@ namespace utils /*! \brief Round a pair of a pointer and a size_t to their nearest page size multiples. The pointer will be rounded down, the size_t upwards. */ - template <class T> inline T round_to_page_size(T i, size_t pagesize) noexcept + LLFIO_TEMPLATE(class T) + LLFIO_TREQUIRES(LLFIO_TEXPR(std::declval<T>().data()), LLFIO_TEXPR(std::declval<T>().size())) + inline T round_to_page_size_larger(T i, size_t pagesize) noexcept { assert(pagesize > 0); - i = {reinterpret_cast<byte *>((LLFIO_V2_NAMESPACE::detail::unsigned_integer_cast<uintptr_t>(i.data())) & ~(pagesize - 1)), (i.size() + pagesize - 1) & ~(pagesize - 1)}; + const auto base = LLFIO_V2_NAMESPACE::detail::unsigned_integer_cast<uintptr_t>(i.data()); + i = {reinterpret_cast<byte *>(base & ~(pagesize - 1)), ((base + i.size() + pagesize - 1) & ~(pagesize - 1)) - (base & ~(pagesize - 1))}; + return i; + } + /*! \brief Round a pair of a pointer and a size_t to their nearest page size multiples. The pointer will be rounded + upwards, the size_t downwards. + */ + LLFIO_TEMPLATE(class T) + LLFIO_TREQUIRES(LLFIO_TEXPR(std::declval<T>().data()), LLFIO_TEXPR(std::declval<T>().size())) + inline T round_to_page_size_smaller(T i, size_t pagesize) noexcept + { + assert(pagesize > 0); + const auto base = LLFIO_V2_NAMESPACE::detail::unsigned_integer_cast<uintptr_t>(i.data()); + i = {reinterpret_cast<byte *>((base + pagesize - 1) & ~(pagesize - 1)), ((base + i.size()) & ~(pagesize - 1)) - ((base + pagesize - 1) & ~(pagesize - 1))}; + return i; + } + /*! \brief Round a pair of values to their nearest page size multiples. The first will be rounded + down, the second upwards. + */ + template <class A, class B> inline std::pair<A, B> round_to_page_size_larger(std::pair<A, B> i, size_t pagesize) noexcept + { + assert(pagesize > 0); + const auto base = LLFIO_V2_NAMESPACE::detail::unsigned_integer_cast<uintptr_t>(i.first); + i = {static_cast<A>(base & ~(pagesize - 1)), static_cast<B>(((base + i.second + pagesize - 1) & ~(pagesize - 1)) - (base & ~(pagesize - 1)))}; + return i; + } + /*! \brief Round a pair of values to their nearest page size multiples. The first will be rounded + upwards, the second downwards. + */ + template <class A, class B> inline std::pair<A, B> round_to_page_size_smaller(std::pair<A, B> i, size_t pagesize) noexcept + { + assert(pagesize > 0); + const auto base = LLFIO_V2_NAMESPACE::detail::unsigned_integer_cast<uintptr_t>(i.first); + i = {static_cast<A>((base + pagesize - 1) & ~(pagesize - 1)), static_cast<B>(((base + i.second) & ~(pagesize - 1)) - ((base + pagesize - 1) & ~(pagesize - 1)))}; return i; } @@ -160,7 +195,7 @@ namespace utils #endif /*! \brief Memory usage statistics for a process. - */ + */ struct process_memory_usage { //! The total virtual address space in use. @@ -174,7 +209,7 @@ namespace utils size_t private_paged_in{0}; }; /*! \brief Retrieve the current memory usage statistics for this process. - + \note Mac OS provides no way of reading how much memory a process has committed. We therefore supply as `private_committed` the same value as `private_paged_in`. */ LLFIO_HEADERS_ONLY_FUNC_SPEC result<process_memory_usage> current_process_memory_usage() noexcept; |