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

Sunil Mushran sunil.mushran at oracle.com
Thu Jul 28 13:37:45 PDT 2011


On 07/28/2011 03:20 AM, Joel Becker 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?

So this one is already in the repo.

I had other issues with it. Mostly I wanted the block type detection and swapping
to be part of libocfs2. Those patches are in the following review branch.

http://oss.oracle.com/git/?p=ocfs2-tools.git;a=shortlog;h=for-review-20110722

dump_block_check() still swaps from and to, but the function is a lot smaller.
http://oss.oracle.com/git/?p=ocfs2-tools.git;a=commitdiff;h=d91381e016f9b2f5b753a1f48a4f54d4e794a1dc




More information about the Ocfs2-tools-devel mailing list