linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Sterba <dsterba@suse.cz>
To: fdmanana@kernel.org
Cc: linux-btrfs@vger.kernel.org
Subject: Re: [PATCH] Btrfs: send, allow clone operations within the same file
Date: Fri, 1 Nov 2019 15:28:00 +0100	[thread overview]
Message-ID: <20191101142759.GR3001@twin.jikos.cz> (raw)
In-Reply-To: <20191030122311.31349-1-fdmanana@kernel.org>

On Wed, Oct 30, 2019 at 12:23:11PM +0000, fdmanana@kernel.org wrote:
> From: Filipe Manana <fdmanana@suse.com>
> 
> For send we currently skip clone operations when the source and destination
> files are the same. This is so because clone didn't support this case in
> its early days, but support for it was added back in May 2013 by commit
> a96fbc72884fcb ("Btrfs: allow file data clone within a file"). This change
> adds support for it.
> 
> Example:
> 
>   $ mkfs.btrfs -f /dev/sdd
>   $ mount /dev/sdd /mnt/sdd
> 
>   $ xfs_io -f -c "pwrite -S 0xab -b 64K 0 64K" /mnt/sdd/foobar
>   $ xfs_io -c "reflink /mnt/sdd/foobar 0 64K 64K" /mnt/sdd/foobar
> 
>   $ btrfs subvolume snapshot -r /mnt/sdd /mnt/sdd/snap
> 
>   $ mkfs.btrfs -f /dev/sde
>   $ mount /dev/sde /mnt/sde
> 
>   $ btrfs send /mnt/sdd/snap | btrfs receive /mnt/sde
> 
> Without this change file foobar at the destination has a single 128Kb
> extent:
> 
>   $ filefrag -v /mnt/sde/snap/foobar
>   Filesystem type is: 9123683e
>   File size of /mnt/sde/snap/foobar is 131072 (32 blocks of 4096 bytes)
>    ext:     logical_offset:        physical_offset: length:   expected: flags:
>      0:        0..      31:          0..        31:     32:             last,unknown_loc,delalloc,eof
>   /mnt/sde/snap/foobar: 1 extent found
> 
> With this we get a single 64Kb extent that is shared at file offsets 0
> and 64K, just like in the source filesystem:
> 
>   $ filefrag -v /mnt/sde/snap/foobar
>   Filesystem type is: 9123683e
>   File size of /mnt/sde/snap/foobar is 131072 (32 blocks of 4096 bytes)
>    ext:     logical_offset:        physical_offset: length:   expected: flags:
>      0:        0..      15:       3328..      3343:     16:             shared
>      1:       16..      31:       3328..      3343:     16:       3344: last,shared,eof
>   /mnt/sde/snap/foobar: 2 extents found
> 
> Signed-off-by: Filipe Manana <fdmanana@suse.com>

Added to misc-next, thanks.

      parent reply	other threads:[~2019-11-01 14:27 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-30 12:23 [PATCH] Btrfs: send, allow clone operations within the same file fdmanana
2019-10-31 12:55 ` Josef Bacik
2019-11-01 14:28 ` David Sterba [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191101142759.GR3001@twin.jikos.cz \
    --to=dsterba@suse.cz \
    --cc=fdmanana@kernel.org \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).