From 9864053c9c969ef6b725504de192b29aed8a28a9 Mon Sep 17 00:00:00 2001 From: Darshan Sen Date: Thu, 13 May 2021 20:48:43 +0530 Subject: [PATCH] unix,fs: use uv__load_relaxed and uv__store_relaxed This is more clear about the intended semantics with multiple threads. PR-URL: https://github.com/libuv/libuv/pull/3124 Reviewed-By: Ben Noordhuis Reviewed-By: Jameson Nash --- src/unix/fs.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/unix/fs.c b/src/unix/fs.c index 8ff5fd24d..eb17fb4a2 100644 --- a/src/unix/fs.c +++ b/src/unix/fs.c @@ -965,18 +965,20 @@ static ssize_t uv__fs_sendfile(uv_fs_t* req) { #ifdef __linux__ { - static int copy_file_range_support = 1; + static int no_copy_file_range_support; - if (copy_file_range_support) { + if (uv__load_relaxed(&no_copy_file_range_support) == 0) { r = uv__fs_copy_file_range(in_fd, &off, out_fd, NULL, req->bufsml[0].len, 0); if (r == -1 && errno == ENOSYS) { /* ENOSYS - it will never work */ errno = 0; - copy_file_range_support = 0; + uv__store_relaxed(&no_copy_file_range_support, 1); } else if (r == -1 && errno == EACCES && uv__is_buggy_cephfs(in_fd)) { + /* EACCES - pre-4.20 kernels have a bug where CephFS uses the RADOS + copy-from command when it shouldn't */ errno = 0; - copy_file_range_support = 0; + uv__store_relaxed(&no_copy_file_range_support, 1); } else if (r == -1 && (errno == ENOTSUP || errno == EXDEV)) { /* ENOTSUP - it could work on another file system type */ /* EXDEV - it will not work when in_fd and out_fd are not on the same