junneyang / zumastor

Automatically exported from code.google.com/p/zumastor
0 stars 1 forks source link

64/32bit interaction issues #110

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hi,

Issues with 32bit systems replicating to 64bit systems.

hosta - 32bit kernel/userland
hostb - 64bit kernel/userland

hosta:
lvcreate -n cross_vol -L10G sysvg
lvcreate -n cross_snap -L20G sysvg
zumastor define volume cross /dev/sysvg/cross_vol /dev/sysvg/cross_snap
--initialize
mkfs.ext3 /dev/mapper/cross
zumastor define master cross
zumastor define schedule cross --hourly 24
date > /var/run/zumastor/mount/cross/dateoutput
zumastor snapshot cross hourly
zumastor define target cross hostb --period 600

hostb:
lvcreate -n cross_vol -L10G sysvg
lvcreate -n cross_snap -L20G sysvg
zumastor define volume cross /dev/sysvg/cross_vol /dev/sysvg/cross_snap
--initialize
zumastor define source cross hostb:33221 --period 600

hosta:
zumastor replicate cross hostb

Logs on hostb:
--delta.log:
got client connection
processing
Thu Apr 10 19:14:07 2008: [19592] ddsnap_delta_server: closing connection 
on
error: incomplete SEND_DELTA request sent by client: length 28, size 32
Thu Apr 10 19:14:07 2008: [19583] ddsnap_delta_server: unable to accept
connection: Interrupted system call
Thu Apr 10 19:14:07 2008: [19583] ddsnap_delta_server: Caught signal 17
Thu Apr 10 19:14:12 2008: [19583] ddsnap_delta_server: unable to accept
connection: Interrupted system call
Thu Apr 10 19:14:12 2008: [19583] ddsnap_delta_server: Caught signal 15
Thu Apr 10 19:14:12 2008: [19621] daemonize: starting at Thu Apr 10 
19:14:12
2008

--server.log:
Thu Apr 10 19:06:34 2008: [17303] daemonize: starting at Thu Apr 10 
19:06:34
2008
Thu Apr 10 19:06:34 2008: [17303] event_parse_options: invalid count in
DDSNAP_COUNT
Thu Apr 10 19:06:34 2008: [17303] snap_server: Received connection
Thu Apr 10 19:06:34 2008: [17303] incoming: Activating server
Thu Apr 10 19:06:34 2008: [17303] snap_server: Client 0 disconnected
Thu Apr 10 19:06:34 2008: [17303] snap_server: Received connection
Thu Apr 10 19:06:34 2008: [17303] incoming: client id 0, snaptag 
4294967295
Thu Apr 10 19:08:00 2008: [17303] snap_server: Received connection
Thu Apr 10 19:08:00 2008: [17303] snap_server: Client 0 disconnected

Original issue reported on code.google.com by williama...@gmail.com on 10 Apr 2008 at 11:16

GoogleCodeExporter commented 9 years ago
hostb:
Linux hostb 2.6.22-14-zumastor #1 SMP Thu Mar 27 06:36:14 GMT 2008 x86_64 
GNU/Linux
zumastor v0.8.0 revision 1532 built on Thu Apr 10 18:15:33 EDT 2008 by 
root@hostb
(X4500)

hosta:
zumastor v0.8.0 revision 1532 built on Wed Apr 9 14:17:00 PDT 2008 by 
build@unassigned
Linux hosta 2.6.22.18-zumastor-r1491 #1 SMP PREEMPT Mon Mar 24 12:10:22 PDT 
2008 
i686 GNU/Linux
(Dell PE2950)

Original comment by williama...@gmail.com on 10 Apr 2008 at 11:20

GoogleCodeExporter commented 9 years ago
if hostb replicates to hosta you get:
Thu Apr 10 16:38:39 2008: [30958] apply_delta_extents: compressed data 
corrupted in 
delta for 4294967296 chunk extent starting at offset 0
applied streamed delta to "/dev/mapper/smallvol", closing connection
Thu Apr 10 16:38:39 2008: [30956] ddsnap_delta_server: unable to accept 
connection: 
Interrupted system call
Thu Apr 10 16:38:39 2008: [30956] ddsnap_delta_server: Caught signal 17
Thu Apr 10 16:38:40 2008: [30956] ddsnap_delta_server: unable to accept 
connection: 
Interrupted system call
Thu Apr 10 16:38:40 2008: [30956] ddsnap_delta_server: Caught signal 15
Thu Apr 10 16:38:40 2008: [30983] daemonize: starting at Thu Apr 10 16:38:40 
2008

