[Top] [All Lists]

Re: How to find the inodes in XFS

To: Eric Sandeen <sandeen@xxxxxxxxxxx>
Subject: Re: How to find the inodes in XFS
From: Felipe Monteiro de Carvalho <felipemonteiro.carvalho@xxxxxxxxx>
Date: Sun, 27 Apr 2014 12:53:36 -0300
Cc: xfs@xxxxxxxxxxx
Delivered-to: xfs@xxxxxxxxxxx
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=txPEHIJ+vddLXAZ4sW3QjGnQz2o3jdPRQVotCpXlXCc=; b=PBbct7K8hMM4/uWmfy2+XWhYi+pICfFk1UllQky4pDlVXw2utRr25tYu7JwuFcKl9d L3J1ZPyj/KXOZ4QPNFrxuMs3fokL/MQor4fda6PgzyHVo7nkwk2A0rSZkXsSOos5+N5+ FvOTq4O7KEEoSd/UDyrxVyzDz6asqE7kgePianUKgtbbb2hURYQ01cWn0UkEOb/4zBoQ B7ohSr85fQW6vEKXTISlQgVBFb8K/MgXyOZTZtA3ejPnxqm9UJcIjwPPtULRQ6IwDmxJ 0vqk5GMHIhT2GLhVMJUQHZYLsY5WbI8VI13GPNfj9GH41SaPKUnvwgrtUpwtAFNaCOlu LzOQ==
In-reply-to: <CACyNnZPzJGCQf5FYm+Oqkw5U3Ggm8wQd5LKC5Jnwiyksa-K1OA@xxxxxxxxxxxxxx>
References: <CACyNnZMtP87y6VHum+J4xKEZqaYp2YERVnt3YuaCmeiZBmMTzQ@xxxxxxxxxxxxxx> <5359912A.70603@xxxxxxxxxxx> <CACyNnZPV89C87DggE4fiJX+_r3zh1hKhcX3ExmXRzpLLhWJ6CQ@xxxxxxxxxxxxxx> <535AE19D.8@xxxxxxxxxxx> <CACyNnZPzJGCQf5FYm+Oqkw5U3Ggm8wQd5LKC5Jnwiyksa-K1OA@xxxxxxxxxxxxxx>
Oh, well, ...now my code works great for low inode numbers, but it
doesn't work at all for high inode numbers. =)

If inode is the root one 0x80 or similar small numbers which as 0x83
it will map correctly to the block 8, which means position 0x8000 +
internal offset inside the block

But in high inodes, for example 0x204B87 and 0x204B80 it will split
the inode number like this:
Block inside AG Nr=0x4B8

And since XFS_INO_TO_FSB just recombines back together the parts:

#define XFS_INO_TO_FSB(mp,i) \

#define XFS_AGB_TO_FSB(mp,agno,agbno) \
(((xfs_fsblock_t)(agno) << (mp)->m_sb.sb_agblklog) | (agbno))

I get as the result from XFS_INO_TO_FSB 0x204B8, which would mean
position 0x204B8000, but this is a wrong position =(

I opened the partition with a hex viewer and the correct position is
block 0x1521A which means position 0x1521A000 + offset inside block

My superblock has these values:

XFS_INO_AGINO_BITS = mp^.m_agino_log = 20
XFS_INO_OFFSET_BITS= m_sb^.sb_inopblog = 4
XFS_INO_AGBNO_BITS = m_sb^.sb_agblklog = 16
sb_agcount = 4

Any ideas?

Maybe my flaw is that to get the disk position I simply multiply the
block number by the size of a block ... I tryed to use
XFS_FSB_TO_DADDR instead but it gives 64 for block nr 8, which doesn't
make much sense, I'd expect 0x8000

Felipe Monteiro de Carvalho

<Prev in Thread] Current Thread [Next in Thread>