libblkid: add dax capability detection in topology probing

The dax (direct access) blockdev capability is exposed via sysfs, add it
to the list of topology values to be obtained while probing.

Expose blkid_topology_get_dax() symbol that programs can link against
for querying the capability.

Reorder the idinfos array to give precedence to the sysfs over ioctl so
that the dax probe has a chance to be executed, as there is no ioctl
interface for it.

Signed-off-by: Anthony Iliopoulos <ailiop@suse.com>
This commit is contained in:
Anthony Iliopoulos 2020-05-05 16:31:45 +02:00 committed by Karel Zak
parent 885336d9dc
commit 17c57e2509
6 changed files with 30 additions and 1 deletions

View file

@ -51,6 +51,8 @@ int main(int argc, char *argv[])
blkid_topology_get_logical_sector_size(tp));
printf("\tphysical sector size : %lu\n",
blkid_topology_get_physical_sector_size(tp));
printf("\tdax support : %lu\n",
blkid_topology_get_dax(tp));
}
/*

View file

@ -325,6 +325,8 @@ extern unsigned long blkid_topology_get_logical_sector_size(blkid_topology tp)
__ul_attribute__((nonnull));
extern unsigned long blkid_topology_get_physical_sector_size(blkid_topology tp)
__ul_attribute__((nonnull));
extern unsigned long blkid_topology_get_dax(blkid_topology tp)
__ul_attribute__((nonnull));
/*
* partitions probing

View file

@ -174,3 +174,7 @@ BLKID_2_31 {
blkid_probe_reset_buffers;
blkid_probe_hide_range;
} BLKID_2.30;
BLKID_2_35 {
blkid_topology_get_dax;
} BLKID_2_31;

View file

@ -37,6 +37,7 @@ static struct topology_val {
{ "queue/minimum_io_size", blkid_topology_set_minimum_io_size },
{ "queue/optimal_io_size", blkid_topology_set_optimal_io_size },
{ "queue/physical_block_size", blkid_topology_set_physical_sector_size },
{ "queue/dax", blkid_topology_set_dax },
};
static int probe_sysfs_tp(blkid_probe pr,

View file

@ -67,6 +67,7 @@ struct blkid_struct_topology {
unsigned long optimal_io_size;
unsigned long logical_sector_size;
unsigned long physical_sector_size;
unsigned long dax;
};
/*
@ -75,8 +76,8 @@ struct blkid_struct_topology {
static const struct blkid_idinfo *idinfos[] =
{
#ifdef __linux__
&ioctl_tp_idinfo,
&sysfs_tp_idinfo,
&ioctl_tp_idinfo,
&md_tp_idinfo,
&dm_tp_idinfo,
&lvm_tp_idinfo,
@ -303,6 +304,14 @@ int blkid_topology_set_physical_sector_size(blkid_probe pr, unsigned long val)
val);
}
int blkid_topology_set_dax(blkid_probe pr, unsigned long val)
{
return topology_set_value(pr,
"DAX",
offsetof(struct blkid_struct_topology, dax),
val);
}
/**
* blkid_topology_get_alignment_offset:
* @tp: topology
@ -358,3 +367,13 @@ unsigned long blkid_topology_get_physical_sector_size(blkid_topology tp)
return tp->physical_sector_size;
}
/**
* blkid_topology_get_dax
* @tp: topology
*
* Returns: 1 if dax is supported, 0 otherwise.
*/
unsigned long blkid_topology_get_dax(blkid_topology tp)
{
return tp->dax;
}

View file

@ -7,6 +7,7 @@ extern int blkid_topology_set_alignment_offset(blkid_probe pr, int val);
extern int blkid_topology_set_minimum_io_size(blkid_probe pr, unsigned long val);
extern int blkid_topology_set_optimal_io_size(blkid_probe pr, unsigned long val);
extern int blkid_topology_set_physical_sector_size(blkid_probe pr, unsigned long val);
extern int blkid_topology_set_dax(blkid_probe pr, unsigned long val);
/*
* topology probers