At 2014-09-04 08:07:32, "Eric Blake" <ebl...@redhat.com> wrote: >On 09/04/2014 02:58 AM, Stefan Hajnoczi wrote: >> On-disk structures should be marked packed so the compiler does not >> insert padding for field alignment. Padding should be explicit so >> on-disk layout is obvious and we don't rely on the architecture-specific >> ABI for alignment rules. >> >> The pahole(1) diff shows that the padding is now explicit and offsets >> are unchanged: >> >> char backing_file[1024]; /* 8 1024 */ >> /* --- cacheline 16 boundary (1024 bytes) was 8 bytes ago --- */ >> int32_t mtime; /* 1032 4 */ >> - >> - /* XXX 4 bytes hole, try to pack */ >> - >> + uint32_t padding; /* 1036 4 */ >> uint64_t size; /* 1040 8 */ > >Was a 32-bit build also inserting this padding, or do we have historical >differences where 32-bit and 64-bit cow files are actually different, >and we may need to be prepared to parse files from both sources? >
Tried on my x86 32bits computer, and seems the padding is not needed: struct cow_header_v2 { uint32_t magic; /* 0 4 */ uint32_t version; /* 4 4 */ char backing_file[1024]; /* 8 1024 */ /* --- cacheline 16 boundary (1024 bytes) was 8 bytes ago --- */ int32_t mtime; /* 1032 4 */ uint64_t size; /* 1036 8 */ uint32_t sectorsize; /* 1044 4 */ /* size: 1048, cachelines: 17, members: 6 */ /* last cacheline: 24 bytes */ }; >-- >Eric Blake eblake redhat com +1-919-301-3266 >Libvirt virtualization library http://libvirt.org > Regards, shhuiw