Hi folks,

When you issue a BIO, the requested byte offset (bio_offset) gets
transformed by each layer of the GEOM stack as needed. If the bottom of
the stack is a physical disk, g_disk_start() transforms the final offset
to a device block address (bio_pblkno), which the disk device driver uses
as the LBA.

My question is this - is there a way to go in the other direction, from an
LBA to a byte offset? For example, let's say I have a set of four drives
which are configured as a RAID10:

    STRIPE: /dev/ada0p2 && /dev/ada1p2 => /dev/stripe/gs0
    STRIPE: /dev/ada2p2 && /dev/ada3p2 => /dev/stripe/gs1
    MIRROR: /dev/stripe/gs0 && /dev/stripe/gs1 => /dev/stripe/gm0

I kick off a media scrub of the drive devices, to look for unreadable
sectors. For the sake of saving bandwidth, I use the ATA_READ_VERIFY /
ATA_READ_VERIFY48 commands (which read from the media, set the status and
error bits, but don't transfer the data to the host). That requires
talking directly to the drive, not the higher-level GEOMs, so I have to
work in terms of LBAs.

If I find an unreadable sector on one of the drives, I'd like to re-write
the sector to heal it. I can do that by reading from the mirror; that will
either pick the good side of the mirror in the first place, or will try
and fail from the bad side, then failover to read from the good side.
Either way, I end up with the proper data, and can re-write unreadable
sector. The problem is, how do I calculate the byte offset in the mirror
to read from?

In the example above, since it's a relatively straightforward stack, I
could do some math taking into account the LBA offsets for the GPT
partitions, and the stripesize of the stripes, etc. That would work for
this example, but it gets ugly fast if there are more complex transforms
in the stack.

It's easy enough to look at the partition table and say "LBA 12345 is in
the range 1024 - 1048576, which is part of ada0p2". Going from there to
"ada0p2 is part of gs0, which has a stripe interleave of 256KB" is more
complicated. If there's something like GEOM_RAID3 in the mix - which has
parity sectors which are not visible to the higher layers of the stack -
then it gets uglier still.

Is there a generic, supported way for doing this mapping? Or can someone
point me in the right direction so, I can *create* a generic way for doing
this, and submit it? :-)

Thanks,

Ravi

_______________________________________________
freebsd-geom@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-geom
To unsubscribe, send any mail to "freebsd-geom-unsubscr...@freebsd.org"

Reply via email to