[Ocfs2-tools-devel] [PATCH] debugfs.ocfs2: fix dump_block_check for big-endian

Goldwyn Rodrigues rgoldwyn at gmail.com
Thu Jul 28 16:50:46 PDT 2011


Hi Joel,

On Thu, Jul 28, 2011 at 5:20 AM, Joel Becker <jlbec at evilplan.org> wrote:
> On Wed, Jul 06, 2011 at 05:19:39PM -0500, Goldwyn Rodrigues wrote:
>> The block check or metaecc code expects the data to be in little-endian
>> format for calculating CRC and ECC. However, with big-endian machines,
>> the block is in big-endian format.
>>
>> Convert the block to little-endian format before feeding to meta ecc
>> computation. After computing, change data format back to CPU.
>>
>
>> ---
>> diff --git a/debugfs.ocfs2/dump.c b/debugfs.ocfs2/dump.c
>> index ad58126..d54c31a 100644
>> --- a/debugfs.ocfs2/dump.c
>> +++ b/debugfs.ocfs2/dump.c
>> @@ -166,10 +166,74 @@ void dump_block_check(FILE *out, struct
>> ocfs2_block_check *bc, void *block)
>>  {
>>       struct ocfs2_block_check tmp = *bc;
>>       int crc_fail;
>> +     enum dump_block_type bt = detect_block(block);
>> +
>> +     /* Swap block to little endian for compute_meta_ecc */
>> +     switch (bt) {
>> +             case DUMP_BLOCK_INODE:
>> +                     ocfs2_swap_inode_from_cpu(gbls.fs, block);
>> +                     break;
>
>        Instead, why not allocate a temporary block, copy the data over,
> and then swap the temporary buffer.  That way you aren't having to swap
> back?

Depends on what you consider more expensive: a memcpy of the block
which happens in all archs, or a swap which is almost null for
little-endian archs.

-- 
Goldwyn



More information about the Ocfs2-tools-devel mailing list