Subject: bug#6131: [PATCH]: fiemap support for efficient sparse file copy

From: Pádraig Brady <[email-masked]>
Date: Fri, 21 May 2010 13:04:28 +0100

On 13/05/10 15:25, jeff.liu wrote:
>
> diff --git a/src/copy.c b/src/copy.c
> index c16cef6..960e5fb 100644
> --- a/src/copy.c
> +++ b/src/copy.c
> @@ -63,6 +63,10 @@
>
>  #include <sys/ioctl.h>
>
> +#ifndef HAVE_FIEMAP
> +# include "fiemap.h"
> +#endif

Is HAVE_FIEMAP ever defined anywhere?
In future will we use this to check for <linux/fiemap.h> ?

On 20/05/10 20:23, Jim Meyering wrote:
> 
> diff --git a/tests/cp/sparse-fiemap b/tests/cp/sparse-fiemap
> old mode 100644
> new mode 100755
> index f9d3a94..814d537
> --- a/tests/cp/sparse-fiemap
> +++ b/tests/cp/sparse-fiemap
> @@ -28,8 +28,7 @@ cwd=`pwd`
>  cleanup_() { cd /; umount "$cwd/mnt"; }
> 
>  # Create an ext4 loopback file system
> -dd if=/dev/zero of=blob bs=8192 count=1000 > /dev/null 2>&1 \
> -                                               || skip=1
> +dd if=/dev/zero of=blob bs=8192 count=1000 || skip=1
>  mkdir mnt
>  mkfs -t ext4 -F blob ||
>    skip_test_ "failed to create ext4 file system"

There is the unlikely combination of ext4 without fiemap support I think?
If so then that dependency is worth a comment.

> @@ -42,20 +41,15 @@ test $skip = 1 &&
> 
>  rm -f mnt/f
> 
> -# Create a 2gb sparse file
> -dd if=/dev/zero of=mnt/sparse bs=1k count=1 seek=2096128 > /dev/null 2>&1 || framework_failure
> +# Create a 2TiB sparse file
> +dd if=/dev/zero of=mnt/sparse bs=1k count=1 seek=2G || framework_failure

If we don't need any actual data in the files then one could use:
  truncate -s 2TB mnt/sparse

For my reference, I used TB rather than TiB because on ext3
the limit is 0x1FEFF7FC000 (2194719883264)
(0x1FF7FFFD000 (2196875759616) before 2.6.25)

cheers,
Pádraig.