[Ocfs2-tools-devel] [PATCH 5/6] debugfs.ocfs2: Swap blocks we're dumping from the journal.

Sunil Mushran sunil.mushran at oracle.com
Fri Jan 9 17:02:39 PST 2009


Signed-off-by: Sunil Mushran <sunil.mushran at oracle.com>

Good catch. I guess this was written before the endian code
was added. Appears we never did a logdump on ppc.



Joel Becker wrote:
> The 'logdump' command reads blocks from the journal and tries to guess
> what kind of block they are.  If it finds a known block type, it then
> dumps the block.
>
> However, there is a bug.  The dump_*() functions of degugfs.ocfs2 assume
> the block has already been brought to cpu-endian.  The other callers
> (regular debugfs commands) swap the blocks.  So we need to swap the
> blocks in dump_jbd_metadata() before we call the dump_*() functions.
>
> Signed-off-by: Joel Becker <joel.becker at oracle.com>
> ---
>  debugfs.ocfs2/dump.c  |    3 +++
>  include/ocfs2/ocfs2.h |    2 ++
>  libocfs2/extents.c    |    5 +++--
>  3 files changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/debugfs.ocfs2/dump.c b/debugfs.ocfs2/dump.c
> index c29f580..f1a2560 100644
> --- a/debugfs.ocfs2/dump.c
> +++ b/debugfs.ocfs2/dump.c
> @@ -649,16 +649,19 @@ void dump_jbd_metadata (FILE *out, enum dump_block_type type, char *buf,
>  	switch (type) {
>  	case DUMP_BLOCK_INODE:
>  		fprintf(out, "Inode\n");
> +		ocfs2_swap_inode_to_cpu((struct ocfs2_dinode *)buf);
>  		dump_inode (out, (struct ocfs2_dinode *)buf);
>  		fprintf (out, "\n");
>  		break;
>  	case DUMP_BLOCK_EXTENT_BLOCK:
>  		fprintf(out, "Extent\n");
> +		ocfs2_swap_extent_block_to_cpu((struct ocfs2_extent_block *)buf);
>  		dump_extent_block (out, (struct ocfs2_extent_block *)buf);
>  		fprintf (out, "\n");
>  		break;
>  	case DUMP_BLOCK_GROUP_DESCRIPTOR:
>  		fprintf(out, "Group\n");
> +		ocfs2_swap_group_desc((struct ocfs2_group_desc *)buf);
>  		dump_group_descriptor (out, (struct ocfs2_group_desc *)buf, 0);
>  		fprintf (out, "\n");
>  		break;
> diff --git a/include/ocfs2/ocfs2.h b/include/ocfs2/ocfs2.h
> index e515205..7f00786 100644
> --- a/include/ocfs2/ocfs2.h
> +++ b/include/ocfs2/ocfs2.h
> @@ -298,6 +298,8 @@ extern size_t ocfs2_journal_tag_bytes(journal_superblock_t *jsb);
>  extern uint64_t ocfs2_journal_tag_block(journal_block_tag_t *tag,
>  					size_t tag_bytes);
>  
> +void ocfs2_swap_extent_block_to_cpu(struct ocfs2_extent_block *eb);
> +void ocfs2_swap_extent_block_from_cpu(struct ocfs2_extent_block *eb);
>  errcode_t ocfs2_read_extent_block(ocfs2_filesys *fs, uint64_t blkno,
>         				  char *eb_buf);
>  errcode_t ocfs2_read_extent_block_nocheck(ocfs2_filesys *fs, uint64_t blkno,
> diff --git a/libocfs2/extents.c b/libocfs2/extents.c
> index 5f16789..a014437 100644
> --- a/libocfs2/extents.c
> +++ b/libocfs2/extents.c
> @@ -85,7 +85,7 @@ static void ocfs2_swap_extent_block_header(struct ocfs2_extent_block *eb)
>  	eb->h_next_leaf_blk = bswap_64(eb->h_next_leaf_blk);
>  }
>  
> -static void ocfs2_swap_extent_block_from_cpu(struct ocfs2_extent_block *eb)
> +void ocfs2_swap_extent_block_from_cpu(struct ocfs2_extent_block *eb)
>  {
>  	if (cpu_is_little_endian)
>  		return;
> @@ -93,7 +93,8 @@ static void ocfs2_swap_extent_block_from_cpu(struct ocfs2_extent_block *eb)
>  	ocfs2_swap_extent_block_header(eb);
>  	ocfs2_swap_extent_list_from_cpu(&eb->h_list);
>  }
> -static void ocfs2_swap_extent_block_to_cpu(struct ocfs2_extent_block *eb)
> +
> +void ocfs2_swap_extent_block_to_cpu(struct ocfs2_extent_block *eb)
>  {
>  	if (cpu_is_little_endian)
>  		return;
>   




More information about the Ocfs2-tools-devel mailing list