On Tue, Oct 20, 2015 at 2:29 PM, Timofey Titovets <nefelim4ag@xxxxxxxxx> wrote:
> For performance reason, leave data at the start of disk, is preferable
> while deduping
Have you made any performance tests to verify that?
> It's might sense for the reasons:
> 1. Spinning rust - start of the disk is much faster
> 2. Btrfs can deallocate empty data chunk from the end of fs - ie it's compact fs
I don't see why that makes sense. First the clone/extent_same ioctls
don't copy data, they just update metadata of the destination inode to
point to the same extents as the source inode, secondly, just because
an offset of a file is lower the offset of the other file, it doesn't
mean the physical (on disk) offset of the first file is lower than
that of the other file...
>
> Signed-off-by: Timofey Titovets <nefelim4ag@xxxxxxxxx>
> ---
> fs/btrfs/ioctl.c | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
> index 3e3e613..3eb77c0 100644
> --- a/fs/btrfs/ioctl.c
> +++ b/fs/btrfs/ioctl.c
> @@ -3074,8 +3074,13 @@ static int btrfs_extent_same(struct inode *src,
> u64 loff, u64 olen,
>
> /* pass original length for comparison so we stay within i_size */
> ret = btrfs_cmp_data(src, loff, dst, dst_loff, olen, &cmp);
> - if (ret == 0)
> - ret = btrfs_clone(src, dst, loff, olen, len, dst_loff, 1);
> + if (ret == 0) {
> + /* prefer inode with lowest offset as source for clone*/
> + if (loff > dest_loff)
> + ret = btrfs_clone(dst, src, dst_loff, olen, len, loff, 1);
> + else
> + ret = btrfs_clone(src, dst, loff, olen, len, dst_loff, 1);
> + }
>
> if (same_inode)
> unlock_extent(&BTRFS_I(src)->io_tree, same_lock_start,
> --
> 2.6.1
--
Filipe David Manana,
"Reasonable men adapt themselves to the world.
Unreasonable men adapt the world to themselves.
That's why all progress depends on unreasonable men."
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html