3
0
forked from pool/coreutils
coreutils/coreutils-ocfs2_reflinks.patch
Philipp Thomas 0954d8e70f - Update to 8.24:
** Bug fixes
  * dd supports more robust SIGINFO/SIGUSR1 handling for outputting statistics.
    Previously those signals may have inadvertently terminated the process.
  * df --local no longer hangs with inaccessible remote mounts.
    [bug introduced in coreutils-8.21]
  * du now silently ignores all directory cycles due to bind mounts.
    Previously it would issue a warning and exit with a failure status.
    [bug introduced in coreutils-8.1 and partially fixed in coreutils-8.23]
  * chroot again calls chroot(DIR) and chdir("/"), even if DIR is "/".
    This handles separate bind mounted "/" trees, and environments
    depending on the implicit chdir("/").
    [bugs introduced in coreutils-8.23]
  * cp no longer issues an incorrect warning about directory hardlinks when a
    source directory is specified multiple times.  Now, consistent with other
    file types, a warning is issued for source directories with duplicate names,
    or with -H the directory is copied again using the symlink name.
  * factor avoids writing partial lines, thus supporting parallel operation.
    [the bug dates back to the initial implementation]
  * head, od, split, tac, tail, and wc no longer mishandle input from files in
    /proc and /sys file systems that report somewhat-incorrect file sizes.
  * mkdir --parents -Z now correctly sets the context for the last component,
    even if the parent directory exists and has a different default context.
    [bug introduced with the -Z restorecon functionality in coreutils-8.22]
  * numfmt no longer outputs incorrect overflowed values seen with certain
    large numbers, or with numbers with increased precision.
    [bug introduced when numfmt was added in coreutils-8.21]
  * numfmt now handles leading zeros correctly, not counting them when
    settings processing limits, and making them optional with floating point.
    [bug introduced when numfmt was added in coreutils-8.21]
  * paste no longer truncates output for large input files.  This would happen
    for example with files larger than 4GiB on 32 bit systems with a '\n'
    character at the 4GiB position.
    [the bug dates back to the initial implementation]
  * rm indicates the correct number of arguments in its confirmation prompt,
    on all platforms.  [bug introduced in coreutils-8.22]
  * shuf -i with a single redundant operand, would crash instead of issuing
    a diagnostic.  [bug introduced in coreutils-8.22]
  * tail releases inotify resources when unused.  Previously it could exhaust
    resources with many files, or with -F if files were replaced many times.
    [bug introduced in coreutils-7.5]
  * tail -f again follows changes to a file after it's renamed.
    [bug introduced in coreutils-7.5]
  * tail --follow no longer misses changes to files if those files were
    replaced before inotify watches were created.
    [bug introduced in coreutils-7.5]
  * tail --follow consistently outputs all data for a truncated file.
    [bug introduced in the beginning]
  * tail --follow=name correctly outputs headers for multiple files
    when those files are being created or renamed.
    [bug introduced in coreutils-7.5]
  ** New features
  * chroot accepts the new --skip-chdir option to not change the working directory
    to "/" after changing into the chroot(2) jail, thus retaining the current wor-
    king directory.  The new option is only permitted if the new root directory is
    the old "/", and therefore is useful with the --group and --userspec options.
  * dd accepts a new status=progress level to print data transfer statistics
    on stderr approximately every second.
  * numfmt can now process multiple fields with field range specifications similar
    to cut, and supports setting the output precision with the --format option.
  * split accepts a new --separator option to select a record separator character
    other than the default newline character.
  * stty allows setting the "extproc" option where supported, which is
    a useful setting with high latency links.
  * sync no longer ignores arguments, and syncs each specified file, or with the
    --file-system option, the file systems associated with each specified file.
  * tee accepts a new --output-error option to control operation with pipes
    and output errors in general.
  ** Changes in behavior
  * df no longer suppresses separate exports of the same remote device, as
    these are generally explicitly mounted.  The --total option does still
    suppress duplicate remote file systems.
    [suppression was introduced in coreutils-8.21]
  * mv no longer supports moving a file to a hardlink, instead issuing an error.
    The implementation was susceptible to races in the presence of multiple mv
    instances, which could result in both hardlinks being deleted.  Also on case
    insensitive file systems like HFS, mv would just remove a hardlinked 'file'
    if called like `mv file File`.  The feature was added in coreutils-5.0.1.
  * numfmt --from-unit and --to-unit options now interpret suffixes as SI units,
    and IEC (power of 2) units are now specified by appending 'i'.
  * tee will exit early if there are no more writable outputs.
  * tee does not treat the file operand '-' as meaning standard output any longer,
    for better conformance to POSIX.  This feature was added in coreutils-5.3.0.
  * timeout --foreground no longer sends SIGCONT to the monitored process,
    which was seen to cause intermittent issues with GDB for example.
  ** Improvements
  * cp,install,mv will convert smaller runs of NULs in the input to holes,
    and cp --sparse=always avoids speculative preallocation on XFS for example.
  * cp will read sparse files more efficiently when the destination is a
    non regular file.  For example when copying a disk image to a device node.
  * mv will try a reflink before falling back to a standard copy, which is
    more efficient when moving files across BTRFS subvolume boundaries.
  * stat and tail now know about IBRIX.  stat -f --format=%T now reports the file
    system type, and tail -f uses polling for files on IBRIX file systems.
  * wc -l processes short lines much more efficiently.
  * References from --help and the man pages of utilities have been corrected
    in various cases, and more direct links to the corresponding online
    documentation are provided.
