Subject: Re: bug#12656: cp since 8.11 corrupts files

From: Jim Meyering <[email-masked]>
Date: Mon, 15 Oct 2012 19:51:35 +0200

Mike Gerth wrote:
> I noticed an error in cp (8.11 upwards till 8.19) when copying many files
> from an fragmented ext3fs (to an empty partition).
>
> ERROR:
>         The copied file has exact length.
>         The SourceFile has in the middle a 4K-block filled with ZERO, the
> DestFile this 4k-block and the previous 4k-block also filled with ZERO.
>
>
> I can reproduce this:
>         Conditions:
>                 *I have a strong fragmented 110GB ext3-partition with >300
> Files
>                 *I have to copy about 100 files (ca. 15GB) to another
> HDD-Partition or ramdisk
>                 *cp must be 8.11 or higher (compiled under SLES11SP2
> kernel 3.0) (everything is ok with 6.11. 8.05..8.10)
>                 *Command:
>                         cp819    $FILES $DEST #here the corruption comes
>                         *$FILES is a list of about 100 DatabaseFiles. The
> last one is the file that becomes corrupted

Thanks a lot for the detailed report.
...
> But since the Files are Database files I can not provide it. Are there any
> tests that I can do?

Can you run this command, and then send us the part of the LOG file
that reads and writes the file that is corrupted, i.e., only the
presumably small fraction at the end:

    strace -s8 -oLOG cp819 $FILES $DEST

The interesting-to-us part will start with "open" syscalls that
operate on the src and dest corrupted files.

However, note that the read syscalls will expose a few bytes (8 per
block read -- per the -s8 option above) of the contents of your
final file.  If you're not comfortable with that, let us know
and we'll try to come up with something else.

If LOG is larger than say 40KB, please compress and attach e.g., LOG.xz.