[Ocfs2-tools-devel] [PATCH] debugfs.ocfs2: fix dump_block_check for big-endian
Joel Becker
jlbec at evilplan.org
Sun Aug 21 20:57:45 PDT 2011
On Thu, Jul 28, 2011 at 06:50:46PM -0500, Goldwyn Rodrigues wrote:
> 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.
This is debugfs.ocfs2. There is no importance to the time taken
by a single memcpy(). We're not in a performance-intensive place.
My concern is that swaping-and-back in place could have side
effects, eg in the case of corruption.
Joel
--
Life's Little Instruction Book #222
"Think twice before burdening a friend with a secret."
http://www.jlbec.org/
jlbec at evilplan.org
More information about the Ocfs2-tools-devel
mailing list