- Patches adapted because of changed sources:
  coreutils-disable_tests.patch
  coreutils-i18n.patch
  coreutils-misc.patch
  coreutils-ocfs2_reflinks.patch
  coreutils-remove_hostname_documentation.patch
  coreutils-remove_kill_documentation.patch
  coreutils-skip-gnulib-test-tls.patch
  coreutils-tests-shorten-extreme-factor-tests.patch
  sort-keycompare-mb.patch
- Patches removed because they're included in 8.24:  
  coreutils-chroot-perform-chdir-unless-skip-chdir.patch
  coreutils-df-doc-df-a-includes-duplicate-file-systems.patch
  coreutils-df-improve-mount-point-selection.patch
  coreutils-df-show-all-remote-file-systems.patch
  coreutils-df-total-suppress-separate-remotes.patch
  coreutils-doc-adjust-reference-to-info-nodes-in-man-pages.patch
  coreutils-fix_false_du_failure_on_newer_xfs.patch
  coreutils-fix-man-deps.patch
  coreutils-tests-aarch64-env.patch
  coreutils-tests-make-inotify-rotate-more-robust-and-efficient.patch
  coreutils-tests-rm-ext3-perf-increase-timeout.patch

OBS-URL: https://build.opensuse.org/package/show/Base:System/coreutils?expand=0&rev=262
2015-07-09 15:40:19 +00:00

144 lines
5.3 KiB
Diff

>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 | 99 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-----
1 file changed, 91 insertions(+), 8 deletions(-)
Index: src/copy.c
===================================================================
--- src/copy.c.orig 2015-06-26 19:05:22.000000000 +0200
+++ src/copy.c 2015-07-09 14:58:48.105027875 +0200
@@ -324,6 +324,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
@@ -1040,6 +1081,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"),
+ quote_n (0, dst_name), quote_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)
@@ -1185,17 +1265,20 @@ copy_reg (char const *src_name, char con
/* --attributes-only overrides --reflink. */
if (data_copy_required && x->reflink_mode)
{
- bool clone_ok = clone_file (dest_desc, source_desc) == 0;
- if (clone_ok || x->reflink_mode == REFLINK_ALWAYS)
+ if (! reflink_ok)
{
- if (!clone_ok)
+ bool clone_ok = clone_file (dest_desc, source_desc) == 0;
+ if (clone_ok || x->reflink_mode == REFLINK_ALWAYS)
{
- error (0, errno, _("failed to clone %s from %s"),
- quote_n (0, dst_name), quote_n (1, src_name));
- return_val = false;
- goto close_src_and_dst_desc;
+ if (!clone_ok)
+ {
+ error (0, errno, _("failed to clone %s from %s"),
+ quote_n (0, dst_name), quote_n (1, src_name));
+ return_val = false;
+ goto close_src_and_dst_desc;
+ }
+ data_copy_required = false;
}
- data_copy_required = false;
}
}