in the log of hosta

Original comment by williama...@gmail.com on 10 Apr 2008 at 11:39

GoogleCodeExporter commented 9 years ago
Looks like the problem is because of the different alignment on 32-bit and 
64-bit
machines.
struct delta_header
{
        char magic[MAGIC_SIZE];
        u64 chunk_num;
        u32 chunk_size;
        u32 src_snap;
        u32 tgt_snap;
};

sizeof(struct delta_header) returns 28 on 32-bit machine, but 32 on 64-bit 
machine.
We can use #pragma pack(4) to solve the problem, but it may have some 
performance
impact. Any other thoughts?

Jiaying

Original comment by jiayin...@gmail.com on 11 Apr 2008 at 1:20

GoogleCodeExporter commented 9 years ago
Marking the structure as packed is fine, and is in fact probably what Dan P. 
intended.

Original comment by daniel.r...@gmail.com on 11 Apr 2008 at 1:25

GoogleCodeExporter commented 9 years ago
Here is the proposed patch:

Index: ddsnap.c
===================================================================
--- ddsnap.c    (revision 1533)
+++ ddsnap.c    (working copy)
@@ -226,13 +226,7 @@
        u32 tgt_snap;
 };

-struct vol_header
-{
-       char magic[MAGIC_SIZE];
-       u64 vol_size_bytes;
-       u32 chunksize_bits;
-};
-
+#pragma pack(4)
 struct delta_header
 {
        char magic[MAGIC_SIZE];
@@ -253,6 +247,7 @@
        u64 ext1_chksum;
        u64 ext2_chksum;
 };
+#pragma options align=reset

 static u64 checksum(const unsigned char *data, u32 data_length)
 {

Except for using packed structure for delta_header and delta_extent_header, I 
also
deleted a structure vol_header that is not used anywhere. I tried the patch on 
my
32bit and 64bit testing machines. Looks like it solves the problem.

Jiaying

Original comment by jiayin...@gmail.com on 11 Apr 2008 at 7:30

GoogleCodeExporter commented 9 years ago
Just write PACKED before the semicolon at the end of the struct definition.  
This is
a macro for gcc's __attribute__ ((packed))

Daniel

Original comment by Daniel.R...@gmail.com on 13 Apr 2008 at 11:14

GoogleCodeExporter commented 9 years ago
Thanks for the comments! Here is the modified patch.

Index: ddsnap.c
===================================================================
--- ddsnap.c    (revision 1533)
+++ ddsnap.c    (working copy)
@@ -226,13 +226,6 @@
        u32 tgt_snap;
 };

-struct vol_header
-{
-       char magic[MAGIC_SIZE];
-       u64 vol_size_bytes;
-       u32 chunksize_bits;
-};
-
 struct delta_header
 {
        char magic[MAGIC_SIZE];
@@ -240,7 +233,7 @@
        u32 chunk_size;
        u32 src_snap;
        u32 tgt_snap;
-};
+} PACKED;

 struct delta_extent_header
 {
@@ -252,7 +245,7 @@
        u64 extents_delta_length;
        u64 ext1_chksum;
        u64 ext2_chksum;
-};
+} PACKED;

 static u64 checksum(const unsigned char *data, u32 data_length)
 {

Jiaying

Original comment by jiayin...@gmail.com on 14 Apr 2008 at 7:07

GoogleCodeExporter commented 9 years ago
Looks like the whitespace got munged, attaching a copy of that patch.

Original comment by williama...@gmail.com on 14 Apr 2008 at 8:16

Attachments:

GoogleCodeExporter commented 9 years ago
Fixed with revision 1537.

Original comment by jiahotc...@gmail.com on 15 Apr 2008 at 6:25