Page MenuHomeFreeBSD

pathconf(_PC_MEDIA) - an API to tell the media at a given path
Needs ReviewPublic

Authored by glebius on Apr 5 2018, 9:31 PM.
Tags
None
Referenced Files
Unknown Object (File)
Jan 17 2024, 11:07 PM
Unknown Object (File)
Dec 23 2023, 3:29 AM
Unknown Object (File)
Dec 13 2023, 3:57 AM
Unknown Object (File)
Dec 11 2023, 6:09 PM
Unknown Object (File)
Nov 30 2023, 6:59 AM
Unknown Object (File)
Nov 27 2023, 5:06 PM
Unknown Object (File)
Sep 14 2023, 2:35 AM
Unknown Object (File)
Sep 13 2023, 7:05 PM
Subscribers
None

Details

Summary

This API will allow a userland application to tell on which media
a path is located. A practical use case is to determine whether it
is worth to use readahead (worth for spinning disk) or not (solid).

Diff Detail

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

Event Timeline

Example:

# df
Filesystem        1K-blocks       Used     Avail Capacity  Mounted on
/dev/mirror/prim    3095920    1129672   1718576    40%    /
/dev/md5            5061628         24   5061604     0%    /var/svm
/dev/nda1p8      3585929296 3084809040 214245920    94%    /usr/local/www/2
/dev/mirror/logs   51581936    8159504  39295880    17%    /var/log
/dev/ada0p8       897802144  745401144  80576832    90%    /usr/local/www/a
/dev/da16p1      7691453560 6677369072 398768208    94%    /usr/local/www/12
# ./pathconf-media /usr/local/www/12
/usr/local/www/12=2001<SPINNING,SCSI>
# ./pathconf-media /usr/local/www/a
/usr/local/www/a=1002<SOLID,ATA>
# ./pathconf-media /var/log/
/var/log/=11002<SOLID,ATA,MIRROR>
# ./pathconf-media /usr/local/www/2
/usr/local/www/2=2<SOLID>
# ./pathconf-media /var/svm/
/var/svm/=8<MEMORY>
# ./pathconf-media /
/=10002<SOLID,MIRROR>

Instead of using strcmp() augment struct disk with media info.

Better that there's not a list of devices and strcmp. Still not sure that your desired use of this data is completely valid... But it's likely to be useful enough for enough people...

sys/cam/ata/ata_da.c
1769

Is there some way to get the spinning rate?

sys/dev/md/md.c
1243โ€“1245

should fix this....

sys/geom/geom_disk.c
241

missing nda in this ugly list :)

241

This is actually stale.

sys/geom/geom_disk.h
106

This changes struct disk without changing the version.

128

If you want to MFC this, you should add d_mediaword here for the MFC. While we have an API to encode the sizeof(struct disk), every driver encodes the offsets into it, making it part of the ABI.

155โ€“156

You need to bump this.

sys/cam/ata/ata_da.c
1769

Do you want to spend some bits of the word to report d_rotation_rate?

  • Support vnode backed md(4).
  • Bump disk version.

Is this API and device classification exist somewhere else, or being just designed? Differentiation between STRIPE, MIRROR and RAID sound somewhat odd to me, same as between SPINNING and CDROM. Besides it duplicates "GEOM::rotation_rate" attribute, we already have and use in some places (though obviously it is not passed through UFS).

In D14980#316840, @mav wrote:

Is this API and device classification exist somewhere else, or being just designed? Differentiation between STRIPE, MIRROR and RAID sound somewhat odd to me, same as between SPINNING and CDROM. Besides it duplicates "GEOM::rotation_rate" attribute, we already have and use in some places (though obviously it is not passed through UFS).

It is being just designed. The goal is to bring information all the way to the userland, and desirably via existing syscall. GEOM::rotation_rate doesn't do that.

STRIPE stands for any kind of array that adds disks together doubling space, be it gstripe, gconcat or zfs pool. MIRROR stands for mirror be it geom_mirror or zpool mirror. RAID stands for anything that uses parity for tolerance, RAID5 or RAIDZ. Names are discuss-able. We can rename STRIPE to CONCAT, or RAID can be renamed to PARITY or whatever. SPINNING can be renamed to HDD, although I anticipate that next reviewer will say that difference between HDD and SSD is odd, since both are named "disks". :)

Update patch wrt newer head.