Skip to contentSkip to conversation

How can I get my sector size (via queue_limits?) from a dm_target?

DISCUSSION Eric Wheeler 2 participants 2 messages Jan 20, 2016 Device mapper

lore
Share & tools
lore
#0 lore raw

Hello all,

dm_target->len gives me sector count, but I need to know the default sector size discovered by the blk stacking code without assuming 512b.

Now that I have the dm .iterate_devices callback defined and my queue_limits are sane by default, how can I get a pointer to the queue_limits structure for my device given a dm_target structure?

It looks like I should call dm_get_md_queue() after getting the md from dm_table_get_md(target->table), but dm_get_md_queue is not an exported symbol.

Also, is that value correct within the .ctr, or only after the .ctr returns? If after, how can I hook in after limits are assigned but before .map gets called? Otherwise stated, I would like to know the stacked queue_limits corrected for lower layers within the .ctr function.

Thanks for your help!

-Eric

#1 lore raw
Quoted 9 lines · Eric Wheeler

Hello all,

dm_target->len gives me sector count, but I need to know the default sector size discovered by the blk stacking code without assuming 512b.

Now that I have the dm .iterate_devices callback defined and my queue_limits are sane by default, how can I get a pointer to the queue_limits structure for my device given a dm_target structure?

Quoted 8 lines

It looks like I should call dm_get_md_queue() after getting the md from dm_table_get_md(target->table), but dm_get_md_queue is not an exported symbol.

Also, is that value correct within the .ctr, or only after the .ctr returns? If after, how can I hook in after limits are assigned but before .map gets called? Otherwise stated, I would like to know the stacked queue_limits corrected for lower layers within the .ctr function.

You cannot know it from .ctr because the device is actively being constructed. The .io_hints hook allows you access to stacked queue_limits -- see dm_calculate_queue_limits() which calls ->io_hints _after_ combining all underlying queue_limits.

See dm-thin.c's pool_io_hints() and thin_io_hints() for examples of how the .io_hints hook is used for DM-thinp.

Mike