3
0
forked from pool/coreutils

Accepting request 517144 from Base:System

Drop coreutils-ocfs2_reflinks.patch,OCFS2 file system has supported file clone ioctls like btrfs,
then, coreutils doesn't need this patch from the kernel v4.10-rc1. (forwarded request 517127 from ganghe)

OBS-URL: https://build.opensuse.org/request/show/517144
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/coreutils?expand=0&rev=124
This commit is contained in:
Dominique Leuenberger 2017-08-21 09:31:32 +00:00 committed by Git OBS Bridge
parent d8863ca283
commit 2f9179b5e0
5 changed files with 14 additions and 131 deletions

View File

@ -1,123 +0,0 @@
>From 34556c4e36effc165032724cd37e6a4d2682f880 Mon Sep 17 00:00:00 2001
From: Jie Liu <jeff....@oracle.com>
Date: Tue, 3 May 2011 22:21:41 +0800
Subject: [PATCH 1/1] copy: add OCFS2 reflink support
* src/copy.c (copy_reg): When cp is invoked with '--reflink=[WHEN]', try
OCFS2 reflink file first, if it fails, try btrfs clone file later if
possible. The reflink will fail with EEXIST if the destination file
already exists on OCFS2, in this case, it means the user intended to
do OCFS2 reflink rather than btrfs clone, so we need not try the latter.
Signed-off-by: Jie Liu <jeff....@oracle.com>
---
src/copy.c | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 81 insertions(+), 1 deletion(-)
Index: src/copy.c
===================================================================
--- src/copy.c.orig
+++ src/copy.c
@@ -327,6 +327,47 @@ sparse_copy (int src_fd, int dest_fd, ch
return true;
}
+/* Perform the OCFS2 CoW reflink ioctl(2) operation if possible.
+ When using '-p' option, the file's default attributes(i.e. mode,timestamp,
+ ownership and security context if possbile) are reflinked to the destination
+ file as well, we will then skip over the standard preserve process for such
+ attributes. Upon success, return 0, Otherwise, return -1 and set errno. */
+static inline int
+reflink_file (char const *src_name, char const *dst_name,
+ int src_fd, bool preserve_attrs)
+{
+#ifdef __linux__
+# ifndef REFLINK_ATTR_NONE
+# define REFLINK_ATTR_NONE 0
+# endif
+# ifndef REFLINK_ATTR_PRESERVE
+# define REFLINK_ATTR_PRESERVE 1
+# endif
+# ifndef OCFS2_IOC_REFLINK
+ struct reflink_arguments {
+ uint64_t old_path;
+ uint64_t new_path;
+ uint64_t preserve;
+ };
+# define OCFS2_IOC_REFLINK _IOW ('o', 4, struct reflink_arguments)
+# endif
+ struct reflink_arguments args = {
+ .old_path = (unsigned long) src_name,
+ .new_path = (unsigned long) dst_name,
+ .preserve = preserve_attrs ? REFLINK_ATTR_PRESERVE : REFLINK_ATTR_NONE,
+ };
+ return ioctl (src_fd, OCFS2_IOC_REFLINK, &args);
+#else
+ (void) src_name;
+ (void) dst_name;
+ (void) src_fd;
+ (void) preserve_attrs;
+ errno = ENOTSUP;
+ return -1;
+#endif
+}
+
+
/* Perform the O(1) btrfs clone operation, if possible.
Upon success, return 0. Otherwise, return -1 and set errno. */
static inline int
@@ -1057,6 +1098,45 @@ copy_reg (char const *src_name, char con
goto close_src_desc;
}
+ /* When cp is invoked with '--reflink=[WHEN]', try to do OCFS2 reflink
+ ioctl(2) first, if it fails, try btrfs clone file later if possible.
+ The reason why perform those operations separately is because `cp'
+ will create the destination file if it is a '*new_dst'. In this case,
+ we have to unlink(2) it firstly, otherwise, OCFS2 reflink will fail with
+ 'EEXIST'. */
+ bool reflink_ok = false;
+ if (data_copy_required && x->reflink_mode)
+ {
+ bool preserve_attributes = (x->preserve_ownership
+ && x->preserve_mode
+ && x->preserve_timestamps);
+ reflink_ok = reflink_file (src_name, dst_name, source_desc,
+ preserve_attributes) == 0;
+ if (reflink_ok)
+ {
+ *new_dst = false;
+
+ /* Skip over the standard attributes preserve process
+ if reflink succeeds and they are already reflinked. */
+ if (preserve_attributes)
+ goto close_src_desc;
+ }
+ else
+ {
+ /* When the destination file is aready exists on OCFS2, the
+ above reflink should fails with EEXIST. If that happens,
+ we need not try btrfs clone again since it means the user
+ is definitely want a OCFS2 reflink. */
+ if (errno == EEXIST)
+ {
+ error (0, errno, _("failed to reflink %s from %s"),
+ quoteaf_n (0, dst_name), quoteaf_n (1, src_name));
+ return_val = false;
+ goto close_src_desc;
+ }
+ }
+ }
+
/* The semantics of the following open calls are mandated
by the specs for both cp and mv. */
if (! *new_dst)
@@ -1200,7 +1280,7 @@ copy_reg (char const *src_name, char con
}
/* --attributes-only overrides --reflink. */
- if (data_copy_required && x->reflink_mode)
+ if (data_copy_required && x->reflink_mode && ! reflink_ok)
{
bool clone_ok = clone_file (dest_desc, source_desc) == 0;
if (clone_ok || x->reflink_mode == REFLINK_ALWAYS)

View File

@ -1,3 +1,10 @@
-------------------------------------------------------------------
Wed Aug 16 14:26:30 UTC 2017 - ghe@suse.com
- Drop coreutils-ocfs2_reflinks.patch
OCFS2 file system has supported file clone ioctls like btrfs,
then, coreutils doesn't need this patch from the kernel v4.10-rc1
-------------------------------------------------------------------
Tue May 2 21:29:32 UTC 2017 - mail@bernhard-voelker.de

View File

@ -106,9 +106,6 @@ Patch16: coreutils-invalid-ids.patch
# OBS / RPMLINT require /usr/bin/timeout to be built with the -fpie option.
Patch100: coreutils-build-timeout-as-pie.patch
# At least a bit of reflink support
Patch111: coreutils-ocfs2_reflinks.patch
# There is no network in the build root so make the test succeed
Patch112: coreutils-getaddrinfo.patch
@ -167,7 +164,6 @@ the GNU fileutils, sh-utils, and textutils packages.
%if %{suse_version} <= 1320
%patch100
%endif
%patch111
%patch112
%patch113

View File

@ -1,3 +1,10 @@
-------------------------------------------------------------------
Wed Aug 16 14:26:30 UTC 2017 - ghe@suse.com
- Drop coreutils-ocfs2_reflinks.patch
OCFS2 file system has supported file clone ioctls like btrfs,
then, coreutils doesn't need this patch from the kernel v4.10-rc1
-------------------------------------------------------------------
Tue May 2 21:29:32 UTC 2017 - mail@bernhard-voelker.de

View File

@ -106,9 +106,6 @@ Patch16: coreutils-invalid-ids.patch
# OBS / RPMLINT require /usr/bin/timeout to be built with the -fpie option.
Patch100: coreutils-build-timeout-as-pie.patch
# At least a bit of reflink support
Patch111: coreutils-ocfs2_reflinks.patch
# There is no network in the build root so make the test succeed
Patch112: coreutils-getaddrinfo.patch
@ -167,7 +164,6 @@ the GNU fileutils, sh-utils, and textutils packages.
%if %{suse_version} <= 1320
%patch100
%endif
%patch111
%patch112
%patch113