Subject: bug#12656: Re[3]: bug#12656: cp since 8.11 corrupts files

From: "Mike Gerth" <[email-masked]>
Date: Tue, 16 Oct 2012 10:24:22 +0200

Hi Alan,

the difference between bulk copy (then the corruption comes) and single 
file copy (everything ok) is:

diff /PatchLogBulk.txt /PatchLogSingle.txt
635c635
< Julius.nsf merged extent#3 off=18239488 len=155648 flags=0x1000
---
> Julius.nsf merged extent#3 off=18239488 len=159744 flags=0x1000

Thanks,
Mike

Von:    "Alan Curry" <[email-masked]>
An:     [email-masked]
Kopie:  [email-masked] (Jim Meyering), [email-masked]
Datum:  16.10.2012 03:14
Betreff:        Re: bug#12656: Re[2]: bug#12656: cp since 8.11 corrupts 
files

The critical piece of the trace is here:

lseek(3, 18239488, SEEK_SET)            = 18239488
lseek(4, 18239488, SEEK_SET)            = 18239488
read(3, "\0\0\0\0\0\0\0\0"..., 65536)   = 65536
write(4, "\0\0\0\0\0\0\0\0"..., 65536)  = 65536
read(3, "?\0\r\0\20\0\0\37"..., 65536)  = 65536
write(4, "?\0\r\0\20\0\0\37"..., 65536) = 65536
read(3, "\20\0\0\377\0\20\0\0"..., 24576) = 24576
write(4, "\20\0\0\377\0\20\0\0"..., 24576) = 24576
lseek(3, 18403328, SEEK_SET)            = 18403328
lseek(4, 18403328, SEEK_SET)            = 18403328

The 24576-byte read and write should be 4096 bytes longer. cp has got the
extents mixed up somehow.

Here are some quick and dirty patches to make cp dump what it thinks the
extents are at a couple of different stages. It would be interesting to 
see
what they say about the troublesome file.

--- src/extent-scan.c            2012-10-15 19:24:55.112096929 -0500
+++ src/extent-scan.c            2012-10-15 19:56:22.533209742 -0500
@@ -131,6 +131,12 @@
                                   sizeof (struct extent_info));
 
       unsigned int i = 0;
+      for(i=0; i<fiemap->fm_mapped_extents; ++i)
+        fprintf(stderr, "fd %d extent#%d log=%llu len=%llu 
flags=0x%llx\n",
+                scan->fd, i,
+                (unsigned long long)fm_extents[i].fe_logical,
+                (unsigned long long)fm_extents[i].fe_length,
+                (unsigned long long)fm_extents[i].fe_flags);
       for (i = 0; i < fiemap->fm_mapped_extents; i++)
         {
           assert (fm_extents[i].fe_logical
--- src/copy.c           2012-10-15 18:55:39.397899266 -0500
+++ src/copy.c           2012-10-15 19:56:23.417209716 -0500
@@ -317,6 +317,12 @@
 
       unsigned int i;
       bool empty_extent = false;
+      for(i=0; i<scan.ei_count; ++i)
+        fprintf(stderr, "%s merged extent#%d off=%llu len=%llu 
flags=0x%llx\n",
+                src_name, i,
+                (unsigned long long)scan.ext_info[i].ext_logical,
+                (unsigned long long)scan.ext_info[i].ext_length,
+                (unsigned long long)scan.ext_info[i].ext_flags);
       for (i = 0; i < scan.ei_count || empty_extent; i++)
         {
           off_t ext_start;

-- 
Alan Curry