* Conversion Routine Help
@ 2011-12-29 14:12 Vijay Chauhan
2011-12-29 16:44 ` Amit Sahrawat
2011-12-29 21:54 ` Dave Chinner
0 siblings, 2 replies; 4+ messages in thread
From: Vijay Chauhan @ 2011-12-29 14:12 UTC (permalink / raw)
To: xfs
Hi list,
Can anyone please provide me links about the basic explanations of XFS
basic blocks and filesystem logical block mapping and conversion
routines?
I tried to understand from code but its not clear to me:
#define XFS_FSB_TO_BB(mp,fsbno) ((fsbno) << (mp)->m_blkbb_log)
#define XFS_BB_TO_FSB(mp,bb) \
(((bb) + (XFS_FSB_TO_BB(mp,1) - 1)) >> (mp)->m_blkbb_log)
#define XFS_BB_TO_FSBT(mp,bb) ((bb) >> (mp)->m_blkbb_log)
#define XFS_BB_FSB_OFFSET(mp,bb) ((bb) & ((mp)->m_bsize - 1))
lets consider the last one:
#define XFS_BB_FSB_OFFSET(mp,bb) ((bb) & ((mp)->m_bsize - 1))
if basic block (512 byte size) number is 7 and m_bsize is 12
(considering FS block size 4096), then this will return 3 [e.g. ( 7 &
11) ]. then what does 3 means here? what offset value it is denoting?
Thanks in advance.
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Conversion Routine Help
2011-12-29 14:12 Conversion Routine Help Vijay Chauhan
@ 2011-12-29 16:44 ` Amit Sahrawat
2011-12-29 21:54 ` Dave Chinner
1 sibling, 0 replies; 4+ messages in thread
From: Amit Sahrawat @ 2011-12-29 16:44 UTC (permalink / raw)
To: Vijay Chauhan; +Cc: xfs
On Thu, Dec 29, 2011 at 7:42 PM, Vijay Chauhan <kernel.vijay@gmail.com> wrote:
> Hi list,
>
> Can anyone please provide me links about the basic explanations of XFS
> basic blocks and filesystem logical block mapping and conversion
> routines?
You can refer the XFSdocuments from the links:
http://oss.sgi.com/projects/xfs/papers/xfs_filesystem_structure.pdf
http://xfs.org/docs/xfsdocs-xml-dev/XFS_Filesystem_Structure//tmp/en-US/html/index.html
But the information which you are looking for is actually - trying to
dig into the layout of filesystem on disk.
After going through intial documents - few things can be verified by
taking a hexdump of the disk and then analysing the data. Keeping the
filesystem partition to empty and to a small partition size will help
fast analyses. You can give this a try with a 100MB XFS formatted
partition.
>
> I tried to understand from code but its not clear to me:
> #define XFS_FSB_TO_BB(mp,fsbno) ((fsbno) << (mp)->m_blkbb_log)
> #define XFS_BB_TO_FSB(mp,bb) \
> (((bb) + (XFS_FSB_TO_BB(mp,1) - 1)) >> (mp)->m_blkbb_log)
> #define XFS_BB_TO_FSBT(mp,bb) ((bb) >> (mp)->m_blkbb_log)
> #define XFS_BB_FSB_OFFSET(mp,bb) ((bb) & ((mp)->m_bsize - 1))
>
> lets consider the last one:
> #define XFS_BB_FSB_OFFSET(mp,bb) ((bb) & ((mp)->m_bsize - 1))
>
> if basic block (512 byte size) number is 7 and m_bsize is 12
> (considering FS block size 4096), then this will return 3 [e.g. ( 7 &
> 11) ]. then what does 3 means here? what offset value it is denoting?
If I am correct this indicates the starting block with respect to that
partition.
So, If I have 20GB disk with 10-10 GB partitions, and Suppose the
second partition is XFS formatted - then layout will be in terms of
offset on that partition and not with respect to Starting of the disk.
For actually checking the data about some file and understanding more:
Create a file on XFS partition and then use xfs_bmap to view the block
mapping of the file(xfs_db can also be used - this is explained in the
documents - but this works on unmounted device)
xfs_bmap <filename> will return a layout for the file(in terms of extent)
0: [0..9503]: 67181048..67190551
where the values in [] - indicates starting and ending offset, while
the values next to it represent the block numbers on that disk with
respect to that partition. These values are in terms of 'sectors' and
not in blocks - so to actually correlate them - divide each values by
'8'(512 =4096/8)
Thanks
Amit Sahrawat
>
> Thanks in advance.
>
> _______________________________________________
> xfs mailing list
> xfs@oss.sgi.com
> http://oss.sgi.com/mailman/listinfo/xfs
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Conversion Routine Help
2011-12-29 14:12 Conversion Routine Help Vijay Chauhan
2011-12-29 16:44 ` Amit Sahrawat
@ 2011-12-29 21:54 ` Dave Chinner
2012-01-04 7:56 ` Vijay Chauhan
1 sibling, 1 reply; 4+ messages in thread
From: Dave Chinner @ 2011-12-29 21:54 UTC (permalink / raw)
To: Vijay Chauhan; +Cc: xfs
On Thu, Dec 29, 2011 at 07:42:31PM +0530, Vijay Chauhan wrote:
> Hi list,
>
> Can anyone please provide me links about the basic explanations of XFS
> basic blocks and filesystem logical block mapping and conversion
> routines?
>
> I tried to understand from code but its not clear to me:
> #define XFS_FSB_TO_BB(mp,fsbno) ((fsbno) << (mp)->m_blkbb_log)
Convert FileSystem Blocks to Basic Blocks
FSBs are defined at mkfs time, BBs are always 512 bytes.
> #define XFS_BB_TO_FSB(mp,bb) \
> (((bb) + (XFS_FSB_TO_BB(mp,1) - 1)) >> (mp)->m_blkbb_log)
Convert BB to FSB, rounding up to the next FSB
> #define XFS_BB_TO_FSBT(mp,bb) ((bb) >> (mp)->m_blkbb_log)
Convert BB to FSB, rounding down to the FSB containing the BB
> #define XFS_BB_FSB_OFFSET(mp,bb) ((bb) & ((mp)->m_bsize - 1))
Offset of the give BB within a FSB. e.g. if FSB = 4k = 8BB, then
"bb = 5" would return 5, "bb = 63" would return 7...
> lets consider the last one:
> #define XFS_BB_FSB_OFFSET(mp,bb) ((bb) & ((mp)->m_bsize - 1))
>
> if basic block (512 byte size) number is 7 and m_bsize is 12
m_bsize is the FSB in BB, which will always be a power of 2.
> (considering FS block size 4096), then this will return 3 [e.g. ( 7 &
in that case, m_bsize = 8.
> 11) ]. then what does 3 means here? what offset value it is denoting?
It's the offset of the BB within the first partial FSB in the range
given. This was once used for sub-block zeroing needed by direct IO,
but is now stale code as the generic DIO layer does this zeroing.
Care to submit a patch to remove that macro?
Cheers,
Dave.
--
Dave Chinner
david@fromorbit.com
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Conversion Routine Help
2011-12-29 21:54 ` Dave Chinner
@ 2012-01-04 7:56 ` Vijay Chauhan
0 siblings, 0 replies; 4+ messages in thread
From: Vijay Chauhan @ 2012-01-04 7:56 UTC (permalink / raw)
To: Dave Chinner; +Cc: xfs
Hi,
>>
>> Can anyone please provide me links about the basic explanations of XFS
>> basic blocks and filesystem logical block mapping and conversion
>> routines?
>>
>> I tried to understand from code but its not clear to me:
>> #define XFS_FSB_TO_BB(mp,fsbno) ((fsbno) << (mp)->m_blkbb_log)
>
> Convert FileSystem Blocks to Basic Blocks
>
> FSBs are defined at mkfs time, BBs are always 512 bytes.
>
>> #define XFS_BB_TO_FSB(mp,bb) \
>> (((bb) + (XFS_FSB_TO_BB(mp,1) - 1)) >> (mp)->m_blkbb_log)
>
> Convert BB to FSB, rounding up to the next FSB
>
>> #define XFS_BB_TO_FSBT(mp,bb) ((bb) >> (mp)->m_blkbb_log)
>
> Convert BB to FSB, rounding down to the FSB containing the BB
>
>> #define XFS_BB_FSB_OFFSET(mp,bb) ((bb) & ((mp)->m_bsize - 1))
>
> Offset of the give BB within a FSB. e.g. if FSB = 4k = 8BB, then
> "bb = 5" would return 5, "bb = 63" would return 7...
>
>> lets consider the last one:
>> #define XFS_BB_FSB_OFFSET(mp,bb) ((bb) & ((mp)->m_bsize - 1))
>>
>> if basic block (512 byte size) number is 7 and m_bsize is 12
>
> m_bsize is the FSB in BB, which will always be a power of 2.
>
>> (considering FS block size 4096), then this will return 3 [e.g. ( 7 &
>
> in that case, m_bsize = 8.
>
>> 11) ]. then what does 3 means here? what offset value it is denoting?
>
> It's the offset of the BB within the first partial FSB in the range
> given. This was once used for sub-block zeroing needed by direct IO,
> but is now stale code as the generic DIO layer does this zeroing.
> Care to submit a patch to remove that macro?
>
Thanks Dave. I understand.
I am newbie and learning. Sure, i'll create the patch but before let
me try out further in the code.
Thanks.
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-01-04 7:56 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-29 14:12 Conversion Routine Help Vijay Chauhan
2011-12-29 16:44 ` Amit Sahrawat
2011-12-29 21:54 ` Dave Chinner
2012-01-04 7:56 ` Vijay Chauhan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox