Fedora Account System
Red Hat Associate
Red Hat Customer
Shouldn't be too tricky - the info is available via sysfs, so we can just set defaults from it if the sysfs files exist for the particular device in question.
Chat to Mike Snitzer who's recently been dealing with this in lvm2 and device-mapper.
Please have a look at the latest Linux 2.6.31+ Documentation/ABI/testing/sysfs-block It contains information about the sysfs interfaces that have been exposed. Aside from the raw sysfs interfaces there has been progress in the upstream util-linux-ng project to have its libblkid provide a programmatic API to access the I/O topology information. libblkid simply pulls the information out of sysfs; but it _should_ also abstract the nuance of getting the proper 'alignment_offset' depending on whether a device is a partition or not. Similarly it needs to (and should already) know that the other sysfs values for a partition (e.g. logical_block_size, minimum_io_size, etc) reside in the parent device's queue/ directory. Christoph Hellwig derived his preliminary patch to support I/O topology support in libblkid from LVM2's code (code which I wrote): http://article.gmane.org/gmane.linux.utilities.util-linux-ng/2471 Karel Zak later took Christoph's preliminary util-linux-ng patch and refactored it to be more in-keeping with the nature of the libblkid API: http://article.gmane.org/gmane.linux.utilities.util-linux-ng/2489 But I'm not yet seeing the I/O topology code in upstream's util-linux-ng git repo. Cc'ing Karel Zak for more info.
(In reply to comment #2) > But I'm not yet seeing the I/O topology code in upstream's util-linux-ng git > repo. Cc'ing Karel Zak for more info. The code is in the topic/libblkid-2.17 branch (upstream repo). For more details about API see the samples/ directory, for example: http://git.kernel.org/?p=utils/util-linux-ng/util-linux-ng.git;a=blob;f=shlibs/blkid/samples/topology.c;hb=topic/libblkid-2.17 http://git.kernel.org/?p=utils/util-linux-ng/util-linux-ng.git;a=blob;f=shlibs/blkid/samples/mkfs.c;hb=topic/libblkid-2.17 I'd like to release something useful (= 2.17-rc1) in September.
There might be an ioctl() interface as well, as per this email, still pending review upstream: Delivery-date: Wed, 23 Sep 2009 14:21:56 +0100 To: linux-fsdevel.org Cc: Eric Sandeen <sandeen>, Andreas Dilger <adilger>, Jim Meyering <jim>, jens.axboe Subject: Topology ioctls From: "Martin K. Petersen" <martin.petersen>
(In reply to comment #4) > There might be an ioctl() interface as well, as per this email, still pending > review upstream: Yes the ioctl() interface is now upstream, see: http://git.kernel.org/linus/ac481c20ef8f6c6 In summary: BLKALIGNOFF: alignment_offset BLKPBSZGET: physical_block_size BLKSSZGET: logical_block_size BLKIOMIN: minimum_io_size BLKIOOPT: optimal_io_size
I pushed a patch to the STABLE3 branch of the cluster git tree that does some of this work, and that is built into rawhide as of today. I will be opening another bug to do more follow-on work for making gfs2 work with raid stripe information and such.