bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: BTRFS file clone support for cp


From: Jim Meyering
Subject: Re: BTRFS file clone support for cp
Date: Tue, 04 Aug 2009 17:21:50 +0200

Giuseppe Scrivano wrote:
> I attached the cleaned patch, according to your advises.  If there are
> other things, I'll fix them.

Thanks!

...
> address@hidden --reflink
> address@hidden --reflink
> +Attempt a O(1) copy-on-write (COW) when the underlying file system
> +supports this operation instead of really copying the file.
> +The source and destination files share the same disk data blocks until
> +they are equal.  Changes done in a file are not visible in the other
> +one because shared blocks will be duplicated before these changes are
> +stored.

I'll adjust the wording above, to something like this:

Perform a lightweight, copy-on-write (COW) copy.
Copying with this option can succeed only on some relatively new file systems.
Once it has succeeded, beware that the source and destination files
share the same disk data blocks as long as they remain unmodified.
Thus, if a disk I/O error affects data blocks of one of the files,
the other suffers the exact same fate.

>  @item --remove-destination
>  @opindex --remove-destination
>  Remove each existing destination file before attempting to open it
> diff --git a/src/copy.c b/src/copy.c
> index bbed336..5eae9f4 100644
> --- a/src/copy.c
> +++ b/src/copy.c
> @@ -610,13 +610,16 @@ copy_reg (char const *src_name, char const *dst_name,
>        goto close_src_and_dst_desc;
>      }
>
> -  /* If --sparse=auto is in effect, attempt a btrfs clone operation.
> -     If the operation is not supported or it fails then copy the file
> -     in the usual way.  */
> -  bool copied = (x->sparse_mode == SPARSE_AUTO
> -                 && clone_file (dest_desc, source_desc) == 0);
> +  if (x->reflink)
> +    {
> +      if (clone_file (dest_desc, source_desc))
> +        {
> +          error (0, errno, _("cannot fstat %s"), quote (dst_name));

I prefer this diagnostic ;-)

             error (0, errno, _("failed to clone %s"), quote (dst_name));




reply via email to

[Prev in Thread] Current Thread [Next in Thread]