sys/buf.h struct buf missing b_blkno member
dillon at apollo.backplane.com
Tue Jul 8 11:02:39 PDT 2008
:Afaik b_blkno member from struct buf defined on sys/buf.h was dropped
:(as well as other b_*blkno members). Is there any replacement for that?
:What should we use instead?
:tuxillo at EFNet in #dragonflybsd
They got moved to the buffer's BIO array, and changed from block numbers
to 64 bit byte granular offsets. Each buffer has a stack of up to four
translation layers, each given its own BIO.
bp->b_bio1.bio_offset Logical byte offset
bp->b_bio2.bio_offset Physical byte offset (depends on the VFS)
bio->bio_offset Physical byte offset from the point of view
of a block device driver.
What you see depends on where in the I/O stream you are sitting. If
you are a block device driver the strategy calls all pass a BIO, not
a BUF, and the disk offset is just bio->bio_offset. The buffer can
be accessed via the bio using bio->bio_buf.
If you are a higher layer, such as a filesystem, bp->b_bio1.bio_offset
is typically a logical inode-relative offset. For UFS
bp->b_bio2.bio_offset is the BMAPped physical device offset. For other
filesystems it will depend... for example, HAMMER encodes a volume
number along with the byte offset in its b_bio2 and pushes a third
layer BIO to the actual block device.
The best place to deal with I/O operations is in the block device's
strategy call, where the BIO is passed directly and bio->bio_offset is
thus exactly what you desire.
<dillon at backplane.com>
More information about the Kernel