* libblkid: newbie question about enabling whole disk sysfs probe
@ 2012-10-22 12:45 Venkatraman S
2012-10-22 14:28 ` Karel Zak
0 siblings, 1 reply; 3+ messages in thread
From: Venkatraman S @ 2012-10-22 12:45 UTC (permalink / raw)
To: util-linux
Hi,
I am new to util-linux and working on adding some intelligence into
mkswap to be
aware of the underlying device properties.
I want to understand how to discover a sysfs property of a disk, when
mkswap is actually
invoked with a partition id of that disk.
If a new probe is invoked with these calls set, and mkswap is invoked
on the "whole disk" /dev/sdb
blkdid_probe pr = new_prober(fd);
blkid_probe_enable_superblocks(pr, 1);
blkid_probe_enable_partitions(pr, 1);
blkid_probe_set_superblocks_flags(pr, BLKID_SUBLKS_MAGIC);
blkid_probe_enable_topology(pr, 1);
I am able to get to the property value (which is set from the sysfs
value for the disk).
But when mkswap is invokded with /dev/sdbX, then sysfs_probe is not
able to discover the parent disk's sysfs property.
Obviously it's easy to do string manipulation and invoke the probe for
the whole disk
in the latter case, I am assuming there is a library interface that'll
do the trick.
Any help would be great.
Thanks,
Venkat.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: libblkid: newbie question about enabling whole disk sysfs probe
2012-10-22 12:45 libblkid: newbie question about enabling whole disk sysfs probe Venkatraman S
@ 2012-10-22 14:28 ` Karel Zak
2012-10-22 16:33 ` Venkatraman S
0 siblings, 1 reply; 3+ messages in thread
From: Karel Zak @ 2012-10-22 14:28 UTC (permalink / raw)
To: Venkatraman S; +Cc: util-linux
On Mon, Oct 22, 2012 at 06:15:57PM +0530, Venkatraman S wrote:
> blkid_probe_enable_topology(pr, 1);
This is strings based interface (NAME=value). It's probably
better to use:
tp = blkid_probe_get_topology(pr);
blkid_topology_get_alignment_offset(tp);
see libblkid/samples/topology.c.
> I am able to get to the property value (which is set from the sysfs
> value for the disk).
>
> But when mkswap is invokded with /dev/sdbX, then sysfs_probe is not
> able to discover the parent disk's sysfs property.
Really? It should be able to translate the partition name to the
whole-disk name and us it.
# ./sample-topology /dev/sdd1
----- binary interface:
alignment offset : 0
minimum io size : 4096
optimal io size : 262144
logical sector size : 4096
physical sector size : 4096
----- NAME=value interface (values: 4):
MINIMUM_IO_SIZE = 4096
OPTIMAL_IO_SIZE = 262144
PHYSICAL_SECTOR_SIZE = 4096
LOGICAL_SECTOR_SIZE = 4096
> Any help would be great.
What exactly is your goal?
Karel
--
Karel Zak <kzak@redhat.com>
http://karelzak.blogspot.com
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: libblkid: newbie question about enabling whole disk sysfs probe
2012-10-22 14:28 ` Karel Zak
@ 2012-10-22 16:33 ` Venkatraman S
0 siblings, 0 replies; 3+ messages in thread
From: Venkatraman S @ 2012-10-22 16:33 UTC (permalink / raw)
To: Karel Zak; +Cc: util-linux
Hi Karel,
On 22 October 2012 19:58, Karel Zak <kzak@redhat.com> wrote:
> On Mon, Oct 22, 2012 at 06:15:57PM +0530, Venkatraman S wrote:
>> blkid_probe_enable_topology(pr, 1);
>
> This is strings based interface (NAME=value). It's probably
> better to use:
>
> tp = blkid_probe_get_topology(pr);
>
> blkid_topology_get_alignment_offset(tp);
>
> see libblkid/samples/topology.c.
>
>
>> I am able to get to the property value (which is set from the sysfs
>> value for the disk).
>>
>> But when mkswap is invokded with /dev/sdbX, then sysfs_probe is not
>> able to discover the parent disk's sysfs property.
>
> Really? It should be able to translate the partition name to the
> whole-disk name and us it.
>
> # ./sample-topology /dev/sdd1
> ----- binary interface:
> alignment offset : 0
> minimum io size : 4096
> optimal io size : 262144
> logical sector size : 4096
> physical sector size : 4096
> ----- NAME=value interface (values: 4):
> MINIMUM_IO_SIZE = 4096
> OPTIMAL_IO_SIZE = 262144
> PHYSICAL_SECTOR_SIZE = 4096
> LOGICAL_SECTOR_SIZE = 4096
>
I understand. I assume this works because each of these are present in both
/sys/block/sda/ and /sys/block/sdaX/. But I am seeking a new property
(for which I have already coded the appropriate lookup hooks in topology.c)
The property (device/preferred_erase_size is present usually in eMMC
and SD cards,
and not regular hard disks, and it only present in the root device node sysfs
I think it would be easier for you after looking at the patches that I
already have
(crude with lots of hacks and debug). I'll post them now
>
>
>> Any help would be great.
>
> What exactly is your goal?
>
My objective is to implement / experiment some of the ideas that were bounced
around in kernel mailing list for optimizing swap on flash media [1]
[2] and make compatible
changes in both kernel and mkswap.
The changes revolve around embedding useful information in swap header that the
kernel can use to optimize it's swap algorithm.
[1] https://lkml.org/lkml/2012/3/30/410
[2] http://thread.gmane.org/gmane.linux.kernel.mmc/14864
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-10-22 16:33 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-22 12:45 libblkid: newbie question about enabling whole disk sysfs probe Venkatraman S
2012-10-22 14:28 ` Karel Zak
2012-10-22 16:33 ` Venkatraman S
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox