Compare commits

...
Sign in to create a new pull request.

4 commits

Author SHA1 Message Date
Jonathan Wakely
007f23d850 Add boost-json to umbrella package 2022-07-14 13:28:47 +01:00
Jonathan Wakely
641b90a547 Add patch to fix filesystem::copy_file EXDEV handling
Resolves: #2106878
2022-07-14 12:53:00 +01:00
Jonathan Wakely
2775e939cb Add patch to fix Asio includes
Resolves: #2106441
2022-07-14 12:52:50 +01:00
Thomas W Rodgers
e0266acc24 Add BuildRequires: libzstd-devel to fix (#2042336) 2022-04-27 18:28:01 +01:00
3 changed files with 206 additions and 1 deletions

View file

@ -0,0 +1,34 @@
From 71964b22c7fade69cc4caa1c869a868e3a32cc97 Mon Sep 17 00:00:00 2001
From: Christopher Kohlhoff <chris@kohlhoff.com>
Date: Wed, 2 Mar 2022 21:41:04 +1100
Subject: [PATCH] Header <utility> 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 <experimental/coroutine>
#endif // defined(BOOST_ASIO_HAS_STD_COROUTINE)
+#include <utility>
#include <boost/asio/any_io_executor.hpp>
#include <boost/asio/detail/push_options.hpp>
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 <exception>
#include <new>
#include <tuple>
-#include <utility>
#include <boost/asio/detail/thread_context.hpp>
#include <boost/asio/detail/thread_info_base.hpp>
#include <boost/asio/detail/type_traits.hpp>

View file

@ -0,0 +1,152 @@
From 4b9052f1e0b2acf625e8247582f44acdcc78a4ce Mon Sep 17 00:00:00 2001
From: Andrey Semashev <andrey.semashev@gmail.com>
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 <atomic>
+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 = &copy_file_data_read_write;
+atomic_ns::atomic< copy_file_data_t* > copy_file_data(&copy_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(&copy_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(&copy_file_data_sendfile, atomic_ns::memory_order_relaxed);
+ goto fallback_to_sendfile;
+#else
+ copy_file_data.store(&copy_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 = &copy_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

View file

@ -42,7 +42,7 @@ Name: boost
%global real_name boost %global real_name boost
Summary: The free peer-reviewed portable C++ source libraries Summary: The free peer-reviewed portable C++ source libraries
Version: 1.76.0 Version: 1.76.0
Release: 10%{?dist} Release: 12%{?dist}
License: Boost and MIT and Python License: Boost and MIT and Python
# Replace each . with _ in %%{version} # Replace each . with _ in %%{version}
@ -85,6 +85,7 @@ Requires: %{name}-fiber%{?_isa} = %{version}-%{release}
Requires: %{name}-filesystem%{?_isa} = %{version}-%{release} Requires: %{name}-filesystem%{?_isa} = %{version}-%{release}
Requires: %{name}-graph%{?_isa} = %{version}-%{release} Requires: %{name}-graph%{?_isa} = %{version}-%{release}
Requires: %{name}-iostreams%{?_isa} = %{version}-%{release} Requires: %{name}-iostreams%{?_isa} = %{version}-%{release}
Requires: %{name}-json%{?_isa} = %{version}-%{release}
Requires: %{name}-locale%{?_isa} = %{version}-%{release} Requires: %{name}-locale%{?_isa} = %{version}-%{release}
Requires: %{name}-log%{?_isa} = %{version}-%{release} Requires: %{name}-log%{?_isa} = %{version}-%{release}
Requires: %{name}-math%{?_isa} = %{version}-%{release} Requires: %{name}-math%{?_isa} = %{version}-%{release}
@ -123,6 +124,7 @@ BuildRequires: libicu-devel
BuildRequires: libquadmath-devel BuildRequires: libquadmath-devel
%endif %endif
BuildRequires: bison BuildRequires: bison
BuildRequires: libzstd-devel
# https://bugzilla.redhat.com/show_bug.cgi?id=828856 # https://bugzilla.redhat.com/show_bug.cgi?id=828856
# https://bugzilla.redhat.com/show_bug.cgi?id=828857 # https://bugzilla.redhat.com/show_bug.cgi?id=828857
@ -173,6 +175,13 @@ Patch104: boost-1.76.0-fix-narrowing-conversions-for-ppc.patch
# https://github.com/boostorg/ptr_container/pull/27 # https://github.com/boostorg/ptr_container/pull/27
Patch105: boost-1.76.0-ptr_cont-xml.patch 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 tests
%bcond_with docs_generated %bcond_with docs_generated
@ -700,6 +709,8 @@ find ./boost -name '*.hpp' -perm /111 | xargs chmod a-x
%patch103 -p2 %patch103 -p2
%patch104 -p2 %patch104 -p2
%patch105 -p1 %patch105 -p1
%patch106 -p2
%patch107 -p1
%build %build
%set_build_flags %set_build_flags
@ -1301,6 +1312,14 @@ fi
%{_mandir}/man1/b2.1* %{_mandir}/man1/b2.1*
%changelog %changelog
* Thu Jul 14 2022 Jonathan Wakely <jwakely@redhat.com> - 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 <trodgers@redhat.com> - 1.76.0-11
- Add BuildRequires: libzstd-devel to fix (#2042336)
* Thu Mar 31 2022 Jonathan Wakely <jwakely@redhat.com> - 1.76.0-10 * Thu Mar 31 2022 Jonathan Wakely <jwakely@redhat.com> - 1.76.0-10
- Add patch to fix XML validation errors in ptr_container docs - Add patch to fix XML validation errors in ptr_container docs