[Ocfs2-tools-devel] [PATCH] debugfs.ocfs2: fix the endian error in find_block_inode

Joel Becker Joel.Becker at oracle.com
Tue May 1 19:30:09 PDT 2007


On Tue, May 01, 2007 at 02:59:53PM -0700, Sunil Mushran wrote:
> Shouldn't this be fixed in ocfs2_get_next_inode()? As in, all this
> endian swapping business needs to be done in the libocfs2 not the
> individual tools.
> 
> Joel?

r1035 | zab | 2005-08-10 13:17:37 -0700 (Wed, 10 Aug 2005) | 7 lines

Oops, don't check signatures down in the scan inode interface.
It's meant to be much more low level than that, callers are
expected to swap after verifying signatures.

Also update some debugging macros I used when tracking this down.

	I think what Zach was doing here is that an inode scan comes up
with unallocated -- and *uninitialized* -- blocks in the inode files.
So you can't safely swap them.  Things like next_free_rec are completely
invalid.
	The original consumer of inode_scan() is fsck(8).  It gets the
raw blocks from the inode allocator and checks the signature before
trusting that swap_inode() will work.

Joel

> 
> On Sat, 2007-04-28 at 14:22 +0800, tao.ma wrote:
> > Function find_block_inode forget to swap the information from disk to 
> > cpu. This may cause problem in some big-endian machine.
> > 
> > plain text document attachment (find_block_inode.patch)
> > Index: debugfs.ocfs2/find_block_inode.c
> > ===================================================================
> > --- debugfs.ocfs2/find_block_inode.c	(revision 1346)
> > +++ debugfs.ocfs2/find_block_inode.c	(working copy)
> > @@ -368,6 +368,8 @@ errcode_t find_block_inode(ocfs2_filesys
> >  			   strlen(OCFS2_INODE_SIGNATURE)))
> >  			continue;
> >  
> > +		ocfs2_swap_inode_to_cpu(di);
> > +
> >  		if (!(di->i_flags & OCFS2_VALID_FL))
> >  			continue;
> >  
> > _______________________________________________
> > Ocfs2-tools-devel mailing list
> > Ocfs2-tools-devel at oss.oracle.com
> > http://oss.oracle.com/mailman/listinfo/ocfs2-tools-devel
> 
> 
> _______________________________________________
> Ocfs2-tools-devel mailing list
> Ocfs2-tools-devel at oss.oracle.com
> http://oss.oracle.com/mailman/listinfo/ocfs2-tools-devel

-- 

"Any man who is under 30, and is not a liberal, has not heart;
 and any man who is over 30, and is not a conservative, has no brains."
         - Sir Winston Churchill 

Joel Becker
Principal Software Developer
Oracle
E-mail: joel.becker at oracle.com
Phone: (650) 506-8127



More information about the Ocfs2-tools-devel mailing list