]> git.ipfire.org Git - thirdparty/coreutils.git/commit
bug#6131: [PATCH]: fiemap support for efficient sparse file copy
authorjeff.liu <jeff.liu@oracle.com>
Wed, 29 Sep 2010 08:11:41 +0000 (16:11 +0800)
committerJim Meyering <meyering@redhat.com>
Sat, 22 Jan 2011 11:16:43 +0000 (12:16 +0100)
commitbfda815cf4c889ac8165004fee5678fee67fbaf1
tree0b2ebc8e4eed1ca8e14ddb2989ca943f3c013928
parent63b743902d99aa67adbad795bf11a1ce4d27c39b
bug#6131: [PATCH]: fiemap support for efficient sparse file copy

Jim Meyering wrote:
> jeff.liu wrote:
>> Sorry for the delay.
>>
>> This is the new patch to isolate the stuff regarding to extents reading to a new module. and teach
>> cp(1) to make use of it.
>
> Jeff,
>
> I applied your patch to my rebased fiemap-copy branch.
> My first step was to run the usual
>
>   ./bootstrap && ./configure && make && make check
>
> "make check" failed on due to a double free in your new code:
> (x86_64, Fedora 13, ext4 working directory)
>
> To get details, I made this temporary modification:
Hi Jim,

I am sorry for the fault, it fixed at the patch below.
Would you please revie at your convenience?

Changes:
========
1. fix write_zeros() as Jim's comments, thanks for pointing this out.
2. remove char const *fname from struct extent_scan.
3. change the signature of open_extent_scan() from "void open_extent_scan(struct extent_scan
**scan)" to "void open_extent_scan(struct extent_scan *scan)"; the reason is I'd like to reduce once
memory allocation for the extent_scan variable, instead, using stack to save it.
4. remove close_extent_scan() from a function defined at extent-scan.c to extent-scan.h as a Macro
definination, but it does nothing for now, since initial extent scan defined at stack.
5. add a macro "free_extents_info()" defined at extent-scan.h to release the memory allocated to
extent info which should be called combine with get_extents_info(), it just one line, so IMHO,
define it as macro should be ok.

I have done the memory check via `valgrind`, no issue found.
make test against cp/sparse-fiemap failed at the extent compare stage, but the file content is
identical to each other by comparing those two files "j1/j2" manually.
Is it make sense if we verify them through diff(1) since the testing file is in small size?
or we have to merge the contig extents from the output of `filefrag', I admit I have not dig into
the filefrag-extent-compare at the moment, I need to recall the perl language syntax. :-P.

>From 50a3338db06442fa2d789fd65175172d140cc96e Mon Sep 17 00:00:00 2001
From: Jie Liu <jeff.liu@oracle.com>
Date: Wed, 29 Sep 2010 15:35:43 +0800
Subject: [PATCH 1/1] cp: add a new module for scanning extents

* src/extent-scan.c: Source code for scanning extents.
  Call open_extent_scan() to initialize extent scan.
  Call get_extents_info() to get a number of extents for each iteration.
* src/extent-scan.h: Header file of extent-scan.c.
  Wrap free_extent_info() as macro define to release the space allocated extent_info per extent scan.
  Wrap close_extent_scan() as macro define but do nothing at the moment.
* src/Makefile.am: Reference it and link it to copy_source.
* src/copy.c: Make use of the new module, replace fiemap_copy() with extent_copy().

Signed-off-by: Jie Liu <jeff.liu@oracle.com>
src/Makefile.am
src/copy.c
src/extent-scan.c [new file with mode: 0644]
src/extent-scan.h [new file with mode: 0644]