From e0266acc24c0a33ba9337173d2c6483fb55cfde2 Mon Sep 17 00:00:00 2001 From: Thomas W Rodgers Date: Tue, 26 Apr 2022 20:53:21 -0700 Subject: [PATCH 1/4] Add BuildRequires: libzstd-devel to fix (#2042336) --- boost.spec | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/boost.spec b/boost.spec index 243da2f..2ec6a72 100644 --- a/boost.spec +++ b/boost.spec @@ -42,7 +42,7 @@ Name: boost %global real_name boost Summary: The free peer-reviewed portable C++ source libraries Version: 1.76.0 -Release: 10%{?dist} +Release: 11%{?dist} License: Boost and MIT and Python # Replace each . with _ in %%{version} @@ -123,6 +123,7 @@ BuildRequires: libicu-devel BuildRequires: libquadmath-devel %endif BuildRequires: bison +BuildRequires: libzstd-devel # https://bugzilla.redhat.com/show_bug.cgi?id=828856 # https://bugzilla.redhat.com/show_bug.cgi?id=828857 @@ -1301,6 +1302,9 @@ fi %{_mandir}/man1/b2.1* %changelog +* Tue Apr 26 2022 Thomas Rodgers - 1.76.0-11 +- Add BuildRequires: libzstd-devel to fix (#2042336) + * Thu Mar 31 2022 Jonathan Wakely - 1.76.0-10 - Add patch to fix XML validation errors in ptr_container docs From 2775e939cb78103851fcad07fcb42f84eb48d87d Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Thu, 14 Jul 2022 11:50:14 +0100 Subject: [PATCH 2/4] Add patch to fix Asio includes Resolves: #2106441 --- boost-1.76.0-asio-header.patch | 34 ++++++++++++++++++++++++++++++++++ boost.spec | 9 ++++++++- 2 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 boost-1.76.0-asio-header.patch diff --git a/boost-1.76.0-asio-header.patch b/boost-1.76.0-asio-header.patch new file mode 100644 index 0000000..95ce2bc --- /dev/null +++ b/boost-1.76.0-asio-header.patch @@ -0,0 +1,34 @@ +From 71964b22c7fade69cc4caa1c869a868e3a32cc97 Mon Sep 17 00:00:00 2001 +From: Christopher Kohlhoff +Date: Wed, 2 Mar 2022 21:41:04 +1100 +Subject: [PATCH] Header is needed for std::exchange. + +--- + include/boost/asio/awaitable.hpp | 1 + + include/boost/asio/impl/awaitable.hpp | 1 - + 2 files changed, 1 insertion(+), 1 deletion(-) + +diff --git a/include/boost/asio/awaitable.hpp b/include/boost/asio/awaitable.hpp +index a9cc90d43..750198995 100644 +--- a/include/boost/asio/awaitable.hpp ++++ b/include/boost/asio/awaitable.hpp +@@ -25,6 +25,7 @@ + # include + #endif // defined(BOOST_ASIO_HAS_STD_COROUTINE) + ++#include + #include + + #include +diff --git a/include/boost/asio/impl/awaitable.hpp b/include/boost/asio/impl/awaitable.hpp +index 49a47e29a..c66fa74c6 100644 +--- a/include/boost/asio/impl/awaitable.hpp ++++ b/include/boost/asio/impl/awaitable.hpp +@@ -19,7 +19,6 @@ + #include + #include + #include +-#include + #include + #include + #include diff --git a/boost.spec b/boost.spec index 2ec6a72..e6140c5 100644 --- a/boost.spec +++ b/boost.spec @@ -42,7 +42,7 @@ Name: boost %global real_name boost Summary: The free peer-reviewed portable C++ source libraries Version: 1.76.0 -Release: 11%{?dist} +Release: 12%{?dist} License: Boost and MIT and Python # Replace each . with _ in %%{version} @@ -174,6 +174,9 @@ Patch104: boost-1.76.0-fix-narrowing-conversions-for-ppc.patch # https://github.com/boostorg/ptr_container/pull/27 Patch105: boost-1.76.0-ptr_cont-xml.patch +# https://bugzilla.redhat.com/show_bug.cgi?id=2106441 +Patch106: boost-1.76.0-asio-header.patch + %bcond_with tests %bcond_with docs_generated @@ -701,6 +704,7 @@ find ./boost -name '*.hpp' -perm /111 | xargs chmod a-x %patch103 -p2 %patch104 -p2 %patch105 -p1 +%patch106 -p2 %build %set_build_flags @@ -1302,6 +1306,9 @@ fi %{_mandir}/man1/b2.1* %changelog +* Thu Jul 14 2022 Jonathan Wakely - 1.76.0-12 +- Add patch to fix Asio includes (#2106441) + * Tue Apr 26 2022 Thomas Rodgers - 1.76.0-11 - Add BuildRequires: libzstd-devel to fix (#2042336) From 641b90a54799cf569885875ce0a200917bf87eb5 Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Thu, 14 Jul 2022 12:52:42 +0100 Subject: [PATCH 3/4] Add patch to fix filesystem::copy_file EXDEV handling Resolves: #2106878 --- boost-1.76.0-filesystem-copy_file-exdev.patch | 152 ++++++++++++++++++ boost.spec | 6 + 2 files changed, 158 insertions(+) create mode 100644 boost-1.76.0-filesystem-copy_file-exdev.patch diff --git a/boost-1.76.0-filesystem-copy_file-exdev.patch b/boost-1.76.0-filesystem-copy_file-exdev.patch new file mode 100644 index 0000000..9d1b630 --- /dev/null +++ b/boost-1.76.0-filesystem-copy_file-exdev.patch @@ -0,0 +1,152 @@ +From 4b9052f1e0b2acf625e8247582f44acdcc78a4ce Mon Sep 17 00:00:00 2001 +From: Andrey Semashev +Date: Tue, 18 May 2021 22:53:40 +0300 +Subject: [PATCH] Fallback to read/write loop if sendfile/copy_file_range fail. + +Since sendfile and copy_file_range can fail for some filesystems +(e.g. eCryptFS), we have to fallback to the read/write loop in copy_file +implementation. Additionally, since we implement the fallback now, +fallback to sendfile if copy_file_range fails with EXDEV and use +copy_file_range on older kernels that don't implement it for +cross-filesystem copying. This may be beneficial if copy_file_range +is used within a filesystem, and is performed on a remote server NFS or CIFS). + +Also, it was discovered that copy_file_range can also fail with EOPNOTSUPP +when it is performed on an NFSv4 filesystem and the remote server does +not support COPY operation. This happens on some patched kernels in RHEL/CentOS. + +Lastly, to make sure the copy_file_data pointer is accessed atomically, +it is now declared as an atomic value. If std::atomic is unavailable, +Boost.Atomic is used. + +Fixes https://github.com/boostorg/filesystem/issues/184. +--- + +diff --git a/src/operations.cpp b/src/operations.cpp +index abc7e4f6e..8f1130f00 100644 +--- a/libs/filesystem/src/operations.cpp ++++ b/libs/filesystem/src/operations.cpp +@@ -135,6 +135,8 @@ using std::time_t; + # endif // BOOST_WINDOWS_API + + #include "error_handling.hpp" ++#include ++namespace atomic_ns = std; + + namespace fs = boost::filesystem; + using boost::filesystem::path; +@@ -521,6 +522,9 @@ int copy_file_data_read_write(int infile, int outfile, uintmax_t size) + if (BOOST_UNLIKELY(!buf.get())) + return ENOMEM; + ++ // Don't use file size to limit the amount of data to copy since some filesystems, like procfs or sysfs, ++ // provide files with generated content and indicate that their size is zero or 4096. Just copy as much data ++ // as we can read from the input file. + while (true) + { + ssize_t sz_read = ::read(infile, buf.get(), buf_sz); +@@ -555,7 +559,7 @@ int copy_file_data_read_write(int infile, int outfile, uintmax_t size) + } + + //! Pointer to the actual implementation of the copy_file_data implementation +-copy_file_data_t* copy_file_data = ©_file_data_read_write; ++atomic_ns::atomic< copy_file_data_t* > copy_file_data(©_file_data_read_write); + + #if defined(BOOST_FILESYSTEM_USE_SENDFILE) + +@@ -577,6 +581,23 @@ int copy_file_data_sendfile(int infile, int outfile, uintmax_t size) + int err = errno; + if (err == EINTR) + continue; ++ ++ if (offset == 0u) ++ { ++ // sendfile may fail with EINVAL if the underlying filesystem does not support it ++ if (err == EINVAL) ++ { ++ fallback_to_read_write: ++ return copy_file_data_read_write(infile, outfile, size); ++ } ++ ++ if (err == ENOSYS) ++ { ++ copy_file_data.store(©_file_data_read_write, atomic_ns::memory_order_relaxed); ++ goto fallback_to_read_write; ++ } ++ } ++ + return err; + } + +@@ -611,6 +632,44 @@ int copy_file_data_copy_file_range(int infile, int outfile, uintmax_t size) + int err = errno; + if (err == EINTR) + continue; ++ ++ if (offset == 0u) ++ { ++ // copy_file_range may fail with EINVAL if the underlying filesystem does not support it. ++ // In some RHEL/CentOS 7.7-7.8 kernel versions, copy_file_range on NFSv4 is also known to return EOPNOTSUPP ++ // if the remote server does not support COPY, despite that it is not a documented error code. ++ // See https://patchwork.kernel.org/project/linux-nfs/patch/20190411183418.4510-1-olga.kornievskaia@gmail.com/ ++ // and https://bugzilla.redhat.com/show_bug.cgi?id=1783554. ++ if (err == EINVAL || err == EOPNOTSUPP) ++ { ++#if !defined(BOOST_FILESYSTEM_USE_SENDFILE) ++ fallback_to_read_write: ++#endif ++ return copy_file_data_read_write(infile, outfile, size); ++ } ++ ++ if (err == EXDEV) ++ { ++#if defined(BOOST_FILESYSTEM_USE_SENDFILE) ++ fallback_to_sendfile: ++ return copy_file_data_sendfile(infile, outfile, size); ++#else ++ goto fallback_to_read_write; ++#endif ++ } ++ ++ if (err == ENOSYS) ++ { ++#if defined(BOOST_FILESYSTEM_USE_SENDFILE) ++ copy_file_data.store(©_file_data_sendfile, atomic_ns::memory_order_relaxed); ++ goto fallback_to_sendfile; ++#else ++ copy_file_data.store(©_file_data_read_write, atomic_ns::memory_order_relaxed); ++ goto fallback_to_read_write; ++#endif ++ } ++ } ++ + return err; + } + +@@ -646,13 +705,14 @@ struct copy_file_data_initializer + #endif + + #if defined(BOOST_FILESYSTEM_USE_COPY_FILE_RANGE) +- // Although copy_file_range appeared in Linux 4.5, it did not support cross-filesystem copying until 5.3 +- if (major > 5u || (major == 5u && minor >= 3u)) ++ // Although copy_file_range appeared in Linux 4.5, it did not support cross-filesystem copying until 5.3. ++ // copy_file_data_copy_file_range will fallback to copy_file_data_sendfile if copy_file_range returns EXDEV. ++ if (major > 4u || (major == 4u && minor >= 5u)) + cfd = ©_file_data_copy_file_range; + #endif + +- copy_file_data = cfd; ++ copy_file_data.store(cfd, atomic_ns::memory_order_relaxed); + } + } + const copy_file_data_init; + +@@ -1412,7 +1472,7 @@ bool copy_file(path const& from, path const& to, unsigned int options, error_cod + goto fail_errno; + } + +- err = detail::copy_file_data(infile.fd, outfile.fd, get_size(from_stat)); ++ err = detail::copy_file_data.load(atomic_ns::memory_order_relaxed)(infile.fd, outfile.fd, get_size(from_stat)); + if (BOOST_UNLIKELY(err != 0)) + goto fail; // err already contains the error code + diff --git a/boost.spec b/boost.spec index e6140c5..8ced878 100644 --- a/boost.spec +++ b/boost.spec @@ -177,6 +177,10 @@ Patch105: boost-1.76.0-ptr_cont-xml.patch # https://bugzilla.redhat.com/show_bug.cgi?id=2106441 Patch106: boost-1.76.0-asio-header.patch +# https://bugzilla.redhat.com/show_bug.cgi?id=2106878 +# https://github.com/boostorg/filesystem/issues/184 +Patch107: boost-1.76.0-filesystem-copy_file-exdev.patch + %bcond_with tests %bcond_with docs_generated @@ -705,6 +709,7 @@ find ./boost -name '*.hpp' -perm /111 | xargs chmod a-x %patch104 -p2 %patch105 -p1 %patch106 -p2 +%patch107 -p1 %build %set_build_flags @@ -1308,6 +1313,7 @@ fi %changelog * Thu Jul 14 2022 Jonathan Wakely - 1.76.0-12 - Add patch to fix Asio includes (#2106441) +- Add patch to fix filesystem::copy_file EXDEV handling (#2106878) * Tue Apr 26 2022 Thomas Rodgers - 1.76.0-11 - Add BuildRequires: libzstd-devel to fix (#2042336) From 007f23d8508053c0bfbbd68651b4be10e65593ed Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Thu, 14 Jul 2022 13:28:47 +0100 Subject: [PATCH 4/4] Add boost-json to umbrella package --- boost.spec | 2 ++ 1 file changed, 2 insertions(+) diff --git a/boost.spec b/boost.spec index 8ced878..cb59aca 100644 --- a/boost.spec +++ b/boost.spec @@ -85,6 +85,7 @@ Requires: %{name}-fiber%{?_isa} = %{version}-%{release} Requires: %{name}-filesystem%{?_isa} = %{version}-%{release} Requires: %{name}-graph%{?_isa} = %{version}-%{release} Requires: %{name}-iostreams%{?_isa} = %{version}-%{release} +Requires: %{name}-json%{?_isa} = %{version}-%{release} Requires: %{name}-locale%{?_isa} = %{version}-%{release} Requires: %{name}-log%{?_isa} = %{version}-%{release} Requires: %{name}-math%{?_isa} = %{version}-%{release} @@ -1314,6 +1315,7 @@ fi * Thu Jul 14 2022 Jonathan Wakely - 1.76.0-12 - Add patch to fix Asio includes (#2106441) - Add patch to fix filesystem::copy_file EXDEV handling (#2106878) +- Add boost-json to umbrella package * Tue Apr 26 2022 Thomas Rodgers - 1.76.0-11 - Add BuildRequires: libzstd-devel to fix (#2042336)