Page MenuHomeFreeBSD

Implement disk_ioctl() to support DIOCGSECTORSIZE and DIOCGMEDIASIZE.
ClosedPublic

Authored by tsoome on Nov 20 2016, 9:37 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Dec 8, 2:17 PM
Unknown Object (File)
Nov 14 2024, 5:46 PM
Unknown Object (File)
Nov 14 2024, 4:08 PM
Unknown Object (File)
Nov 9 2024, 9:33 PM
Unknown Object (File)
Nov 7 2024, 1:03 PM
Unknown Object (File)
Nov 4 2024, 9:01 PM
Unknown Object (File)
Nov 2 2024, 11:26 AM
Unknown Object (File)
Oct 24 2024, 9:45 PM
Subscribers

Details

Summary

Need interface to extract information about disk abstraction,
to read disk or partition size depending on the provided argument
and adjust disk size based on information in partition table.

The disk handle from disk_open() has d_offset field to point to
partition start. So we can use this fact to return either whole disk
size or partition size. For this we only need to record partition size
we get from disk_open() anyhow.

In addition, this will also make it possible to adjust the disk media size
based on information from partition table. The problem with disk size is
about some BIOS systems reporting bogus disk size for 2+TB disks, but
since such disks are using GPT partitioning, and GPT does have information
about disk size (alternate LBA + 1), we can use this fact to record disk
size based on partition table.

This patch does exactly this: implements DIOCGSECTORSIZE and DIOCGMEDIASIZE
ioctl, and DIOCGMEDIASIZE will report either disk media size or partition size.

Adds ptable_getsize() call to read partition size in bytes from ptable pointer.
Updates disk_open() to use ptable_getsize() to update mediasize value.

Implements GPT detection function to update ptable size (used by
ptable_getsize()) according to alternate lba (which is location of backup copy
of GPT header table).

This implementation is used by https://reviews.freebsd.org/D8581
and not yet posted code to fix biosdisk.c for large disks.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 6014
Build 6281: arc lint + arc unit

Event Timeline

tsoome retitled this revision from to Implement disk_ioctl() to support DIOCGSECTORSIZE and DIOCGMEDIASIZE..
tsoome updated this object.
tsoome edited the test plan for this revision. (Show Details)
tsoome added reviewers: allanjude, imp.

svn update to current state.

sys/boot/common/disk.c
271

Does it make sense to keep this? Do any of the classes use this?

sys/boot/common/disk.c
271

I haven't seen any need. in fact the need is reversed, the specific interfaces "extend" the disk_* api, like bd_open() does its internal thing and then calls disk_open(), bd_ioctl calls up to disk_ioctl() etc.

allanjude edited edge metadata.

Approved for commit

This revision is now accepted and ready to land.Feb 5 2017, 10:38 PM
This revision was automatically updated to reflect the committed changes.